Consumer: Implement lttng_consumer_clear_channel
[lttng-tools.git] / src / common / sessiond-comm / sessiond-comm.h
CommitLineData
6e3805e2
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Julien Desfossez <julien.desfossez@polymtl.ca>
773168b7 4 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fac6795d 5 *
d14d33bf
AM
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2 only,
8 * as published by the Free Software Foundation.
ba999de0 9 *
990570ed
DG
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d14d33bf 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
990570ed 13 * more details.
ba999de0 14 *
d14d33bf
AM
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
fac6795d
DG
18 */
19
773168b7 20/*
990570ed
DG
21 * This header is meant for liblttng and libust internal use ONLY. These
22 * declarations should NOT be considered stable API.
773168b7 23 */
fac6795d 24
990570ed
DG
25#ifndef _LTTNG_SESSIOND_COMM_H
26#define _LTTNG_SESSIOND_COMM_H
27
fac6795d 28#include <limits.h>
f3ed775e 29#include <lttng/lttng.h>
da3c9ec1 30#include <lttng/snapshot-internal.h>
00c76cea 31#include <lttng/save-internal.h>
e9404c27
JG
32#include <lttng/channel-internal.h>
33#include <lttng/trigger/trigger-internal.h>
d88744a4 34#include <lttng/rotate-internal.h>
b17231c6 35#include <common/compat/socket.h>
a4b92340 36#include <common/uri.h>
ce2a9e76 37#include <common/defaults.h>
ffe60014 38#include <common/compat/uuid.h>
5e16da05 39
6364a07a
DG
40#include <arpa/inet.h>
41#include <netinet/in.h>
42#include <sys/un.h>
43
44#include "inet.h"
45#include "inet6.h"
2038dd6c 46#include <common/unix.h>
0d37f2bc 47
fac6795d 48/* Queue size of listen(2) */
f158a754 49#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
fac6795d 50
990570ed
DG
51/* Maximum number of FDs that can be sent over a Unix socket */
52#define LTTCOMM_MAX_SEND_FDS 4
53
3817e7df
DG
54/*
55 * Get the error code index from 0 since LTTCOMM_OK start at 1000
fac6795d 56 */
f73fabfd 57#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_CONSUMERD_COMMAND_SOCK_READY)
fac6795d 58
6abb15de 59enum lttcomm_sessiond_command {
0d0c377a 60 /* Tracer command */
66ea93b1 61 LTTNG_ADD_CONTEXT = 0,
b812e5ca 62 /* LTTNG_CALIBRATE used to be here */
66ea93b1
JG
63 LTTNG_DISABLE_CHANNEL = 2,
64 LTTNG_DISABLE_EVENT = 3,
65 LTTNG_LIST_SYSCALLS = 4,
66 LTTNG_ENABLE_CHANNEL = 5,
67 LTTNG_ENABLE_EVENT = 6,
18a720cd 68 /* 7 */
0d0c377a 69 /* Session daemon command */
66ea93b1
JG
70 LTTNG_CREATE_SESSION = 8,
71 LTTNG_DESTROY_SESSION = 9,
72 LTTNG_LIST_CHANNELS = 10,
73 LTTNG_LIST_DOMAINS = 11,
74 LTTNG_LIST_EVENTS = 12,
75 LTTNG_LIST_SESSIONS = 13,
76 LTTNG_LIST_TRACEPOINTS = 14,
77 LTTNG_REGISTER_CONSUMER = 15,
78 LTTNG_START_TRACE = 16,
79 LTTNG_STOP_TRACE = 17,
80 LTTNG_LIST_TRACEPOINT_FIELDS = 18,
53a80697 81
de5e9086 82 /* Consumer */
66ea93b1
JG
83 LTTNG_DISABLE_CONSUMER = 19,
84 LTTNG_ENABLE_CONSUMER = 20,
85 LTTNG_SET_CONSUMER_URI = 21,
67676bd8
DG
86 /* 22 */
87 /* 23 */
66ea93b1
JG
88 LTTNG_DATA_PENDING = 24,
89 LTTNG_SNAPSHOT_ADD_OUTPUT = 25,
90 LTTNG_SNAPSHOT_DEL_OUTPUT = 26,
91 LTTNG_SNAPSHOT_LIST_OUTPUT = 27,
92 LTTNG_SNAPSHOT_RECORD = 28,
93 LTTNG_CREATE_SESSION_SNAPSHOT = 29,
94 LTTNG_CREATE_SESSION_LIVE = 30,
95 LTTNG_SAVE_SESSION = 31,
96 LTTNG_TRACK_PID = 32,
97 LTTNG_UNTRACK_PID = 33,
98 LTTNG_LIST_TRACKER_PIDS = 34,
99 LTTNG_SET_SESSION_SHM_PATH = 40,
100 LTTNG_REGENERATE_METADATA = 41,
101 LTTNG_REGENERATE_STATEDUMP = 42,
102 LTTNG_REGISTER_TRIGGER = 43,
103 LTTNG_UNREGISTER_TRIGGER = 44,
104 LTTNG_ROTATE_SESSION = 45,
105 LTTNG_ROTATION_GET_INFO = 46,
106 LTTNG_ROTATION_SET_SCHEDULE = 47,
2c2de71e 107 LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 48,
7c9534d6
JD
108};
109
110enum lttcomm_relayd_command {
111 RELAYD_ADD_STREAM = 1,
112 RELAYD_CREATE_SESSION = 2,
113 RELAYD_START_DATA = 3,
114 RELAYD_UPDATE_SYNC_INFO = 4,
115 RELAYD_VERSION = 5,
116 RELAYD_SEND_METADATA = 6,
117 RELAYD_CLOSE_STREAM = 7,
118 RELAYD_DATA_PENDING = 8,
119 RELAYD_QUIESCENT_CONTROL = 9,
120 RELAYD_BEGIN_DATA_PENDING = 10,
121 RELAYD_END_DATA_PENDING = 11,
1c20f0e2
JD
122 RELAYD_ADD_INDEX = 12,
123 RELAYD_SEND_INDEX = 13,
124 RELAYD_CLOSE_INDEX = 14,
a4baae1b 125 /* Live-reading commands (2.4+). */
d3e2ba59 126 RELAYD_LIST_SESSIONS = 15,
a4baae1b
JD
127 /* All streams of the channel have been sent to the relayd (2.4+). */
128 RELAYD_STREAMS_SENT = 16,
93ec662e
JD
129 /* Ask the relay to reset the metadata trace file (2.8+) */
130 RELAYD_RESET_METADATA = 17,
d3ecc550
JD
131 /* Ask the relay to rotate a stream file (2.11+) */
132 RELAYD_ROTATE_STREAM = 18,
00fb02ac
JD
133 /* Rename a chunk after the rotation is completed (2.11+) */
134 RELAYD_ROTATE_RENAME = 19,
e2acc8d2
JD
135 /* Check if a chunk has data pending (2.11+) */
136 RELAYD_ROTATE_PENDING = 20,
a1ae2ea5
JD
137 /* Create a folder on the relayd FS (2.11+) */
138 RELAYD_MKDIR = 21,
fac6795d
DG
139};
140
141/*
142 * lttcomm error code.
143 */
144enum lttcomm_return_code {
0c759fc9 145 LTTCOMM_CONSUMERD_SUCCESS = 0, /* Everything went fine. */
f73fabfd
DG
146 LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 1, /* Command socket ready */
147 LTTCOMM_CONSUMERD_SUCCESS_RECV_FD, /* Success on receiving fds */
148 LTTCOMM_CONSUMERD_ERROR_RECV_FD, /* Error on receiving fds */
149 LTTCOMM_CONSUMERD_ERROR_RECV_CMD, /* Error on receiving command */
150 LTTCOMM_CONSUMERD_POLL_ERROR, /* Error in polling thread */
151 LTTCOMM_CONSUMERD_POLL_NVAL, /* Poll on closed fd */
152 LTTCOMM_CONSUMERD_POLL_HUP, /* All fds have hungup */
153 LTTCOMM_CONSUMERD_EXIT_SUCCESS, /* Consumerd exiting normally */
154 LTTCOMM_CONSUMERD_EXIT_FAILURE, /* Consumerd exiting on error */
155 LTTCOMM_CONSUMERD_OUTFD_ERROR, /* Error opening the tracefile */
156 LTTCOMM_CONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */
157 LTTCOMM_CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */
158 LTTCOMM_CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
159 LTTCOMM_CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
ffe60014 160 LTTCOMM_CONSUMERD_ENOMEM, /* Consumer is out of memory */
d88aee68
DG
161 LTTCOMM_CONSUMERD_ERROR_METADATA, /* Error with metadata. */
162 LTTCOMM_CONSUMERD_FATAL, /* Fatal error. */
618a6a28 163 LTTCOMM_CONSUMERD_RELAYD_FAIL, /* Error on remote relayd */
0c759fc9 164 LTTCOMM_CONSUMERD_CHANNEL_FAIL, /* Channel creation failed. */
e462382a 165 LTTCOMM_CONSUMERD_CHAN_NOT_FOUND, /* Channel not found. */
e9404c27 166 LTTCOMM_CONSUMERD_ALREADY_SET, /* Resource already set. */
92b7a7f8
MD
167 LTTCOMM_CONSUMERD_ROTATION_FAIL, /* Rotation has failed. */
168 LTTCOMM_CONSUMERD_ROTATE_RENAME_FAILED, /* Rotation rename has failed. */
169 LTTCOMM_CONSUMERD_ROTATION_PENDING_LOCAL_FAILED, /* Rotation pending relay failed. */
170 LTTCOMM_CONSUMERD_ROTATION_PENDING_RELAY_FAILED, /* Rotation pending relay failed. */
171 LTTCOMM_CONSUMERD_MKDIR_FAILED, /* mkdir has failed. */
3eb928aa 172 LTTCOMM_CONSUMERD_SNAPSHOT_FAILED, /* snapshot has failed. */
80e327fa 173
20fe2104
DG
174 /* MUST be last element */
175 LTTCOMM_NR, /* Last element */
fac6795d
DG
176};
177
de5e9086
DG
178/* lttng socket protocol. */
179enum lttcomm_sock_proto {
180 LTTCOMM_SOCK_UDP,
181 LTTCOMM_SOCK_TCP,
182};
183
184/*
185 * Index in the net_families array below. Please keep in sync!
186 */
187enum lttcomm_sock_domain {
01d0a631
CB
188 LTTCOMM_INET = 0,
189 LTTCOMM_INET6 = 1,
de5e9086
DG
190};
191
331744e3
JD
192enum lttcomm_metadata_command {
193 LTTCOMM_METADATA_REQUEST = 1,
194};
195
196/*
197 * Commands sent from the consumerd to the sessiond to request if new metadata
198 * is available. This message is used to find the per UID _or_ per PID registry
199 * for the channel key. For per UID lookup, the triplet
200 * bits_per_long/uid/session_id is used. On lookup failure, we search for the
201 * per PID registry indexed by session id ignoring the other values.
202 */
203struct lttcomm_metadata_request_msg {
1950109e
JD
204 uint64_t session_id; /* Tracing session id */
205 uint64_t session_id_per_pid; /* Tracing session id for per-pid */
331744e3
JD
206 uint32_t bits_per_long; /* Consumer ABI */
207 uint32_t uid;
208 uint64_t key; /* Metadata channel key. */
209} LTTNG_PACKED;
210
de5e9086
DG
211struct lttcomm_sockaddr {
212 enum lttcomm_sock_domain type;
213 union {
214 struct sockaddr_in sin;
215 struct sockaddr_in6 sin6;
216 } addr;
fc5e05b7 217} LTTNG_PACKED;
de5e9086
DG
218
219struct lttcomm_sock {
d88aee68 220 int32_t fd;
de5e9086
DG
221 enum lttcomm_sock_proto proto;
222 struct lttcomm_sockaddr sockaddr;
223 const struct lttcomm_proto_ops *ops;
fc5e05b7 224} LTTNG_PACKED;
de5e9086 225
6151a90f
JD
226/*
227 * Relayd sock. Adds the protocol version to use for the communications with
228 * the relayd.
229 */
230struct lttcomm_relayd_sock {
231 struct lttcomm_sock sock;
232 uint32_t major;
233 uint32_t minor;
234} LTTNG_PACKED;
235
de5e9086
DG
236struct lttcomm_net_family {
237 int family;
238 int (*create) (struct lttcomm_sock *sock, int type, int proto);
239};
240
241struct lttcomm_proto_ops {
242 int (*bind) (struct lttcomm_sock *sock);
243 int (*close) (struct lttcomm_sock *sock);
244 int (*connect) (struct lttcomm_sock *sock);
245 struct lttcomm_sock *(*accept) (struct lttcomm_sock *sock);
246 int (*listen) (struct lttcomm_sock *sock, int backlog);
247 ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len,
248 int flags);
c2d69327
JG
249 ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
250 size_t len, int flags);
de5e9086
DG
251};
252
fac6795d 253/*
9bda164d 254 * Data structure received from lttng client to session daemon.
fac6795d
DG
255 */
256struct lttcomm_session_msg {
d0b96690 257 uint32_t cmd_type; /* enum lttcomm_sessiond_command */
42abccdb 258 struct lttng_session session;
9f19cc17 259 struct lttng_domain domain;
fac6795d 260 union {
f3ed775e 261 /* Event data */
fac6795d 262 struct {
db8870ed 263 char channel_name[LTTNG_SYMBOL_NAME_LEN];
1179a48f 264 struct lttng_event event LTTNG_PACKED;
6b453b5e
JG
265 /* Length of following filter expression. */
266 uint32_t expression_len;
025faf73
DG
267 /* Length of following bytecode for filter. */
268 uint32_t bytecode_len;
15e37663 269 /* Exclusion count (fixed-size strings). */
a5516688 270 uint32_t exclusion_count;
15e37663
JG
271 /* Userspace probe location size. */
272 uint32_t userspace_probe_location_len;
a5516688
JI
273 /*
274 * After this structure, the following variable-length
275 * items are transmitted:
276 * - char exclusion_names[LTTNG_SYMBOL_NAME_LEN][exclusion_count]
15e37663 277 * - char filter_expression[expression_len]
a5516688
JI
278 * - unsigned char filter_bytecode[bytecode_len]
279 */
fc5e05b7 280 } LTTNG_PACKED enable;
6e911cad
MD
281 struct {
282 char channel_name[LTTNG_SYMBOL_NAME_LEN];
283 struct lttng_event event LTTNG_PACKED;
284 /* Length of following filter expression. */
285 uint32_t expression_len;
286 /* Length of following bytecode for filter. */
287 uint32_t bytecode_len;
288 /*
289 * After this structure, the following variable-length
290 * items are transmitted:
291 * - unsigned char filter_expression[expression_len]
292 * - unsigned char filter_bytecode[bytecode_len]
293 */
294 } LTTNG_PACKED disable;
f3ed775e
DG
295 /* Create channel */
296 struct {
1179a48f 297 struct lttng_channel chan LTTNG_PACKED;
e9404c27
JG
298 /* struct lttng_channel_extended is already packed. */
299 struct lttng_channel_extended extended;
fc5e05b7 300 } LTTNG_PACKED channel;
d65106b1
DG
301 /* Context */
302 struct {
db8870ed 303 char channel_name[LTTNG_SYMBOL_NAME_LEN];
1179a48f 304 struct lttng_event_context ctx LTTNG_PACKED;
2001793c
JG
305 uint32_t provider_name_len;
306 uint32_t context_name_len;
fc5e05b7 307 } LTTNG_PACKED context;
d9800920
DG
308 /* Use by register_consumer */
309 struct {
310 char path[PATH_MAX];
fc5e05b7 311 } LTTNG_PACKED reg;
9f19cc17
DG
312 /* List */
313 struct {
db8870ed 314 char channel_name[LTTNG_SYMBOL_NAME_LEN];
fc5e05b7 315 } LTTNG_PACKED list;
d0254c7c 316 struct lttng_calibrate calibrate;
a4b92340 317 /* Used by the set_consumer_url and used by create_session also call */
de5e9086 318 struct {
a4b92340
DG
319 /* Number of lttng_uri following */
320 uint32_t size;
fc5e05b7 321 } LTTNG_PACKED uri;
da3c9ec1 322 struct {
1179a48f 323 struct lttng_snapshot_output output LTTNG_PACKED;
da3c9ec1
DG
324 } LTTNG_PACKED snapshot_output;
325 struct {
326 uint32_t wait;
1179a48f 327 struct lttng_snapshot_output output LTTNG_PACKED;
da3c9ec1 328 } LTTNG_PACKED snapshot_record;
ecc48a90
JD
329 struct {
330 uint32_t nb_uri;
331 unsigned int timer_interval; /* usec */
332 } LTTNG_PACKED session_live;
00c76cea 333 struct {
1179a48f 334 struct lttng_save_session_attr attr; /* struct already packed */
00c76cea 335 } LTTNG_PACKED save_session;
d7ba1388
MD
336 struct {
337 char shm_path[PATH_MAX];
338 } LTTNG_PACKED set_shm_path;
ccf10263
MD
339 struct {
340 uint32_t pid;
341 } LTTNG_PACKED pid_tracker;
e9404c27
JG
342 struct {
343 uint32_t length;
344 } LTTNG_PACKED trigger;
d88744a4 345 struct {
d68c9a04
JD
346 uint64_t rotation_id;
347 } LTTNG_PACKED get_rotation_info;
259c2674 348 struct {
66ea93b1
JG
349 /* enum lttng_rotation_schedule_type */
350 uint8_t type;
351 /*
352 * If set == 1, set schedule to value, if set == 0,
353 * clear this schedule type.
354 */
355 uint8_t set;
356 uint64_t value;
357 } LTTNG_PACKED rotation_set_schedule;
fac6795d 358 } u;
fc5e05b7 359} LTTNG_PACKED;
fac6795d 360
d93c4f1f 361#define LTTNG_FILTER_MAX_LEN 65536
53a80697
MD
362
363/*
364 * Filter bytecode data. The reloc table is located at the end of the
365 * bytecode. It is made of tuples: (uint16_t, var. len. string). It
366 * starts at reloc_table_offset.
367 */
b6bbed5f 368#define LTTNG_FILTER_PADDING 32
53a80697 369struct lttng_filter_bytecode {
d93c4f1f
CB
370 uint32_t len; /* len of data */
371 uint32_t reloc_table_offset;
f3f0db50 372 uint64_t seqnum;
b6bbed5f 373 char padding[LTTNG_FILTER_PADDING];
53a80697 374 char data[0];
fc5e05b7 375} LTTNG_PACKED;
53a80697 376
579640f9
JI
377/*
378 * Event exclusion data. At the end of the structure, there will actually
379 * by zero or more names, where the actual number of names is given by
380 * the 'count' item of the structure.
381 */
382#define LTTNG_EVENT_EXCLUSION_PADDING 32
383struct lttng_event_exclusion {
384 uint32_t count;
385 char padding[LTTNG_EVENT_EXCLUSION_PADDING];
caafa356 386 char names[0][LTTNG_SYMBOL_NAME_LEN];
579640f9
JI
387} LTTNG_PACKED;
388
d7af3565
PP
389#define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
390 (&(_exclusion)->names[_i][0])
391
b4e3ceb9
PP
392/*
393 * Event command header.
394 */
395struct lttcomm_event_command_header {
396 /* Number of events */
397 uint32_t nb_events;
398} LTTNG_PACKED;
399
400/*
401 * Event extended info header. This is the structure preceding each
402 * extended info data.
403 */
404struct lttcomm_event_extended_header {
405 /*
406 * Size of filter string immediately following this header.
407 * This size includes the terminal null character.
408 */
409 uint32_t filter_len;
795d57ce
PP
410
411 /*
412 * Number of exclusion names, immediately following the filter
413 * string. Each exclusion name has a fixed length of
414 * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null
415 * character.
416 */
417 uint32_t nb_exclusions;
56f0bc67
JG
418
419 /*
420 * Size of the event's userspace probe location (if applicable).
421 */
422 uint32_t userspace_probe_location_len;
b4e3ceb9
PP
423} LTTNG_PACKED;
424
fac6795d 425/*
5e16da05 426 * Data structure for the response from sessiond to the lttng client.
fac6795d 427 */
5461b305 428struct lttcomm_lttng_msg {
d0b96690
DG
429 uint32_t cmd_type; /* enum lttcomm_sessiond_command */
430 uint32_t ret_code; /* enum lttcomm_return_code */
431 uint32_t pid; /* pid_t */
795a978d 432 uint32_t cmd_header_size;
773168b7 433 uint32_t data_size;
fc5e05b7 434} LTTNG_PACKED;
fac6795d 435
da3c9ec1
DG
436struct lttcomm_lttng_output_id {
437 uint32_t id;
438} LTTNG_PACKED;
439
6e3805e2 440/*
3bd1e081
MD
441 * lttcomm_consumer_msg is the message sent from sessiond to consumerd
442 * to either add a channel, add a stream, update a stream, or stop
443 * operation.
6e3805e2 444 */
3bd1e081 445struct lttcomm_consumer_msg {
92816cc3 446 uint32_t cmd_type; /* enum lttng_consumer_command */
3bd1e081
MD
447 union {
448 struct {
d88aee68 449 uint64_t channel_key;
ffe60014
DG
450 uint64_t session_id;
451 char pathname[PATH_MAX];
d88aee68
DG
452 uint32_t uid;
453 uint32_t gid;
454 uint64_t relayd_id;
c30aaa51 455 /* nb_init_streams is the number of streams open initially. */
d88aee68 456 uint32_t nb_init_streams;
de5e9086 457 char name[LTTNG_SYMBOL_NAME_LEN];
ffe60014
DG
458 /* Use splice or mmap to consume this fd */
459 enum lttng_event_output output;
460 int type; /* Per cpu or metadata. */
1624d5b7
JD
461 uint64_t tracefile_size; /* bytes */
462 uint32_t tracefile_count; /* number of tracefiles */
2bba9e53
DG
463 /* If the channel's streams have to be monitored or not. */
464 uint32_t monitor;
ecc48a90
JD
465 /* timer to check the streams usage in live mode (usec). */
466 unsigned int live_timer_interval;
e9404c27
JG
467 /* timer to sample a channel's positions (usec). */
468 unsigned int monitor_timer_interval;
ffe60014 469 } LTTNG_PACKED channel; /* Only used by Kernel. */
3bd1e081 470 struct {
d88aee68
DG
471 uint64_t stream_key;
472 uint64_t channel_key;
473 int32_t cpu; /* On which CPU this stream is assigned. */
6dc3064a
DG
474 /* Tells the consumer if the stream should be or not monitored. */
475 uint32_t no_monitor;
e098433c
JG
476 /*
477 * The archive id that was "current" at the time this
478 * stream was created. This is used to determine
479 * whether a rotation request was sent before or after
480 * the creation of a stream.
481 */
482 uint64_t trace_archive_id;
ffe60014 483 } LTTNG_PACKED stream; /* Only used by Kernel. */
de5e9086 484 struct {
d88aee68 485 uint64_t net_index;
de5e9086
DG
486 enum lttng_stream_type type;
487 /* Open socket to the relayd */
6151a90f 488 struct lttcomm_relayd_sock sock;
46e6455f
DG
489 /* Tracing session id associated to the relayd. */
490 uint64_t session_id;
d3e2ba59
JD
491 /* Relayd session id, only used with control socket. */
492 uint64_t relayd_session_id;
fc5e05b7 493 } LTTNG_PACKED relayd_sock;
173af62f
DG
494 struct {
495 uint64_t net_seq_idx;
fc5e05b7 496 } LTTNG_PACKED destroy_relayd;
53632229
DG
497 struct {
498 uint64_t session_id;
fc5e05b7 499 } LTTNG_PACKED data_pending;
ffe60014 500 struct {
d0b96690
DG
501 uint64_t subbuf_size; /* bytes */
502 uint64_t num_subbuf; /* power of 2 */
d88aee68
DG
503 int32_t overwrite; /* 1: overwrite, 0: discard */
504 uint32_t switch_timer_interval; /* usec */
505 uint32_t read_timer_interval; /* usec */
e9404c27
JG
506 unsigned int live_timer_interval; /* usec */
507 uint32_t monitor_timer_interval; /* usec */
d88aee68
DG
508 int32_t output; /* splice, mmap */
509 int32_t type; /* metadata or per_cpu */
d0b96690
DG
510 uint64_t session_id; /* Tracing session id */
511 char pathname[PATH_MAX]; /* Channel file path. */
ffe60014 512 char name[LTTNG_SYMBOL_NAME_LEN]; /* Channel name. */
d88aee68
DG
513 uint32_t uid; /* User ID of the session */
514 uint32_t gid; /* Group ID ot the session */
515 uint64_t relayd_id; /* Relayd id if apply. */
516 uint64_t key; /* Unique channel key. */
b6d38284 517 unsigned char uuid[UUID_LEN]; /* uuid for ust tracer. */
7972aab2 518 uint32_t chan_id; /* Channel ID on the tracer side. */
1624d5b7
JD
519 uint64_t tracefile_size; /* bytes */
520 uint32_t tracefile_count; /* number of tracefiles */
1950109e 521 uint64_t session_id_per_pid; /* Per-pid session ID. */
2bba9e53
DG
522 /* Tells the consumer if the stream should be or not monitored. */
523 uint32_t monitor;
567eb353
DG
524 /*
525 * For UST per UID buffers, this is the application UID of the
526 * channel. This can be different from the user UID requesting the
527 * channel creation and used for the rights on the stream file
528 * because the application can be in the tracing for instance.
529 */
530 uint32_t ust_app_uid;
491d1539 531 int64_t blocking_timeout;
e098433c
JG
532 /*
533 * The archive id that was "current" at the time this
534 * channel was created. This is used to determine
535 * whether a rotation request was sent before or after
536 * the creation of a channel.
537 */
538 uint64_t trace_archive_id;
3d071855 539 char root_shm_path[PATH_MAX];
d7ba1388 540 char shm_path[PATH_MAX];
ffe60014
DG
541 } LTTNG_PACKED ask_channel;
542 struct {
d88aee68 543 uint64_t key;
ffe60014
DG
544 } LTTNG_PACKED get_channel;
545 struct {
d88aee68 546 uint64_t key;
ffe60014 547 } LTTNG_PACKED destroy_channel;
d88aee68
DG
548 struct {
549 uint64_t key; /* Metadata channel key. */
550 uint64_t target_offset; /* Offset in the consumer */
551 uint64_t len; /* Length of metadata to be received. */
93ec662e 552 uint64_t version; /* Version of the metadata. */
d88aee68
DG
553 } LTTNG_PACKED push_metadata;
554 struct {
555 uint64_t key; /* Metadata channel key. */
556 } LTTNG_PACKED close_metadata;
557 struct {
558 uint64_t key; /* Metadata channel key. */
559 } LTTNG_PACKED setup_metadata;
7972aab2
DG
560 struct {
561 uint64_t key; /* Channel key. */
562 } LTTNG_PACKED flush_channel;
0dd01979
MD
563 struct {
564 uint64_t key; /* Channel key. */
565 } LTTNG_PACKED clear_quiescent_channel;
6dc3064a
DG
566 struct {
567 char pathname[PATH_MAX];
568 /* Indicate if the snapshot goes on the relayd or locally. */
569 uint32_t use_relayd;
570 uint32_t metadata; /* This a metadata snapshot. */
571 uint64_t relayd_id; /* Relayd id if apply. */
572 uint64_t key;
d07ceecd 573 uint64_t nb_packets_per_stream;
e098433c
JG
574 /*
575 * The session's current trace archive id is propagated
576 * since a snapshot triggers the creation of an
577 * ephemeral metadata stream.
578 */
579 uint64_t trace_archive_id;
6dc3064a 580 } LTTNG_PACKED snapshot_channel;
a4baae1b
JD
581 struct {
582 uint64_t channel_key;
583 uint64_t net_seq_idx;
584 } LTTNG_PACKED sent_streams;
fb83fe64
JD
585 struct {
586 uint64_t session_id;
587 uint64_t channel_key;
588 } LTTNG_PACKED discarded_events;
589 struct {
590 uint64_t session_id;
591 uint64_t channel_key;
592 } LTTNG_PACKED lost_packets;
93ec662e
JD
593 struct {
594 uint64_t session_id;
eded6438 595 } LTTNG_PACKED regenerate_metadata;
b99a8d42
JD
596 struct {
597 char pathname[PATH_MAX];
598 uint32_t metadata; /* This is a metadata channel. */
599 uint64_t relayd_id; /* Relayd id if apply. */
600 uint64_t key;
601 uint64_t new_chunk_id;
602 } LTTNG_PACKED rotate_channel;
00fb02ac
JD
603 struct {
604 char old_path[LTTNG_PATH_MAX];
605 char new_path[LTTNG_PATH_MAX];
606 uint64_t relayd_id; /* Relayd id if apply. */
607 uint64_t session_id;
608 uint32_t uid;
609 uint32_t gid;
610 } LTTNG_PACKED rotate_rename;
92816cc3
JG
611 struct {
612 uint64_t session_id;
613 uint64_t chunk_id;
614 } LTTNG_PACKED check_rotation_pending_local;
d88744a4
JD
615 struct {
616 uint64_t relayd_id;
617 uint64_t session_id;
618 uint64_t chunk_id;
92816cc3 619 } LTTNG_PACKED check_rotation_pending_relay;
a1ae2ea5
JD
620 struct {
621 char path[LTTNG_PATH_MAX];
622 uint64_t relayd_id; /* Relayd id if apply. */
623 uint64_t session_id;
624 uint32_t uid;
625 uint32_t gid;
626 } LTTNG_PACKED mkdir;
3bd1e081 627 } u;
fc5e05b7 628} LTTNG_PACKED;
6e3805e2 629
e9404c27
JG
630/*
631 * Channel monitoring message returned to the session daemon on every
632 * monitor timer expiration.
633 */
634struct lttcomm_consumer_channel_monitor_msg {
635 /* Key of the sampled channel. */
636 uint64_t key;
637 /*
638 * Lowest and highest usage (bytes) at the moment the sample was taken.
639 */
640 uint64_t lowest, highest;
e8360425
JD
641 /*
642 * Sum of all the consumed positions for a channel.
643 */
644 uint64_t total_consumed;
e9404c27
JG
645} LTTNG_PACKED;
646
f50f23d9
DG
647/*
648 * Status message returned to the sessiond after a received command.
649 */
650struct lttcomm_consumer_status_msg {
0c759fc9 651 enum lttcomm_return_code ret_code;
fc5e05b7 652} LTTNG_PACKED;
f50f23d9 653
ffe60014 654struct lttcomm_consumer_status_channel {
0c759fc9 655 enum lttcomm_return_code ret_code;
d88aee68 656 uint64_t key;
ffe60014
DG
657 unsigned int stream_count;
658} LTTNG_PACKED;
659
74d0b642 660#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 661
9df8df5e 662#include <lttng/ust-abi.h>
6e3805e2 663
3817e7df
DG
664/*
665 * Data structure for the commands sent from sessiond to UST.
666 */
667struct lttcomm_ust_msg {
3817e7df
DG
668 uint32_t handle;
669 uint32_t cmd;
670 union {
3817e7df 671 struct lttng_ust_channel channel;
00a17c97 672 struct lttng_ust_stream stream;
3817e7df
DG
673 struct lttng_ust_event event;
674 struct lttng_ust_context context;
00a17c97 675 struct lttng_ust_tracer_version version;
3817e7df 676 } u;
fc5e05b7 677} LTTNG_PACKED;
3817e7df
DG
678
679/*
680 * Data structure for the response from UST to the session daemon.
681 * cmd_type is sent back in the reply for validation.
682 */
683struct lttcomm_ust_reply {
684 uint32_t handle;
685 uint32_t cmd;
686 uint32_t ret_code; /* enum lttcomm_return_code */
687 uint32_t ret_val; /* return value */
688 union {
2b0bf864
DG
689 struct {
690 uint64_t memory_map_size;
fc5e05b7 691 } LTTNG_PACKED channel;
2b0bf864
DG
692 struct {
693 uint64_t memory_map_size;
fc5e05b7 694 } LTTNG_PACKED stream;
00a17c97 695 struct lttng_ust_tracer_version version;
3817e7df 696 } u;
fc5e05b7 697} LTTNG_PACKED;
3817e7df 698
74d0b642 699#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 700
79445cf0 701LTTNG_HIDDEN const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
fac6795d 702
79445cf0 703LTTNG_HIDDEN int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
6364a07a 704 const char *ip, unsigned int port);
79445cf0 705LTTNG_HIDDEN int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
6364a07a
DG
706 const char *ip, unsigned int port);
707
79445cf0
JG
708LTTNG_HIDDEN struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
709LTTNG_HIDDEN int lttcomm_create_sock(struct lttcomm_sock *sock);
710LTTNG_HIDDEN struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
711LTTNG_HIDDEN void lttcomm_destroy_sock(struct lttcomm_sock *sock);
712LTTNG_HIDDEN struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
713LTTNG_HIDDEN void lttcomm_copy_sock(struct lttcomm_sock *dst,
de5e9086 714 struct lttcomm_sock *src);
6364a07a 715
6151a90f 716/* Relayd socket object. */
79445cf0 717LTTNG_HIDDEN struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
6151a90f
JD
718 struct lttng_uri *uri, uint32_t major, uint32_t minor);
719
79445cf0
JG
720LTTNG_HIDDEN int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
721LTTNG_HIDDEN int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
783a3b9a 722
2288467f
JG
723LTTNG_HIDDEN int lttcomm_sock_get_port(const struct lttcomm_sock *sock,
724 uint16_t *port);
725/*
726 * Set a port to an lttcomm_sock. This will have no effect is the socket is
727 * already bound.
728 */
729LTTNG_HIDDEN int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
730
79445cf0 731LTTNG_HIDDEN void lttcomm_init(void);
554831e7 732/* Get network timeout, in milliseconds */
79445cf0 733LTTNG_HIDDEN unsigned long lttcomm_get_network_timeout(void);
554831e7 734
773168b7 735#endif /* _LTTNG_SESSIOND_COMM_H */
This page took 0.113349 seconds and 5 git commands to generate.