Fix lttng bug having the wrong sessiond path
[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 {
fac6795d
DG
51 LTTNG_CREATE_SESSION,
52 LTTNG_DESTROY_SESSION,
53 LTTNG_FORCE_SUBBUF_SWITCH,
54 LTTNG_GET_ALL_SESSION,
55 LTTNG_GET_SOCK_PATH,
56 LTTNG_GET_SUBBUF_NUM_SIZE,
57 LTTNG_LIST_MARKERS,
58 LTTNG_LIST_SESSIONS,
1657e9bb 59 LTTNG_LIST_TRACES,
fac6795d
DG
60 LTTNG_LIST_TRACE_EVENTS,
61 LTTNG_SETUP_TRACE,
62 LTTNG_SET_SOCK_PATH,
63 LTTNG_SET_SUBBUF_NUM,
64 LTTNG_SET_SUBBUF_SIZE,
65 UST_ALLOC_TRACE,
66 UST_CREATE_TRACE,
67 UST_DESTROY_TRACE,
68 UST_DISABLE_MARKER,
69 UST_ENABLE_MARKER,
70 UST_LIST_APPS,
71 UST_START_TRACE,
72 UST_STOP_TRACE,
73};
74
75/*
76 * lttcomm error code.
77 */
78enum lttcomm_return_code {
79 LTTCOMM_OK = 1000, /* Ok */
80 LTTCOMM_ERR, /* Unknown Error */
81 LTTCOMM_UND, /* Undefine command */
82 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
83 LTTCOMM_NO_SESSION, /* No session found */
84 LTTCOMM_CREATE_FAIL, /* Create trace fail */
85 LTTCOMM_SESSION_FAIL, /* Create session fail */
86 LTTCOMM_START_FAIL, /* Start tracing fail */
520ff687 87 LTTCOMM_STOP_FAIL, /* Stop tracing fail */
fac6795d 88 LTTCOMM_LIST_FAIL, /* Listing apps fail */
e065084a 89 LTTCOMM_NO_APPS, /* No traceable application */
57167058 90 LTTCOMM_NO_SESS, /* No sessions available */
ce3d728c 91 LTTCOMM_NO_TRACE, /* No trace exist */
ca95a216 92 LTTCOMM_FATAL, /* Session daemon had a fatal error */
379473d2
DG
93 LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */
94 LTTCOMM_SELECT_SESS, /* Must select a session */
27673bb6 95 LTTCOMM_EXIST_SESS, /* Session name already exist */
fac6795d
DG
96 LTTCOMM_NR, /* Last element */
97};
98
6e3805e2
DG
99/* commands for kconsumerd */
100enum lttcomm_consumerd_command {
101 LTTCOMM_ADD_STREAM = 1100,
102 LTTCOMM_UPDATE_STREAM, /* pause, delete, start depending on fd state */
103 LTTCOMM_STOP, /* delete all */
104};
105
106/* state of each fd in consumerd */
107enum lttcomm_kconsumerd_fd_state {
108 ACTIVE_FD,
109 PAUSE_FD,
110 DELETE_FD,
111};
112
fac6795d 113/*
9bda164d 114 * Data structure received from lttng client to session daemon.
fac6795d
DG
115 */
116struct lttcomm_session_msg {
9bda164d 117 u32 cmd_type; /* enum lttcomm_sessiond_command */
5461b305 118 uuid_t session_uuid;
fac6795d
DG
119 char trace_name[NAME_MAX];
120 char session_name[NAME_MAX];
9bda164d 121 u32 pid; /* pid_t */
fac6795d
DG
122 union {
123 struct {
124 int auto_session;
125 } create_session;
126 /* Marker data */
127 struct {
128 char channel[NAME_MAX];
129 char marker[NAME_MAX];
130 } marker;
131 /* SET_SOCK_PATH */
132 struct {
133 char sock_path[PATH_MAX];
134 } sock_path;
135 /* SET_SUBBUF_NUM */
136 struct {
137 unsigned int subbuf_num;
138 char channel[NAME_MAX];
139 } subbuf_num;
140 /* SET_SUBBUF_SIZE */
141 struct {
142 unsigned int subbuf_size;
143 char channel[NAME_MAX];
144 } subbuf_size;
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 */
6e3805e2
DG
181};
182
fac6795d
DG
183extern int lttcomm_create_unix_sock(const char *pathname);
184extern int lttcomm_connect_unix_sock(const char *pathname);
185extern int lttcomm_accept_unix_sock(int sock);
186extern int lttcomm_listen_unix_sock(int sock);
87378cf5 187extern int lttcomm_close_unix_sock(int sock);
fac6795d
DG
188extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
189extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
190extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
191
192#endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.048699 seconds and 4 git commands to generate.