Commit | Line | Data |
---|---|---|
2f8f53af DG |
1 | #ifndef LTTNG_VIEWER_ABI_H |
2 | #define LTTNG_VIEWER_ABI_H | |
ddea0ada | 3 | |
d3e2ba59 JD |
4 | /* |
5 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> | |
c404302f | 6 | * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
d3e2ba59 JD |
7 | * David Goulet <dgoulet@efficios.com> |
8 | * | |
c404302f JD |
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | * of this software and associated documentation files (the "Software"), to deal | |
11 | * in the Software without restriction, including without limitation the rights | |
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
13 | * copies of the Software, and to permit persons to whom the Software is | |
14 | * furnished to do so, subject to the following conditions: | |
d3e2ba59 | 15 | * |
c404302f JD |
16 | * The above copyright notice and this permission notice shall be included in |
17 | * all copies or substantial portions of the Software. | |
d3e2ba59 | 18 | * |
c404302f JD |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
25 | * SOFTWARE. | |
d3e2ba59 JD |
26 | */ |
27 | ||
d3e2ba59 JD |
28 | #include <limits.h> |
29 | ||
30 | #define LTTNG_VIEWER_PATH_MAX 4096 | |
31 | #define LTTNG_VIEWER_NAME_MAX 255 | |
2f8f53af | 32 | #define LTTNG_VIEWER_ABI_HOST_NAME_MAX 64 |
d3e2ba59 JD |
33 | |
34 | /* Flags in reply to get_next_index and get_packet. */ | |
35 | /* New metadata is required to read this packet. */ | |
36 | #define LTTNG_VIEWER_FLAG_NEW_METADATA (1 << 0) | |
ddea0ada | 37 | /* New stream got added to the trace. */ |
d3e2ba59 JD |
38 | #define LTTNG_VIEWER_FLAG_NEW_STREAM (1 << 1) |
39 | ||
40 | enum lttng_viewer_command { | |
41 | VIEWER_CONNECT = 1, | |
42 | VIEWER_LIST_SESSIONS = 2, | |
43 | VIEWER_ATTACH_SESSION = 3, | |
44 | VIEWER_GET_NEXT_INDEX = 4, | |
45 | VIEWER_GET_PACKET = 5, | |
46 | VIEWER_GET_METADATA = 6, | |
80e8027a | 47 | VIEWER_GET_NEW_STREAMS = 7, |
d3e2ba59 JD |
48 | }; |
49 | ||
50 | enum lttng_viewer_attach_return_code { | |
51 | VIEWER_ATTACH_OK = 1, /* If the attach command succeeded. */ | |
52 | VIEWER_ATTACH_ALREADY = 2, /* If a viewer is already attached. */ | |
53 | VIEWER_ATTACH_UNK = 3, /* If the session ID is unknown. */ | |
54 | VIEWER_ATTACH_NOT_LIVE = 4, /* If the session is not live. */ | |
55 | VIEWER_ATTACH_SEEK_ERR = 5, /* Seek error. */ | |
56 | }; | |
57 | ||
58 | enum lttng_viewer_next_index_return_code { | |
59 | VIEWER_INDEX_OK = 1, /* Index is available. */ | |
60 | VIEWER_INDEX_RETRY = 2, /* Index not yet available. */ | |
61 | VIEWER_INDEX_HUP = 3, /* Index closed (trace destroyed). */ | |
62 | VIEWER_INDEX_ERR = 4, /* Unknow error. */ | |
63 | VIEWER_INDEX_INACTIVE = 5, /* Inactive stream beacon. */ | |
6b6b9a5a | 64 | VIEWER_INDEX_EOF = 6, /* End of index file. */ |
d3e2ba59 JD |
65 | }; |
66 | ||
67 | enum lttng_viewer_get_packet_return_code { | |
68 | VIEWER_GET_PACKET_OK = 1, | |
69 | VIEWER_GET_PACKET_RETRY = 2, | |
70 | VIEWER_GET_PACKET_ERR = 3, | |
6b6b9a5a | 71 | VIEWER_GET_PACKET_EOF = 4, |
d3e2ba59 JD |
72 | }; |
73 | ||
74 | enum lttng_viewer_get_metadata_return_code { | |
75 | VIEWER_METADATA_OK = 1, | |
76 | VIEWER_NO_NEW_METADATA = 2, | |
77 | VIEWER_METADATA_ERR = 3, | |
78 | }; | |
79 | ||
80 | enum lttng_viewer_connection_type { | |
81 | VIEWER_CLIENT_COMMAND = 1, | |
82 | VIEWER_CLIENT_NOTIFICATION = 2, | |
83 | }; | |
84 | ||
85 | enum lttng_viewer_seek { | |
ddea0ada JD |
86 | /* Receive the trace packets from the beginning. */ |
87 | VIEWER_SEEK_BEGINNING = 1, | |
88 | /* Receive the trace packets from now. */ | |
89 | VIEWER_SEEK_LAST = 2, | |
d3e2ba59 JD |
90 | }; |
91 | ||
80e8027a JD |
92 | enum lttng_viewer_new_streams_return_code { |
93 | VIEWER_NEW_STREAMS_OK = 1, /* If new streams are being sent. */ | |
94 | VIEWER_NEW_STREAMS_NO_NEW = 2, /* If no new streams are available. */ | |
95 | VIEWER_NEW_STREAMS_ERR = 3, /* Error. */ | |
96 | }; | |
97 | ||
d3e2ba59 JD |
98 | struct lttng_viewer_session { |
99 | uint64_t id; | |
d3e2ba59 JD |
100 | uint32_t live_timer; |
101 | uint32_t clients; | |
87b576ec | 102 | uint32_t streams; |
2f8f53af | 103 | char hostname[LTTNG_VIEWER_ABI_HOST_NAME_MAX]; |
ddea0ada | 104 | char session_name[LTTNG_VIEWER_NAME_MAX]; |
d3e2ba59 JD |
105 | } __attribute__((__packed__)); |
106 | ||
107 | struct lttng_viewer_stream { | |
108 | uint64_t id; | |
109 | uint64_t ctf_trace_id; | |
ddea0ada | 110 | int metadata_flag; |
d3e2ba59 JD |
111 | char path_name[LTTNG_VIEWER_PATH_MAX]; |
112 | char channel_name[LTTNG_VIEWER_NAME_MAX]; | |
d3e2ba59 JD |
113 | } __attribute__((__packed__)); |
114 | ||
115 | struct lttng_viewer_cmd { | |
116 | uint64_t data_size; /* data size following this header */ | |
117 | uint32_t cmd; /* enum lttcomm_relayd_command */ | |
118 | uint32_t cmd_version; /* command version */ | |
119 | } __attribute__((__packed__)); | |
120 | ||
121 | /* | |
122 | * CONNECT payload. | |
123 | */ | |
124 | struct lttng_viewer_connect { | |
ddea0ada JD |
125 | /* session ID assigned by the relay for command connections */ |
126 | uint64_t viewer_session_id; | |
d3e2ba59 JD |
127 | uint32_t major; |
128 | uint32_t minor; | |
129 | uint32_t type; /* enum lttng_viewer_connection_type */ | |
d3e2ba59 JD |
130 | } __attribute__((__packed__)); |
131 | ||
132 | /* | |
133 | * VIEWER_LIST_SESSIONS payload. | |
134 | */ | |
135 | struct lttng_viewer_list_sessions { | |
136 | uint32_t sessions_count; | |
137 | char session_list[]; /* struct lttng_viewer_session */ | |
138 | } __attribute__((__packed__)); | |
139 | ||
140 | /* | |
141 | * VIEWER_ATTACH_SESSION payload. | |
142 | */ | |
143 | struct lttng_viewer_attach_session_request { | |
144 | uint64_t session_id; | |
d3e2ba59 | 145 | uint64_t offset; /* unused for now */ |
ddea0ada | 146 | uint32_t seek; /* enum lttng_viewer_seek */ |
d3e2ba59 JD |
147 | } __attribute__((__packed__)); |
148 | ||
149 | struct lttng_viewer_attach_session_response { | |
ddea0ada JD |
150 | /* enum lttng_viewer_attach_return_code */ |
151 | uint32_t status; | |
d3e2ba59 | 152 | uint32_t streams_count; |
ddea0ada JD |
153 | /* struct lttng_viewer_stream */ |
154 | char stream_list[]; | |
d3e2ba59 JD |
155 | } __attribute__((__packed__)); |
156 | ||
157 | /* | |
158 | * VIEWER_GET_NEXT_INDEX payload. | |
159 | */ | |
160 | struct lttng_viewer_get_next_index { | |
161 | uint64_t stream_id; | |
162 | } __attribute__ ((__packed__)); | |
163 | ||
164 | struct lttng_viewer_index { | |
d3e2ba59 JD |
165 | uint64_t offset; |
166 | uint64_t packet_size; | |
167 | uint64_t content_size; | |
168 | uint64_t timestamp_begin; | |
169 | uint64_t timestamp_end; | |
170 | uint64_t events_discarded; | |
171 | uint64_t stream_id; | |
ddea0ada JD |
172 | /* enum lttng_viewer_next_index_return_code */ |
173 | uint32_t status; | |
d3e2ba59 JD |
174 | uint32_t flags; /* LTTNG_VIEWER_FLAG_* */ |
175 | } __attribute__ ((__packed__)); | |
176 | ||
177 | /* | |
178 | * VIEWER_GET_PACKET payload. | |
179 | */ | |
180 | struct lttng_viewer_get_packet { | |
181 | uint64_t stream_id; | |
182 | uint64_t offset; | |
183 | uint32_t len; | |
184 | } __attribute__((__packed__)); | |
185 | ||
186 | struct lttng_viewer_trace_packet { | |
ddea0ada JD |
187 | /* enum lttng_viewer_get_packet_return_code */ |
188 | uint32_t status; | |
d3e2ba59 JD |
189 | uint32_t len; |
190 | uint32_t flags; /* LTTNG_VIEWER_FLAG_* */ | |
191 | char data[]; | |
192 | } __attribute__((__packed__)); | |
193 | ||
194 | /* | |
195 | * VIEWER_GET_METADATA payload. | |
196 | */ | |
197 | struct lttng_viewer_get_metadata { | |
198 | uint64_t stream_id; | |
199 | } __attribute__((__packed__)); | |
200 | ||
201 | struct lttng_viewer_metadata_packet { | |
d3e2ba59 | 202 | uint64_t len; |
ddea0ada JD |
203 | /* enum lttng_viewer_get_metadata_return_code */ |
204 | uint32_t status; | |
d3e2ba59 JD |
205 | char data[]; |
206 | } __attribute__((__packed__)); | |
207 | ||
80e8027a JD |
208 | /* |
209 | * VIEWER_GET_NEW_STREAMS payload. | |
210 | */ | |
211 | struct lttng_viewer_new_streams_request { | |
212 | uint64_t session_id; | |
213 | } __attribute__((__packed__)); | |
214 | ||
215 | struct lttng_viewer_new_streams_response { | |
216 | /* enum lttng_viewer_new_streams_return_code */ | |
217 | uint32_t status; | |
218 | uint32_t streams_count; | |
219 | /* struct lttng_viewer_stream */ | |
220 | char stream_list[]; | |
221 | } __attribute__((__packed__)); | |
222 | ||
223 | ||
2f8f53af | 224 | #endif /* LTTNG_VIEWER_ABI_H */ |