Commit | Line | Data |
---|---|---|
b8aa1682 JD |
1 | /* |
2 | * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com> | |
3 | * Julien Desfossez <julien.desfossez@efficios.com> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License, version 2 only, | |
7 | * as published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; if not, write to the Free Software Foundation, Inc., | |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | */ | |
18 | ||
19 | #ifndef _RELAYD_COMM | |
20 | #define _RELAYD_COMM | |
21 | ||
b8aa1682 JD |
22 | #include <limits.h> |
23 | #include <stdint.h> | |
24 | ||
25 | #include <lttng/lttng.h> | |
ce2a9e76 | 26 | #include <common/defaults.h> |
50adc264 | 27 | #include <common/index/ctf-index.h> |
f79a92e2 | 28 | #include <common/macros.h> |
fdc04e4b | 29 | #include <common/compat/uuid.h> |
165a2054 | 30 | #include <common/optional.h> |
b8aa1682 | 31 | |
6947778e MD |
32 | #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR |
33 | #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR | |
0a6b5085 | 34 | |
1c17e424 JR |
35 | #define RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4 64 |
36 | #define RELAYD_COMM_LTTNG_NAME_MAX_2_4 255 | |
37 | #define RELAYD_COMM_LTTNG_PATH_MAX 4096 | |
38 | #define RELAYD_COMM_DEFAULT_STREAM_NAME_LEN 264 /* 256 + 8 */ | |
39 | ||
b8aa1682 JD |
40 | /* |
41 | * lttng-relayd communication header. | |
42 | */ | |
43 | struct lttcomm_relayd_hdr { | |
44 | /* Circuit ID not used for now so always ignored */ | |
45 | uint64_t circuit_id; | |
46 | uint64_t data_size; /* data size following this header */ | |
7c9534d6 | 47 | uint32_t cmd; /* enum lttcomm_relayd_command */ |
b8aa1682 | 48 | uint32_t cmd_version; /* command version */ |
a9e87764 | 49 | } LTTNG_PACKED; |
b8aa1682 JD |
50 | |
51 | /* | |
52 | * lttng-relayd data header. | |
53 | */ | |
54 | struct lttcomm_relayd_data_hdr { | |
55 | /* Circuit ID not used for now so always ignored */ | |
56 | uint64_t circuit_id; | |
57 | uint64_t stream_id; /* Stream ID known by the relayd */ | |
173af62f | 58 | uint64_t net_seq_num; /* Network sequence number, per stream. */ |
b8aa1682 | 59 | uint32_t data_size; /* data size following this header */ |
1d4dfdef | 60 | uint32_t padding_size; /* Size of 0 padding the data */ |
a9e87764 | 61 | } LTTNG_PACKED; |
b8aa1682 | 62 | |
c5b6f4f0 DG |
63 | /* |
64 | * Reply from a create session command. | |
65 | */ | |
66 | struct lttcomm_relayd_status_session { | |
67 | uint64_t session_id; | |
68 | uint32_t ret_code; | |
a9e87764 | 69 | } LTTNG_PACKED; |
c5b6f4f0 | 70 | |
b8aa1682 JD |
71 | /* |
72 | * Used to add a stream on the relay daemon. | |
73 | */ | |
74 | struct lttcomm_relayd_add_stream { | |
1c17e424 JR |
75 | char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN]; |
76 | char pathname[RELAYD_COMM_LTTNG_PATH_MAX]; | |
a9e87764 | 77 | } LTTNG_PACKED; |
b8aa1682 | 78 | |
0f907de1 JD |
79 | /* |
80 | * Used to add a stream on the relay daemon. | |
81 | * Protocol version 2.2 | |
82 | */ | |
83 | struct lttcomm_relayd_add_stream_2_2 { | |
1c17e424 JR |
84 | char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN]; |
85 | char pathname[RELAYD_COMM_LTTNG_PATH_MAX]; | |
0f907de1 JD |
86 | uint64_t tracefile_size; |
87 | uint64_t tracefile_count; | |
88 | } LTTNG_PACKED; | |
89 | ||
2f21a469 JR |
90 | struct lttcomm_relayd_add_stream_2_11 { |
91 | uint32_t channel_name_len; | |
92 | uint32_t pathname_len; | |
93 | uint64_t tracefile_size; | |
94 | uint64_t tracefile_count; | |
61ace1d3 | 95 | uint64_t trace_chunk_id; |
2f21a469 JR |
96 | char names[]; |
97 | } LTTNG_PACKED; | |
98 | ||
b8aa1682 JD |
99 | /* |
100 | * Answer from an add stream command. | |
101 | */ | |
102 | struct lttcomm_relayd_status_stream { | |
103 | uint64_t handle; | |
104 | uint32_t ret_code; | |
a9e87764 | 105 | } LTTNG_PACKED; |
b8aa1682 JD |
106 | |
107 | /* | |
108 | * Used to return command code for command not needing special data. | |
109 | */ | |
110 | struct lttcomm_relayd_generic_reply { | |
111 | uint32_t ret_code; | |
a9e87764 | 112 | } LTTNG_PACKED; |
b8aa1682 | 113 | |
b8aa1682 JD |
114 | /* |
115 | * Version command. | |
116 | */ | |
117 | struct lttcomm_relayd_version { | |
118 | uint32_t major; | |
119 | uint32_t minor; | |
a9e87764 | 120 | } LTTNG_PACKED; |
b8aa1682 JD |
121 | |
122 | /* | |
123 | * Metadata payload used when metadata command is sent. | |
124 | */ | |
125 | struct lttcomm_relayd_metadata_payload { | |
126 | uint64_t stream_id; | |
1d4dfdef | 127 | uint32_t padding_size; |
b8aa1682 | 128 | char payload[]; |
a9e87764 | 129 | } LTTNG_PACKED; |
b8aa1682 | 130 | |
173af62f DG |
131 | /* |
132 | * Used to indicate that a specific stream id can now be closed. | |
133 | */ | |
134 | struct lttcomm_relayd_close_stream { | |
135 | uint64_t stream_id; | |
136 | uint64_t last_net_seq_num; /* sequence number of last packet */ | |
a9e87764 | 137 | } LTTNG_PACKED; |
173af62f | 138 | |
c8f59ee5 | 139 | /* |
6d805429 DG |
140 | * Used to test if for a given stream id the data is pending on the relayd side |
141 | * for reading. | |
c8f59ee5 | 142 | */ |
6d805429 | 143 | struct lttcomm_relayd_data_pending { |
c8f59ee5 DG |
144 | uint64_t stream_id; |
145 | uint64_t last_net_seq_num; /* Sequence number of the last packet */ | |
a9e87764 | 146 | } LTTNG_PACKED; |
c8f59ee5 | 147 | |
f7079f67 DG |
148 | struct lttcomm_relayd_begin_data_pending { |
149 | uint64_t session_id; | |
a9e87764 | 150 | } LTTNG_PACKED; |
f7079f67 DG |
151 | |
152 | struct lttcomm_relayd_end_data_pending { | |
153 | uint64_t session_id; | |
a9e87764 | 154 | } LTTNG_PACKED; |
f7079f67 | 155 | |
ad7051c0 DG |
156 | struct lttcomm_relayd_quiescent_control { |
157 | uint64_t stream_id; | |
158 | } LTTNG_PACKED; | |
159 | ||
1c20f0e2 JD |
160 | /* |
161 | * Index data. | |
162 | */ | |
163 | struct lttcomm_relayd_index { | |
164 | uint64_t relay_stream_id; | |
165 | uint64_t net_seq_num; | |
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; | |
f8f3885c | 172 | /* 2.8+ */ |
234cd636 JD |
173 | uint64_t stream_instance_id; |
174 | uint64_t packet_seq_num; | |
1c20f0e2 JD |
175 | } LTTNG_PACKED; |
176 | ||
f8f3885c MD |
177 | static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor) |
178 | { | |
179 | if (major == 1) { | |
180 | switch (minor) { | |
181 | case 0: | |
182 | return offsetof(struct lttcomm_relayd_index, stream_id) | |
183 | + member_sizeof(struct lttcomm_relayd_index, | |
184 | stream_id); | |
185 | case 1: | |
186 | return offsetof(struct lttcomm_relayd_index, packet_seq_num) | |
187 | + member_sizeof(struct lttcomm_relayd_index, | |
188 | packet_seq_num); | |
189 | default: | |
190 | abort(); | |
191 | } | |
192 | } | |
193 | abort(); | |
194 | } | |
195 | ||
d3e2ba59 JD |
196 | /* |
197 | * Create session in 2.4 adds additionnal parameters for live reading. | |
198 | */ | |
199 | struct lttcomm_relayd_create_session_2_4 { | |
1c17e424 JR |
200 | char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4]; |
201 | char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4]; | |
d3e2ba59 | 202 | uint32_t live_timer; |
7d2f7452 | 203 | uint32_t snapshot; |
d3e2ba59 JD |
204 | } LTTNG_PACKED; |
205 | ||
f86f6389 JR |
206 | struct lttcomm_relayd_create_session_2_11 { |
207 | uint32_t session_name_len; | |
208 | uint32_t hostname_len; | |
6ef36453 MD |
209 | /* Optional, set to 0 to indicate it is not user-specified. */ |
210 | uint32_t base_path_len; | |
f86f6389 JR |
211 | uint32_t live_timer; |
212 | uint8_t snapshot; | |
55ce50b6 | 213 | uint8_t session_name_contains_creation_time; |
fdc04e4b JG |
214 | /* Sessiond instance UUID */ |
215 | lttng_uuid sessiond_uuid; | |
216 | /* Sessiond session id */ | |
217 | uint64_t session_id; | |
0fb564b1 JG |
218 | /* Session creation time, in seconds since UNIX Epoch. */ |
219 | uint64_t creation_time; | |
220 | LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED current_chunk_id; | |
6ef36453 | 221 | /* Contains the session_name, hostname, base_path. */ |
f86f6389 JR |
222 | char names[]; |
223 | } LTTNG_PACKED; | |
224 | ||
41b23598 MD |
225 | struct lttcomm_relayd_create_session_reply_2_11 { |
226 | struct lttcomm_relayd_status_session generic; | |
227 | /* Includes the '\0' terminator. */ | |
228 | uint32_t output_path_length; | |
229 | char output_path[]; | |
230 | } LTTNG_PACKED; | |
231 | ||
93ec662e JD |
232 | /* |
233 | * Used to ask the relay to reset the metadata trace file (regeneration). | |
234 | * Send the new version of the metadata (starts at 0). | |
235 | */ | |
236 | struct lttcomm_relayd_reset_metadata { | |
237 | uint64_t stream_id; | |
238 | uint64_t version; | |
239 | } LTTNG_PACKED; | |
240 | ||
84a93c08 | 241 | struct lttcomm_relayd_stream_rotation_position { |
d3ecc550 | 242 | uint64_t stream_id; |
84a93c08 JG |
243 | /* |
244 | * Sequence number of the first packet belonging to the new | |
245 | * "destination" trace chunk to which the stream is rotating. | |
246 | * | |
247 | * Ignored for metadata streams. | |
248 | */ | |
d3ecc550 | 249 | uint64_t rotate_at_seq_num; |
84a93c08 JG |
250 | } LTTNG_PACKED; |
251 | ||
252 | struct lttcomm_relayd_rotate_streams { | |
253 | uint32_t stream_count; | |
254 | /* | |
255 | * Streams can be rotated outside of a chunk but not be parented to | |
256 | * a new chunk. | |
257 | */ | |
258 | LTTNG_OPTIONAL_COMM(uint64_t) new_chunk_id; | |
259 | /* `stream_count` positions follow. */ | |
260 | struct lttcomm_relayd_stream_rotation_position rotation_positions[]; | |
d3ecc550 JD |
261 | } LTTNG_PACKED; |
262 | ||
0ebdafe0 JG |
263 | struct lttcomm_relayd_create_trace_chunk { |
264 | uint64_t chunk_id; | |
265 | /* Seconds since EPOCH. */ | |
266 | uint64_t creation_timestamp; | |
267 | /* Includes trailing NULL. */ | |
268 | uint32_t override_name_length; | |
269 | char override_name[]; | |
270 | } LTTNG_PACKED; | |
271 | ||
6bbcff33 JG |
272 | struct lttcomm_relayd_close_trace_chunk { |
273 | uint64_t chunk_id; | |
274 | /* Seconds since EPOCH. */ | |
275 | uint64_t close_timestamp; | |
276 | /* enum lttng_trace_chunk_command_type */ | |
277 | LTTNG_OPTIONAL_COMM(uint32_t) LTTNG_PACKED close_command; | |
278 | } LTTNG_PACKED; | |
279 | ||
41b23598 MD |
280 | struct lttcomm_relayd_close_trace_chunk_reply { |
281 | struct lttcomm_relayd_generic_reply generic; | |
282 | /* Includes trailing NULL. */ | |
283 | uint32_t path_length; | |
284 | char path[]; | |
285 | } LTTNG_PACKED; | |
286 | ||
84a93c08 JG |
287 | struct lttcomm_relayd_trace_chunk_exists { |
288 | uint64_t chunk_id; | |
289 | } LTTNG_PACKED; | |
290 | ||
291 | struct lttcomm_relayd_trace_chunk_exists_reply { | |
292 | struct lttcomm_relayd_generic_reply generic; | |
293 | uint8_t trace_chunk_exists; | |
294 | } LTTNG_PACKED; | |
295 | ||
b8aa1682 | 296 | #endif /* _RELAYD_COMM */ |