Add tags from ctags to gitignore
[lttng-tools.git] / liblttsessiondcomm / liblttsessiondcomm.h
CommitLineData
6e3805e2
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Julien Desfossez <julien.desfossez@polymtl.ca>
fac6795d
DG
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20
21#ifndef _LIBLTTSESSIONDCOMM_H
22#define _LIBLTTSESSIONDCOMM_H
23
24#include <limits.h>
25#include <uuid/uuid.h>
26
9bda164d 27#include "lttng-share.h"
5e16da05 28
d6f42150
DG
29#define LTTNG_RUNDIR "/var/run/lttng"
30
fac6795d 31/* Default unix socket path */
d6f42150
DG
32#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-ltt-sessiond"
33#define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-ltt-sessiond"
fac6795d
DG
34#define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond"
35#define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond"
36
d6f42150
DG
37/* Kernel consumer path */
38#define KCONSUMERD_PATH LTTNG_RUNDIR "/kconsumerd"
39#define KCONSUMERD_CMD_SOCK_PATH KCONSUMERD_PATH "/command"
40#define KCONSUMERD_ERR_SOCK_PATH KCONSUMERD_PATH "/error"
41
fac6795d
DG
42/* Queue size of listen(2) */
43#define MAX_LISTEN 10
44
fac6795d
DG
45/* Get the error code index from 0 since
46 * LTTCOMM_OK start at 1000
47 */
686204ab 48#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
fac6795d 49
6abb15de 50enum lttcomm_sessiond_command {
1df4dedd
DG
51 KERNEL_CREATE_CHANNEL,
52 KERNEL_CREATE_SESSION,
53 KERNEL_DISABLE_EVENT,
54 KERNEL_ENABLE_EVENT,
aaf26714 55 KERNEL_OPEN_METADATA,
1df4dedd
DG
56 KERNEL_START_TRACE,
57 KERNEL_STOP_TRACE,
fac6795d
DG
58 LTTNG_CREATE_SESSION,
59 LTTNG_DESTROY_SESSION,
60 LTTNG_FORCE_SUBBUF_SWITCH,
61 LTTNG_GET_ALL_SESSION,
62 LTTNG_GET_SOCK_PATH,
63 LTTNG_GET_SUBBUF_NUM_SIZE,
64 LTTNG_LIST_MARKERS,
65 LTTNG_LIST_SESSIONS,
1657e9bb 66 LTTNG_LIST_TRACES,
fac6795d
DG
67 LTTNG_LIST_TRACE_EVENTS,
68 LTTNG_SETUP_TRACE,
69 LTTNG_SET_SOCK_PATH,
70 LTTNG_SET_SUBBUF_NUM,
71 LTTNG_SET_SUBBUF_SIZE,
72 UST_ALLOC_TRACE,
73 UST_CREATE_TRACE,
74 UST_DESTROY_TRACE,
75 UST_DISABLE_MARKER,
76 UST_ENABLE_MARKER,
77 UST_LIST_APPS,
78 UST_START_TRACE,
79 UST_STOP_TRACE,
80};
81
82/*
83 * lttcomm error code.
84 */
85enum lttcomm_return_code {
20fe2104
DG
86 LTTCOMM_OK = 1000, /* Ok */
87 LTTCOMM_ERR, /* Unknown Error */
88 LTTCOMM_UND, /* Undefine command */
89 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
90 LTTCOMM_NO_SESSION, /* No session found */
91 LTTCOMM_CREATE_FAIL, /* Create trace fail */
92 LTTCOMM_SESSION_FAIL, /* Create session fail */
93 LTTCOMM_START_FAIL, /* Start tracing fail */
94 LTTCOMM_STOP_FAIL, /* Stop tracing fail */
95 LTTCOMM_LIST_FAIL, /* Listing apps fail */
96 LTTCOMM_NO_APPS, /* No traceable application */
97 LTTCOMM_NO_SESS, /* No sessions available */
98 LTTCOMM_NO_TRACE, /* No trace exist */
99 LTTCOMM_FATAL, /* Session daemon had a fatal error */
100 LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */
101 LTTCOMM_SELECT_SESS, /* Must select a session */
102 LTTCOMM_EXIST_SESS, /* Session name already exist */
103 LTTCOMM_NO_EVENT, /* No event found */
104 LTTCOMM_KERN_NA, /* Kernel tracer unavalable */
105 LTTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */
106 LTTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */
f34daff7
DG
107 LTTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */
108 LTTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */
aaf26714 109 LTTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */
d4a1283e 110 KCONSUMERD_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */
20fe2104
DG
111 KCONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */
112 KCONSUMERD_ERROR_RECV_FD, /* error on receiving fds */
113 KCONSUMERD_POLL_ERROR, /* Error in polling thread in kconsumerd */
114 KCONSUMERD_POLL_NVAL, /* Poll on closed fd */
115 KCONSUMERD_POLL_HUP, /* All fds have hungup */
116 KCONSUMERD_EXIT_SUCCESS, /* kconsumerd exiting normally */
117 KCONSUMERD_EXIT_FAILURE, /* kconsumerd exiting on error */
118 KCONSUMERD_OUTFD_ERROR, /* error opening the tracefile */
0632499a
JD
119 KCONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */
120 KCONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */
121 KCONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
122 KCONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
20fe2104
DG
123 /* MUST be last element */
124 LTTCOMM_NR, /* Last element */
fac6795d
DG
125};
126
6e3805e2
DG
127/* commands for kconsumerd */
128enum lttcomm_consumerd_command {
129 LTTCOMM_ADD_STREAM = 1100,
130 LTTCOMM_UPDATE_STREAM, /* pause, delete, start depending on fd state */
131 LTTCOMM_STOP, /* delete all */
132};
133
134/* state of each fd in consumerd */
135enum lttcomm_kconsumerd_fd_state {
136 ACTIVE_FD,
137 PAUSE_FD,
138 DELETE_FD,
139};
140
fac6795d 141/*
9bda164d 142 * Data structure received from lttng client to session daemon.
fac6795d
DG
143 */
144struct lttcomm_session_msg {
9bda164d 145 u32 cmd_type; /* enum lttcomm_sessiond_command */
5461b305 146 uuid_t session_uuid;
fac6795d
DG
147 char trace_name[NAME_MAX];
148 char session_name[NAME_MAX];
9bda164d 149 u32 pid; /* pid_t */
fac6795d
DG
150 union {
151 struct {
152 int auto_session;
153 } create_session;
154 /* Marker data */
155 struct {
1df4dedd
DG
156 char event_name[NAME_MAX];
157 } event;
fac6795d
DG
158 } u;
159};
160
161/*
5e16da05 162 * Data structure for the response from sessiond to the lttng client.
fac6795d 163 */
5461b305 164struct lttcomm_lttng_msg {
9bda164d
DG
165 u32 cmd_type; /* enum lttcomm_sessiond_command */
166 u32 ret_code; /* enum lttcomm_return_code */
167 u32 pid; /* pid_t */
5461b305
DG
168 u32 trace_name_offset;
169 u32 data_size;
170 uuid_t session_uuid;
171 /* Contains: trace_name + data */
172 char payload[];
fac6795d
DG
173};
174
6e3805e2
DG
175/*
176 * Data structures for the kconsumerd communications
177 *
178 * The header structure is sent to the kconsumerd daemon to inform
179 * how many lttcomm_kconsumerd_msg it is about to receive
180 */
181struct lttcomm_kconsumerd_header {
9bda164d
DG
182 u32 payload_size;
183 u32 cmd_type; /* enum lttcomm_consumerd_command */
184 u32 ret_code; /* enum lttcomm_return_code */
6e3805e2
DG
185};
186
187/* lttcomm_kconsumerd_msg represents a file descriptor to consume the
188 * data and a path name to write it
189 */
190struct lttcomm_kconsumerd_msg {
191 char path_name[PATH_MAX];
192 int fd;
9bda164d 193 u32 state; /* enum lttcomm_kconsumerd_fd_state */
d4a1283e 194 unsigned long max_sb_size; /* the subbuffer size for this channel */
6e3805e2
DG
195};
196
fac6795d
DG
197extern int lttcomm_create_unix_sock(const char *pathname);
198extern int lttcomm_connect_unix_sock(const char *pathname);
199extern int lttcomm_accept_unix_sock(int sock);
200extern int lttcomm_listen_unix_sock(int sock);
87378cf5 201extern int lttcomm_close_unix_sock(int sock);
fac6795d
DG
202extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
203extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
204extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
205
206#endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.047238 seconds and 4 git commands to generate.