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> |
b8aa1682 | 30 | |
6947778e MD |
31 | #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR |
32 | #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR | |
0a6b5085 | 33 | |
1c17e424 JR |
34 | #define RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4 64 |
35 | #define RELAYD_COMM_LTTNG_NAME_MAX_2_4 255 | |
36 | #define RELAYD_COMM_LTTNG_PATH_MAX 4096 | |
37 | #define RELAYD_COMM_DEFAULT_STREAM_NAME_LEN 264 /* 256 + 8 */ | |
38 | ||
b8aa1682 JD |
39 | /* |
40 | * lttng-relayd communication header. | |
41 | */ | |
42 | struct lttcomm_relayd_hdr { | |
43 | /* Circuit ID not used for now so always ignored */ | |
44 | uint64_t circuit_id; | |
45 | uint64_t data_size; /* data size following this header */ | |
7c9534d6 | 46 | uint32_t cmd; /* enum lttcomm_relayd_command */ |
b8aa1682 | 47 | uint32_t cmd_version; /* command version */ |
a9e87764 | 48 | } LTTNG_PACKED; |
b8aa1682 JD |
49 | |
50 | /* | |
51 | * lttng-relayd data header. | |
52 | */ | |
53 | struct lttcomm_relayd_data_hdr { | |
54 | /* Circuit ID not used for now so always ignored */ | |
55 | uint64_t circuit_id; | |
56 | uint64_t stream_id; /* Stream ID known by the relayd */ | |
173af62f | 57 | uint64_t net_seq_num; /* Network sequence number, per stream. */ |
b8aa1682 | 58 | uint32_t data_size; /* data size following this header */ |
1d4dfdef | 59 | uint32_t padding_size; /* Size of 0 padding the data */ |
a9e87764 | 60 | } LTTNG_PACKED; |
b8aa1682 | 61 | |
c5b6f4f0 DG |
62 | /* |
63 | * Reply from a create session command. | |
64 | */ | |
65 | struct lttcomm_relayd_status_session { | |
66 | uint64_t session_id; | |
67 | uint32_t ret_code; | |
a9e87764 | 68 | } LTTNG_PACKED; |
c5b6f4f0 | 69 | |
b8aa1682 JD |
70 | /* |
71 | * Used to add a stream on the relay daemon. | |
72 | */ | |
73 | struct lttcomm_relayd_add_stream { | |
1c17e424 JR |
74 | char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN]; |
75 | char pathname[RELAYD_COMM_LTTNG_PATH_MAX]; | |
a9e87764 | 76 | } LTTNG_PACKED; |
b8aa1682 | 77 | |
0f907de1 JD |
78 | /* |
79 | * Used to add a stream on the relay daemon. | |
80 | * Protocol version 2.2 | |
81 | */ | |
82 | struct lttcomm_relayd_add_stream_2_2 { | |
1c17e424 JR |
83 | char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN]; |
84 | char pathname[RELAYD_COMM_LTTNG_PATH_MAX]; | |
0f907de1 JD |
85 | uint64_t tracefile_size; |
86 | uint64_t tracefile_count; | |
87 | } LTTNG_PACKED; | |
88 | ||
2f21a469 JR |
89 | struct lttcomm_relayd_add_stream_2_11 { |
90 | uint32_t channel_name_len; | |
91 | uint32_t pathname_len; | |
92 | uint64_t tracefile_size; | |
93 | uint64_t tracefile_count; | |
0b50e4b3 | 94 | uint64_t trace_archive_id; |
2f21a469 JR |
95 | char names[]; |
96 | } LTTNG_PACKED; | |
97 | ||
b8aa1682 JD |
98 | /* |
99 | * Answer from an add stream command. | |
100 | */ | |
101 | struct lttcomm_relayd_status_stream { | |
102 | uint64_t handle; | |
103 | uint32_t ret_code; | |
a9e87764 | 104 | } LTTNG_PACKED; |
b8aa1682 JD |
105 | |
106 | /* | |
107 | * Used to return command code for command not needing special data. | |
108 | */ | |
109 | struct lttcomm_relayd_generic_reply { | |
110 | uint32_t ret_code; | |
a9e87764 | 111 | } LTTNG_PACKED; |
b8aa1682 | 112 | |
b8aa1682 JD |
113 | /* |
114 | * Version command. | |
115 | */ | |
116 | struct lttcomm_relayd_version { | |
117 | uint32_t major; | |
118 | uint32_t minor; | |
a9e87764 | 119 | } LTTNG_PACKED; |
b8aa1682 JD |
120 | |
121 | /* | |
122 | * Metadata payload used when metadata command is sent. | |
123 | */ | |
124 | struct lttcomm_relayd_metadata_payload { | |
125 | uint64_t stream_id; | |
1d4dfdef | 126 | uint32_t padding_size; |
b8aa1682 | 127 | char payload[]; |
a9e87764 | 128 | } LTTNG_PACKED; |
b8aa1682 | 129 | |
173af62f DG |
130 | /* |
131 | * Used to indicate that a specific stream id can now be closed. | |
132 | */ | |
133 | struct lttcomm_relayd_close_stream { | |
134 | uint64_t stream_id; | |
135 | uint64_t last_net_seq_num; /* sequence number of last packet */ | |
a9e87764 | 136 | } LTTNG_PACKED; |
173af62f | 137 | |
c8f59ee5 | 138 | /* |
6d805429 DG |
139 | * Used to test if for a given stream id the data is pending on the relayd side |
140 | * for reading. | |
c8f59ee5 | 141 | */ |
6d805429 | 142 | struct lttcomm_relayd_data_pending { |
c8f59ee5 DG |
143 | uint64_t stream_id; |
144 | uint64_t last_net_seq_num; /* Sequence number of the last packet */ | |
a9e87764 | 145 | } LTTNG_PACKED; |
c8f59ee5 | 146 | |
f7079f67 DG |
147 | struct lttcomm_relayd_begin_data_pending { |
148 | uint64_t session_id; | |
a9e87764 | 149 | } LTTNG_PACKED; |
f7079f67 DG |
150 | |
151 | struct lttcomm_relayd_end_data_pending { | |
152 | uint64_t session_id; | |
a9e87764 | 153 | } LTTNG_PACKED; |
f7079f67 | 154 | |
ad7051c0 DG |
155 | struct lttcomm_relayd_quiescent_control { |
156 | uint64_t stream_id; | |
157 | } LTTNG_PACKED; | |
158 | ||
1c20f0e2 JD |
159 | /* |
160 | * Index data. | |
161 | */ | |
162 | struct lttcomm_relayd_index { | |
163 | uint64_t relay_stream_id; | |
164 | uint64_t net_seq_num; | |
165 | uint64_t packet_size; | |
166 | uint64_t content_size; | |
167 | uint64_t timestamp_begin; | |
168 | uint64_t timestamp_end; | |
169 | uint64_t events_discarded; | |
170 | uint64_t stream_id; | |
f8f3885c | 171 | /* 2.8+ */ |
234cd636 JD |
172 | uint64_t stream_instance_id; |
173 | uint64_t packet_seq_num; | |
1c20f0e2 JD |
174 | } LTTNG_PACKED; |
175 | ||
f8f3885c MD |
176 | static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor) |
177 | { | |
178 | if (major == 1) { | |
179 | switch (minor) { | |
180 | case 0: | |
181 | return offsetof(struct lttcomm_relayd_index, stream_id) | |
182 | + member_sizeof(struct lttcomm_relayd_index, | |
183 | stream_id); | |
184 | case 1: | |
185 | return offsetof(struct lttcomm_relayd_index, packet_seq_num) | |
186 | + member_sizeof(struct lttcomm_relayd_index, | |
187 | packet_seq_num); | |
188 | default: | |
189 | abort(); | |
190 | } | |
191 | } | |
192 | abort(); | |
193 | } | |
194 | ||
d3e2ba59 JD |
195 | /* |
196 | * Create session in 2.4 adds additionnal parameters for live reading. | |
197 | */ | |
198 | struct lttcomm_relayd_create_session_2_4 { | |
1c17e424 JR |
199 | char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4]; |
200 | char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4]; | |
d3e2ba59 | 201 | uint32_t live_timer; |
7d2f7452 | 202 | uint32_t snapshot; |
d3e2ba59 JD |
203 | } LTTNG_PACKED; |
204 | ||
f86f6389 JR |
205 | struct lttcomm_relayd_create_session_2_11 { |
206 | uint32_t session_name_len; | |
207 | uint32_t hostname_len; | |
208 | uint32_t live_timer; | |
209 | uint8_t snapshot; | |
fdc04e4b JG |
210 | /* Sessiond instance UUID */ |
211 | lttng_uuid sessiond_uuid; | |
212 | /* Sessiond session id */ | |
213 | uint64_t session_id; | |
f86f6389 JR |
214 | /* Contains the session_name and hostname */ |
215 | char names[]; | |
216 | } LTTNG_PACKED; | |
217 | ||
93ec662e JD |
218 | /* |
219 | * Used to ask the relay to reset the metadata trace file (regeneration). | |
220 | * Send the new version of the metadata (starts at 0). | |
221 | */ | |
222 | struct lttcomm_relayd_reset_metadata { | |
223 | uint64_t stream_id; | |
224 | uint64_t version; | |
225 | } LTTNG_PACKED; | |
226 | ||
d3ecc550 JD |
227 | struct lttcomm_relayd_rotate_stream { |
228 | uint64_t stream_id; | |
d73bf3d7 | 229 | /* Ignored for metadata streams. */ |
d3ecc550 JD |
230 | uint64_t rotate_at_seq_num; |
231 | uint64_t new_chunk_id; | |
232 | /* Includes trailing NULL. */ | |
233 | uint32_t pathname_length; | |
234 | /* Must be the last member of this structure. */ | |
235 | char new_pathname[]; | |
236 | } LTTNG_PACKED; | |
237 | ||
00fb02ac JD |
238 | struct lttcomm_relayd_rotate_rename { |
239 | uint32_t old_path_length; | |
240 | uint32_t new_path_length; | |
241 | /* Concatenation of the old and new paths, separated by \0. */ | |
242 | char paths[]; | |
243 | } LTTNG_PACKED; | |
244 | ||
e2acc8d2 JD |
245 | struct lttcomm_relayd_rotate_pending { |
246 | uint64_t chunk_id; | |
247 | } LTTNG_PACKED; | |
248 | ||
d88744a4 JD |
249 | struct lttcomm_relayd_rotate_pending_reply { |
250 | struct lttcomm_relayd_generic_reply generic; | |
251 | /* Valid values are [0, 1]. */ | |
252 | uint8_t is_pending; | |
253 | } LTTNG_PACKED; | |
254 | ||
a1ae2ea5 JD |
255 | struct lttcomm_relayd_mkdir { |
256 | /* Includes trailing NULL */ | |
257 | uint32_t length; | |
258 | char path[]; | |
259 | } LTTNG_PACKED; | |
260 | ||
b8aa1682 | 261 | #endif /* _RELAYD_COMM */ |