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