Move to kernel style SPDX license identifiers
[lttng-tools.git] / src / bin / lttng-relayd / lttng-viewer-abi.h
1 #ifndef LTTNG_VIEWER_ABI_H
2 #define LTTNG_VIEWER_ABI_H
3
4 /*
5 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
6 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
8 *
9 * SPDX-License-Identifier: MIT
10 *
11 */
12
13 #include <limits.h>
14 #include <common/macros.h>
15
16 #define LTTNG_VIEWER_PATH_MAX 4096
17 #define LTTNG_VIEWER_NAME_MAX 255
18 #define LTTNG_VIEWER_HOST_NAME_MAX 64
19
20 /* Flags in reply to get_next_index and get_packet. */
21 enum {
22 /* New metadata is required to read this packet. */
23 LTTNG_VIEWER_FLAG_NEW_METADATA = (1 << 0),
24 /* New stream got added to the trace. */
25 LTTNG_VIEWER_FLAG_NEW_STREAM = (1 << 1),
26 };
27
28 enum lttng_viewer_command {
29 LTTNG_VIEWER_CONNECT = 1,
30 LTTNG_VIEWER_LIST_SESSIONS = 2,
31 LTTNG_VIEWER_ATTACH_SESSION = 3,
32 LTTNG_VIEWER_GET_NEXT_INDEX = 4,
33 LTTNG_VIEWER_GET_PACKET = 5,
34 LTTNG_VIEWER_GET_METADATA = 6,
35 LTTNG_VIEWER_GET_NEW_STREAMS = 7,
36 LTTNG_VIEWER_CREATE_SESSION = 8,
37 LTTNG_VIEWER_DETACH_SESSION = 9,
38 };
39
40 enum lttng_viewer_attach_return_code {
41 LTTNG_VIEWER_ATTACH_OK = 1, /* The attach command succeeded. */
42 LTTNG_VIEWER_ATTACH_ALREADY = 2, /* A viewer is already attached. */
43 LTTNG_VIEWER_ATTACH_UNK = 3, /* The session ID is unknown. */
44 LTTNG_VIEWER_ATTACH_NOT_LIVE = 4, /* The session is not live. */
45 LTTNG_VIEWER_ATTACH_SEEK_ERR = 5, /* Seek error. */
46 LTTNG_VIEWER_ATTACH_NO_SESSION = 6, /* No viewer session created. */
47 };
48
49 enum lttng_viewer_next_index_return_code {
50 LTTNG_VIEWER_INDEX_OK = 1, /* Index is available. */
51 LTTNG_VIEWER_INDEX_RETRY = 2, /* Index not yet available. */
52 LTTNG_VIEWER_INDEX_HUP = 3, /* Index closed (trace destroyed). */
53 LTTNG_VIEWER_INDEX_ERR = 4, /* Unknow error. */
54 LTTNG_VIEWER_INDEX_INACTIVE = 5, /* Inactive stream beacon. */
55 LTTNG_VIEWER_INDEX_EOF = 6, /* End of index file. */
56 };
57
58 enum lttng_viewer_get_packet_return_code {
59 LTTNG_VIEWER_GET_PACKET_OK = 1,
60 LTTNG_VIEWER_GET_PACKET_RETRY = 2,
61 LTTNG_VIEWER_GET_PACKET_ERR = 3,
62 LTTNG_VIEWER_GET_PACKET_EOF = 4,
63 };
64
65 enum lttng_viewer_get_metadata_return_code {
66 LTTNG_VIEWER_METADATA_OK = 1,
67 LTTNG_VIEWER_NO_NEW_METADATA = 2,
68 LTTNG_VIEWER_METADATA_ERR = 3,
69 };
70
71 enum lttng_viewer_connection_type {
72 LTTNG_VIEWER_CLIENT_COMMAND = 1,
73 LTTNG_VIEWER_CLIENT_NOTIFICATION = 2,
74 };
75
76 enum lttng_viewer_seek {
77 /* Receive the trace packets from the beginning. */
78 LTTNG_VIEWER_SEEK_BEGINNING = 1,
79 /* Receive the trace packets from now. */
80 LTTNG_VIEWER_SEEK_LAST = 2,
81 };
82
83 enum lttng_viewer_new_streams_return_code {
84 LTTNG_VIEWER_NEW_STREAMS_OK = 1, /* If new streams are being sent. */
85 LTTNG_VIEWER_NEW_STREAMS_NO_NEW = 2, /* If no new streams are available. */
86 LTTNG_VIEWER_NEW_STREAMS_ERR = 3, /* Error. */
87 LTTNG_VIEWER_NEW_STREAMS_HUP = 4, /* Session closed. */
88 };
89
90 enum lttng_viewer_create_session_return_code {
91 LTTNG_VIEWER_CREATE_SESSION_OK = 1,
92 LTTNG_VIEWER_CREATE_SESSION_ERR = 2,
93 };
94
95 enum lttng_viewer_detach_session_return_code {
96 LTTNG_VIEWER_DETACH_SESSION_OK = 1,
97 LTTNG_VIEWER_DETACH_SESSION_UNK = 2,
98 LTTNG_VIEWER_DETACH_SESSION_ERR = 3,
99 };
100
101 struct lttng_viewer_session {
102 uint64_t id;
103 uint32_t live_timer;
104 uint32_t clients;
105 uint32_t streams;
106 char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
107 char session_name[LTTNG_VIEWER_NAME_MAX];
108 } LTTNG_PACKED;
109
110 struct lttng_viewer_stream {
111 uint64_t id;
112 uint64_t ctf_trace_id;
113 uint32_t metadata_flag;
114 char path_name[LTTNG_VIEWER_PATH_MAX];
115 char channel_name[LTTNG_VIEWER_NAME_MAX];
116 } LTTNG_PACKED;
117
118 struct lttng_viewer_cmd {
119 uint64_t data_size; /* data size following this header */
120 uint32_t cmd; /* enum lttcomm_relayd_command */
121 uint32_t cmd_version; /* command version */
122 } LTTNG_PACKED;
123
124 /*
125 * LTTNG_VIEWER_CONNECT payload.
126 */
127 struct lttng_viewer_connect {
128 /* session ID assigned by the relay for command connections */
129 uint64_t viewer_session_id;
130 uint32_t major;
131 uint32_t minor;
132 uint32_t type; /* enum lttng_viewer_connection_type */
133 } LTTNG_PACKED;
134
135 /*
136 * LTTNG_VIEWER_LIST_SESSIONS payload.
137 */
138 struct lttng_viewer_list_sessions {
139 uint32_t sessions_count;
140 char session_list[]; /* struct lttng_viewer_session */
141 } LTTNG_PACKED;
142
143 /*
144 * LTTNG_VIEWER_ATTACH_SESSION payload.
145 */
146 struct lttng_viewer_attach_session_request {
147 uint64_t session_id;
148 uint64_t offset; /* unused for now */
149 uint32_t seek; /* enum lttng_viewer_seek */
150 } LTTNG_PACKED;
151
152 struct lttng_viewer_attach_session_response {
153 /* enum lttng_viewer_attach_return_code */
154 uint32_t status;
155 uint32_t streams_count;
156 /* struct lttng_viewer_stream */
157 char stream_list[];
158 } LTTNG_PACKED;
159
160 /*
161 * LTTNG_VIEWER_GET_NEXT_INDEX payload.
162 */
163 struct lttng_viewer_get_next_index {
164 uint64_t stream_id;
165 } __attribute__ ((__packed__));
166
167 struct lttng_viewer_index {
168 uint64_t offset;
169 uint64_t packet_size;
170 uint64_t content_size;
171 uint64_t timestamp_begin;
172 uint64_t timestamp_end;
173 uint64_t events_discarded;
174 uint64_t stream_id;
175 uint32_t status; /* enum lttng_viewer_next_index_return_code */
176 uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
177 } __attribute__ ((__packed__));
178
179 /*
180 * LTTNG_VIEWER_GET_PACKET payload.
181 */
182 struct lttng_viewer_get_packet {
183 uint64_t stream_id;
184 uint64_t offset;
185 uint32_t len;
186 } LTTNG_PACKED;
187
188 struct lttng_viewer_trace_packet {
189 uint32_t status; /* enum lttng_viewer_get_packet_return_code */
190 uint32_t len;
191 uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
192 char data[];
193 } LTTNG_PACKED;
194
195 /*
196 * LTTNG_VIEWER_GET_METADATA payload.
197 */
198 struct lttng_viewer_get_metadata {
199 uint64_t stream_id;
200 } LTTNG_PACKED;
201
202 struct lttng_viewer_metadata_packet {
203 uint64_t len;
204 uint32_t status; /* enum lttng_viewer_get_metadata_return_code */
205 char data[];
206 } LTTNG_PACKED;
207
208 /*
209 * LTTNG_VIEWER_GET_NEW_STREAMS payload.
210 */
211 struct lttng_viewer_new_streams_request {
212 uint64_t session_id;
213 } LTTNG_PACKED;
214
215 struct lttng_viewer_new_streams_response {
216 /* enum lttng_viewer_new_streams_return_code */
217 uint32_t status;
218 uint32_t streams_count;
219 /* struct lttng_viewer_stream */
220 char stream_list[];
221 } LTTNG_PACKED;
222
223 struct lttng_viewer_create_session_response {
224 /* enum lttng_viewer_create_session_return_code */
225 uint32_t status;
226 } LTTNG_PACKED;
227
228 /*
229 * LTTNG_VIEWER_DETACH_SESSION payload.
230 */
231 struct lttng_viewer_detach_session_request {
232 uint64_t session_id;
233 } LTTNG_PACKED;
234
235 struct lttng_viewer_detach_session_response {
236 /* enum lttng_viewer_detach_session_return_code */
237 uint32_t status;
238 } LTTNG_PACKED;
239
240 #endif /* LTTNG_VIEWER_ABI_H */
This page took 0.053053 seconds and 5 git commands to generate.