2 * Copyright (C) 2012 - David Goulet <dgoulet@efficios.com>
3 * Julien Desfossez <julien.desfossez@efficios.com>
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.
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
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.
25 #include <lttng/lttng.h>
26 #include <common/defaults.h>
27 #include <common/index/ctf-index.h>
28 #include <common/macros.h>
29 #include <common/compat/uuid.h>
31 #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR
32 #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR
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 */
40 * lttng-relayd communication header.
42 struct lttcomm_relayd_hdr
{
43 /* Circuit ID not used for now so always ignored */
45 uint64_t data_size
; /* data size following this header */
46 uint32_t cmd
; /* enum lttcomm_relayd_command */
47 uint32_t cmd_version
; /* command version */
51 * lttng-relayd data header.
53 struct lttcomm_relayd_data_hdr
{
54 /* Circuit ID not used for now so always ignored */
56 uint64_t stream_id
; /* Stream ID known by the relayd */
57 uint64_t net_seq_num
; /* Network sequence number, per stream. */
58 uint32_t data_size
; /* data size following this header */
59 uint32_t padding_size
; /* Size of 0 padding the data */
63 * Reply from a create session command.
65 struct lttcomm_relayd_status_session
{
71 * Used to add a stream on the relay daemon.
73 struct lttcomm_relayd_add_stream
{
74 char channel_name
[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN
];
75 char pathname
[RELAYD_COMM_LTTNG_PATH_MAX
];
79 * Used to add a stream on the relay daemon.
80 * Protocol version 2.2
82 struct lttcomm_relayd_add_stream_2_2
{
83 char channel_name
[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN
];
84 char pathname
[RELAYD_COMM_LTTNG_PATH_MAX
];
85 uint64_t tracefile_size
;
86 uint64_t tracefile_count
;
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
;
94 uint64_t trace_archive_id
;
99 * Answer from an add stream command.
101 struct lttcomm_relayd_status_stream
{
107 * Used to return command code for command not needing special data.
109 struct lttcomm_relayd_generic_reply
{
116 struct lttcomm_relayd_version
{
122 * Metadata payload used when metadata command is sent.
124 struct lttcomm_relayd_metadata_payload
{
126 uint32_t padding_size
;
131 * Used to indicate that a specific stream id can now be closed.
133 struct lttcomm_relayd_close_stream
{
135 uint64_t last_net_seq_num
; /* sequence number of last packet */
139 * Used to test if for a given stream id the data is pending on the relayd side
142 struct lttcomm_relayd_data_pending
{
144 uint64_t last_net_seq_num
; /* Sequence number of the last packet */
147 struct lttcomm_relayd_begin_data_pending
{
151 struct lttcomm_relayd_end_data_pending
{
155 struct lttcomm_relayd_quiescent_control
{
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
;
172 uint64_t stream_instance_id
;
173 uint64_t packet_seq_num
;
176 static inline size_t lttcomm_relayd_index_len(uint32_t major
, uint32_t minor
)
181 return offsetof(struct lttcomm_relayd_index
, stream_id
)
182 + member_sizeof(struct lttcomm_relayd_index
,
185 return offsetof(struct lttcomm_relayd_index
, packet_seq_num
)
186 + member_sizeof(struct lttcomm_relayd_index
,
196 * Create session in 2.4 adds additionnal parameters for live reading.
198 struct lttcomm_relayd_create_session_2_4
{
199 char session_name
[RELAYD_COMM_LTTNG_NAME_MAX_2_4
];
200 char hostname
[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4
];
205 struct lttcomm_relayd_create_session_2_11
{
206 uint32_t session_name_len
;
207 uint32_t hostname_len
;
210 /* Sessiond instance UUID */
211 lttng_uuid sessiond_uuid
;
212 /* Sessiond session id */
214 /* Contains the session_name and hostname */
219 * Used to ask the relay to reset the metadata trace file (regeneration).
220 * Send the new version of the metadata (starts at 0).
222 struct lttcomm_relayd_reset_metadata
{
227 struct lttcomm_relayd_rotate_stream
{
229 /* Ignored for metadata streams. */
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. */
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. */
245 struct lttcomm_relayd_rotate_pending
{
249 struct lttcomm_relayd_rotate_pending_reply
{
250 struct lttcomm_relayd_generic_reply generic
;
251 /* Valid values are [0, 1]. */
255 struct lttcomm_relayd_mkdir
{
256 /* Includes trailing NULL */
261 #endif /* _RELAYD_COMM */