Add listing session option
[lttng-tools.git] / liblttsessiondcomm / liblttsessiondcomm.h
1 /* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 */
18
19 #ifndef _LIBLTTSESSIONDCOMM_H
20 #define _LIBLTTSESSIONDCOMM_H
21
22 #include <limits.h>
23 #include <uuid/uuid.h>
24
25 /* Default unix socket path */
26 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK "/tmp/client-ltt-sessiond"
27 #define DEFAULT_GLOBAL_APPS_UNIX_SOCK "/tmp/apps-ltt-sessiond"
28 #define DEFAULT_HOME_APPS_UNIX_SOCK "%s/.apps-ltt-sessiond"
29 #define DEFAULT_HOME_CLIENT_UNIX_SOCK "%s/.client-ltt-sessiond"
30
31 /* Queue size of listen(2) */
32 #define MAX_LISTEN 10
33
34 /* Get the error code index from 0 since
35 * LTTCOMM_OK start at 1000
36 */
37 #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
38
39 enum lttcomm_command_type {
40 LTTNG_CREATE_SESSION,
41 LTTNG_DESTROY_SESSION,
42 LTTNG_FORCE_SUBBUF_SWITCH,
43 LTTNG_GET_ALL_SESSION,
44 LTTNG_GET_SOCK_PATH,
45 LTTNG_GET_SUBBUF_NUM_SIZE,
46 LTTNG_LIST_MARKERS,
47 LTTNG_LIST_SESSIONS,
48 LTTNG_LIST_TRACE_EVENTS,
49 LTTNG_SETUP_TRACE,
50 LTTNG_SET_SOCK_PATH,
51 LTTNG_SET_SUBBUF_NUM,
52 LTTNG_SET_SUBBUF_SIZE,
53 UST_ALLOC_TRACE,
54 UST_CREATE_TRACE,
55 UST_DESTROY_TRACE,
56 UST_DISABLE_MARKER,
57 UST_ENABLE_MARKER,
58 UST_LIST_APPS,
59 UST_START_TRACE,
60 UST_STOP_TRACE,
61 };
62
63 /*
64 * lttcomm error code.
65 */
66 enum lttcomm_return_code {
67 LTTCOMM_OK = 1000, /* Ok */
68 LTTCOMM_ERR, /* Unknown Error */
69 LTTCOMM_UND, /* Undefine command */
70 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
71 LTTCOMM_NO_SESSION, /* No session found */
72 LTTCOMM_CREATE_FAIL, /* Create trace fail */
73 LTTCOMM_SESSION_FAIL, /* Create session fail */
74 LTTCOMM_START_FAIL, /* Start tracing fail */
75 LTTCOMM_LIST_FAIL, /* Listing apps fail */
76 LTTCOMM_NO_APPS, /* No traceable application */
77 LTTCOMM_NO_SESS, /* No sessions available */
78 LTTCOMM_NR, /* Last element */
79 };
80
81 /*
82 * Data structure for ltt-session received message
83 */
84 struct lttcomm_session_msg {
85 /* Common data to almost all command */
86 enum lttcomm_command_type cmd_type;
87 uuid_t session_id;
88 char trace_name[NAME_MAX];
89 char session_name[NAME_MAX];
90 pid_t pid;
91 union {
92 struct {
93 int auto_session;
94 } create_session;
95 /* Marker data */
96 struct {
97 char channel[NAME_MAX];
98 char marker[NAME_MAX];
99 } marker;
100 /* SET_SOCK_PATH */
101 struct {
102 char sock_path[PATH_MAX];
103 } sock_path;
104 /* SET_SUBBUF_NUM */
105 struct {
106 unsigned int subbuf_num;
107 char channel[NAME_MAX];
108 } subbuf_num;
109 /* SET_SUBBUF_SIZE */
110 struct {
111 unsigned int subbuf_size;
112 char channel[NAME_MAX];
113 } subbuf_size;
114 } u;
115 };
116
117 /*
118 * Data structure for the lttng client response
119 */
120 struct lttcomm_lttng_msg {
121 enum lttcomm_command_type cmd_type;
122 enum lttcomm_return_code ret_code;
123 uuid_t session_id;
124 pid_t pid;
125 char trace_name[NAME_MAX];
126 /* This flag indicates how many packet are in
127 * the transmission. Ex: If list apps is requested,
128 * and there is 4 pids registered, num_pckt will be 4
129 */
130 unsigned int num_pckt;
131 union {
132 /* UST_LIST_APPS */
133 struct {
134 pid_t pid;
135 } list_apps;
136 /* LTTNG_LIST_SESSIONS */
137 struct {
138 char name[NAME_MAX];
139 char uuid[37]; /* See libuuid not exported size UUID_STR_LEN */
140 } list_sessions;
141 } u;
142 };
143
144 extern int lttcomm_create_unix_sock(const char *pathname);
145 extern int lttcomm_connect_unix_sock(const char *pathname);
146 extern int lttcomm_accept_unix_sock(int sock);
147 extern int lttcomm_listen_unix_sock(int sock);
148 extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
149 extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
150 extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
151
152 #endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.035419 seconds and 5 git commands to generate.