SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl-helper.h
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 <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. */
23 void lttng_ctl_copy_string(char *dst, const char *src, size_t len);
24 void lttng_ctl_copy_lttng_domain(struct lttng_domain *dst,
25 struct lttng_domain *src);
26
27 /*
28 * Sends the lttcomm message to the session daemon and fills buf if the
29 * returned data is not NULL.
30 *
31 * Return the size of the received data on success or else a negative lttng
32 * error code. If buf is NULL, 0 is returned on success.
33 */
34 int lttng_ctl_ask_sessiond_fds_varlen(struct lttcomm_session_msg *lsm,
35 const int *fds, size_t nb_fd,
36 const void *vardata, size_t vardata_len,
37 void **user_payload_buf, void **user_cmd_header_buf,
38 size_t *user_cmd_header_len);
39
40 /*
41 * Calls lttng_ctl_ask_sessiond_fds_varlen() with no expected command header.
42 */
43 static inline
44 int lttng_ctl_ask_sessiond_varlen_no_cmd_header(struct lttcomm_session_msg *lsm,
45 void *vardata, size_t vardata_len, void **user_payload_buf)
46 {
47 return lttng_ctl_ask_sessiond_fds_varlen(lsm, NULL, 0, vardata,
48 vardata_len, user_payload_buf, NULL, NULL);
49 }
50
51 /*
52 * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds and no expected command header.
53 */
54 static inline
55 int lttng_ctl_ask_sessiond_fds_no_cmd_header(struct lttcomm_session_msg *lsm,
56 const int *fds, size_t nb_fd, void **buf)
57 {
58 return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, NULL,
59 0, NULL, NULL, NULL);
60 }
61
62 /*
63 * Calls lttng_ctl_ask_sessiond_fds_varlen() with fds with no expected command
64 * header and with varlen data.
65 */
66 static inline int lttng_ctl_ask_sessiond_fds_varlen_no_cmd_header(
67 struct lttcomm_session_msg *lsm,
68 const int *fds,
69 size_t nb_fd,
70 void *vardata,
71 size_t vardata_len,
72 void **user_payload_buf)
73 {
74 return lttng_ctl_ask_sessiond_fds_varlen(lsm, fds, nb_fd, vardata,
75 vardata_len, user_payload_buf, NULL, NULL);
76 }
77
78 /*
79 * Use this if no variable length data needs to be sent.
80 */
81 static inline
82 int lttng_ctl_ask_sessiond(struct lttcomm_session_msg *lsm, void **buf)
83 {
84 return lttng_ctl_ask_sessiond_varlen_no_cmd_header(lsm, NULL, 0, buf);
85 }
86
87 int lttng_check_tracing_group(void);
88
89 int connect_sessiond(void);
90
91 #endif /* LTTNG_CTL_HELPER_H */
This page took 0.044998 seconds and 5 git commands to generate.