Send domain with streams to the relay
[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 * Used to add a stream on the relay daemon.
84 * Protocol version 2.11
85 */
86 struct lttcomm_relayd_add_stream_2_11 {
87 char channel_name[DEFAULT_STREAM_NAME_LEN];
88 char pathname[LTTNG_PATH_MAX];
89 uint32_t domain; /* enum lttng_domain_type */
90 uint64_t tracefile_size;
91 uint64_t tracefile_count;
92 } LTTNG_PACKED;
93
94 /*
95 * Answer from an add stream command.
96 */
97 struct lttcomm_relayd_status_stream {
98 uint64_t handle;
99 uint32_t ret_code;
100 } LTTNG_PACKED;
101
102 /*
103 * Used to return command code for command not needing special data.
104 */
105 struct lttcomm_relayd_generic_reply {
106 uint32_t ret_code;
107 } LTTNG_PACKED;
108
109 /*
110 * Version command.
111 */
112 struct lttcomm_relayd_version {
113 uint32_t major;
114 uint32_t minor;
115 } LTTNG_PACKED;
116
117 /*
118 * Metadata payload used when metadata command is sent.
119 */
120 struct lttcomm_relayd_metadata_payload {
121 uint64_t stream_id;
122 uint32_t padding_size;
123 char payload[];
124 } LTTNG_PACKED;
125
126 /*
127 * Used to indicate that a specific stream id can now be closed.
128 */
129 struct lttcomm_relayd_close_stream {
130 uint64_t stream_id;
131 uint64_t last_net_seq_num; /* sequence number of last packet */
132 } LTTNG_PACKED;
133
134 /*
135 * Used to test if for a given stream id the data is pending on the relayd side
136 * for reading.
137 */
138 struct lttcomm_relayd_data_pending {
139 uint64_t stream_id;
140 uint64_t last_net_seq_num; /* Sequence number of the last packet */
141 } LTTNG_PACKED;
142
143 struct lttcomm_relayd_begin_data_pending {
144 uint64_t session_id;
145 } LTTNG_PACKED;
146
147 struct lttcomm_relayd_end_data_pending {
148 uint64_t session_id;
149 } LTTNG_PACKED;
150
151 struct lttcomm_relayd_quiescent_control {
152 uint64_t stream_id;
153 } LTTNG_PACKED;
154
155 /*
156 * Index data.
157 */
158 struct lttcomm_relayd_index {
159 uint64_t relay_stream_id;
160 uint64_t net_seq_num;
161 uint64_t packet_size;
162 uint64_t content_size;
163 uint64_t timestamp_begin;
164 uint64_t timestamp_end;
165 uint64_t events_discarded;
166 uint64_t stream_id;
167 /* 2.8+ */
168 uint64_t stream_instance_id;
169 uint64_t packet_seq_num;
170 } LTTNG_PACKED;
171
172 static inline size_t lttcomm_relayd_index_len(uint32_t major, uint32_t minor)
173 {
174 if (major == 1) {
175 switch (minor) {
176 case 0:
177 return offsetof(struct lttcomm_relayd_index, stream_id)
178 + member_sizeof(struct lttcomm_relayd_index,
179 stream_id);
180 case 1:
181 return offsetof(struct lttcomm_relayd_index, packet_seq_num)
182 + member_sizeof(struct lttcomm_relayd_index,
183 packet_seq_num);
184 default:
185 abort();
186 }
187 }
188 abort();
189 }
190
191 /*
192 * Create session in 2.4 adds additionnal parameters for live reading.
193 */
194 struct lttcomm_relayd_create_session_2_4 {
195 char session_name[LTTNG_NAME_MAX];
196 char hostname[LTTNG_HOST_NAME_MAX];
197 uint32_t live_timer;
198 uint32_t snapshot;
199 } LTTNG_PACKED;
200
201 /*
202 * Used to ask the relay to reset the metadata trace file (regeneration).
203 * Send the new version of the metadata (starts at 0).
204 */
205 struct lttcomm_relayd_reset_metadata {
206 uint64_t stream_id;
207 uint64_t version;
208 } LTTNG_PACKED;
209
210 struct lttcomm_relayd_rotate_stream {
211 uint64_t stream_id;
212 char new_pathname[LTTNG_PATH_MAX];
213 } LTTNG_PACKED;
214
215 struct lttcomm_relayd_rotate_rename {
216 char current_path[LTTNG_PATH_MAX];
217 char new_path[LTTNG_PATH_MAX];
218 } LTTNG_PACKED;
219
220 #endif /* _RELAYD_COMM */
This page took 0.035177 seconds and 5 git commands to generate.