Copyright ownership transfer
[lttng-ust.git] / src / common / ustcomm.h
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2011 EfficiOS Inc.
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 */
7
8/*
9 * This header is meant for liblttng and libust internal use ONLY.
10 * These declarations should NOT be considered stable API.
11 */
12
13#ifndef _UST_COMMON_UST_COMM_H
14#define _UST_COMMON_UST_COMM_H
15
16#include <stdint.h>
17#include <limits.h>
18#include <unistd.h>
19#include <lttng/ust-abi.h>
20#include <lttng/ust-error.h>
21#include <lttng/ust-compiler.h>
22#include <lttng/ust-ctl.h>
23
24/*
25 * Default timeout the application waits for the sessiond to send its
26 * "register done" command. Can be overridden with the environment
27 * variable "LTTNG_UST_REGISTER_TIMEOUT". Note that if the sessiond is not
28 * found, the application proceeds directly without any delay.
29 */
30#define LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS 3000
31
32#define LTTNG_DEFAULT_RUNDIR LTTNG_SYSTEM_RUNDIR
33#define LTTNG_DEFAULT_HOME_RUNDIR ".lttng"
34
35/* Queue size of listen(2) */
36#define LTTNG_UST_COMM_MAX_LISTEN 10
37#define LTTNG_UST_COMM_REG_MSG_PADDING 64
38
39struct lttng_ust_event_field;
40struct lttng_ust_ctx_field;
41struct lttng_ust_enum_entry;
42struct lttng_integer_type;
43struct lttng_ust_session;
44
45struct lttng_ust_ctl_reg_msg {
46 uint32_t magic;
47 uint32_t major;
48 uint32_t minor;
49 uint32_t pid;
50 uint32_t ppid;
51 uint32_t uid;
52 uint32_t gid;
53 uint32_t bits_per_long;
54 uint32_t uint8_t_alignment;
55 uint32_t uint16_t_alignment;
56 uint32_t uint32_t_alignment;
57 uint32_t uint64_t_alignment;
58 uint32_t long_alignment;
59 uint32_t socket_type; /* enum lttng_ust_ctl_socket_type */
60 char name[LTTNG_UST_ABI_PROCNAME_LEN]; /* process name */
61 char padding[LTTNG_UST_COMM_REG_MSG_PADDING];
62} __attribute__((packed));
63
64/*
65 * Data structure for the commands sent from sessiond to UST.
66 */
67#define USTCOMM_MSG_PADDING1 32
68#define USTCOMM_MSG_PADDING2 32
69struct ustcomm_ust_msg {
70 uint32_t handle;
71 uint32_t cmd;
72 char padding[USTCOMM_MSG_PADDING1];
73 union {
74 struct lttng_ust_abi_channel channel;
75 struct lttng_ust_abi_stream stream;
76 struct lttng_ust_abi_event event;
77 struct lttng_ust_abi_context context;
78 struct lttng_ust_abi_tracer_version version;
79 struct lttng_ust_abi_tracepoint_iter tracepoint;
80 struct {
81 uint32_t data_size; /* following filter data */
82 uint32_t reloc_offset;
83 uint64_t seqnum;
84 } __attribute__((packed)) filter;
85 struct {
86 uint32_t count; /* how many names follow */
87 } __attribute__((packed)) exclusion;
88 struct {
89 uint32_t data_size; /* following capture data */
90 uint32_t reloc_offset;
91 uint64_t seqnum;
92 } __attribute__((packed)) capture;
93 struct lttng_ust_abi_counter counter;
94 struct lttng_ust_abi_counter_global counter_global;
95 struct lttng_ust_abi_counter_cpu counter_cpu;
96 /*
97 * For lttng_ust_abi_EVENT_NOTIFIER_CREATE, a struct
98 * lttng_ust_abi_event_notifier implicitly follows struct
99 * ustcomm_ust_msg.
100 */
101 struct {
102 /* Length of struct lttng_ust_abi_event_notifier */
103 uint32_t len;
104 } event_notifier;
105 char padding[USTCOMM_MSG_PADDING2];
106 } u;
107} __attribute__((packed));
108
109/*
110 * Data structure for the response from UST to the session daemon.
111 * cmd_type is sent back in the reply for validation.
112 */
113#define USTCOMM_REPLY_PADDING1 32
114#define USTCOMM_REPLY_PADDING2 32
115struct ustcomm_ust_reply {
116 uint32_t handle;
117 uint32_t cmd;
118 int32_t ret_code; /* enum ustcomm_return_code */
119 uint32_t ret_val; /* return value */
120 char padding[USTCOMM_REPLY_PADDING1];
121 union {
122 struct {
123 uint64_t memory_map_size;
124 } __attribute__((packed)) channel;
125 struct {
126 uint64_t memory_map_size;
127 } __attribute__((packed)) stream;
128 struct lttng_ust_abi_tracer_version version;
129 struct lttng_ust_abi_tracepoint_iter tracepoint;
130 char padding[USTCOMM_REPLY_PADDING2];
131 } u;
132} __attribute__((packed));
133
134struct ustcomm_notify_hdr {
135 uint32_t notify_cmd;
136} __attribute__((packed));
137
138#define USTCOMM_NOTIFY_EVENT_MSG_PADDING 32
139struct ustcomm_notify_event_msg {
140 uint32_t session_objd;
141 uint32_t channel_objd;
142 char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
143 int32_t loglevel;
144 uint32_t signature_len;
145 uint32_t fields_len;
146 uint32_t model_emf_uri_len;
147 char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
148 /* followed by signature, fields, and model_emf_uri */
149} __attribute__((packed));
150
151#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
152struct ustcomm_notify_event_reply {
153 int32_t ret_code; /* 0: ok, negative: error code */
154 uint32_t event_id;
155 char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
156} __attribute__((packed));
157
158#define USTCOMM_NOTIFY_ENUM_MSG_PADDING 32
159struct ustcomm_notify_enum_msg {
160 uint32_t session_objd;
161 char enum_name[LTTNG_UST_ABI_SYM_NAME_LEN];
162 uint32_t entries_len;
163 char padding[USTCOMM_NOTIFY_ENUM_MSG_PADDING];
164 /* followed by enum entries */
165} __attribute__((packed));
166
167#define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 32
168struct ustcomm_notify_enum_reply {
169 int32_t ret_code; /* 0: ok, negative: error code */
170 uint64_t enum_id;
171 char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING];
172} __attribute__((packed));
173
174#define USTCOMM_NOTIFY_CHANNEL_MSG_PADDING 32
175struct ustcomm_notify_channel_msg {
176 uint32_t session_objd;
177 uint32_t channel_objd;
178 uint32_t ctx_fields_len;
179 char padding[USTCOMM_NOTIFY_CHANNEL_MSG_PADDING];
180 /* followed by context fields */
181} __attribute__((packed));
182
183#define USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING 32
184struct ustcomm_notify_channel_reply {
185 int32_t ret_code; /* 0: ok, negative: error code */
186 uint32_t chan_id;
187 uint32_t header_type; /* enum lttng_ust_ctl_channel_header */
188 char padding[USTCOMM_NOTIFY_CHANNEL_REPLY_PADDING];
189} __attribute__((packed));
190
191/*
192 * LTTNG_UST_TRACEPOINT_FIELD_LIST reply is followed by a
193 * struct lttng_ust_field_iter field.
194 */
195
196int ustcomm_create_unix_sock(const char *pathname)
197 __attribute__((visibility("hidden")));
198
199int ustcomm_connect_unix_sock(const char *pathname,
200 long timeout)
201 __attribute__((visibility("hidden")));
202
203int ustcomm_accept_unix_sock(int sock)
204 __attribute__((visibility("hidden")));
205
206int ustcomm_listen_unix_sock(int sock)
207 __attribute__((visibility("hidden")));
208
209int ustcomm_shutdown_unix_sock(int sock)
210 __attribute__((visibility("hidden")));
211
212int ustcomm_close_unix_sock(int sock)
213 __attribute__((visibility("hidden")));
214
215ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len)
216 __attribute__((visibility("hidden")));
217
218ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len)
219 __attribute__((visibility("hidden")));
220
221ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
222 __attribute__((visibility("hidden")));
223
224ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
225 __attribute__((visibility("hidden")));
226
227const char *ustcomm_get_readable_code(int code)
228 __attribute__((visibility("hidden")));
229
230int ustcomm_send_app_msg(int sock, struct ustcomm_ust_msg *lum)
231 __attribute__((visibility("hidden")));
232
233int ustcomm_recv_app_reply(int sock, struct ustcomm_ust_reply *lur,
234 uint32_t expected_handle, uint32_t expected_cmd)
235 __attribute__((visibility("hidden")));
236
237int ustcomm_send_app_cmd(int sock,
238 struct ustcomm_ust_msg *lum,
239 struct ustcomm_ust_reply *lur)
240 __attribute__((visibility("hidden")));
241
242int ustcomm_recv_fd(int sock)
243 __attribute__((visibility("hidden")));
244
245ssize_t ustcomm_recv_channel_from_sessiond(int sock,
246 void **chan_data, uint64_t len, int *wakeup_fd)
247 __attribute__((visibility("hidden")));
248
249int ustcomm_recv_stream_from_sessiond(int sock,
250 uint64_t *memory_map_size,
251 int *shm_fd, int *wakeup_fd)
252 __attribute__((visibility("hidden")));
253
254ssize_t ustcomm_recv_event_notifier_notif_fd_from_sessiond(int sock,
255 int *event_notifier_notif_fd)
256 __attribute__((visibility("hidden")));
257
258ssize_t ustcomm_recv_counter_from_sessiond(int sock,
259 void **counter_data, uint64_t len)
260 __attribute__((visibility("hidden")));
261
262int ustcomm_recv_counter_shm_from_sessiond(int sock,
263 int *shm_fd)
264 __attribute__((visibility("hidden")));
265
266/*
267 * Returns 0 on success, negative error value on error.
268 * Returns -EPIPE or -ECONNRESET if other end has hung up.
269 */
270int ustcomm_send_reg_msg(int sock,
271 enum lttng_ust_ctl_socket_type type,
272 uint32_t bits_per_long,
273 uint32_t uint8_t_alignment,
274 uint32_t uint16_t_alignment,
275 uint32_t uint32_t_alignment,
276 uint32_t uint64_t_alignment,
277 uint32_t long_alignment,
278 const char *procname)
279 __attribute__((visibility("hidden")));
280
281/*
282 * Returns 0 on success, negative error value on error.
283 * Returns -EPIPE or -ECONNRESET if other end has hung up.
284 */
285int ustcomm_register_event(int sock,
286 struct lttng_ust_session *session,
287 int session_objd, /* session descriptor */
288 int channel_objd, /* channel descriptor */
289 const char *event_name, /* event name (input) */
290 int loglevel,
291 const char *signature, /* event signature (input) */
292 size_t nr_fields, /* fields */
293 const struct lttng_ust_event_field * const *fields,
294 const char *model_emf_uri,
295 uint32_t *id) /* event id (output) */
296 __attribute__((visibility("hidden")));
297
298/*
299 * Returns 0 on success, negative error value on error.
300 * Returns -EPIPE or -ECONNRESET if other end has hung up.
301 */
302int ustcomm_register_enum(int sock,
303 int session_objd, /* session descriptor */
304 const char *enum_name, /* enum name (input) */
305 size_t nr_entries, /* entries */
306 const struct lttng_ust_enum_entry * const *entries,
307 uint64_t *id) /* enum id (output) */
308 __attribute__((visibility("hidden")));
309
310/*
311 * Returns 0 on success, negative error value on error.
312 * Returns -EPIPE or -ECONNRESET if other end has hung up.
313 */
314int ustcomm_register_channel(int sock,
315 struct lttng_ust_session *session,
316 int session_objd, /* session descriptor */
317 int channel_objd, /* channel descriptor */
318 size_t nr_ctx_fields,
319 struct lttng_ust_ctx_field *ctx_fields,
320 uint32_t *chan_id, /* channel id (output) */
321 int *header_type) /* header type (output) */
322 __attribute__((visibility("hidden")));
323
324int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
325 __attribute__((visibility("hidden")));
326
327int ustcomm_setsockopt_snd_timeout(int sock, unsigned int msec)
328 __attribute__((visibility("hidden")));
329
330#endif /* _UST_COMMON_UST_COMM_H */
This page took 0.03452 seconds and 4 git commands to generate.