Implement ustctl_tracepoint_list/list_get
[lttng-ust.git] / include / lttng / ust-comm.h
CommitLineData
b35d179d
MD
1#ifndef _LTTNG_UST_COMM_H
2#define _LTTNG_UST_COMM_H
67c5b804
MD
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>
57773204 30#include <unistd.h>
4318ae1b 31#include <lttng/ust-abi.h>
67c5b804 32
11ff9c7d 33/*
cf12a773
MD
34 * Default timeout the application waits for the sessiond to send its
35 * "register done" command. Can be overridden with the environment
69400ac4 36 * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
cf12a773 37 * found, the application proceeds directly without any delay.
11ff9c7d 38 */
cf12a773 39#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000
11ff9c7d 40
67c5b804
MD
41#define LTTNG_RUNDIR "/var/run/lttng"
42
43/* Default unix socket path */
8d1dae7c
MD
44#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-lttng-sessiond"
45#define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-lttng-sessiond"
f36af1be
MD
46#define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-lttng-sessiond"
47#define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-lttng-sessiond"
67c5b804 48
7fc90dca 49#define DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait"
58d4b2a2 50#define DEFAULT_HOME_APPS_WAIT_SHM_PATH "/lttng-ust-apps-wait-%u"
7fc90dca 51
67c5b804 52/* Queue size of listen(2) */
e41474be 53#define LTTNG_UST_COMM_MAX_LISTEN 10
67c5b804 54
57773204 55/* Get the error code index from 0. USTCOMM_ERR starts at 1000.
67c5b804 56 */
57773204 57#define USTCOMM_ERR_INDEX(code) (code - USTCOMM_ERR)
67c5b804 58
67c5b804 59/*
57773204 60 * ustcomm error code.
67c5b804 61 */
57773204
MD
62enum 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) */
67c5b804 116 /* MUST be last element */
57773204 117 USTCOMM_NR, /* Last element */
67c5b804
MD
118};
119
120/*
e7723462 121 * Data structure for the commands sent from sessiond to UST.
67c5b804 122 */
57773204 123struct ustcomm_ust_msg {
1ece9766 124 uint32_t handle;
46050b1a 125 uint32_t cmd;
67c5b804 126 union {
1ece9766 127 struct lttng_ust_channel channel;
381c0f1e 128 struct lttng_ust_stream stream;
1ece9766
MD
129 struct lttng_ust_event event;
130 struct lttng_ust_context context;
57773204 131 struct lttng_ust_tracer_version version;
51489cad 132 char tracepoint_list_entry[LTTNG_UST_SYM_NAME_LEN];
67c5b804
MD
133 } u;
134};
135
9eb62b9c
MD
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 */
57773204 140struct ustcomm_ust_reply {
46050b1a
MD
141 uint32_t handle;
142 uint32_t cmd;
57773204 143 uint32_t ret_code; /* enum enum ustcomm_return_code */
1ece9766 144 uint32_t ret_val; /* return value */
9eb62b9c 145 union {
193183fb
MD
146 struct {
147 uint64_t memory_map_size;
148 } channel;
381c0f1e
MD
149 struct {
150 uint64_t memory_map_size;
151 } stream;
57773204 152 struct lttng_ust_tracer_version version;
b115631f 153 char tracepoint_list_entry[LTTNG_UST_SYM_NAME_LEN];
9eb62b9c
MD
154 } u;
155};
156
57773204
MD
157extern int ustcomm_create_unix_sock(const char *pathname);
158extern int ustcomm_connect_unix_sock(const char *pathname);
159extern int ustcomm_accept_unix_sock(int sock);
160extern int ustcomm_listen_unix_sock(int sock);
161extern int ustcomm_close_unix_sock(int sock);
67c5b804 162/* Send fd(s) over a unix socket. */
57773204 163extern ssize_t ustcomm_send_fds_unix_sock(int sock, void *buf, int *fds,
67c5b804 164 size_t nb_fd, size_t len);
57773204
MD
165extern ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len);
166extern ssize_t ustcomm_send_unix_sock(int sock, void *buf, size_t len);
167extern const char *ustcomm_get_readable_code(int code);
168extern int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum);
169extern int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
170 uint32_t expected_handle, uint32_t expected_cmd);
171extern int ustcomm_send_app_cmd(int sock,
172 struct ustcomm_ust_msg *lum,
173 struct ustcomm_ust_reply *lur);
174int ustcomm_recv_fd(int sock);
67c5b804 175
b35d179d 176#endif /* _LTTNG_UST_COMM_H */
This page took 0.044352 seconds and 4 git commands to generate.