a3d78bb2caf4e185bae73fa974705306e5a8d6f9
[lttng-tools.git] / src / bin / lttng-relayd / lttng-viewer-abi.h
1 #ifndef LTTNG_VIEWER_ABI_H
2 #define LTTNG_VIEWER_ABI_H
3
4 /*
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * David Goulet <dgoulet@efficios.com>
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
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.
26 */
27
28 #include <limits.h>
29 #include <common/macros.h>
30
31 #define LTTNG_VIEWER_PATH_MAX 4096
32 #define LTTNG_VIEWER_NAME_MAX 255
33 #define LTTNG_VIEWER_HOST_NAME_MAX 64
34
35 /* Flags in reply to get_next_index and get_packet. */
36 enum {
37 /* New metadata is required to read this packet. */
38 LTTNG_VIEWER_FLAG_NEW_METADATA = (1 << 0),
39 /* New stream got added to the trace. */
40 LTTNG_VIEWER_FLAG_NEW_STREAM = (1 << 1),
41 };
42
43 enum lttng_viewer_command {
44 LTTNG_VIEWER_CONNECT = 1,
45 LTTNG_VIEWER_LIST_SESSIONS = 2,
46 LTTNG_VIEWER_ATTACH_SESSION = 3,
47 LTTNG_VIEWER_GET_NEXT_INDEX = 4,
48 LTTNG_VIEWER_GET_PACKET = 5,
49 LTTNG_VIEWER_GET_METADATA = 6,
50 LTTNG_VIEWER_GET_NEW_STREAMS = 7,
51 LTTNG_VIEWER_CREATE_SESSION = 8,
52 LTTNG_VIEWER_DETACH_SESSION = 9,
53 };
54
55 enum lttng_viewer_attach_return_code {
56 LTTNG_VIEWER_ATTACH_OK = 1, /* The attach command succeeded. */
57 LTTNG_VIEWER_ATTACH_ALREADY = 2, /* A viewer is already attached. */
58 LTTNG_VIEWER_ATTACH_UNK = 3, /* The session ID is unknown. */
59 LTTNG_VIEWER_ATTACH_NOT_LIVE = 4, /* The session is not live. */
60 LTTNG_VIEWER_ATTACH_SEEK_ERR = 5, /* Seek error. */
61 LTTNG_VIEWER_ATTACH_NO_SESSION = 6, /* No viewer session created. */
62 };
63
64 enum lttng_viewer_next_index_return_code {
65 LTTNG_VIEWER_INDEX_OK = 1, /* Index is available. */
66 LTTNG_VIEWER_INDEX_RETRY = 2, /* Index not yet available. */
67 LTTNG_VIEWER_INDEX_HUP = 3, /* Index closed (trace destroyed). */
68 LTTNG_VIEWER_INDEX_ERR = 4, /* Unknow error. */
69 LTTNG_VIEWER_INDEX_INACTIVE = 5, /* Inactive stream beacon. */
70 LTTNG_VIEWER_INDEX_EOF = 6, /* End of index file. */
71 };
72
73 enum lttng_viewer_get_packet_return_code {
74 LTTNG_VIEWER_GET_PACKET_OK = 1,
75 LTTNG_VIEWER_GET_PACKET_RETRY = 2,
76 LTTNG_VIEWER_GET_PACKET_ERR = 3,
77 LTTNG_VIEWER_GET_PACKET_EOF = 4,
78 };
79
80 enum lttng_viewer_get_metadata_return_code {
81 LTTNG_VIEWER_METADATA_OK = 1,
82 LTTNG_VIEWER_NO_NEW_METADATA = 2,
83 LTTNG_VIEWER_METADATA_ERR = 3,
84 };
85
86 enum lttng_viewer_connection_type {
87 LTTNG_VIEWER_CLIENT_COMMAND = 1,
88 LTTNG_VIEWER_CLIENT_NOTIFICATION = 2,
89 };
90
91 enum lttng_viewer_seek {
92 /* Receive the trace packets from the beginning. */
93 LTTNG_VIEWER_SEEK_BEGINNING = 1,
94 /* Receive the trace packets from now. */
95 LTTNG_VIEWER_SEEK_LAST = 2,
96 };
97
98 enum lttng_viewer_new_streams_return_code {
99 LTTNG_VIEWER_NEW_STREAMS_OK = 1, /* If new streams are being sent. */
100 LTTNG_VIEWER_NEW_STREAMS_NO_NEW = 2, /* If no new streams are available. */
101 LTTNG_VIEWER_NEW_STREAMS_ERR = 3, /* Error. */
102 LTTNG_VIEWER_NEW_STREAMS_HUP = 4, /* Session closed. */
103 };
104
105 enum lttng_viewer_create_session_return_code {
106 LTTNG_VIEWER_CREATE_SESSION_OK = 1,
107 LTTNG_VIEWER_CREATE_SESSION_ERR = 2,
108 };
109
110 enum lttng_viewer_detach_session_return_code {
111 LTTNG_VIEWER_DETACH_SESSION_OK = 1,
112 LTTNG_VIEWER_DETACH_SESSION_UNK = 2,
113 LTTNG_VIEWER_DETACH_SESSION_ERR = 3,
114 };
115
116 struct lttng_viewer_session {
117 uint64_t id;
118 uint32_t live_timer;
119 uint32_t clients;
120 uint32_t streams;
121 char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
122 char session_name[LTTNG_VIEWER_NAME_MAX];
123 } LTTNG_PACKED;
124
125 struct lttng_viewer_stream {
126 uint64_t id;
127 uint64_t ctf_trace_id;
128 uint32_t metadata_flag;
129 char path_name[LTTNG_VIEWER_PATH_MAX];
130 char channel_name[LTTNG_VIEWER_NAME_MAX];
131 } LTTNG_PACKED;
132
133 struct lttng_viewer_cmd {
134 uint64_t data_size; /* data size following this header */
135 uint32_t cmd; /* enum lttcomm_relayd_command */
136 uint32_t cmd_version; /* command version */
137 } LTTNG_PACKED;
138
139 /*
140 * LTTNG_VIEWER_CONNECT payload.
141 */
142 struct lttng_viewer_connect {
143 /* session ID assigned by the relay for command connections */
144 uint64_t viewer_session_id;
145 uint32_t major;
146 uint32_t minor;
147 uint32_t type; /* enum lttng_viewer_connection_type */
148 } LTTNG_PACKED;
149
150 /*
151 * LTTNG_VIEWER_LIST_SESSIONS payload.
152 */
153 struct lttng_viewer_list_sessions {
154 uint32_t sessions_count;
155 char session_list[]; /* struct lttng_viewer_session */
156 } LTTNG_PACKED;
157
158 /*
159 * LTTNG_VIEWER_ATTACH_SESSION payload.
160 */
161 struct lttng_viewer_attach_session_request {
162 uint64_t session_id;
163 uint64_t offset; /* unused for now */
164 uint32_t seek; /* enum lttng_viewer_seek */
165 } LTTNG_PACKED;
166
167 struct lttng_viewer_attach_session_response {
168 /* enum lttng_viewer_attach_return_code */
169 uint32_t status;
170 uint32_t streams_count;
171 /* struct lttng_viewer_stream */
172 char stream_list[];
173 } LTTNG_PACKED;
174
175 /*
176 * LTTNG_VIEWER_GET_NEXT_INDEX payload.
177 */
178 struct lttng_viewer_get_next_index {
179 uint64_t stream_id;
180 } __attribute__ ((__packed__));
181
182 struct lttng_viewer_index {
183 uint64_t offset;
184 uint64_t packet_size;
185 uint64_t content_size;
186 uint64_t timestamp_begin;
187 uint64_t timestamp_end;
188 uint64_t events_discarded;
189 uint64_t stream_id;
190 uint32_t status; /* enum lttng_viewer_next_index_return_code */
191 uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
192 } __attribute__ ((__packed__));
193
194 /*
195 * LTTNG_VIEWER_GET_PACKET payload.
196 */
197 struct lttng_viewer_get_packet {
198 uint64_t stream_id;
199 uint64_t offset;
200 uint32_t len;
201 } LTTNG_PACKED;
202
203 struct lttng_viewer_trace_packet {
204 uint32_t status; /* enum lttng_viewer_get_packet_return_code */
205 uint32_t len;
206 uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
207 char data[];
208 } LTTNG_PACKED;
209
210 /*
211 * LTTNG_VIEWER_GET_METADATA payload.
212 */
213 struct lttng_viewer_get_metadata {
214 uint64_t stream_id;
215 } LTTNG_PACKED;
216
217 struct lttng_viewer_metadata_packet {
218 uint64_t len;
219 uint32_t status; /* enum lttng_viewer_get_metadata_return_code */
220 char data[];
221 } LTTNG_PACKED;
222
223 /*
224 * LTTNG_VIEWER_GET_NEW_STREAMS payload.
225 */
226 struct lttng_viewer_new_streams_request {
227 uint64_t session_id;
228 } LTTNG_PACKED;
229
230 struct lttng_viewer_new_streams_response {
231 /* enum lttng_viewer_new_streams_return_code */
232 uint32_t status;
233 uint32_t streams_count;
234 /* struct lttng_viewer_stream */
235 char stream_list[];
236 } LTTNG_PACKED;
237
238 struct lttng_viewer_create_session_response {
239 /* enum lttng_viewer_create_session_return_code */
240 uint32_t status;
241 } LTTNG_PACKED;
242
243 /*
244 * LTTNG_VIEWER_DETACH_SESSION payload.
245 */
246 struct lttng_viewer_detach_session_request {
247 uint64_t session_id;
248 } LTTNG_PACKED;
249
250 struct lttng_viewer_detach_session_response {
251 /* enum lttng_viewer_detach_session_return_code */
252 uint32_t status;
253 } LTTNG_PACKED;
254
255 #endif /* LTTNG_VIEWER_ABI_H */
This page took 0.050992 seconds and 4 git commands to generate.