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 | ||
c9e313bc | 11 | #include <common/sessiond-comm/sessiond-comm.hpp> |
28f23191 | 12 | |
cac3069d DG |
13 | #include <lttng/lttng.h> |
14 | ||
28f23191 JG |
15 | #include <stdio.h> |
16 | ||
cac3069d | 17 | /* Copy helper functions. */ |
28f23191 | 18 | void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst, struct lttng_domain *src); |
cac3069d DG |
19 | |
20 | /* | |
c2d69327 | 21 | * Sends the lttcomm message to the session daemon and fills buf if the |
cac3069d DG |
22 | * returned data is not NULL. |
23 | * | |
24 | * Return the size of the received data on success or else a negative lttng | |
25 | * error code. If buf is NULL, 0 is returned on success. | |
26 | */ | |
a04d53fc | 27 | int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm, |
28f23191 JG |
28 | const int *fds, |
29 | size_t nb_fd, | |
30 | const void *vardata, | |
31 | size_t vardata_len, | |
32 | void **user_payload_buf, | |
33 | void **user_cmd_header_buf, | |
34 | size_t *user_cmd_header_len); | |
795a978d | 35 | |
e368fb43 JG |
36 | /* |
37 | * Sends the lttcomm message to the session daemon and fills the reply payload. | |
38 | * | |
39 | * Return the size of the received data on success or else a negative lttng | |
40 | * error code. | |
41 | */ | |
28f23191 | 42 | int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, struct lttng_payload *reply); |
e368fb43 | 43 | |
795a978d | 44 | /* |
a04d53fc | 45 | * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header. |
795a978d | 46 | */ |
28f23191 JG |
47 | static inline int lttng_ctl_ask_sessiond_varlen_no_cmd_header(struct lttcomm_session_msg *lsm, |
48 | const void *vardata, | |
49 | size_t vardata_len, | |
50 | void **user_payload_buf) | |
795a978d | 51 | { |
28f23191 | 52 | return lttng_ctl_ask_sessiond_fds_varlen( |
0f4aa1a8 | 53 | lsm, nullptr, 0, vardata, vardata_len, user_payload_buf, nullptr, nullptr); |
795a978d | 54 | } |
cac3069d | 55 | |
a04d53fc FD |
56 | /* |
57 | * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header. | |
58 | */ | |
28f23191 JG |
59 | static inline int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm, |
60 | const int *fds, | |
61 | size_t nb_fd, | |
62 | void **buf __attribute__((unused))) | |
a04d53fc | 63 | { |
0f4aa1a8 JG |
64 | return lttng_ctl_ask_sessiond_fds_varlen( |
65 | lsm, fds, nb_fd, nullptr, 0, nullptr, nullptr, nullptr); | |
a04d53fc | 66 | } |
cac3069d DG |
67 | /* |
68 | * Use this if no variable length data needs to be sent. | |
69 | */ | |
28f23191 | 70 | static inline int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf) |
cac3069d | 71 | { |
0f4aa1a8 | 72 | return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, nullptr, 0, buf); |
cac3069d DG |
73 | } |
74 | ||
0f4aa1a8 | 75 | int lttng_check_tracing_group(); |
6c71277b | 76 | |
0f4aa1a8 | 77 | int connect_sessiond(); |
3e3665b8 | 78 | |
cac3069d | 79 | #endif /* LTTNG_CTL_HELPER_H */ |