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
28 #include <babeltrace/compat/limits.h>
30 #define LTTNG_VIEWER_PATH_MAX 4096
31 #define LTTNG_VIEWER_NAME_MAX 255
32 #define LTTNG_VIEWER_HOST_NAME_MAX 64
34 /* Flags in reply to get_next_index and get_packet. */
36 /* New metadata is required to read this packet. */
37 LTTNG_VIEWER_FLAG_NEW_METADATA
= (1 << 0),
38 /* New stream got added to the trace. */
39 LTTNG_VIEWER_FLAG_NEW_STREAM
= (1 << 1),
42 enum lttng_viewer_command
{
43 LTTNG_VIEWER_CONNECT
= 1,
44 LTTNG_VIEWER_LIST_SESSIONS
= 2,
45 LTTNG_VIEWER_ATTACH_SESSION
= 3,
46 LTTNG_VIEWER_GET_NEXT_INDEX
= 4,
47 LTTNG_VIEWER_GET_PACKET
= 5,
48 LTTNG_VIEWER_GET_METADATA
= 6,
49 LTTNG_VIEWER_GET_NEW_STREAMS
= 7,
50 LTTNG_VIEWER_CREATE_SESSION
= 8,
53 enum lttng_viewer_attach_return_code
{
54 LTTNG_VIEWER_ATTACH_OK
= 1, /* The attach command succeeded. */
55 LTTNG_VIEWER_ATTACH_ALREADY
= 2, /* A viewer is already attached. */
56 LTTNG_VIEWER_ATTACH_UNK
= 3, /* The session ID is unknown. */
57 LTTNG_VIEWER_ATTACH_NOT_LIVE
= 4, /* The session is not live. */
58 LTTNG_VIEWER_ATTACH_SEEK_ERR
= 5, /* Seek error. */
59 LTTNG_VIEWER_ATTACH_NO_SESSION
= 6, /* No viewer session created. */
62 enum lttng_viewer_next_index_return_code
{
63 LTTNG_VIEWER_INDEX_OK
= 1, /* Index is available. */
64 LTTNG_VIEWER_INDEX_RETRY
= 2, /* Index not yet available. */
65 LTTNG_VIEWER_INDEX_HUP
= 3, /* Index closed (trace destroyed). */
66 LTTNG_VIEWER_INDEX_ERR
= 4, /* Unknow error. */
67 LTTNG_VIEWER_INDEX_INACTIVE
= 5, /* Inactive stream beacon. */
68 LTTNG_VIEWER_INDEX_EOF
= 6, /* End of index file. */
71 enum lttng_viewer_get_packet_return_code
{
72 LTTNG_VIEWER_GET_PACKET_OK
= 1,
73 LTTNG_VIEWER_GET_PACKET_RETRY
= 2,
74 LTTNG_VIEWER_GET_PACKET_ERR
= 3,
75 LTTNG_VIEWER_GET_PACKET_EOF
= 4,
78 enum lttng_viewer_get_metadata_return_code
{
79 LTTNG_VIEWER_METADATA_OK
= 1,
80 LTTNG_VIEWER_NO_NEW_METADATA
= 2,
81 LTTNG_VIEWER_METADATA_ERR
= 3,
84 enum lttng_viewer_connection_type
{
85 LTTNG_VIEWER_CLIENT_COMMAND
= 1,
86 LTTNG_VIEWER_CLIENT_NOTIFICATION
= 2,
89 enum lttng_viewer_seek
{
90 /* Receive the trace packets from the beginning. */
91 LTTNG_VIEWER_SEEK_BEGINNING
= 1,
92 /* Receive the trace packets from now. */
93 LTTNG_VIEWER_SEEK_LAST
= 2,
96 enum lttng_viewer_new_streams_return_code
{
97 LTTNG_VIEWER_NEW_STREAMS_OK
= 1, /* If new streams are being sent. */
98 LTTNG_VIEWER_NEW_STREAMS_NO_NEW
= 2, /* If no new streams are available. */
99 LTTNG_VIEWER_NEW_STREAMS_ERR
= 3, /* Error. */
100 LTTNG_VIEWER_NEW_STREAMS_HUP
= 4, /* Session closed. */
103 enum lttng_viewer_create_session_return_code
{
104 LTTNG_VIEWER_CREATE_SESSION_OK
= 1,
105 LTTNG_VIEWER_CREATE_SESSION_ERR
= 2,
108 struct lttng_viewer_session
{
113 char hostname
[LTTNG_VIEWER_HOST_NAME_MAX
];
114 char session_name
[LTTNG_VIEWER_NAME_MAX
];
115 } __attribute__((__packed__
));
117 struct lttng_viewer_stream
{
119 uint64_t ctf_trace_id
;
120 uint32_t metadata_flag
;
121 char path_name
[LTTNG_VIEWER_PATH_MAX
];
122 char channel_name
[LTTNG_VIEWER_NAME_MAX
];
123 } __attribute__((__packed__
));
125 struct lttng_viewer_cmd
{
126 uint64_t data_size
; /* data size following this header */
127 uint32_t cmd
; /* enum lttcomm_relayd_command */
128 uint32_t cmd_version
; /* command version */
129 } __attribute__((__packed__
));
132 * LTTNG_VIEWER_CONNECT payload.
134 struct lttng_viewer_connect
{
135 /* session ID assigned by the relay for command connections */
136 uint64_t viewer_session_id
;
139 uint32_t type
; /* enum lttng_viewer_connection_type */
140 } __attribute__((__packed__
));
143 * LTTNG_VIEWER_LIST_SESSIONS payload.
145 struct lttng_viewer_list_sessions
{
146 uint32_t sessions_count
;
147 char session_list
[]; /* struct lttng_viewer_session */
148 } __attribute__((__packed__
));
151 * LTTNG_VIEWER_ATTACH_SESSION payload.
153 struct lttng_viewer_attach_session_request
{
155 uint64_t offset
; /* unused for now */
156 uint32_t seek
; /* enum lttng_viewer_seek */
157 } __attribute__((__packed__
));
159 struct lttng_viewer_attach_session_response
{
160 /* enum lttng_viewer_attach_return_code */
162 uint32_t streams_count
;
163 /* struct lttng_viewer_stream */
165 } __attribute__((__packed__
));
168 * LTTNG_VIEWER_GET_NEXT_INDEX payload.
170 struct lttng_viewer_get_next_index
{
172 } __attribute__ ((__packed__
));
174 struct lttng_viewer_index
{
176 uint64_t packet_size
;
177 uint64_t content_size
;
178 uint64_t timestamp_begin
;
179 uint64_t timestamp_end
;
180 uint64_t events_discarded
;
182 uint32_t status
; /* enum lttng_viewer_next_index_return_code */
183 uint32_t flags
; /* LTTNG_VIEWER_FLAG_* */
184 } __attribute__ ((__packed__
));
187 * LTTNG_VIEWER_GET_PACKET payload.
189 struct lttng_viewer_get_packet
{
193 } __attribute__((__packed__
));
195 struct lttng_viewer_trace_packet
{
196 uint32_t status
; /* enum lttng_viewer_get_packet_return_code */
198 uint32_t flags
; /* LTTNG_VIEWER_FLAG_* */
200 } __attribute__((__packed__
));
203 * LTTNG_VIEWER_GET_METADATA payload.
205 struct lttng_viewer_get_metadata
{
207 } __attribute__((__packed__
));
209 struct lttng_viewer_metadata_packet
{
211 uint32_t status
; /* enum lttng_viewer_get_metadata_return_code */
213 } __attribute__((__packed__
));
216 * LTTNG_VIEWER_GET_NEW_STREAMS payload.
218 struct lttng_viewer_new_streams_request
{
220 } __attribute__((__packed__
));
222 struct lttng_viewer_new_streams_response
{
223 /* enum lttng_viewer_new_streams_return_code */
225 uint32_t streams_count
;
226 /* struct lttng_viewer_stream */
228 } __attribute__((__packed__
));
230 struct lttng_viewer_create_session_response
{
231 /* enum lttng_viewer_create_session_return_code */
233 } __attribute__((__packed__
));
235 #endif /* LTTNG_VIEWER_ABI_H */