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