1 #ifndef LTTNG_VIEWER_ABI_H
2 #define LTTNG_VIEWER_ABI_H
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * David Goulet <dgoulet@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include "compat/limits.h"
31 #define LTTNG_VIEWER_PATH_MAX 4096
32 #define LTTNG_VIEWER_NAME_MAX 255
33 #define LTTNG_VIEWER_HOST_NAME_MAX 64
35 /* Flags in reply to get_next_index and get_packet. */
37 /* New metadata is required to read this packet. */
38 LTTNG_VIEWER_FLAG_NEW_METADATA
= (1 << 0),
39 /* New stream got added to the trace. */
40 LTTNG_VIEWER_FLAG_NEW_STREAM
= (1 << 1),
43 enum lttng_viewer_command
{
44 LTTNG_VIEWER_CONNECT
= 1,
45 LTTNG_VIEWER_LIST_SESSIONS
= 2,
46 LTTNG_VIEWER_ATTACH_SESSION
= 3,
47 LTTNG_VIEWER_GET_NEXT_INDEX
= 4,
48 LTTNG_VIEWER_GET_PACKET
= 5,
49 LTTNG_VIEWER_GET_METADATA
= 6,
50 LTTNG_VIEWER_GET_NEW_STREAMS
= 7,
51 LTTNG_VIEWER_CREATE_SESSION
= 8,
52 LTTNG_VIEWER_DETACH_SESSION
= 9,
55 enum lttng_viewer_attach_return_code
{
56 LTTNG_VIEWER_ATTACH_OK
= 1, /* The attach command succeeded. */
57 LTTNG_VIEWER_ATTACH_ALREADY
= 2, /* A viewer is already attached. */
58 LTTNG_VIEWER_ATTACH_UNK
= 3, /* The session ID is unknown. */
59 LTTNG_VIEWER_ATTACH_NOT_LIVE
= 4, /* The session is not live. */
60 LTTNG_VIEWER_ATTACH_SEEK_ERR
= 5, /* Seek error. */
61 LTTNG_VIEWER_ATTACH_NO_SESSION
= 6, /* No viewer session created. */
64 enum lttng_viewer_detach_session_return_code
{
65 LTTNG_VIEWER_DETACH_SESSION_OK
= 1,
66 LTTNG_VIEWER_DETACH_SESSION_UNK
= 2,
67 LTTNG_VIEWER_DETACH_SESSION_ERR
= 3,
70 enum lttng_viewer_next_index_return_code
{
71 LTTNG_VIEWER_INDEX_OK
= 1, /* Index is available. */
72 LTTNG_VIEWER_INDEX_RETRY
= 2, /* Index not yet available. */
73 LTTNG_VIEWER_INDEX_HUP
= 3, /* Index closed (trace destroyed). */
74 LTTNG_VIEWER_INDEX_ERR
= 4, /* Unknow error. */
75 LTTNG_VIEWER_INDEX_INACTIVE
= 5, /* Inactive stream beacon. */
76 LTTNG_VIEWER_INDEX_EOF
= 6, /* End of index file. */
79 enum lttng_viewer_get_packet_return_code
{
80 LTTNG_VIEWER_GET_PACKET_OK
= 1,
81 LTTNG_VIEWER_GET_PACKET_RETRY
= 2,
82 LTTNG_VIEWER_GET_PACKET_ERR
= 3,
83 LTTNG_VIEWER_GET_PACKET_EOF
= 4,
86 enum lttng_viewer_get_metadata_return_code
{
87 LTTNG_VIEWER_METADATA_OK
= 1,
88 LTTNG_VIEWER_NO_NEW_METADATA
= 2,
89 LTTNG_VIEWER_METADATA_ERR
= 3,
92 enum lttng_viewer_connection_type
{
93 LTTNG_VIEWER_CLIENT_COMMAND
= 1,
94 LTTNG_VIEWER_CLIENT_MESSAGE
= 2,
97 enum lttng_viewer_seek
{
98 /* Receive the trace packets from the beginning. */
99 LTTNG_VIEWER_SEEK_BEGINNING
= 1,
100 /* Receive the trace packets from now. */
101 LTTNG_VIEWER_SEEK_LAST
= 2,
104 enum lttng_viewer_new_streams_return_code
{
105 LTTNG_VIEWER_NEW_STREAMS_OK
= 1, /* If new streams are being sent. */
106 LTTNG_VIEWER_NEW_STREAMS_NO_NEW
= 2, /* If no new streams are available. */
107 LTTNG_VIEWER_NEW_STREAMS_ERR
= 3, /* Error. */
108 LTTNG_VIEWER_NEW_STREAMS_HUP
= 4, /* Session closed. */
111 enum lttng_viewer_create_session_return_code
{
112 LTTNG_VIEWER_CREATE_SESSION_OK
= 1,
113 LTTNG_VIEWER_CREATE_SESSION_ERR
= 2,
116 struct lttng_viewer_session
{
121 char hostname
[LTTNG_VIEWER_HOST_NAME_MAX
];
122 char session_name
[LTTNG_VIEWER_NAME_MAX
];
123 } __attribute__((__packed__
));
125 struct lttng_viewer_stream
{
127 uint64_t ctf_trace_id
;
128 uint32_t metadata_flag
;
129 char path_name
[LTTNG_VIEWER_PATH_MAX
];
130 char channel_name
[LTTNG_VIEWER_NAME_MAX
];
131 } __attribute__((__packed__
));
133 struct lttng_viewer_cmd
{
134 uint64_t data_size
; /* data size following this header */
135 uint32_t cmd
; /* enum lttcomm_relayd_command */
136 uint32_t cmd_version
; /* command version */
137 } __attribute__((__packed__
));
140 * LTTNG_VIEWER_CONNECT payload.
142 struct lttng_viewer_connect
{
143 /* session ID assigned by the relay for command connections */
144 uint64_t viewer_session_id
;
147 uint32_t type
; /* enum lttng_viewer_connection_type */
148 } __attribute__((__packed__
));
151 * LTTNG_VIEWER_LIST_SESSIONS payload.
153 struct lttng_viewer_list_sessions
{
154 uint32_t sessions_count
;
155 char session_list
[]; /* struct lttng_viewer_session */
156 } __attribute__((__packed__
));
159 * LTTNG_VIEWER_ATTACH_SESSION payload.
161 struct lttng_viewer_attach_session_request
{
163 uint64_t offset
; /* unused for now */
164 uint32_t seek
; /* enum lttng_viewer_seek */
165 } __attribute__((__packed__
));
167 struct lttng_viewer_attach_session_response
{
168 /* enum lttng_viewer_attach_return_code */
170 uint32_t streams_count
;
171 /* struct lttng_viewer_stream */
173 } __attribute__((__packed__
));
176 * LTTNG_VIEWER_GET_NEXT_INDEX payload.
178 struct lttng_viewer_get_next_index
{
180 } __attribute__ ((__packed__
));
182 struct lttng_viewer_index
{
184 uint64_t packet_size
;
185 uint64_t content_size
;
186 uint64_t timestamp_begin
;
187 uint64_t timestamp_end
;
188 uint64_t events_discarded
;
190 uint32_t status
; /* enum lttng_viewer_next_index_return_code */
191 uint32_t flags
; /* LTTNG_VIEWER_FLAG_* */
192 } __attribute__ ((__packed__
));
195 * LTTNG_VIEWER_GET_PACKET payload.
197 struct lttng_viewer_get_packet
{
201 } __attribute__((__packed__
));
203 struct lttng_viewer_trace_packet
{
204 uint32_t status
; /* enum lttng_viewer_get_packet_return_code */
206 uint32_t flags
; /* LTTNG_VIEWER_FLAG_* */
208 } __attribute__((__packed__
));
211 * LTTNG_VIEWER_GET_METADATA payload.
213 struct lttng_viewer_get_metadata
{
215 } __attribute__((__packed__
));
217 struct lttng_viewer_metadata_packet
{
219 uint32_t status
; /* enum lttng_viewer_get_metadata_return_code */
221 } __attribute__((__packed__
));
224 * LTTNG_VIEWER_GET_NEW_STREAMS payload.
226 struct lttng_viewer_new_streams_request
{
228 } __attribute__((__packed__
));
230 struct lttng_viewer_new_streams_response
{
231 /* enum lttng_viewer_new_streams_return_code */
233 uint32_t streams_count
;
234 /* struct lttng_viewer_stream */
236 } __attribute__((__packed__
));
238 struct lttng_viewer_create_session_response
{
239 /* enum lttng_viewer_create_session_return_code */
241 } __attribute__((__packed__
));
244 * LTTNG_VIEWER_DETACH_SESSION payload.
246 struct lttng_viewer_detach_session_request
{
248 } __attribute__((__packed__
));
250 struct lttng_viewer_detach_session_response
{
251 /* enum lttng_viewer_detach_session_return_code */
253 } __attribute__((__packed__
));
255 #endif /* LTTNG_VIEWER_ABI_H */