2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
3 * Copyright (C) 2012 Julien Desfossez <julien.desfossez@efficios.com>
5 * SPDX-License-Identifier: GPL-2.0-only
15 #include <lttng/lttng.h>
16 #include <common/defaults.h>
17 #include <common/index/ctf-index.h>
18 #include <common/macros.h>
19 #include <common/uuid.h>
20 #include <common/optional.h>
22 #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR
23 #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR
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 */
31 * lttng-relayd communication header.
33 struct lttcomm_relayd_hdr
{
34 /* Circuit ID not used for now so always ignored */
36 uint64_t data_size
; /* data size following this header */
37 uint32_t cmd
; /* enum lttcomm_relayd_command */
38 uint32_t cmd_version
; /* command version */
42 * lttng-relayd data header.
44 struct lttcomm_relayd_data_hdr
{
45 /* Circuit ID not used for now so always ignored */
47 uint64_t stream_id
; /* Stream ID known by the relayd */
48 uint64_t net_seq_num
; /* Network sequence number, per stream. */
49 uint32_t data_size
; /* data size following this header */
50 uint32_t padding_size
; /* Size of 0 padding the data */
54 * Reply from a create session command.
56 struct lttcomm_relayd_status_session
{
62 * Used to add a stream on the relay daemon.
64 struct lttcomm_relayd_add_stream
{
65 char channel_name
[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN
];
66 char pathname
[RELAYD_COMM_LTTNG_PATH_MAX
];
70 * Used to add a stream on the relay daemon.
71 * Protocol version 2.2
73 struct lttcomm_relayd_add_stream_2_2
{
74 char channel_name
[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN
];
75 char pathname
[RELAYD_COMM_LTTNG_PATH_MAX
];
76 uint64_t tracefile_size
;
77 uint64_t tracefile_count
;
80 struct 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
;
85 uint64_t trace_chunk_id
;
90 * Answer from an add stream command.
92 struct lttcomm_relayd_status_stream
{
98 * Used to return command code for command not needing special data.
100 struct lttcomm_relayd_generic_reply
{
107 struct lttcomm_relayd_version
{
113 * Metadata payload used when metadata command is sent.
115 struct lttcomm_relayd_metadata_payload
{
117 uint32_t padding_size
;
122 * Used to indicate that a specific stream id can now be closed.
124 struct lttcomm_relayd_close_stream
{
126 uint64_t last_net_seq_num
; /* sequence number of last packet */
130 * Used to test if for a given stream id the data is pending on the relayd side
133 struct lttcomm_relayd_data_pending
{
135 uint64_t last_net_seq_num
; /* Sequence number of the last packet */
138 struct lttcomm_relayd_begin_data_pending
{
142 struct lttcomm_relayd_end_data_pending
{
146 struct lttcomm_relayd_quiescent_control
{
153 struct 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
;
163 uint64_t stream_instance_id
;
164 uint64_t packet_seq_num
;
167 static inline size_t lttcomm_relayd_index_len(uint32_t major
, uint32_t minor
)
172 return offsetof(struct lttcomm_relayd_index
, stream_id
)
173 + member_sizeof(struct lttcomm_relayd_index
,
176 return offsetof(struct lttcomm_relayd_index
, packet_seq_num
)
177 + member_sizeof(struct lttcomm_relayd_index
,
187 * Create session in 2.4 adds additionnal parameters for live reading.
189 struct lttcomm_relayd_create_session_2_4
{
190 char session_name
[RELAYD_COMM_LTTNG_NAME_MAX_2_4
];
191 char hostname
[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4
];
196 struct lttcomm_relayd_create_session_2_11
{
197 uint32_t session_name_len
;
198 uint32_t hostname_len
;
199 /* Optional, set to 0 to indicate it is not user-specified. */
200 uint32_t base_path_len
;
203 uint8_t session_name_contains_creation_time
;
204 /* Sessiond instance UUID */
205 lttng_uuid sessiond_uuid
;
206 /* Sessiond session id */
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
;
211 /* Contains the session_name, hostname, base_path. */
215 struct 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
;
223 * Used to ask the relay to reset the metadata trace file (regeneration).
224 * Send the new version of the metadata (starts at 0).
226 struct lttcomm_relayd_reset_metadata
{
231 struct lttcomm_relayd_stream_rotation_position
{
234 * Sequence number of the first packet belonging to the new
235 * "destination" trace chunk to which the stream is rotating.
237 * Ignored for metadata streams.
239 uint64_t rotate_at_seq_num
;
242 struct lttcomm_relayd_rotate_streams
{
243 uint32_t stream_count
;
245 * Streams can be rotated outside of a chunk but not be parented to
248 LTTNG_OPTIONAL_COMM(uint64_t) new_chunk_id
;
249 /* `stream_count` positions follow. */
250 struct lttcomm_relayd_stream_rotation_position rotation_positions
[];
253 struct lttcomm_relayd_create_trace_chunk
{
255 /* Seconds since EPOCH. */
256 uint64_t creation_timestamp
;
257 /* Includes trailing NULL. */
258 uint32_t override_name_length
;
259 char override_name
[];
262 struct lttcomm_relayd_close_trace_chunk
{
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
;
270 struct lttcomm_relayd_close_trace_chunk_reply
{
271 struct lttcomm_relayd_generic_reply generic
;
272 /* Includes trailing NULL. */
273 uint32_t path_length
;
277 struct lttcomm_relayd_trace_chunk_exists
{
281 struct lttcomm_relayd_trace_chunk_exists_reply
{
282 struct lttcomm_relayd_generic_reply generic
;
283 uint8_t trace_chunk_exists
;
286 enum 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),
291 struct lttcomm_relayd_get_configuration
{
292 uint64_t query_flags
;
296 * Used to return a relay daemon's configuration in reply to the
297 * RELAYD_GET_CONFIGURATION command.
299 struct 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. */
307 #endif /* _RELAYD_COMM */