Initial import
[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 /* Maximum amount of PID the list_apps command
35 * can send back to the lttng client.
36 */
37 #define MAX_APPS_PID 20
38
39 /* Get the error code index from 0 since
40 * LTTCOMM_OK start at 1000
41 */
42 #define LTTCOMM_ERR_INDEX(code) code - LTTCOMM_OK
43
44 enum lttcomm_command_type {
45 LTTNG_CREATE_SESSION,
46 LTTNG_DESTROY_SESSION,
47 LTTNG_FORCE_SUBBUF_SWITCH,
48 LTTNG_GET_ALL_SESSION,
49 LTTNG_GET_SOCK_PATH,
50 LTTNG_GET_SUBBUF_NUM_SIZE,
51 LTTNG_LIST_MARKERS,
52 LTTNG_LIST_SESSIONS,
53 LTTNG_LIST_TRACE_EVENTS,
54 LTTNG_SETUP_TRACE,
55 LTTNG_SET_SOCK_PATH,
56 LTTNG_SET_SUBBUF_NUM,
57 LTTNG_SET_SUBBUF_SIZE,
58 UST_ALLOC_TRACE,
59 UST_CREATE_TRACE,
60 UST_DESTROY_TRACE,
61 UST_DISABLE_MARKER,
62 UST_ENABLE_MARKER,
63 UST_LIST_APPS,
64 UST_START_TRACE,
65 UST_STOP_TRACE,
66 };
67
68 /*
69 * lttcomm error code.
70 */
71 enum lttcomm_return_code {
72 LTTCOMM_OK = 1000, /* Ok */
73 LTTCOMM_ERR, /* Unknown Error */
74 LTTCOMM_UND, /* Undefine command */
75 LTTCOMM_ALLOC_FAIL, /* Trace allocation fail */
76 LTTCOMM_NO_SESSION, /* No session found */
77 LTTCOMM_CREATE_FAIL, /* Create trace fail */
78 LTTCOMM_SESSION_FAIL, /* Create session fail */
79 LTTCOMM_START_FAIL, /* Start tracing fail */
80 LTTCOMM_LIST_FAIL, /* Listing apps fail */
81 LTTCOMM_NR, /* Last element */
82 };
83
84 /*
85 * Data structure for ltt-session received message
86 */
87 struct lttcomm_session_msg {
88 /* Common data to almost all command */
89 enum lttcomm_command_type cmd_type;
90 uuid_t session_id;
91 char trace_name[NAME_MAX];
92 char session_name[NAME_MAX];
93 pid_t pid;
94 union {
95 struct {
96 int auto_session;
97 } create_session;
98 /* Marker data */
99 struct {
100 char channel[NAME_MAX];
101 char marker[NAME_MAX];
102 } marker;
103 /* SET_SOCK_PATH */
104 struct {
105 char sock_path[PATH_MAX];
106 } sock_path;
107 /* SET_SUBBUF_NUM */
108 struct {
109 unsigned int subbuf_num;
110 char channel[NAME_MAX];
111 } subbuf_num;
112 /* SET_SUBBUF_SIZE */
113 struct {
114 unsigned int subbuf_size;
115 char channel[NAME_MAX];
116 } subbuf_size;
117 } u;
118 };
119
120 /*
121 * Data structure for the lttng client response
122 */
123 struct lttcomm_lttng_msg {
124 enum lttcomm_command_type cmd_type;
125 enum lttcomm_return_code ret_code;
126 uuid_t session_id;
127 pid_t pid;
128 char trace_name[NAME_MAX];
129 union {
130 /* UST_LIST_APPS */
131 struct {
132 size_t size;
133 pid_t pids[MAX_APPS_PID];
134 } list_apps;
135 } u;
136 };
137
138 extern int lttcomm_create_unix_sock(const char *pathname);
139 extern int lttcomm_connect_unix_sock(const char *pathname);
140 extern int lttcomm_accept_unix_sock(int sock);
141 extern int lttcomm_listen_unix_sock(int sock);
142 extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
143 extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
144 extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
145
146 #endif /* _LIBLTTSESSIONDCOMM_H */
This page took 0.044223 seconds and 4 git commands to generate.