ust-event.h: use BYTE_ORDER instead of __BYTE_ORDER
[lttng-ust.git] / include / ust-comm.h
1 #ifndef _LTTNG_UST_COMM_H
2 #define _LTTNG_UST_COMM_H
3
4 /*
5 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
6 * Julien Desfossez <julien.desfossez@polymtl.ca>
7 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
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.
13 *
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.
18 *
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
22 */
23
24 /*
25 * This header is meant for liblttng and libust internal use ONLY.
26 * These declarations should NOT be considered stable API.
27 */
28
29 #include <limits.h>
30 #include <unistd.h>
31 #include <lttng/ust-abi.h>
32
33 /*
34 * Default timeout the application waits for the sessiond to send its
35 * "register done" command. Can be overridden with the environment
36 * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
37 * found, the application proceeds directly without any delay.
38 */
39 #define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000
40
41 #define LTTNG_RUNDIR "/var/run/lttng"
42 #define LTTNG_HOME_RUNDIR "%s/.lttng"
43
44 /* Default unix socket path */
45 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-lttng-sessiond"
46 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-lttng-sessiond"
47 #define DEFAULT_HOME_APPS_UNIX_SOCK LTTNG_HOME_RUNDIR "/apps-lttng-sessiond"
48 #define DEFAULT_HOME_CLIENT_UNIX_SOCK LTTNG_HOME_RUNDIR "/client-lttng-sessiond"
49
50 #define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait"
51 #define DEFAULT_HOME_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait-%u"
52
53 /* Queue size of listen(2) */
54 #define LTTNG_UST_COMM_MAX_LISTEN 10
55
56 /* Get the error code index from 0. USTCOMM_ERR starts at 1000.
57 */
58 #define USTCOMM_ERR_INDEX(code) (code - USTCOMM_ERR)
59
60 /*
61 * ustcomm error code.
62 */
63 enum ustcomm_return_code {
64 USTCOMM_OK = 0, /* Ok */
65 /* Range 1 to 999 used for standard error numbers (errno.h) */
66 USTCOMM_ERR = 1000, /* Unknown Error */
67 USTCOMM_UND, /* Undefine command */
68 USTCOMM_NOT_IMPLEMENTED, /* Command not implemented */
69 USTCOMM_UNKNOWN_DOMAIN, /* Tracing domain not known */
70 USTCOMM_ALLOC_FAIL, /* Trace allocation fail */
71 USTCOMM_NO_SESSION, /* No session found */
72 USTCOMM_CREATE_FAIL, /* Create trace fail */
73 USTCOMM_SESSION_FAIL, /* Create session fail */
74 USTCOMM_START_FAIL, /* Start tracing fail */
75 USTCOMM_STOP_FAIL, /* Stop tracing fail */
76 USTCOMM_LIST_FAIL, /* Listing apps fail */
77 USTCOMM_NO_APPS, /* No traceable application */
78 USTCOMM_SESS_NOT_FOUND, /* Session name not found */
79 USTCOMM_NO_TRACE, /* No trace exist */
80 USTCOMM_FATAL, /* Session daemon had a fatal error */
81 USTCOMM_NO_TRACEABLE, /* Error for non traceable app */
82 USTCOMM_SELECT_SESS, /* Must select a session */
83 USTCOMM_EXIST_SESS, /* Session name already exist */
84 USTCOMM_NO_EVENT, /* No event found */
85 USTCOMM_KERN_NA, /* Kernel tracer unavalable */
86 USTCOMM_KERN_EVENT_EXIST, /* Kernel event already exists */
87 USTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */
88 USTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */
89 USTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */
90 USTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */
91 USTCOMM_KERN_CHAN_ENABLE_FAIL, /* Kernel enable channel failed */
92 USTCOMM_KERN_CONTEXT_FAIL, /* Kernel add context failed */
93 USTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */
94 USTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */
95 USTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */
96 USTCOMM_KERN_START_FAIL, /* Kernel start trace failed */
97 USTCOMM_KERN_STOP_FAIL, /* Kernel stop trace failed */
98 USTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */
99 USTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */
100 USTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */
101 USTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */
102 USTCOMM_KERN_NO_SESSION, /* No kernel session found */
103 USTCOMM_KERN_LIST_FAIL, /* Kernel listing events failed */
104 USTCONSUMER_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */
105 USTCONSUMER_SUCCESS_RECV_FD, /* success on receiving fds */
106 USTCONSUMER_ERROR_RECV_FD, /* error on receiving fds */
107 USTCONSUMER_POLL_ERROR, /* Error in polling thread in kconsumerd */
108 USTCONSUMER_POLL_NVAL, /* Poll on closed fd */
109 USTCONSUMER_POLL_HUP, /* All fds have hungup */
110 USTCONSUMER_EXIT_SUCCESS, /* kconsumerd exiting normally */
111 USTCONSUMER_EXIT_FAILURE, /* kconsumerd exiting on error */
112 USTCONSUMER_OUTFD_ERROR, /* error opening the tracefile */
113 USTCONSUMER_SPLICE_EBADF, /* EBADF from splice(2) */
114 USTCONSUMER_SPLICE_EINVAL, /* EINVAL from splice(2) */
115 USTCONSUMER_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
116 USTCONSUMER_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
117 /* MUST be last element */
118 USTCOMM_NR, /* Last element */
119 };
120
121 /*
122 * Data structure for the commands sent from sessiond to UST.
123 */
124 struct ustcomm_ust_msg {
125 uint32_t handle;
126 uint32_t cmd;
127 union {
128 struct lttng_ust_channel channel;
129 struct lttng_ust_stream stream;
130 struct lttng_ust_event event;
131 struct lttng_ust_context context;
132 struct lttng_ust_tracer_version version;
133 struct lttng_ust_tracepoint_iter tracepoint;
134 } u;
135 };
136
137 /*
138 * Data structure for the response from UST to the session daemon.
139 * cmd_type is sent back in the reply for validation.
140 */
141 struct ustcomm_ust_reply {
142 uint32_t handle;
143 uint32_t cmd;
144 uint32_t ret_code; /* enum enum ustcomm_return_code */
145 uint32_t ret_val; /* return value */
146 union {
147 struct {
148 uint64_t memory_map_size;
149 } channel;
150 struct {
151 uint64_t memory_map_size;
152 } stream;
153 struct lttng_ust_tracer_version version;
154 struct lttng_ust_tracepoint_iter tracepoint;
155 } u;
156 };
157
158 extern int ustcomm_create_unix_sock(const char *pathname);
159 extern int ustcomm_connect_unix_sock(const char *pathname);
160 extern int ustcomm_accept_unix_sock(int sock);
161 extern int ustcomm_listen_unix_sock(int sock);
162 extern int ustcomm_close_unix_sock(int sock);
163 /* Send fd(s) over a unix socket. */
164 extern ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds,
165 size_t nb_fd, size_t len);
166 extern ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len);
167 extern ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len);
168 extern const char *ustcomm_get_readable_code(int code);
169 extern int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum);
170 extern int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
171 uint32_t expected_handle, uint32_t expected_cmd);
172 extern int ustcomm_send_app_cmd(int sock,
173 struct ustcomm_ust_msg *lum,
174 struct ustcomm_ust_reply *lur);
175 int ustcomm_recv_fd(int sock);
176
177 #endif /* _LTTNG_UST_COMM_H */
This page took 0.051407 seconds and 4 git commands to generate.