Commit | Line | Data |
---|---|---|
cac3069d DG |
1 | /* |
2 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> | |
3 | * | |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
cac3069d | 5 | * |
cac3069d DG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_CTL_HELPER_H | |
9 | #define LTTNG_CTL_HELPER_H | |
10 | ||
cac3069d DG |
11 | #include <stdio.h> |
12 | ||
13 | #include <common/sessiond-comm/sessiond-comm.h> | |
14 | #include <lttng/lttng.h> | |
15 | ||
16 | /* | |
17 | * NOTE: Every symbol in this helper header MUST be set to hidden so not to | |
18 | * polute the library name space. Use LTTNG_HIDDEN macro before declaring the | |
19 | * function in the C file. | |
20 | */ | |
21 | ||
22 | /* Copy helper functions. */ | |
cac3069d DG |
23 | void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst, |
24 | struct lttng_domain *src); | |
25 | ||
26 | /* | |
c2d69327 | 27 | * Sends the lttcomm message to the session daemon and fills buf if the |
cac3069d DG |
28 | * returned data is not NULL. |
29 | * | |
30 | * Return the size of the received data on success or else a negative lttng | |
31 | * error code. If buf is NULL, 0 is returned on success. | |
32 | */ | |
a04d53fc FD |
33 | int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm, |
34 | const int *fds, size_t nb_fd, | |
795a978d PP |
35 | const void *vardata, size_t vardata_len, |
36 | void **user_payload_buf, void **user_cmd_header_buf, | |
37 | size_t *user_cmd_header_len); | |
38 | ||
e368fb43 JG |
39 | /* |
40 | * Sends the lttcomm message to the session daemon and fills the reply payload. | |
41 | * | |
42 | * Return the size of the received data on success or else a negative lttng | |
43 | * error code. | |
44 | */ | |
45 | LTTNG_HIDDEN | |
46 | int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, | |
47 | struct lttng_payload *reply); | |
48 | ||
795a978d | 49 | /* |
a04d53fc | 50 | * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header. |
795a978d | 51 | */ |
159b042f JG |
52 | static inline int lttng_ctl_ask_sessiond_varlen_no_cmd_header( |
53 | struct lttcomm_session_msg *lsm, | |
54 | const void *vardata, | |
55 | size_t vardata_len, | |
56 | void **user_payload_buf) | |
795a978d | 57 | { |
a04d53fc | 58 | return lttng_ctl_ask_sessiond_fds_varlen(lsm, NULL, 0, vardata, |
795a978d PP |
59 | vardata_len, user_payload_buf, NULL, NULL); |
60 | } | |
cac3069d | 61 | |
a04d53fc FD |
62 | /* |
63 | * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header. | |
64 | */ | |
65 | static inline | |
66 | int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm, | |
67 | const int *fds, size_t nb_fd, void **buf) | |
68 | { | |
69 | return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, NULL, | |
70 | 0, NULL, NULL, NULL); | |
71 | } | |
cac3069d DG |
72 | /* |
73 | * Use this if no variable length data needs to be sent. | |
74 | */ | |
75 | static inline | |
76 | int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf) | |
77 | { | |
795a978d | 78 | return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, NULL, 0, buf); |
cac3069d DG |
79 | } |
80 | ||
6c71277b MD |
81 | int lttng_check_tracing_group(void); |
82 | ||
3e3665b8 JG |
83 | int connect_sessiond(void); |
84 | ||
cac3069d | 85 | #endif /* LTTNG_CTL_HELPER_H */ |