Add parameters name to the function prototype
[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
d6f42150
DG
27#define LTTNG_RUNDIR "/var/run/lttng"
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
d6f42150
DG
35/* Kernel consumer path */
36#define KCONSUMERD_PATH LTTNG_RUNDIR "/kconsumerd"
37#define KCONSUMERD_CMD_SOCK_PATH KCONSUMERD_PATH "/command"
38#define KCONSUMERD_ERR_SOCK_PATH KCONSUMERD_PATH "/error"
39
fac6795d
DG
40/* Queue size of listen(2) */
41#define MAX_LISTEN 10
42
fac6795d
DG
43/* Get the error code index from 0 since
44 * LTTCOMM_OK start at 1000
45 */
686204ab 46#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
fac6795d 47
6abb15de 48enum lttcomm_sessiond_command {
fac6795d
DG
49 LTTNG_CREATE_SESSION,
50 LTTNG_DESTROY_SESSION,
51 LTTNG_FORCE_SUBBUF_SWITCH,
52 LTTNG_GET_ALL_SESSION,
53 LTTNG_GET_SOCK_PATH,
54 LTTNG_GET_SUBBUF_NUM_SIZE,
55 LTTNG_LIST_MARKERS,
56 LTTNG_LIST_SESSIONS,
1657e9bb 57 LTTNG_LIST_TRACES,
fac6795d
DG
58 LTTNG_LIST_TRACE_EVENTS,
59 LTTNG_SETUP_TRACE,
60 LTTNG_SET_SOCK_PATH,
61 LTTNG_SET_SUBBUF_NUM,
62 LTTNG_SET_SUBBUF_SIZE,
63 UST_ALLOC_TRACE,
64 UST_CREATE_TRACE,
65 UST_DESTROY_TRACE,
66 UST_DISABLE_MARKER,
67 UST_ENABLE_MARKER,
68 UST_LIST_APPS,
69 UST_START_TRACE,
70 UST_STOP_TRACE,
71};
72
73/*
74 * lttcomm error code.
75 */
76enum lttcomm_return_code {
77 LTTCOMM_OK = 1000, /* Ok */
78 LTTCOMM_ERR, /* Unknown Error */
79 LTTCOMM_UND, /* Undefine command */
80 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
81 LTTCOMM_NO_SESSION, /* No session found */
82 LTTCOMM_CREATE_FAIL, /* Create trace fail */
83 LTTCOMM_SESSION_FAIL, /* Create session fail */
84 LTTCOMM_START_FAIL, /* Start tracing fail */
520ff687 85 LTTCOMM_STOP_FAIL, /* Stop tracing fail */
fac6795d 86 LTTCOMM_LIST_FAIL, /* Listing apps fail */
e065084a 87 LTTCOMM_NO_APPS, /* No traceable application */
57167058 88 LTTCOMM_NO_SESS, /* No sessions available */
ce3d728c 89 LTTCOMM_NO_TRACE, /* No trace exist */
ca95a216 90 LTTCOMM_FATAL, /* Session daemon had a fatal error */
379473d2
DG
91 LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */
92 LTTCOMM_SELECT_SESS, /* Must select a session */
27673bb6 93 LTTCOMM_EXIST_SESS, /* Session name already exist */
fac6795d
DG
94 LTTCOMM_NR, /* Last element */
95};
96
6e3805e2
DG
97/* commands for kconsumerd */
98enum lttcomm_consumerd_command {
99 LTTCOMM_ADD_STREAM = 1100,
100 LTTCOMM_UPDATE_STREAM, /* pause, delete, start depending on fd state */
101 LTTCOMM_STOP, /* delete all */
102};
103
104/* state of each fd in consumerd */
105enum lttcomm_kconsumerd_fd_state {
106 ACTIVE_FD,
107 PAUSE_FD,
108 DELETE_FD,
109};
110
fac6795d
DG
111/*
112 * Data structure for ltt-session received message
113 */
114struct lttcomm_session_msg {
115 /* Common data to almost all command */
6abb15de 116 enum lttcomm_sessiond_command cmd_type;
8028d920 117 uuid_t session_id;
fac6795d
DG
118 char trace_name[NAME_MAX];
119 char session_name[NAME_MAX];
120 pid_t pid;
121 union {
122 struct {
123 int auto_session;
124 } create_session;
125 /* Marker data */
126 struct {
127 char channel[NAME_MAX];
128 char marker[NAME_MAX];
129 } marker;
130 /* SET_SOCK_PATH */
131 struct {
132 char sock_path[PATH_MAX];
133 } sock_path;
134 /* SET_SUBBUF_NUM */
135 struct {
136 unsigned int subbuf_num;
137 char channel[NAME_MAX];
138 } subbuf_num;
139 /* SET_SUBBUF_SIZE */
140 struct {
141 unsigned int subbuf_size;
142 char channel[NAME_MAX];
143 } subbuf_size;
144 } u;
145};
146
147/*
ca95a216
DG
148 * Data structure for the lttng client response.
149 *
150 * This data structure is the control struct use in
151 * the header of the transmission. NEVER put variable
152 * size data in here.
fac6795d 153 */
6abb15de
DG
154struct lttcomm_lttng_header {
155 enum lttcomm_sessiond_command cmd_type;
fac6795d 156 enum lttcomm_return_code ret_code;
8028d920 157 uuid_t session_id;
fac6795d
DG
158 pid_t pid;
159 char trace_name[NAME_MAX];
6abb15de 160 unsigned int payload_size;
fac6795d
DG
161};
162
6e3805e2
DG
163/*
164 * Data structures for the kconsumerd communications
165 *
166 * The header structure is sent to the kconsumerd daemon to inform
167 * how many lttcomm_kconsumerd_msg it is about to receive
168 */
169struct lttcomm_kconsumerd_header {
170 unsigned int payload_size;
171 enum lttcomm_consumerd_command cmd_type;
172 enum lttcomm_return_code ret_code;
173};
174
175/* lttcomm_kconsumerd_msg represents a file descriptor to consume the
176 * data and a path name to write it
177 */
178struct lttcomm_kconsumerd_msg {
179 char path_name[PATH_MAX];
180 int fd;
181 enum lttcomm_kconsumerd_fd_state state;
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);
fac6795d
DG
189extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
190extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
191extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
192
193#endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.04568 seconds and 4 git commands to generate.