Implement ustctl_tracepoint_list/list_get
[lttng-ust.git] / include / lttng / 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 program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; only version 2
12 * of the License.
13 *
14 * This program 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
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
43 /* Default unix socket path */
44 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-lttng-sessiond"
45 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-lttng-sessiond"
46 #define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-lttng-sessiond"
47 #define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-lttng-sessiond"
48
49 #define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait"
50 #define DEFAULT_HOME_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait-%u"
51
52 /* Queue size of listen(2) */
53 #define LTTNG_UST_COMM_MAX_LISTEN 10
54
55 /* Get the error code index from 0. USTCOMM_ERR starts at 1000.
56 */
57 #define USTCOMM_ERR_INDEX(code) (code - USTCOMM_ERR)
58
59 /*
60 * ustcomm error code.
61 */
62 enum ustcomm_return_code {
63 USTCOMM_OK = 0, /* Ok */
64 /* Range 1 to 999 used for standard error numbers (errno.h) */
65 USTCOMM_ERR = 1000, /* Unknown Error */
66 USTCOMM_UND, /* Undefine command */
67 USTCOMM_NOT_IMPLEMENTED, /* Command not implemented */
68 USTCOMM_UNKNOWN_DOMAIN, /* Tracing domain not known */
69 USTCOMM_ALLOC_FAIL, /* Trace allocation fail */
70 USTCOMM_NO_SESSION, /* No session found */
71 USTCOMM_CREATE_FAIL, /* Create trace fail */
72 USTCOMM_SESSION_FAIL, /* Create session fail */
73 USTCOMM_START_FAIL, /* Start tracing fail */
74 USTCOMM_STOP_FAIL, /* Stop tracing fail */
75 USTCOMM_LIST_FAIL, /* Listing apps fail */
76 USTCOMM_NO_APPS, /* No traceable application */
77 USTCOMM_SESS_NOT_FOUND, /* Session name not found */
78 USTCOMM_NO_TRACE, /* No trace exist */
79 USTCOMM_FATAL, /* Session daemon had a fatal error */
80 USTCOMM_NO_TRACEABLE, /* Error for non traceable app */
81 USTCOMM_SELECT_SESS, /* Must select a session */
82 USTCOMM_EXIST_SESS, /* Session name already exist */
83 USTCOMM_NO_EVENT, /* No event found */
84 USTCOMM_KERN_NA, /* Kernel tracer unavalable */
85 USTCOMM_KERN_EVENT_EXIST, /* Kernel event already exists */
86 USTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */
87 USTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */
88 USTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */
89 USTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */
90 USTCOMM_KERN_CHAN_ENABLE_FAIL, /* Kernel enable channel failed */
91 USTCOMM_KERN_CONTEXT_FAIL, /* Kernel add context failed */
92 USTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */
93 USTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */
94 USTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */
95 USTCOMM_KERN_START_FAIL, /* Kernel start trace failed */
96 USTCOMM_KERN_STOP_FAIL, /* Kernel stop trace failed */
97 USTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */
98 USTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */
99 USTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */
100 USTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */
101 USTCOMM_KERN_NO_SESSION, /* No kernel session found */
102 USTCOMM_KERN_LIST_FAIL, /* Kernel listing events failed */
103 USTCONSUMER_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */
104 USTCONSUMER_SUCCESS_RECV_FD, /* success on receiving fds */
105 USTCONSUMER_ERROR_RECV_FD, /* error on receiving fds */
106 USTCONSUMER_POLL_ERROR, /* Error in polling thread in kconsumerd */
107 USTCONSUMER_POLL_NVAL, /* Poll on closed fd */
108 USTCONSUMER_POLL_HUP, /* All fds have hungup */
109 USTCONSUMER_EXIT_SUCCESS, /* kconsumerd exiting normally */
110 USTCONSUMER_EXIT_FAILURE, /* kconsumerd exiting on error */
111 USTCONSUMER_OUTFD_ERROR, /* error opening the tracefile */
112 USTCONSUMER_SPLICE_EBADF, /* EBADF from splice(2) */
113 USTCONSUMER_SPLICE_EINVAL, /* EINVAL from splice(2) */
114 USTCONSUMER_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
115 USTCONSUMER_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
116 /* MUST be last element */
117 USTCOMM_NR, /* Last element */
118 };
119
120 /*
121 * Data structure for the commands sent from sessiond to UST.
122 */
123 struct ustcomm_ust_msg {
124 uint32_t handle;
125 uint32_t cmd;
126 union {
127 struct lttng_ust_channel channel;
128 struct lttng_ust_stream stream;
129 struct lttng_ust_event event;
130 struct lttng_ust_context context;
131 struct lttng_ust_tracer_version version;
132 char tracepoint_list_entry[LTTNG_UST_SYM_NAME_LEN];
133 } u;
134 };
135
136 /*
137 * Data structure for the response from UST to the session daemon.
138 * cmd_type is sent back in the reply for validation.
139 */
140 struct ustcomm_ust_reply {
141 uint32_t handle;
142 uint32_t cmd;
143 uint32_t ret_code; /* enum enum ustcomm_return_code */
144 uint32_t ret_val; /* return value */
145 union {
146 struct {
147 uint64_t memory_map_size;
148 } channel;
149 struct {
150 uint64_t memory_map_size;
151 } stream;
152 struct lttng_ust_tracer_version version;
153 char tracepoint_list_entry[LTTNG_UST_SYM_NAME_LEN];
154 } u;
155 };
156
157 extern int ustcomm_create_unix_sock(const char *pathname);
158 extern int ustcomm_connect_unix_sock(const char *pathname);
159 extern int ustcomm_accept_unix_sock(int sock);
160 extern int ustcomm_listen_unix_sock(int sock);
161 extern int ustcomm_close_unix_sock(int sock);
162 /* Send fd(s) over a unix socket. */
163 extern ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds,
164 size_t nb_fd, size_t len);
165 extern ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len);
166 extern ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len);
167 extern const char *ustcomm_get_readable_code(int code);
168 extern int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum);
169 extern int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
170 uint32_t expected_handle, uint32_t expected_cmd);
171 extern int ustcomm_send_app_cmd(int sock,
172 struct ustcomm_ust_msg *lum,
173 struct ustcomm_ust_reply *lur);
174 int ustcomm_recv_fd(int sock);
175
176 #endif /* _LTTNG_UST_COMM_H */
This page took 0.047146 seconds and 4 git commands to generate.