56fa5632db86b6411dc4f2beb88ae9d55058b1f2
[lttngtop.git] / src / lttng-viewer.h
1 /*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * David Goulet <dgoulet@efficios.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25 #ifndef LTTNG_VIEWER_H
26 #define LTTNG_VIEWER_H
27
28 #include <limits.h>
29
30 #define LTTNG_VIEWER_PATH_MAX 4096
31 #define LTTNG_VIEWER_NAME_MAX 255
32 #define LTTNG_VIEWER_HOST_NAME_MAX 64
33
34 /* Flags in reply to get_next_index and get_packet. */
35 /* New metadata is required to read this packet. */
36 #define LTTNG_VIEWER_FLAG_NEW_METADATA (1 << 0)
37 /* New stream got added to the trace */
38 #define LTTNG_VIEWER_FLAG_NEW_STREAM (1 << 1)
39
40 enum lttng_viewer_command {
41 VIEWER_CONNECT = 1,
42 VIEWER_LIST_SESSIONS = 2,
43 VIEWER_ATTACH_SESSION = 3,
44 VIEWER_GET_NEXT_INDEX = 4,
45 VIEWER_GET_PACKET = 5,
46 VIEWER_GET_METADATA = 6,
47 };
48
49 enum lttng_viewer_attach_return_code {
50 VIEWER_ATTACH_OK = 1, /* If the attach command succeeded. */
51 VIEWER_ATTACH_ALREADY = 2, /* If a viewer is already attached. */
52 VIEWER_ATTACH_UNK = 3, /* If the session ID is unknown. */
53 VIEWER_ATTACH_NOT_LIVE = 4, /* If the session is not live. */
54 VIEWER_ATTACH_SEEK_ERR = 5, /* Seek error. */
55 };
56
57 enum lttng_viewer_next_index_return_code {
58 VIEWER_INDEX_OK = 1, /* Index is available. */
59 VIEWER_INDEX_RETRY = 2, /* Index not yet available. */
60 VIEWER_INDEX_HUP = 3, /* Index closed (trace destroyed). */
61 VIEWER_INDEX_ERR = 4, /* Unknow error. */
62 VIEWER_INDEX_INACTIVE = 5, /* Inactive stream beacon. */
63 };
64
65 enum lttng_viewer_get_packet_return_code {
66 VIEWER_GET_PACKET_OK = 1,
67 VIEWER_GET_PACKET_RETRY = 2,
68 VIEWER_GET_PACKET_ERR = 3,
69 };
70
71 enum lttng_viewer_get_metadata_return_code {
72 VIEWER_METADATA_OK = 1,
73 VIEWER_NO_NEW_METADATA = 2,
74 VIEWER_METADATA_ERR = 3,
75 };
76
77 enum lttng_viewer_connection_type {
78 VIEWER_CLIENT_COMMAND = 1,
79 VIEWER_CLIENT_NOTIFICATION = 2,
80 };
81
82 enum lttng_viewer_seek {
83 VIEWER_SEEK_BEGINNING = 1, /* Receive the trace packets from the beginning. */
84 VIEWER_SEEK_LAST = 2, /* Receive the trace packets from now. */
85 };
86
87 struct lttng_viewer_session {
88 uint64_t id;
89 char hostname[LTTNG_VIEWER_HOST_NAME_MAX];
90 char session_name[LTTNG_VIEWER_NAME_MAX];
91 uint32_t live_timer;
92 uint32_t clients;
93 } __attribute__((__packed__));
94
95 struct lttng_viewer_stream {
96 uint64_t id;
97 uint64_t ctf_trace_id;
98 char path_name[LTTNG_VIEWER_PATH_MAX];
99 char channel_name[LTTNG_VIEWER_NAME_MAX];
100 int metadata_flag;
101 } __attribute__((__packed__));
102
103 struct lttng_viewer_cmd {
104 uint64_t data_size; /* data size following this header */
105 uint32_t cmd; /* enum lttcomm_relayd_command */
106 uint32_t cmd_version; /* command version */
107 } __attribute__((__packed__));
108
109 /*
110 * CONNECT payload.
111 */
112 struct lttng_viewer_connect {
113 uint32_t major;
114 uint32_t minor;
115 uint32_t type; /* enum lttng_viewer_connection_type */
116 uint64_t viewer_session_id; /* session ID assigned by the relay for command connections */
117 } __attribute__((__packed__));
118
119 /*
120 * VIEWER_LIST_SESSIONS payload.
121 */
122 struct lttng_viewer_list_sessions {
123 uint32_t sessions_count;
124 char session_list[]; /* struct lttng_viewer_session */
125 } __attribute__((__packed__));
126
127 /*
128 * VIEWER_ATTACH_SESSION payload.
129 */
130 struct lttng_viewer_attach_session_request {
131 uint64_t session_id;
132 uint32_t seek; /* enum lttng_viewer_seek */
133 uint64_t offset; /* unused for now */
134 } __attribute__((__packed__));
135
136 struct lttng_viewer_attach_session_response {
137 uint32_t status; /* enum lttng_viewer_attach_return_code */
138 uint32_t streams_count;
139 char stream_list[]; /* struct lttng_viewer_stream */
140 } __attribute__((__packed__));
141
142 /*
143 * VIEWER_GET_NEXT_INDEX payload.
144 */
145 struct lttng_viewer_get_next_index {
146 uint64_t stream_id;
147 } __attribute__ ((__packed__));
148
149 struct lttng_viewer_index {
150 uint32_t status; /* enum lttng_viewer_next_index_return_code */
151 uint64_t offset;
152 uint64_t packet_size;
153 uint64_t content_size;
154 uint64_t timestamp_begin;
155 uint64_t timestamp_end;
156 uint64_t events_discarded;
157 uint64_t stream_id;
158 uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
159 } __attribute__ ((__packed__));
160
161 /*
162 * VIEWER_GET_PACKET payload.
163 */
164 struct lttng_viewer_get_packet {
165 uint64_t stream_id;
166 uint64_t offset;
167 uint32_t len;
168 } __attribute__((__packed__));
169
170 struct lttng_viewer_trace_packet {
171 uint32_t status; /* enum lttng_viewer_get_packet_return_code */
172 uint32_t len;
173 uint32_t flags; /* LTTNG_VIEWER_FLAG_* */
174 char data[];
175 } __attribute__((__packed__));
176
177 /*
178 * VIEWER_GET_METADATA payload.
179 */
180 struct lttng_viewer_get_metadata {
181 uint64_t stream_id;
182 } __attribute__((__packed__));
183
184 struct lttng_viewer_metadata_packet {
185 uint32_t status; /* enum lttng_viewer_get_metadata_return_code */
186 uint64_t len;
187 char data[];
188 } __attribute__((__packed__));
189
190 #endif /* LTTNG_VIEWER_H */
This page took 0.03185 seconds and 3 git commands to generate.