Remove useless zero initialization
[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
fac6795d 29/* Default unix socket path */
d6f42150
DG
30#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-ltt-sessiond"
31#define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-ltt-sessiond"
fac6795d
DG
32#define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond"
33#define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond"
34
35/* Queue size of listen(2) */
36#define MAX_LISTEN 10
37
fac6795d
DG
38/* Get the error code index from 0 since
39 * LTTCOMM_OK start at 1000
40 */
686204ab 41#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
fac6795d 42
6abb15de 43enum lttcomm_sessiond_command {
1df4dedd
DG
44 KERNEL_CREATE_CHANNEL,
45 KERNEL_CREATE_SESSION,
8c0faa1d 46 KERNEL_CREATE_STREAM,
1df4dedd
DG
47 KERNEL_DISABLE_EVENT,
48 KERNEL_ENABLE_EVENT,
aaf26714 49 KERNEL_OPEN_METADATA,
1df4dedd
DG
50 KERNEL_START_TRACE,
51 KERNEL_STOP_TRACE,
fac6795d
DG
52 LTTNG_CREATE_SESSION,
53 LTTNG_DESTROY_SESSION,
54 LTTNG_FORCE_SUBBUF_SWITCH,
55 LTTNG_GET_ALL_SESSION,
56 LTTNG_GET_SOCK_PATH,
57 LTTNG_GET_SUBBUF_NUM_SIZE,
58 LTTNG_LIST_MARKERS,
59 LTTNG_LIST_SESSIONS,
1657e9bb 60 LTTNG_LIST_TRACES,
fac6795d
DG
61 LTTNG_LIST_TRACE_EVENTS,
62 LTTNG_SETUP_TRACE,
63 LTTNG_SET_SOCK_PATH,
64 LTTNG_SET_SUBBUF_NUM,
65 LTTNG_SET_SUBBUF_SIZE,
66 UST_ALLOC_TRACE,
67 UST_CREATE_TRACE,
68 UST_DESTROY_TRACE,
69 UST_DISABLE_MARKER,
70 UST_ENABLE_MARKER,
71 UST_LIST_APPS,
72 UST_START_TRACE,
73 UST_STOP_TRACE,
74};
75
76/*
77 * lttcomm error code.
78 */
79enum lttcomm_return_code {
20fe2104
DG
80 LTTCOMM_OK = 1000, /* Ok */
81 LTTCOMM_ERR, /* Unknown Error */
82 LTTCOMM_UND, /* Undefine command */
83 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
84 LTTCOMM_NO_SESSION, /* No session found */
85 LTTCOMM_CREATE_FAIL, /* Create trace fail */
86 LTTCOMM_SESSION_FAIL, /* Create session fail */
87 LTTCOMM_START_FAIL, /* Start tracing fail */
88 LTTCOMM_STOP_FAIL, /* Stop tracing fail */
89 LTTCOMM_LIST_FAIL, /* Listing apps fail */
90 LTTCOMM_NO_APPS, /* No traceable application */
91 LTTCOMM_NO_SESS, /* No sessions available */
92 LTTCOMM_NO_TRACE, /* No trace exist */
93 LTTCOMM_FATAL, /* Session daemon had a fatal error */
94 LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */
95 LTTCOMM_SELECT_SESS, /* Must select a session */
96 LTTCOMM_EXIST_SESS, /* Session name already exist */
97 LTTCOMM_NO_EVENT, /* No event found */
98 LTTCOMM_KERN_NA, /* Kernel tracer unavalable */
99 LTTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */
100 LTTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */
f34daff7
DG
101 LTTCOMM_KERN_ENABLE_FAIL, /* Kernel enable event failed */
102 LTTCOMM_KERN_DISABLE_FAIL, /* Kernel disable event failed */
aaf26714 103 LTTCOMM_KERN_META_FAIL, /* Kernel open metadata failed */
8c0faa1d
DG
104 LTTCOMM_KERN_START_FAIL, /* Kernel start trace failed */
105 LTTCOMM_KERN_STOP_FAIL, /* Kernel stop trace failed */
106 LTTCOMM_KERN_CONSUMER_FAIL, /* Kernel consumer start failed */
107 LTTCOMM_KERN_STREAM_FAIL, /* Kernel create stream failed */
108 LTTCOMM_KERN_DIR_FAIL, /* Kernel trace directory creation failed */
84291629
DG
109 LTTCOMM_KERN_DIR_EXIST, /* Kernel trace directory exist */
110 LTTCOMM_KERN_NO_SESSION, /* No kernel session found */
d4a1283e 111 KCONSUMERD_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */
20fe2104
DG
112 KCONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */
113 KCONSUMERD_ERROR_RECV_FD, /* error on receiving fds */
114 KCONSUMERD_POLL_ERROR, /* Error in polling thread in kconsumerd */
115 KCONSUMERD_POLL_NVAL, /* Poll on closed fd */
116 KCONSUMERD_POLL_HUP, /* All fds have hungup */
117 KCONSUMERD_EXIT_SUCCESS, /* kconsumerd exiting normally */
118 KCONSUMERD_EXIT_FAILURE, /* kconsumerd exiting on error */
119 KCONSUMERD_OUTFD_ERROR, /* error opening the tracefile */
0632499a
JD
120 KCONSUMERD_SPLICE_EBADF, /* EBADF from splice(2) */
121 KCONSUMERD_SPLICE_EINVAL, /* EINVAL from splice(2) */
122 KCONSUMERD_SPLICE_ENOMEM, /* ENOMEM from splice(2) */
123 KCONSUMERD_SPLICE_ESPIPE, /* ESPIPE from splice(2) */
20fe2104
DG
124 /* MUST be last element */
125 LTTCOMM_NR, /* Last element */
fac6795d
DG
126};
127
128/*
9bda164d 129 * Data structure received from lttng client to session daemon.
fac6795d
DG
130 */
131struct lttcomm_session_msg {
9bda164d 132 u32 cmd_type; /* enum lttcomm_sessiond_command */
5461b305 133 uuid_t session_uuid;
fac6795d
DG
134 char trace_name[NAME_MAX];
135 char session_name[NAME_MAX];
9bda164d 136 u32 pid; /* pid_t */
fac6795d
DG
137 union {
138 struct {
139 int auto_session;
140 } create_session;
141 /* Marker data */
142 struct {
1df4dedd
DG
143 char event_name[NAME_MAX];
144 } event;
fac6795d
DG
145 } u;
146};
147
148/*
5e16da05 149 * Data structure for the response from sessiond to the lttng client.
fac6795d 150 */
5461b305 151struct lttcomm_lttng_msg {
9bda164d
DG
152 u32 cmd_type; /* enum lttcomm_sessiond_command */
153 u32 ret_code; /* enum lttcomm_return_code */
154 u32 pid; /* pid_t */
5461b305
DG
155 u32 trace_name_offset;
156 u32 data_size;
157 uuid_t session_uuid;
158 /* Contains: trace_name + data */
159 char payload[];
fac6795d
DG
160};
161
6e3805e2
DG
162/*
163 * Data structures for the kconsumerd communications
164 *
165 * The header structure is sent to the kconsumerd daemon to inform
166 * how many lttcomm_kconsumerd_msg it is about to receive
167 */
168struct lttcomm_kconsumerd_header {
9bda164d
DG
169 u32 payload_size;
170 u32 cmd_type; /* enum lttcomm_consumerd_command */
171 u32 ret_code; /* enum lttcomm_return_code */
6e3805e2
DG
172};
173
174/* lttcomm_kconsumerd_msg represents a file descriptor to consume the
175 * data and a path name to write it
176 */
177struct lttcomm_kconsumerd_msg {
178 char path_name[PATH_MAX];
179 int fd;
9bda164d 180 u32 state; /* enum lttcomm_kconsumerd_fd_state */
d4a1283e 181 unsigned long max_sb_size; /* the subbuffer size for this channel */
6e3805e2
DG
182};
183
fac6795d
DG
184extern int lttcomm_create_unix_sock(const char *pathname);
185extern int lttcomm_connect_unix_sock(const char *pathname);
186extern int lttcomm_accept_unix_sock(int sock);
187extern int lttcomm_listen_unix_sock(int sock);
87378cf5 188extern int lttcomm_close_unix_sock(int sock);
8c0faa1d 189extern ssize_t lttcomm_send_fds_unix_sock(int sock, void *buf, int *fds, size_t nb_fd, size_t len);
fac6795d
DG
190extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
191extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
192extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
193
194#endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.046422 seconds and 4 git commands to generate.