Import kernel control interface
[lttng-tools.git] / liblttsessiondcomm / liblttsessiondcomm.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Julien Desfossez <julien.desfossez@polymtl.ca>
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
27#include "lttng-share.h"
28
29#define LTTNG_RUNDIR "/var/run/lttng"
30
31/* Default unix socket path */
32#define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK LTTNG_RUNDIR "/client-ltt-sessiond"
33#define DEFAULT_GLOBAL_APPS_UNIX_SOCK LTTNG_RUNDIR "/apps-ltt-sessiond"
34#define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond"
35#define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond"
36
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
42/* Queue size of listen(2) */
43#define MAX_LISTEN 10
44
45/* Get the error code index from 0 since
46 * LTTCOMM_OK start at 1000
47 */
48#define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
49
50enum lttcomm_sessiond_command {
51 KERNEL_CREATE_CHANNEL,
52 KERNEL_CREATE_SESSION,
53 KERNEL_DISABLE_EVENT,
54 KERNEL_ENABLE_EVENT,
55 KERNEL_START_TRACE,
56 KERNEL_STOP_TRACE,
57 LTTNG_CREATE_SESSION,
58 LTTNG_DESTROY_SESSION,
59 LTTNG_FORCE_SUBBUF_SWITCH,
60 LTTNG_GET_ALL_SESSION,
61 LTTNG_GET_SOCK_PATH,
62 LTTNG_GET_SUBBUF_NUM_SIZE,
63 LTTNG_LIST_MARKERS,
64 LTTNG_LIST_SESSIONS,
65 LTTNG_LIST_TRACES,
66 LTTNG_LIST_TRACE_EVENTS,
67 LTTNG_SETUP_TRACE,
68 LTTNG_SET_SOCK_PATH,
69 LTTNG_SET_SUBBUF_NUM,
70 LTTNG_SET_SUBBUF_SIZE,
71 UST_ALLOC_TRACE,
72 UST_CREATE_TRACE,
73 UST_DESTROY_TRACE,
74 UST_DISABLE_MARKER,
75 UST_ENABLE_MARKER,
76 UST_LIST_APPS,
77 UST_START_TRACE,
78 UST_STOP_TRACE,
79};
80
81/*
82 * lttcomm error code.
83 */
84enum lttcomm_return_code {
85 LTTCOMM_OK = 1000, /* Ok */
86 LTTCOMM_ERR, /* Unknown Error */
87 LTTCOMM_UND, /* Undefine command */
88 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
89 LTTCOMM_NO_SESSION, /* No session found */
90 LTTCOMM_CREATE_FAIL, /* Create trace fail */
91 LTTCOMM_SESSION_FAIL, /* Create session fail */
92 LTTCOMM_START_FAIL, /* Start tracing fail */
93 LTTCOMM_STOP_FAIL, /* Stop tracing fail */
94 LTTCOMM_LIST_FAIL, /* Listing apps fail */
95 LTTCOMM_NO_APPS, /* No traceable application */
96 LTTCOMM_NO_SESS, /* No sessions available */
97 LTTCOMM_NO_TRACE, /* No trace exist */
98 LTTCOMM_FATAL, /* Session daemon had a fatal error */
99 LTTCOMM_NO_TRACEABLE, /* Error for non traceable app */
100 LTTCOMM_SELECT_SESS, /* Must select a session */
101 LTTCOMM_EXIST_SESS, /* Session name already exist */
102 LTTCOMM_NR, /* Last element */
103 KCONSUMERD_COMMAND_SOCK_READY, /* when kconsumerd command socket ready */
104 KCONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */
105 KCONSUMERD_ERROR_RECV_FD, /* error on receiving fds */
106 KCONSUMERD_POLL_ERROR, /* Error in polling thread in kconsumerd */
107 KCONSUMERD_POLL_NVAL, /* Poll on closed fd */
108 KCONSUMERD_POLL_HUP, /* All fds have hungup */
109 KCONSUMERD_EXIT_SUCCESS, /* kconsumerd exiting normally */
110 KCONSUMERD_EXIT_FAILURE, /* kconsumerd exiting on error */
111 KCONSUMERD_OUTFD_ERROR, /* error opening the tracefile */
112};
113
114/* commands for kconsumerd */
115enum lttcomm_consumerd_command {
116 LTTCOMM_ADD_STREAM = 1100,
117 LTTCOMM_UPDATE_STREAM, /* pause, delete, start depending on fd state */
118 LTTCOMM_STOP, /* delete all */
119};
120
121/* state of each fd in consumerd */
122enum lttcomm_kconsumerd_fd_state {
123 ACTIVE_FD,
124 PAUSE_FD,
125 DELETE_FD,
126};
127
128/*
129 * Data structure received from lttng client to session daemon.
130 */
131struct lttcomm_session_msg {
132 u32 cmd_type; /* enum lttcomm_sessiond_command */
133 uuid_t session_uuid;
134 char trace_name[NAME_MAX];
135 char session_name[NAME_MAX];
136 u32 pid; /* pid_t */
137 union {
138 struct {
139 int auto_session;
140 } create_session;
141 /* Marker data */
142 struct {
143 char event_name[NAME_MAX];
144 } event;
145 /* Create channel kernel */
146 struct {
147 int overwrite;
148 u64 subbuf_size;
149 u64 num_subbuf;
150 unsigned int switch_timer_interval;
151 unsigned int read_timer_interval;
152 } create_channel;
153 } u;
154};
155
156/*
157 * Data structure for the response from sessiond to the lttng client.
158 */
159struct lttcomm_lttng_msg {
160 u32 cmd_type; /* enum lttcomm_sessiond_command */
161 u32 ret_code; /* enum lttcomm_return_code */
162 u32 pid; /* pid_t */
163 u32 trace_name_offset;
164 u32 data_size;
165 uuid_t session_uuid;
166 /* Contains: trace_name + data */
167 char payload[];
168};
169
170/*
171 * Data structures for the kconsumerd communications
172 *
173 * The header structure is sent to the kconsumerd daemon to inform
174 * how many lttcomm_kconsumerd_msg it is about to receive
175 */
176struct lttcomm_kconsumerd_header {
177 u32 payload_size;
178 u32 cmd_type; /* enum lttcomm_consumerd_command */
179 u32 ret_code; /* enum lttcomm_return_code */
180};
181
182/* lttcomm_kconsumerd_msg represents a file descriptor to consume the
183 * data and a path name to write it
184 */
185struct lttcomm_kconsumerd_msg {
186 char path_name[PATH_MAX];
187 int fd;
188 u32 state; /* enum lttcomm_kconsumerd_fd_state */
189 unsigned long max_sb_size; /* the subbuffer size for this channel */
190};
191
192extern int lttcomm_create_unix_sock(const char *pathname);
193extern int lttcomm_connect_unix_sock(const char *pathname);
194extern int lttcomm_accept_unix_sock(int sock);
195extern int lttcomm_listen_unix_sock(int sock);
196extern int lttcomm_close_unix_sock(int sock);
197extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
198extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
199extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
200
201#endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.023125 seconds and 4 git commands to generate.