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