1 #ifndef _LTTNG_UST_COMM_H
2 #define _LTTNG_UST_COMM_H
5 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
6 * Julien Desfossez <julien.desfossez@polymtl.ca>
7 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; only
12 * version 2.1 of the License.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 * This header is meant for liblttng and libust internal use ONLY.
26 * These declarations should NOT be considered stable API.
31 #include <lttng/ust-abi.h>
32 #include <lttng/ust-error.h>
33 #include <lttng/ust-compiler.h>
36 * Default timeout the application waits for the sessiond to send its
37 * "register done" command. Can be overridden with the environment
38 * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
39 * found, the application proceeds directly without any delay.
41 #define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000
43 #define LTTNG_RUNDIR "/var/run/lttng"
44 #define LTTNG_HOME_RUNDIR "%s/.lttng"
46 /* Default unix socket path */
47 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-lttng-sessiond"
48 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-lttng-sessiond"
49 #define DEFAULT_HOME_APPS_UNIX_SOCK LTTNG_HOME_RUNDIR "/apps-lttng-sessiond"
50 #define DEFAULT_HOME_CLIENT_UNIX_SOCK LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
52 #define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait"
53 #define DEFAULT_HOME_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait-%u"
55 /* Queue size of listen(2) */
56 #define LTTNG_UST_COMM_MAX_LISTEN 10
59 * Data structure for the commands sent from sessiond to UST.
61 struct ustcomm_ust_msg
{
65 struct lttng_ust_channel channel
;
66 struct lttng_ust_stream stream
;
67 struct lttng_ust_event event
;
68 struct lttng_ust_context context
;
69 struct lttng_ust_tracer_version version
;
70 struct lttng_ust_tracepoint_iter tracepoint
;
72 uint32_t data_size
; /* following filter data */
73 uint32_t reloc_offset
;
75 } LTTNG_PACKED filter
;
80 * Data structure for the response from UST to the session daemon.
81 * cmd_type is sent back in the reply for validation.
83 struct ustcomm_ust_reply
{
86 uint32_t ret_code
; /* enum enum ustcomm_return_code */
87 uint32_t ret_val
; /* return value */
90 uint64_t memory_map_size
;
91 } LTTNG_PACKED channel
;
93 uint64_t memory_map_size
;
94 } LTTNG_PACKED stream
;
95 struct lttng_ust_tracer_version version
;
96 struct lttng_ust_tracepoint_iter tracepoint
;
101 * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
102 * struct lttng_ust_field_iter field.
105 extern int ustcomm_create_unix_sock(const char *pathname
);
106 extern int ustcomm_connect_unix_sock(const char *pathname
);
107 extern int ustcomm_accept_unix_sock(int sock
);
108 extern int ustcomm_listen_unix_sock(int sock
);
109 extern int ustcomm_close_unix_sock(int sock
);
110 /* Send fd(s) over a unix socket. */
111 extern ssize_t
ustcomm_send_fds_unix_sock(int sock
, void *buf
, int *fds
,
112 size_t nb_fd
, size_t len
);
113 extern ssize_t
ustcomm_recv_unix_sock(int sock
, void *buf
, size_t len
);
114 extern ssize_t
ustcomm_send_unix_sock(int sock
, void *buf
, size_t len
);
115 extern const char *ustcomm_get_readable_code(int code
);
116 extern int ustcomm_send_app_msg(int sock
, struct ustcomm_ust_msg
*lum
);
117 extern int ustcomm_recv_app_reply(int sock
, struct ustcomm_ust_reply
*lur
,
118 uint32_t expected_handle
, uint32_t expected_cmd
);
119 extern int ustcomm_send_app_cmd(int sock
,
120 struct ustcomm_ust_msg
*lum
,
121 struct ustcomm_ust_reply
*lur
);
122 int ustcomm_recv_fd(int sock
);
124 #endif /* _LTTNG_UST_COMM_H */