lttng-ctl: register trigger to session daemon
[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>
a440a542 32#include <lttng/trigger/trigger-internal.h>
b17231c6 33#include <common/compat/socket.h>
a4b92340 34#include <common/uri.h>
ce2a9e76 35#include <common/defaults.h>
ffe60014 36#include <common/compat/uuid.h>
5e16da05 37
6364a07a
DG
38#include <arpa/inet.h>
39#include <netinet/in.h>
40#include <sys/un.h>
41
42#include "inet.h"
43#include "inet6.h"
2038dd6c 44#include <common/unix.h>
0d37f2bc 45
fac6795d 46/* Queue size of listen(2) */
f158a754 47#define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
fac6795d 48
990570ed
DG
49/* Maximum number of FDs that can be sent over a Unix socket */
50#define LTTCOMM_MAX_SEND_FDS 4
51
3817e7df
DG
52/*
53 * Get the error code index from 0 since LTTCOMM_OK start at 1000
fac6795d 54 */
f73fabfd 55#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_CONSUMERD_COMMAND_SOCK_READY)
fac6795d 56
6abb15de 57enum lttcomm_sessiond_command {
0d0c377a 58 /* Tracer command */
7c9534d6 59 LTTNG_ADD_CONTEXT = 0,
b812e5ca 60 /* LTTNG_CALIBRATE used to be here */
7c9534d6
JD
61 LTTNG_DISABLE_CHANNEL = 2,
62 LTTNG_DISABLE_EVENT = 3,
834978fd 63 LTTNG_LIST_SYSCALLS = 4,
7c9534d6
JD
64 LTTNG_ENABLE_CHANNEL = 5,
65 LTTNG_ENABLE_EVENT = 6,
18a720cd 66 /* 7 */
0d0c377a 67 /* Session daemon command */
7c9534d6
JD
68 LTTNG_CREATE_SESSION = 8,
69 LTTNG_DESTROY_SESSION = 9,
70 LTTNG_LIST_CHANNELS = 10,
71 LTTNG_LIST_DOMAINS = 11,
72 LTTNG_LIST_EVENTS = 12,
73 LTTNG_LIST_SESSIONS = 13,
74 LTTNG_LIST_TRACEPOINTS = 14,
75 LTTNG_REGISTER_CONSUMER = 15,
76 LTTNG_START_TRACE = 16,
77 LTTNG_STOP_TRACE = 17,
78 LTTNG_LIST_TRACEPOINT_FIELDS = 18,
53a80697 79
de5e9086 80 /* Consumer */
7c9534d6
JD
81 LTTNG_DISABLE_CONSUMER = 19,
82 LTTNG_ENABLE_CONSUMER = 20,
83 LTTNG_SET_CONSUMER_URI = 21,
67676bd8
DG
84 /* 22 */
85 /* 23 */
7c9534d6 86 LTTNG_DATA_PENDING = 24,
da3c9ec1
DG
87 LTTNG_SNAPSHOT_ADD_OUTPUT = 25,
88 LTTNG_SNAPSHOT_DEL_OUTPUT = 26,
89 LTTNG_SNAPSHOT_LIST_OUTPUT = 27,
90 LTTNG_SNAPSHOT_RECORD = 28,
27babd3a 91 LTTNG_CREATE_SESSION_SNAPSHOT = 29,
ecc48a90 92 LTTNG_CREATE_SESSION_LIVE = 30,
00c76cea 93 LTTNG_SAVE_SESSION = 31,
ccf10263
MD
94 LTTNG_TRACK_PID = 32,
95 LTTNG_UNTRACK_PID = 33,
a5dfbb9d 96 LTTNG_LIST_TRACKER_PIDS = 34,
d7ba1388 97 LTTNG_SET_SESSION_SHM_PATH = 40,
eded6438 98 LTTNG_REGENERATE_METADATA = 41,
c2561365 99 LTTNG_REGENERATE_STATEDUMP = 42,
a440a542 100 LTTNG_REGISTER_TRIGGER = 43,
7c9534d6
JD
101};
102
103enum lttcomm_relayd_command {
104 RELAYD_ADD_STREAM = 1,
105 RELAYD_CREATE_SESSION = 2,
106 RELAYD_START_DATA = 3,
107 RELAYD_UPDATE_SYNC_INFO = 4,
108 RELAYD_VERSION = 5,
109 RELAYD_SEND_METADATA = 6,
110 RELAYD_CLOSE_STREAM = 7,
111 RELAYD_DATA_PENDING = 8,
112 RELAYD_QUIESCENT_CONTROL = 9,
113 RELAYD_BEGIN_DATA_PENDING = 10,
114 RELAYD_END_DATA_PENDING = 11,
1c20f0e2
JD
115 RELAYD_ADD_INDEX = 12,
116 RELAYD_SEND_INDEX = 13,
117 RELAYD_CLOSE_INDEX = 14,
a4baae1b 118 /* Live-reading commands (2.4+). */
d3e2ba59 119 RELAYD_LIST_SESSIONS = 15,
a4baae1b
JD
120 /* All streams of the channel have been sent to the relayd (2.4+). */
121 RELAYD_STREAMS_SENT = 16,
93ec662e
JD
122 /* Ask the relay to reset the metadata trace file (2.8+) */
123 RELAYD_RESET_METADATA = 17,
fac6795d
DG
124};
125
126/*
127 * lttcomm error code.
128 */
129enum lttcomm_return_code {
0c759fc9 130 LTTCOMM_CONSUMERD_SUCCESS = 0, /* Everything went fine. */
f73fabfd
DG
131 LTTCOMM_CONSUMERD_COMMAND_SOCK_READY = 1, /* Command socket ready */
132 LTTCOMM_CONSUMERD_SUCCESS_RECV_FD, /* Success on receiving fds */
133 LTTCOMM_CONSUMERD_ERROR_RECV_FD, /* Error on receiving fds */
134 LTTCOMM_CONSUMERD_ERROR_RECV_CMD, /* Error on receiving command */
135 LTTCOMM_CONSUMERD_POLL_ERROR, /* Error in polling thread */
136 LTTCOMM_CONSUMERD_POLL_NVAL, /* Poll on closed fd */
137 LTTCOMM_CONSUMERD_POLL_HUP, /* All fds have hungup */
138 LTTCOMM_CONSUMERD_EXIT_SUCCESS, /* Consumerd exiting normally */
139 LTTCOMM_CONSUMERD_EXIT_FAILURE, /* Consumerd exiting on error */
140 LTTCOMM_CONSUMERD_OUTFD_ERROR, /* Error opening the tracefile */
141 LTTCOMM_CONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */
142 LTTCOMM_CONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */
143 LTTCOMM_CONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
144 LTTCOMM_CONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
ffe60014 145 LTTCOMM_CONSUMERD_ENOMEM, /* Consumer is out of memory */
d88aee68
DG
146 LTTCOMM_CONSUMERD_ERROR_METADATA, /* Error with metadata. */
147 LTTCOMM_CONSUMERD_FATAL, /* Fatal error. */
618a6a28 148 LTTCOMM_CONSUMERD_RELAYD_FAIL, /* Error on remote relayd */
0c759fc9 149 LTTCOMM_CONSUMERD_CHANNEL_FAIL, /* Channel creation failed. */
e462382a 150 LTTCOMM_CONSUMERD_CHAN_NOT_FOUND, /* Channel not found. */
80e327fa 151
20fe2104
DG
152 /* MUST be last element */
153 LTTCOMM_NR, /* Last element */
fac6795d
DG
154};
155
de5e9086
DG
156/* lttng socket protocol. */
157enum lttcomm_sock_proto {
158 LTTCOMM_SOCK_UDP,
159 LTTCOMM_SOCK_TCP,
160};
161
162/*
163 * Index in the net_families array below. Please keep in sync!
164 */
165enum lttcomm_sock_domain {
01d0a631
CB
166 LTTCOMM_INET = 0,
167 LTTCOMM_INET6 = 1,
de5e9086
DG
168};
169
331744e3
JD
170enum lttcomm_metadata_command {
171 LTTCOMM_METADATA_REQUEST = 1,
172};
173
174/*
175 * Commands sent from the consumerd to the sessiond to request if new metadata
176 * is available. This message is used to find the per UID _or_ per PID registry
177 * for the channel key. For per UID lookup, the triplet
178 * bits_per_long/uid/session_id is used. On lookup failure, we search for the
179 * per PID registry indexed by session id ignoring the other values.
180 */
181struct lttcomm_metadata_request_msg {
1950109e
JD
182 uint64_t session_id; /* Tracing session id */
183 uint64_t session_id_per_pid; /* Tracing session id for per-pid */
331744e3
JD
184 uint32_t bits_per_long; /* Consumer ABI */
185 uint32_t uid;
186 uint64_t key; /* Metadata channel key. */
187} LTTNG_PACKED;
188
de5e9086
DG
189struct lttcomm_sockaddr {
190 enum lttcomm_sock_domain type;
191 union {
192 struct sockaddr_in sin;
193 struct sockaddr_in6 sin6;
194 } addr;
fc5e05b7 195} LTTNG_PACKED;
de5e9086
DG
196
197struct lttcomm_sock {
d88aee68 198 int32_t fd;
de5e9086
DG
199 enum lttcomm_sock_proto proto;
200 struct lttcomm_sockaddr sockaddr;
201 const struct lttcomm_proto_ops *ops;
fc5e05b7 202} LTTNG_PACKED;
de5e9086 203
6151a90f
JD
204/*
205 * Relayd sock. Adds the protocol version to use for the communications with
206 * the relayd.
207 */
208struct lttcomm_relayd_sock {
209 struct lttcomm_sock sock;
210 uint32_t major;
211 uint32_t minor;
212} LTTNG_PACKED;
213
de5e9086
DG
214struct lttcomm_net_family {
215 int family;
216 int (*create) (struct lttcomm_sock *sock, int type, int proto);
217};
218
219struct lttcomm_proto_ops {
220 int (*bind) (struct lttcomm_sock *sock);
221 int (*close) (struct lttcomm_sock *sock);
222 int (*connect) (struct lttcomm_sock *sock);
223 struct lttcomm_sock *(*accept) (struct lttcomm_sock *sock);
224 int (*listen) (struct lttcomm_sock *sock, int backlog);
225 ssize_t (*recvmsg) (struct lttcomm_sock *sock, void *buf, size_t len,
226 int flags);
c2d69327
JG
227 ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
228 size_t len, int flags);
de5e9086
DG
229};
230
fac6795d 231/*
9bda164d 232 * Data structure received from lttng client to session daemon.
fac6795d
DG
233 */
234struct lttcomm_session_msg {
d0b96690 235 uint32_t cmd_type; /* enum lttcomm_sessiond_command */
42abccdb 236 struct lttng_session session;
9f19cc17 237 struct lttng_domain domain;
fac6795d 238 union {
f3ed775e 239 /* Event data */
fac6795d 240 struct {
db8870ed 241 char channel_name[LTTNG_SYMBOL_NAME_LEN];
1179a48f 242 struct lttng_event event LTTNG_PACKED;
6b453b5e
JG
243 /* Length of following filter expression. */
244 uint32_t expression_len;
025faf73
DG
245 /* Length of following bytecode for filter. */
246 uint32_t bytecode_len;
a5516688
JI
247 /* exclusion data */
248 uint32_t exclusion_count;
249 /*
250 * After this structure, the following variable-length
251 * items are transmitted:
252 * - char exclusion_names[LTTNG_SYMBOL_NAME_LEN][exclusion_count]
6b453b5e 253 * - unsigned char filter_expression[expression_len]
a5516688
JI
254 * - unsigned char filter_bytecode[bytecode_len]
255 */
fc5e05b7 256 } LTTNG_PACKED enable;
6e911cad
MD
257 struct {
258 char channel_name[LTTNG_SYMBOL_NAME_LEN];
259 struct lttng_event event LTTNG_PACKED;
260 /* Length of following filter expression. */
261 uint32_t expression_len;
262 /* Length of following bytecode for filter. */
263 uint32_t bytecode_len;
264 /*
265 * After this structure, the following variable-length
266 * items are transmitted:
267 * - unsigned char filter_expression[expression_len]
268 * - unsigned char filter_bytecode[bytecode_len]
269 */
270 } LTTNG_PACKED disable;
f3ed775e
DG
271 /* Create channel */
272 struct {
1179a48f 273 struct lttng_channel chan LTTNG_PACKED;
fc5e05b7 274 } LTTNG_PACKED channel;
d65106b1
DG
275 /* Context */
276 struct {
db8870ed 277 char channel_name[LTTNG_SYMBOL_NAME_LEN];
1179a48f 278 struct lttng_event_context ctx LTTNG_PACKED;
2001793c
JG
279 uint32_t provider_name_len;
280 uint32_t context_name_len;
fc5e05b7 281 } LTTNG_PACKED context;
d9800920
DG
282 /* Use by register_consumer */
283 struct {
284 char path[PATH_MAX];
fc5e05b7 285 } LTTNG_PACKED reg;
9f19cc17
DG
286 /* List */
287 struct {
db8870ed 288 char channel_name[LTTNG_SYMBOL_NAME_LEN];
fc5e05b7 289 } LTTNG_PACKED list;
d0254c7c 290 struct lttng_calibrate calibrate;
a4b92340 291 /* Used by the set_consumer_url and used by create_session also call */
de5e9086 292 struct {
a4b92340
DG
293 /* Number of lttng_uri following */
294 uint32_t size;
fc5e05b7 295 } LTTNG_PACKED uri;
da3c9ec1 296 struct {
1179a48f 297 struct lttng_snapshot_output output LTTNG_PACKED;
da3c9ec1
DG
298 } LTTNG_PACKED snapshot_output;
299 struct {
300 uint32_t wait;
1179a48f 301 struct lttng_snapshot_output output LTTNG_PACKED;
da3c9ec1 302 } LTTNG_PACKED snapshot_record;
ecc48a90
JD
303 struct {
304 uint32_t nb_uri;
305 unsigned int timer_interval; /* usec */
306 } LTTNG_PACKED session_live;
00c76cea 307 struct {
1179a48f 308 struct lttng_save_session_attr attr; /* struct already packed */
00c76cea 309 } LTTNG_PACKED save_session;
d7ba1388
MD
310 struct {
311 char shm_path[PATH_MAX];
312 } LTTNG_PACKED set_shm_path;
ccf10263
MD
313 struct {
314 uint32_t pid;
315 } LTTNG_PACKED pid_tracker;
a440a542
JG
316 struct {
317 struct lttng_trigger_comm header;
318 } LTTNG_PACKED trigger;
fac6795d 319 } u;
fc5e05b7 320} LTTNG_PACKED;
fac6795d 321
d93c4f1f 322#define LTTNG_FILTER_MAX_LEN 65536
53a80697
MD
323
324/*
325 * Filter bytecode data. The reloc table is located at the end of the
326 * bytecode. It is made of tuples: (uint16_t, var. len. string). It
327 * starts at reloc_table_offset.
328 */
b6bbed5f 329#define LTTNG_FILTER_PADDING 32
53a80697 330struct lttng_filter_bytecode {
d93c4f1f
CB
331 uint32_t len; /* len of data */
332 uint32_t reloc_table_offset;
f3f0db50 333 uint64_t seqnum;
b6bbed5f 334 char padding[LTTNG_FILTER_PADDING];
53a80697 335 char data[0];
fc5e05b7 336} LTTNG_PACKED;
53a80697 337
579640f9
JI
338/*
339 * Event exclusion data. At the end of the structure, there will actually
340 * by zero or more names, where the actual number of names is given by
341 * the 'count' item of the structure.
342 */
343#define LTTNG_EVENT_EXCLUSION_PADDING 32
344struct lttng_event_exclusion {
345 uint32_t count;
346 char padding[LTTNG_EVENT_EXCLUSION_PADDING];
caafa356 347 char names[0][LTTNG_SYMBOL_NAME_LEN];
579640f9
JI
348} LTTNG_PACKED;
349
d7af3565
PP
350#define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
351 (&(_exclusion)->names[_i][0])
352
b4e3ceb9
PP
353/*
354 * Event command header.
355 */
356struct lttcomm_event_command_header {
357 /* Number of events */
358 uint32_t nb_events;
359} LTTNG_PACKED;
360
361/*
362 * Event extended info header. This is the structure preceding each
363 * extended info data.
364 */
365struct lttcomm_event_extended_header {
366 /*
367 * Size of filter string immediately following this header.
368 * This size includes the terminal null character.
369 */
370 uint32_t filter_len;
795d57ce
PP
371
372 /*
373 * Number of exclusion names, immediately following the filter
374 * string. Each exclusion name has a fixed length of
375 * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null
376 * character.
377 */
378 uint32_t nb_exclusions;
b4e3ceb9
PP
379} LTTNG_PACKED;
380
5ba3702f
JG
381/*
382 * Channel extended info.
383 */
384struct lttcomm_channel_extended {
385 uint64_t discarded_events;
386 uint64_t lost_packets;
387} LTTNG_PACKED;
388
fac6795d 389/*
5e16da05 390 * Data structure for the response from sessiond to the lttng client.
fac6795d 391 */
5461b305 392struct lttcomm_lttng_msg {
d0b96690
DG
393 uint32_t cmd_type; /* enum lttcomm_sessiond_command */
394 uint32_t ret_code; /* enum lttcomm_return_code */
395 uint32_t pid; /* pid_t */
795a978d 396 uint32_t cmd_header_size;
773168b7 397 uint32_t data_size;
fc5e05b7 398} LTTNG_PACKED;
fac6795d 399
da3c9ec1
DG
400struct lttcomm_lttng_output_id {
401 uint32_t id;
402} LTTNG_PACKED;
403
6e3805e2 404/*
3bd1e081
MD
405 * lttcomm_consumer_msg is the message sent from sessiond to consumerd
406 * to either add a channel, add a stream, update a stream, or stop
407 * operation.
6e3805e2 408 */
3bd1e081
MD
409struct lttcomm_consumer_msg {
410 uint32_t cmd_type; /* enum consumerd_command */
411 union {
412 struct {
d88aee68 413 uint64_t channel_key;
ffe60014
DG
414 uint64_t session_id;
415 char pathname[PATH_MAX];
d88aee68
DG
416 uint32_t uid;
417 uint32_t gid;
418 uint64_t relayd_id;
c30aaa51 419 /* nb_init_streams is the number of streams open initially. */
d88aee68 420 uint32_t nb_init_streams;
de5e9086 421 char name[LTTNG_SYMBOL_NAME_LEN];
ffe60014
DG
422 /* Use splice or mmap to consume this fd */
423 enum lttng_event_output output;
424 int type; /* Per cpu or metadata. */
1624d5b7
JD
425 uint64_t tracefile_size; /* bytes */
426 uint32_t tracefile_count; /* number of tracefiles */
2bba9e53
DG
427 /* If the channel's streams have to be monitored or not. */
428 uint32_t monitor;
ecc48a90
JD
429 /* timer to check the streams usage in live mode (usec). */
430 unsigned int live_timer_interval;
ffe60014 431 } LTTNG_PACKED channel; /* Only used by Kernel. */
3bd1e081 432 struct {
d88aee68
DG
433 uint64_t stream_key;
434 uint64_t channel_key;
435 int32_t cpu; /* On which CPU this stream is assigned. */
6dc3064a
DG
436 /* Tells the consumer if the stream should be or not monitored. */
437 uint32_t no_monitor;
ffe60014 438 } LTTNG_PACKED stream; /* Only used by Kernel. */
de5e9086 439 struct {
d88aee68 440 uint64_t net_index;
de5e9086
DG
441 enum lttng_stream_type type;
442 /* Open socket to the relayd */
6151a90f 443 struct lttcomm_relayd_sock sock;
46e6455f
DG
444 /* Tracing session id associated to the relayd. */
445 uint64_t session_id;
d3e2ba59
JD
446 /* Relayd session id, only used with control socket. */
447 uint64_t relayd_session_id;
fc5e05b7 448 } LTTNG_PACKED relayd_sock;
173af62f
DG
449 struct {
450 uint64_t net_seq_idx;
fc5e05b7 451 } LTTNG_PACKED destroy_relayd;
53632229
DG
452 struct {
453 uint64_t session_id;
fc5e05b7 454 } LTTNG_PACKED data_pending;
ffe60014 455 struct {
d0b96690
DG
456 uint64_t subbuf_size; /* bytes */
457 uint64_t num_subbuf; /* power of 2 */
d88aee68
DG
458 int32_t overwrite; /* 1: overwrite, 0: discard */
459 uint32_t switch_timer_interval; /* usec */
460 uint32_t read_timer_interval; /* usec */
ecc48a90 461 unsigned int live_timer_interval; /* usec */
d88aee68
DG
462 int32_t output; /* splice, mmap */
463 int32_t type; /* metadata or per_cpu */
d0b96690
DG
464 uint64_t session_id; /* Tracing session id */
465 char pathname[PATH_MAX]; /* Channel file path. */
ffe60014 466 char name[LTTNG_SYMBOL_NAME_LEN]; /* Channel name. */
d88aee68
DG
467 uint32_t uid; /* User ID of the session */
468 uint32_t gid; /* Group ID ot the session */
469 uint64_t relayd_id; /* Relayd id if apply. */
470 uint64_t key; /* Unique channel key. */
b6d38284 471 unsigned char uuid[UUID_LEN]; /* uuid for ust tracer. */
7972aab2 472 uint32_t chan_id; /* Channel ID on the tracer side. */
1624d5b7
JD
473 uint64_t tracefile_size; /* bytes */
474 uint32_t tracefile_count; /* number of tracefiles */
1950109e 475 uint64_t session_id_per_pid; /* Per-pid session ID. */
2bba9e53
DG
476 /* Tells the consumer if the stream should be or not monitored. */
477 uint32_t monitor;
567eb353
DG
478 /*
479 * For UST per UID buffers, this is the application UID of the
480 * channel. This can be different from the user UID requesting the
481 * channel creation and used for the rights on the stream file
482 * because the application can be in the tracing for instance.
483 */
484 uint32_t ust_app_uid;
3d071855 485 char root_shm_path[PATH_MAX];
d7ba1388 486 char shm_path[PATH_MAX];
ffe60014
DG
487 } LTTNG_PACKED ask_channel;
488 struct {
d88aee68 489 uint64_t key;
ffe60014
DG
490 } LTTNG_PACKED get_channel;
491 struct {
d88aee68 492 uint64_t key;
ffe60014 493 } LTTNG_PACKED destroy_channel;
d88aee68
DG
494 struct {
495 uint64_t key; /* Metadata channel key. */
496 uint64_t target_offset; /* Offset in the consumer */
497 uint64_t len; /* Length of metadata to be received. */
93ec662e 498 uint64_t version; /* Version of the metadata. */
d88aee68
DG
499 } LTTNG_PACKED push_metadata;
500 struct {
501 uint64_t key; /* Metadata channel key. */
502 } LTTNG_PACKED close_metadata;
503 struct {
504 uint64_t key; /* Metadata channel key. */
505 } LTTNG_PACKED setup_metadata;
7972aab2
DG
506 struct {
507 uint64_t key; /* Channel key. */
508 } LTTNG_PACKED flush_channel;
0dd01979
MD
509 struct {
510 uint64_t key; /* Channel key. */
511 } LTTNG_PACKED clear_quiescent_channel;
6dc3064a
DG
512 struct {
513 char pathname[PATH_MAX];
514 /* Indicate if the snapshot goes on the relayd or locally. */
515 uint32_t use_relayd;
516 uint32_t metadata; /* This a metadata snapshot. */
517 uint64_t relayd_id; /* Relayd id if apply. */
518 uint64_t key;
d07ceecd 519 uint64_t nb_packets_per_stream;
6dc3064a 520 } LTTNG_PACKED snapshot_channel;
a4baae1b
JD
521 struct {
522 uint64_t channel_key;
523 uint64_t net_seq_idx;
524 } LTTNG_PACKED sent_streams;
fb83fe64
JD
525 struct {
526 uint64_t session_id;
527 uint64_t channel_key;
528 } LTTNG_PACKED discarded_events;
529 struct {
530 uint64_t session_id;
531 uint64_t channel_key;
532 } LTTNG_PACKED lost_packets;
93ec662e
JD
533 struct {
534 uint64_t session_id;
eded6438 535 } LTTNG_PACKED regenerate_metadata;
3bd1e081 536 } u;
fc5e05b7 537} LTTNG_PACKED;
6e3805e2 538
f50f23d9
DG
539/*
540 * Status message returned to the sessiond after a received command.
541 */
542struct lttcomm_consumer_status_msg {
0c759fc9 543 enum lttcomm_return_code ret_code;
fc5e05b7 544} LTTNG_PACKED;
f50f23d9 545
ffe60014 546struct lttcomm_consumer_status_channel {
0c759fc9 547 enum lttcomm_return_code ret_code;
d88aee68 548 uint64_t key;
ffe60014
DG
549 unsigned int stream_count;
550} LTTNG_PACKED;
551
74d0b642 552#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 553
9df8df5e 554#include <lttng/ust-abi.h>
6e3805e2 555
3817e7df
DG
556/*
557 * Data structure for the commands sent from sessiond to UST.
558 */
559struct lttcomm_ust_msg {
3817e7df
DG
560 uint32_t handle;
561 uint32_t cmd;
562 union {
3817e7df 563 struct lttng_ust_channel channel;
00a17c97 564 struct lttng_ust_stream stream;
3817e7df
DG
565 struct lttng_ust_event event;
566 struct lttng_ust_context context;
00a17c97 567 struct lttng_ust_tracer_version version;
3817e7df 568 } u;
fc5e05b7 569} LTTNG_PACKED;
3817e7df
DG
570
571/*
572 * Data structure for the response from UST to the session daemon.
573 * cmd_type is sent back in the reply for validation.
574 */
575struct lttcomm_ust_reply {
576 uint32_t handle;
577 uint32_t cmd;
578 uint32_t ret_code; /* enum lttcomm_return_code */
579 uint32_t ret_val; /* return value */
580 union {
2b0bf864
DG
581 struct {
582 uint64_t memory_map_size;
fc5e05b7 583 } LTTNG_PACKED channel;
2b0bf864
DG
584 struct {
585 uint64_t memory_map_size;
fc5e05b7 586 } LTTNG_PACKED stream;
00a17c97 587 struct lttng_ust_tracer_version version;
3817e7df 588 } u;
fc5e05b7 589} LTTNG_PACKED;
3817e7df 590
74d0b642 591#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 592
fac6795d
DG
593extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
594
6364a07a
DG
595extern int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
596 const char *ip, unsigned int port);
597extern int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
598 const char *ip, unsigned int port);
599
de5e9086
DG
600extern struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
601extern int lttcomm_create_sock(struct lttcomm_sock *sock);
602extern struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
603extern void lttcomm_destroy_sock(struct lttcomm_sock *sock);
604extern struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
605extern void lttcomm_copy_sock(struct lttcomm_sock *dst,
606 struct lttcomm_sock *src);
6364a07a 607
6151a90f
JD
608/* Relayd socket object. */
609extern struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
610 struct lttng_uri *uri, uint32_t major, uint32_t minor);
611
783a3b9a
MD
612extern int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
613extern int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
614
554831e7
MD
615extern void lttcomm_init(void);
616/* Get network timeout, in milliseconds */
617extern unsigned long lttcomm_get_network_timeout(void);
618
773168b7 619#endif /* _LTTNG_SESSIOND_COMM_H */
This page took 0.095581 seconds and 5 git commands to generate.