9a733df1e7aaa68c5c6e252988012fca0eda6eda
[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 /*
33 * lttng-relayd communication header.
34 */
35 struct lttcomm_relayd_hdr {
36 /* Circuit ID not used for now so always ignored */
37 uint64_t circuit_id;
38 uint64_t data_size; /* data size following this header */
39 uint32_t cmd; /* enum lttcomm_relayd_command */
40 uint32_t cmd_version; /* command version */
41 } LTTNG_PACKED;
42
43 /*
44 * lttng-relayd data header.
45 */
46 struct lttcomm_relayd_data_hdr {
47 /* Circuit ID not used for now so always ignored */
48 uint64_t circuit_id;
49 uint64_t stream_id; /* Stream ID known by the relayd */
50 uint64_t net_seq_num; /* Network sequence number, per stream. */
51 uint32_t data_size; /* data size following this header */
52 uint32_t padding_size; /* Size of 0 padding the data */
53 } LTTNG_PACKED;
54
55 /*
56 * Reply from a create session command.
57 */
58 struct lttcomm_relayd_status_session {
59 uint64_t session_id;
60 uint32_t ret_code;
61 } LTTNG_PACKED;
62
63 /*
64 * Used to add a stream on the relay daemon.
65 */
66 struct lttcomm_relayd_add_stream {
67 char channel_name[DEFAULT_STREAM_NAME_LEN];
68 char pathname[LTTNG_PATH_MAX];
69 } LTTNG_PACKED;
70
71 /*
72 * Used to add a stream on the relay daemon.
73 * Protocol version 2.2
74 */
75 struct lttcomm_relayd_add_stream_2_2 {
76 char channel_name[DEFAULT_STREAM_NAME_LEN];
77 char pathname[LTTNG_PATH_MAX];
78 uint64_t tracefile_size;
79 uint64_t tracefile_count;
80 } LTTNG_PACKED;
81
82 /*
83 * Answer from an add stream command.
84 */
85 struct lttcomm_relayd_status_stream {
86 uint64_t handle;
87 uint32_t ret_code;
88 } LTTNG_PACKED;
89
90 /*
91 * Used to return command code for command not needing special data.
92 */
93 struct lttcomm_relayd_generic_reply {
94 uint32_t ret_code;
95 } LTTNG_PACKED;
96
97 /*
98 * Version command.
99 */
100 struct lttcomm_relayd_version {
101 uint32_t major;
102 uint32_t minor;
103 } LTTNG_PACKED;
104
105 /*
106 * Metadata payload used when metadata command is sent.
107 */
108 struct lttcomm_relayd_metadata_payload {
109 uint64_t stream_id;
110 uint32_t padding_size;
111 char payload[];
112 } LTTNG_PACKED;
113
114 /*
115 * Used to indicate that a specific stream id can now be closed.
116 */
117 struct lttcomm_relayd_close_stream {
118 uint64_t stream_id;
119 uint64_t last_net_seq_num; /* sequence number of last packet */
120 } LTTNG_PACKED;
121
122 /*
123 * Used to test if for a given stream id the data is pending on the relayd side
124 * for reading.
125 */
126 struct lttcomm_relayd_data_pending {
127 uint64_t stream_id;
128 uint64_t last_net_seq_num; /* Sequence number of the last packet */
129 } LTTNG_PACKED;
130
131 struct lttcomm_relayd_begin_data_pending {
132 uint64_t session_id;
133 } LTTNG_PACKED;
134
135 struct lttcomm_relayd_end_data_pending {
136 uint64_t session_id;
137 } LTTNG_PACKED;
138
139 struct lttcomm_relayd_quiescent_control {
140 uint64_t stream_id;
141 } LTTNG_PACKED;
142
143 /*
144 * Index data.
145 */
146 struct lttcomm_relayd_index {
147 uint64_t relay_stream_id;
148 uint64_t net_seq_num;
149 uint64_t packet_size;
150 uint64_t content_size;
151 uint64_t timestamp_begin;
152 uint64_t timestamp_end;
153 uint64_t events_discarded;
154 uint64_t stream_id;
155 /* 2.8+ */
156 uint64_t stream_instance_id;
157 uint64_t packet_seq_num;
158 } LTTNG_PACKED;
159
160 static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
161 {
162 if (major == 1) {
163 switch (minor) {
164 case 0:
165 return offsetof(struct lttcomm_relayd_index, stream_id)
166 + member_sizeof(struct lttcomm_relayd_index,
167 stream_id);
168 case 1:
169 return offsetof(struct lttcomm_relayd_index, packet_seq_num)
170 + member_sizeof(struct lttcomm_relayd_index,
171 packet_seq_num);
172 default:
173 abort();
174 }
175 }
176 abort();
177 }
178
179 /*
180 * Create session in 2.4 adds additionnal parameters for live reading.
181 */
182 struct lttcomm_relayd_create_session_2_4 {
183 char session_name[LTTNG_NAME_MAX];
184 char hostname[LTTNG_HOST_NAME_MAX];
185 uint32_t live_timer;
186 uint32_t snapshot;
187 } LTTNG_PACKED;
188
189 /*
190 * Used to ask the relay to reset the metadata trace file (regeneration).
191 * Send the new version of the metadata (starts at 0).
192 */
193 struct lttcomm_relayd_reset_metadata {
194 uint64_t stream_id;
195 uint64_t version;
196 } LTTNG_PACKED;
197
198 struct lttcomm_relayd_rotate_stream {
199 uint64_t stream_id;
200 uint64_t rotate_at_seq_num;
201 uint64_t new_chunk_id;
202 /* Includes trailing NULL. */
203 uint32_t pathname_length;
204 /* Must be the last member of this structure. */
205 char new_pathname[];
206 } LTTNG_PACKED;
207
208 struct lttcomm_relayd_rotate_rename {
209 uint32_t old_path_length;
210 uint32_t new_path_length;
211 /* Concatenation of the old and new paths, separated by \0. */
212 char paths[];
213 } LTTNG_PACKED;
214
215 struct lttcomm_relayd_rotate_pending {
216 uint64_t chunk_id;
217 } LTTNG_PACKED;
218
219 struct lttcomm_relayd_mkdir {
220 /* Includes trailing NULL */
221 uint32_t length;
222 char path[];
223 } LTTNG_PACKED;
224
225 #endif /* _RELAYD_COMM */
This page took 0.03545 seconds and 5 git commands to generate.