78b94532d096a2d0adb884b734b595b32660e1f5
[lttng-tools.git] / src / common / sessiond-comm / sessiond-comm.h
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Julien Desfossez <julien.desfossez@polymtl.ca>
4 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
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.
9 *
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
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
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.
18 */
19
20 /*
21 * This header is meant for liblttng and libust internal use ONLY. These
22 * declarations should NOT be considered stable API.
23 */
24
25 #ifndef _LTTNG_SESSIOND_COMM_H
26 #define _LTTNG_SESSIOND_COMM_H
27
28 #include <limits.h>
29 #include <lttng/lttng.h>
30 #include <lttng/snapshot-internal.h>
31 #include <lttng/save-internal.h>
32 #include <lttng/channel-internal.h>
33 #include <lttng/trigger/trigger-internal.h>
34 #include <lttng/rotate-internal.h>
35 #include <common/compat/socket.h>
36 #include <common/uri.h>
37 #include <common/defaults.h>
38 #include <common/compat/uuid.h>
39
40 #include <arpa/inet.h>
41 #include <netinet/in.h>
42 #include <sys/un.h>
43
44 #include "inet.h"
45 #include "inet6.h"
46 #include <common/unix.h>
47
48 /* Queue size of listen(2) */
49 #define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
50
51 /* Maximum number of FDs that can be sent over a Unix socket */
52 #define LTTCOMM_MAX_SEND_FDS 4
53
54 /*
55 * Get the error code index from 0 since LTTCOMM_OK start at 1000
56 */
57 #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_CONSUMERD_COMMAND_SOCK_READY)
58
59 enum lttcomm_sessiond_command {
60 /* Tracer command */
61 LTTNG_ADD_CONTEXT = 0,
62 /* LTTNG_CALIBRATE used to be here */
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,
68 /* 7 */
69 /* Session daemon command */
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,
81
82 /* Consumer */
83 LTTNG_DISABLE_CONSUMER = 19,
84 LTTNG_ENABLE_CONSUMER = 20,
85 LTTNG_SET_CONSUMER_URI = 21,
86 /* 22 */
87 /* 23 */
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,
107 LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 48,
108 };
109
110 enum 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,
122 RELAYD_ADD_INDEX = 12,
123 RELAYD_SEND_INDEX = 13,
124 RELAYD_CLOSE_INDEX = 14,
125 /* Live-reading commands (2.4+). */
126 RELAYD_LIST_SESSIONS = 15,
127 /* All streams of the channel have been sent to the relayd (2.4+). */
128 RELAYD_STREAMS_SENT = 16,
129 /* Ask the relay to reset the metadata trace file (2.8+) */
130 RELAYD_RESET_METADATA = 17,
131 /* Ask the relay to rotate a stream file (2.11+) */
132 RELAYD_ROTATE_STREAM = 18,
133 /* Rename a chunk after the rotation is completed (2.11+) */
134 RELAYD_ROTATE_RENAME = 19,
135 /* Check if a chunk has data pending (2.11+) */
136 RELAYD_ROTATE_PENDING = 20,
137 /* Create a folder on the relayd FS (2.11+) */
138 RELAYD_MKDIR = 21,
139 };
140
141 /*
142 * lttcomm error code.
143 */
144 enum lttcomm_return_code {
145 LTTCOMM_CONSUMERD_SUCCESS = 0, /* Everything went fine. */
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) */
160 LTTCOMM_CONSUMERD_ENOMEM, /* Consumer is out of memory */
161 LTTCOMM_CONSUMERD_ERROR_METADATA, /* Error with metadata. */
162 LTTCOMM_CONSUMERD_FATAL, /* Fatal error. */
163 LTTCOMM_CONSUMERD_RELAYD_FAIL, /* Error on remote relayd */
164 LTTCOMM_CONSUMERD_CHANNEL_FAIL, /* Channel creation failed. */
165 LTTCOMM_CONSUMERD_CHAN_NOT_FOUND, /* Channel not found. */
166 LTTCOMM_CONSUMERD_ALREADY_SET, /* Resource already set. */
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. */
172 LTTCOMM_CONSUMERD_SNAPSHOT_FAILED, /* snapshot has failed. */
173
174 /* MUST be last element */
175 LTTCOMM_NR, /* Last element */
176 };
177
178 /* lttng socket protocol. */
179 enum 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 */
187 enum lttcomm_sock_domain {
188 LTTCOMM_INET = 0,
189 LTTCOMM_INET6 = 1,
190 };
191
192 enum 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 */
203 struct lttcomm_metadata_request_msg {
204 uint64_t session_id; /* Tracing session id */
205 uint64_t session_id_per_pid; /* Tracing session id for per-pid */
206 uint32_t bits_per_long; /* Consumer ABI */
207 uint32_t uid;
208 uint64_t key; /* Metadata channel key. */
209 } LTTNG_PACKED;
210
211 struct lttcomm_sockaddr {
212 enum lttcomm_sock_domain type;
213 union {
214 struct sockaddr_in sin;
215 struct sockaddr_in6 sin6;
216 } addr;
217 } LTTNG_PACKED;
218
219 struct lttcomm_sock {
220 int32_t fd;
221 enum lttcomm_sock_proto proto;
222 struct lttcomm_sockaddr sockaddr;
223 const struct lttcomm_proto_ops *ops;
224 } LTTNG_PACKED;
225
226 /*
227 * Relayd sock. Adds the protocol version to use for the communications with
228 * the relayd.
229 */
230 struct lttcomm_relayd_sock {
231 struct lttcomm_sock sock;
232 uint32_t major;
233 uint32_t minor;
234 } LTTNG_PACKED;
235
236 struct lttcomm_net_family {
237 int family;
238 int (*create) (struct lttcomm_sock *sock, int type, int proto);
239 };
240
241 struct 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);
249 ssize_t (*sendmsg) (struct lttcomm_sock *sock, const void *buf,
250 size_t len, int flags);
251 };
252
253 /*
254 * Data structure received from lttng client to session daemon.
255 */
256 struct lttcomm_session_msg {
257 uint32_t cmd_type; /* enum lttcomm_sessiond_command */
258 struct lttng_session session;
259 struct lttng_domain domain;
260 union {
261 /* Event data */
262 struct {
263 char channel_name[LTTNG_SYMBOL_NAME_LEN];
264 struct lttng_event event LTTNG_PACKED;
265 /* Length of following filter expression. */
266 uint32_t expression_len;
267 /* Length of following bytecode for filter. */
268 uint32_t bytecode_len;
269 /* Exclusion count (fixed-size strings). */
270 uint32_t exclusion_count;
271 /* Userspace probe location size. */
272 uint32_t userspace_probe_location_len;
273 /*
274 * After this structure, the following variable-length
275 * items are transmitted:
276 * - char exclusion_names[LTTNG_SYMBOL_NAME_LEN][exclusion_count]
277 * - char filter_expression[expression_len]
278 * - unsigned char filter_bytecode[bytecode_len]
279 */
280 } LTTNG_PACKED enable;
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;
295 /* Create channel */
296 struct {
297 struct lttng_channel chan LTTNG_PACKED;
298 /* struct lttng_channel_extended is already packed. */
299 struct lttng_channel_extended extended;
300 } LTTNG_PACKED channel;
301 /* Context */
302 struct {
303 char channel_name[LTTNG_SYMBOL_NAME_LEN];
304 struct lttng_event_context ctx LTTNG_PACKED;
305 uint32_t provider_name_len;
306 uint32_t context_name_len;
307 } LTTNG_PACKED context;
308 /* Use by register_consumer */
309 struct {
310 char path[PATH_MAX];
311 } LTTNG_PACKED reg;
312 /* List */
313 struct {
314 char channel_name[LTTNG_SYMBOL_NAME_LEN];
315 } LTTNG_PACKED list;
316 struct lttng_calibrate calibrate;
317 /* Used by the set_consumer_url and used by create_session also call */
318 struct {
319 /* Number of lttng_uri following */
320 uint32_t size;
321 } LTTNG_PACKED uri;
322 struct {
323 struct lttng_snapshot_output output LTTNG_PACKED;
324 } LTTNG_PACKED snapshot_output;
325 struct {
326 uint32_t wait;
327 struct lttng_snapshot_output output LTTNG_PACKED;
328 } LTTNG_PACKED snapshot_record;
329 struct {
330 uint32_t nb_uri;
331 unsigned int timer_interval; /* usec */
332 } LTTNG_PACKED session_live;
333 struct {
334 struct lttng_save_session_attr attr; /* struct already packed */
335 } LTTNG_PACKED save_session;
336 struct {
337 char shm_path[PATH_MAX];
338 } LTTNG_PACKED set_shm_path;
339 struct {
340 uint32_t pid;
341 } LTTNG_PACKED pid_tracker;
342 struct {
343 uint32_t length;
344 } LTTNG_PACKED trigger;
345 struct {
346 uint64_t rotation_id;
347 } LTTNG_PACKED get_rotation_info;
348 struct {
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;
358 } u;
359 } LTTNG_PACKED;
360
361 #define LTTNG_FILTER_MAX_LEN 65536
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 */
368 #define LTTNG_FILTER_PADDING 32
369 struct lttng_filter_bytecode {
370 uint32_t len; /* len of data */
371 uint32_t reloc_table_offset;
372 uint64_t seqnum;
373 char padding[LTTNG_FILTER_PADDING];
374 char data[0];
375 } LTTNG_PACKED;
376
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
383 struct lttng_event_exclusion {
384 uint32_t count;
385 char padding[LTTNG_EVENT_EXCLUSION_PADDING];
386 char names[0][LTTNG_SYMBOL_NAME_LEN];
387 } LTTNG_PACKED;
388
389 #define LTTNG_EVENT_EXCLUSION_NAME_AT(_exclusion, _i) \
390 (&(_exclusion)->names[_i][0])
391
392 /*
393 * Event command header.
394 */
395 struct 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 */
404 struct 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;
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;
418
419 /*
420 * Size of the event's userspace probe location (if applicable).
421 */
422 uint32_t userspace_probe_location_len;
423 } LTTNG_PACKED;
424
425 /*
426 * Data structure for the response from sessiond to the lttng client.
427 */
428 struct lttcomm_lttng_msg {
429 uint32_t cmd_type; /* enum lttcomm_sessiond_command */
430 uint32_t ret_code; /* enum lttcomm_return_code */
431 uint32_t pid; /* pid_t */
432 uint32_t cmd_header_size;
433 uint32_t data_size;
434 } LTTNG_PACKED;
435
436 struct lttcomm_lttng_output_id {
437 uint32_t id;
438 } LTTNG_PACKED;
439
440 /*
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.
444 */
445 struct lttcomm_consumer_msg {
446 uint32_t cmd_type; /* enum lttng_consumer_command */
447 union {
448 struct {
449 uint64_t channel_key;
450 uint64_t session_id;
451 char pathname[PATH_MAX];
452 uint32_t uid;
453 uint32_t gid;
454 uint64_t relayd_id;
455 /* nb_init_streams is the number of streams open initially. */
456 uint32_t nb_init_streams;
457 char name[LTTNG_SYMBOL_NAME_LEN];
458 /* Use splice or mmap to consume this fd */
459 enum lttng_event_output output;
460 int type; /* Per cpu or metadata. */
461 uint64_t tracefile_size; /* bytes */
462 uint32_t tracefile_count; /* number of tracefiles */
463 /* If the channel's streams have to be monitored or not. */
464 uint32_t monitor;
465 /* timer to check the streams usage in live mode (usec). */
466 unsigned int live_timer_interval;
467 /* timer to sample a channel's positions (usec). */
468 unsigned int monitor_timer_interval;
469 } LTTNG_PACKED channel; /* Only used by Kernel. */
470 struct {
471 uint64_t stream_key;
472 uint64_t channel_key;
473 int32_t cpu; /* On which CPU this stream is assigned. */
474 /* Tells the consumer if the stream should be or not monitored. */
475 uint32_t no_monitor;
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;
483 } LTTNG_PACKED stream; /* Only used by Kernel. */
484 struct {
485 uint64_t net_index;
486 enum lttng_stream_type type;
487 /* Open socket to the relayd */
488 struct lttcomm_relayd_sock sock;
489 /* Tracing session id associated to the relayd. */
490 uint64_t session_id;
491 /* Relayd session id, only used with control socket. */
492 uint64_t relayd_session_id;
493 } LTTNG_PACKED relayd_sock;
494 struct {
495 uint64_t net_seq_idx;
496 } LTTNG_PACKED destroy_relayd;
497 struct {
498 uint64_t session_id;
499 } LTTNG_PACKED data_pending;
500 struct {
501 uint64_t subbuf_size; /* bytes */
502 uint64_t num_subbuf; /* power of 2 */
503 int32_t overwrite; /* 1: overwrite, 0: discard */
504 uint32_t switch_timer_interval; /* usec */
505 uint32_t read_timer_interval; /* usec */
506 unsigned int live_timer_interval; /* usec */
507 uint32_t monitor_timer_interval; /* usec */
508 int32_t output; /* splice, mmap */
509 int32_t type; /* metadata or per_cpu */
510 uint64_t session_id; /* Tracing session id */
511 char pathname[PATH_MAX]; /* Channel file path. */
512 char name[LTTNG_SYMBOL_NAME_LEN]; /* Channel name. */
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. */
517 unsigned char uuid[UUID_LEN]; /* uuid for ust tracer. */
518 uint32_t chan_id; /* Channel ID on the tracer side. */
519 uint64_t tracefile_size; /* bytes */
520 uint32_t tracefile_count; /* number of tracefiles */
521 uint64_t session_id_per_pid; /* Per-pid session ID. */
522 /* Tells the consumer if the stream should be or not monitored. */
523 uint32_t monitor;
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;
531 int64_t blocking_timeout;
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;
539 char root_shm_path[PATH_MAX];
540 char shm_path[PATH_MAX];
541 } LTTNG_PACKED ask_channel;
542 struct {
543 uint64_t key;
544 } LTTNG_PACKED get_channel;
545 struct {
546 uint64_t key;
547 } LTTNG_PACKED destroy_channel;
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. */
552 uint64_t version; /* Version of the metadata. */
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;
560 struct {
561 uint64_t key; /* Channel key. */
562 } LTTNG_PACKED flush_channel;
563 struct {
564 uint64_t key; /* Channel key. */
565 } LTTNG_PACKED clear_quiescent_channel;
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;
573 uint64_t nb_packets_per_stream;
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;
580 } LTTNG_PACKED snapshot_channel;
581 struct {
582 uint64_t channel_key;
583 uint64_t net_seq_idx;
584 } LTTNG_PACKED sent_streams;
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;
593 struct {
594 uint64_t session_id;
595 } LTTNG_PACKED regenerate_metadata;
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;
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;
611 struct {
612 uint64_t session_id;
613 uint64_t chunk_id;
614 } LTTNG_PACKED check_rotation_pending_local;
615 struct {
616 uint64_t relayd_id;
617 uint64_t session_id;
618 uint64_t chunk_id;
619 } LTTNG_PACKED check_rotation_pending_relay;
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;
627 struct {
628 uint64_t key;
629 } LTTNG_PACKED clear_channel;
630 } u;
631 } LTTNG_PACKED;
632
633 /*
634 * Channel monitoring message returned to the session daemon on every
635 * monitor timer expiration.
636 */
637 struct lttcomm_consumer_channel_monitor_msg {
638 /* Key of the sampled channel. */
639 uint64_t key;
640 /*
641 * Lowest and highest usage (bytes) at the moment the sample was taken.
642 */
643 uint64_t lowest, highest;
644 /*
645 * Sum of all the consumed positions for a channel.
646 */
647 uint64_t total_consumed;
648 } LTTNG_PACKED;
649
650 /*
651 * Status message returned to the sessiond after a received command.
652 */
653 struct lttcomm_consumer_status_msg {
654 enum lttcomm_return_code ret_code;
655 } LTTNG_PACKED;
656
657 struct lttcomm_consumer_status_channel {
658 enum lttcomm_return_code ret_code;
659 uint64_t key;
660 unsigned int stream_count;
661 } LTTNG_PACKED;
662
663 #ifdef HAVE_LIBLTTNG_UST_CTL
664
665 #include <lttng/ust-abi.h>
666
667 /*
668 * Data structure for the commands sent from sessiond to UST.
669 */
670 struct lttcomm_ust_msg {
671 uint32_t handle;
672 uint32_t cmd;
673 union {
674 struct lttng_ust_channel channel;
675 struct lttng_ust_stream stream;
676 struct lttng_ust_event event;
677 struct lttng_ust_context context;
678 struct lttng_ust_tracer_version version;
679 } u;
680 } LTTNG_PACKED;
681
682 /*
683 * Data structure for the response from UST to the session daemon.
684 * cmd_type is sent back in the reply for validation.
685 */
686 struct lttcomm_ust_reply {
687 uint32_t handle;
688 uint32_t cmd;
689 uint32_t ret_code; /* enum lttcomm_return_code */
690 uint32_t ret_val; /* return value */
691 union {
692 struct {
693 uint64_t memory_map_size;
694 } LTTNG_PACKED channel;
695 struct {
696 uint64_t memory_map_size;
697 } LTTNG_PACKED stream;
698 struct lttng_ust_tracer_version version;
699 } u;
700 } LTTNG_PACKED;
701
702 #endif /* HAVE_LIBLTTNG_UST_CTL */
703
704 LTTNG_HIDDEN const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
705
706 LTTNG_HIDDEN int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
707 const char *ip, unsigned int port);
708 LTTNG_HIDDEN int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
709 const char *ip, unsigned int port);
710
711 LTTNG_HIDDEN struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto);
712 LTTNG_HIDDEN int lttcomm_create_sock(struct lttcomm_sock *sock);
713 LTTNG_HIDDEN struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri);
714 LTTNG_HIDDEN void lttcomm_destroy_sock(struct lttcomm_sock *sock);
715 LTTNG_HIDDEN struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src);
716 LTTNG_HIDDEN void lttcomm_copy_sock(struct lttcomm_sock *dst,
717 struct lttcomm_sock *src);
718
719 /* Relayd socket object. */
720 LTTNG_HIDDEN struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
721 struct lttng_uri *uri, uint32_t major, uint32_t minor);
722
723 LTTNG_HIDDEN int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec);
724 LTTNG_HIDDEN int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec);
725
726 LTTNG_HIDDEN int lttcomm_sock_get_port(const struct lttcomm_sock *sock,
727 uint16_t *port);
728 /*
729 * Set a port to an lttcomm_sock. This will have no effect is the socket is
730 * already bound.
731 */
732 LTTNG_HIDDEN int lttcomm_sock_set_port(struct lttcomm_sock *sock, uint16_t port);
733
734 LTTNG_HIDDEN void lttcomm_init(void);
735 /* Get network timeout, in milliseconds */
736 LTTNG_HIDDEN unsigned long lttcomm_get_network_timeout(void);
737
738 #endif /* _LTTNG_SESSIOND_COMM_H */
This page took 0.043696 seconds and 4 git commands to generate.