| 1 | /* |
| 2 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_CTL_HELPER_H |
| 9 | #define LTTNG_CTL_HELPER_H |
| 10 | |
| 11 | #include <common/sessiond-comm/sessiond-comm.hpp> |
| 12 | |
| 13 | #include <lttng/lttng.h> |
| 14 | |
| 15 | #include <stdio.h> |
| 16 | |
| 17 | /* Copy helper functions. */ |
| 18 | void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst, struct lttng_domain *src); |
| 19 | |
| 20 | /* |
| 21 | * Sends the lttcomm message to the session daemon and fills buf if the |
| 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 | */ |
| 27 | int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm, |
| 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); |
| 35 | |
| 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 | */ |
| 42 | int lttng_ctl_ask_sessiond_payload(struct lttng_payload_view *message, struct lttng_payload *reply); |
| 43 | |
| 44 | /* |
| 45 | * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header. |
| 46 | */ |
| 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) |
| 51 | { |
| 52 | return lttng_ctl_ask_sessiond_fds_varlen( |
| 53 | lsm, nullptr, 0, vardata, vardata_len, user_payload_buf, nullptr, nullptr); |
| 54 | } |
| 55 | |
| 56 | /* |
| 57 | * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header. |
| 58 | */ |
| 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))) |
| 63 | { |
| 64 | return lttng_ctl_ask_sessiond_fds_varlen( |
| 65 | lsm, fds, nb_fd, nullptr, 0, nullptr, nullptr, nullptr); |
| 66 | } |
| 67 | /* |
| 68 | * Use this if no variable length data needs to be sent. |
| 69 | */ |
| 70 | static inline int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf) |
| 71 | { |
| 72 | return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, nullptr, 0, buf); |
| 73 | } |
| 74 | |
| 75 | int lttng_check_tracing_group(); |
| 76 | |
| 77 | int connect_sessiond(); |
| 78 | |
| 79 | #endif /* LTTNG_CTL_HELPER_H */ |