Fix: backward relayd communication compatibility.
[lttng-tools.git] / src / common / sessiond-comm / relayd.h
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
22 #include <limits.h>
23 #include <stdint.h>
24
25 #include <lttng/lttng.h>
26 #include <common/defaults.h>
27 #include <common/index/ctf-index.h>
28
29 #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJOR
30 #define RELAYD_VERSION_COMM_MINOR VERSION_MINOR
31
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
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 */
44 uint32_t cmd; /* enum lttcomm_relayd_command */
45 uint32_t cmd_version; /* command version */
46 } LTTNG_PACKED;
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 */
55 uint64_t net_seq_num; /* Network sequence number, per stream. */
56 uint32_t data_size; /* data size following this header */
57 uint32_t padding_size; /* Size of 0 padding the data */
58 } LTTNG_PACKED;
59
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;
66 } LTTNG_PACKED;
67
68 /*
69 * Used to add a stream on the relay daemon.
70 */
71 struct lttcomm_relayd_add_stream {
72 char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
73 char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
74 } LTTNG_PACKED;
75
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 {
81 char channel_name[RELAYD_COMM_DEFAULT_STREAM_NAME_LEN];
82 char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
83 uint64_t tracefile_size;
84 uint64_t tracefile_count;
85 } LTTNG_PACKED;
86
87 /*
88 * Answer from an add stream command.
89 */
90 struct lttcomm_relayd_status_stream {
91 uint64_t handle;
92 uint32_t ret_code;
93 } LTTNG_PACKED;
94
95 /*
96 * Used to return command code for command not needing special data.
97 */
98 struct lttcomm_relayd_generic_reply {
99 uint32_t ret_code;
100 } LTTNG_PACKED;
101
102 /*
103 * Version command.
104 */
105 struct lttcomm_relayd_version {
106 uint32_t major;
107 uint32_t minor;
108 } LTTNG_PACKED;
109
110 /*
111 * Metadata payload used when metadata command is sent.
112 */
113 struct lttcomm_relayd_metadata_payload {
114 uint64_t stream_id;
115 uint32_t padding_size;
116 char payload[];
117 } LTTNG_PACKED;
118
119 /*
120 * Used to indicate that a specific stream id can now be closed.
121 */
122 struct lttcomm_relayd_close_stream {
123 uint64_t stream_id;
124 uint64_t last_net_seq_num; /* sequence number of last packet */
125 } LTTNG_PACKED;
126
127 /*
128 * Used to test if for a given stream id the data is pending on the relayd side
129 * for reading.
130 */
131 struct lttcomm_relayd_data_pending {
132 uint64_t stream_id;
133 uint64_t last_net_seq_num; /* Sequence number of the last packet */
134 } LTTNG_PACKED;
135
136 struct lttcomm_relayd_begin_data_pending {
137 uint64_t session_id;
138 } LTTNG_PACKED;
139
140 struct lttcomm_relayd_end_data_pending {
141 uint64_t session_id;
142 } LTTNG_PACKED;
143
144 struct lttcomm_relayd_quiescent_control {
145 uint64_t stream_id;
146 } LTTNG_PACKED;
147
148 /*
149 * Index data.
150 */
151 struct lttcomm_relayd_index {
152 uint64_t relay_stream_id;
153 uint64_t net_seq_num;
154 uint64_t packet_size;
155 uint64_t content_size;
156 uint64_t timestamp_begin;
157 uint64_t timestamp_end;
158 uint64_t events_discarded;
159 uint64_t stream_id;
160 /* 2.8+ */
161 uint64_t stream_instance_id;
162 uint64_t packet_seq_num;
163 } LTTNG_PACKED;
164
165 static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
166 {
167 if (major == 1) {
168 switch (minor) {
169 case 0:
170 return offsetof(struct lttcomm_relayd_index, stream_id)
171 + member_sizeof(struct lttcomm_relayd_index,
172 stream_id);
173 case 1:
174 return offsetof(struct lttcomm_relayd_index, packet_seq_num)
175 + member_sizeof(struct lttcomm_relayd_index,
176 packet_seq_num);
177 default:
178 abort();
179 }
180 }
181 abort();
182 }
183
184 /*
185 * Create session in 2.4 adds additionnal parameters for live reading.
186 */
187 struct lttcomm_relayd_create_session_2_4 {
188 char session_name[RELAYD_COMM_LTTNG_NAME_MAX_2_4];
189 char hostname[RELAYD_COMM_LTTNG_HOST_NAME_MAX_2_4];
190 uint32_t live_timer;
191 uint32_t snapshot;
192 } LTTNG_PACKED;
193
194 /*
195 * Used to ask the relay to reset the metadata trace file (regeneration).
196 * Send the new version of the metadata (starts at 0).
197 */
198 struct lttcomm_relayd_reset_metadata {
199 uint64_t stream_id;
200 uint64_t version;
201 } LTTNG_PACKED;
202
203 struct lttcomm_relayd_rotate_stream {
204 uint64_t stream_id;
205 /* Ignored for metadata streams. */
206 uint64_t rotate_at_seq_num;
207 uint64_t new_chunk_id;
208 /* Includes trailing NULL. */
209 uint32_t pathname_length;
210 /* Must be the last member of this structure. */
211 char new_pathname[];
212 } LTTNG_PACKED;
213
214 struct lttcomm_relayd_rotate_rename {
215 uint32_t old_path_length;
216 uint32_t new_path_length;
217 /* Concatenation of the old and new paths, separated by \0. */
218 char paths[];
219 } LTTNG_PACKED;
220
221 struct lttcomm_relayd_rotate_pending {
222 uint64_t chunk_id;
223 } LTTNG_PACKED;
224
225 struct lttcomm_relayd_rotate_pending_reply {
226 struct lttcomm_relayd_generic_reply generic;
227 /* Valid values are [0, 1]. */
228 uint8_t is_pending;
229 } LTTNG_PACKED;
230
231 struct lttcomm_relayd_mkdir {
232 /* Includes trailing NULL */
233 uint32_t length;
234 char path[];
235 } LTTNG_PACKED;
236
237 #endif /* _RELAYD_COMM */
This page took 0.033729 seconds and 4 git commands to generate.