1 /* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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.
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.
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.
19 #ifndef _LIBLTTSESSIONDCOMM_H
20 #define _LIBLTTSESSIONDCOMM_H
23 #include <uuid/uuid.h>
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"
31 /* Queue size of listen(2) */
34 /* Get the error code index from 0 since
35 * LTTCOMM_OK start at 1000
37 #define LTTCOMM_ERR_INDEX(code) (code - LTTCOMM_OK)
39 enum lttcomm_command_type
{
41 LTTNG_DESTROY_SESSION
,
42 LTTNG_FORCE_SUBBUF_SWITCH
,
43 LTTNG_GET_ALL_SESSION
,
45 LTTNG_GET_SUBBUF_NUM_SIZE
,
48 LTTNG_LIST_TRACE_EVENTS
,
52 LTTNG_SET_SUBBUF_SIZE
,
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_NO_TRACE
, /* No trace exist */
79 LTTCOMM_FATAL
, /* Session daemon had a fatal error */
80 LTTCOMM_NO_TRACEABLE
, /* Error for non traceable app */
81 LTTCOMM_SELECT_SESS
, /* Must select a session */
82 LTTCOMM_EXIST_SESS
, /* Session name already exist */
83 LTTCOMM_NR
, /* Last element */
87 * Data structure for ltt-session received message
89 struct lttcomm_session_msg
{
90 /* Common data to almost all command */
91 enum lttcomm_command_type cmd_type
;
93 char trace_name
[NAME_MAX
];
94 char session_name
[NAME_MAX
];
102 char channel
[NAME_MAX
];
103 char marker
[NAME_MAX
];
107 char sock_path
[PATH_MAX
];
111 unsigned int subbuf_num
;
112 char channel
[NAME_MAX
];
114 /* SET_SUBBUF_SIZE */
116 unsigned int subbuf_size
;
117 char channel
[NAME_MAX
];
123 * Data structure for the lttng client response.
125 * This data structure is the control struct use in
126 * the header of the transmission. NEVER put variable
129 struct lttcomm_lttng_msg
{
130 enum lttcomm_command_type cmd_type
;
131 enum lttcomm_return_code ret_code
;
134 char trace_name
[NAME_MAX
];
135 unsigned int size_payload
;
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 int lttcomm_close_unix_sock(int sock
);
143 extern ssize_t
lttcomm_recv_unix_sock(int sock
, void *buf
, size_t len
);
144 extern ssize_t
lttcomm_send_unix_sock(int sock
, void *buf
, size_t len
);
145 extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code
);
147 #endif /* _LIBLTTSESSIONDCOMM_H */