2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef LTTNG_VIEWER_H
20 #define LTTNG_VIEWER_H
24 #define LTTNG_VIEWER_PATH_MAX 4096
25 #define LTTNG_VIEWER_NAME_MAX 255
26 #define LTTNG_VIEWER_HOST_NAME_MAX 64
28 /* Flags in reply to get_next_index and get_packet. */
29 /* New metadata is required to read this packet. */
30 #define LTTNG_VIEWER_FLAG_NEW_METADATA (1 << 0)
31 /* New stream got added to the trace */
32 #define LTTNG_VIEWER_FLAG_NEW_STREAM (1 << 1)
34 enum lttng_viewer_command
{
36 VIEWER_LIST_SESSIONS
= 2,
37 VIEWER_ATTACH_SESSION
= 3,
38 VIEWER_GET_NEXT_INDEX
= 4,
39 VIEWER_GET_PACKET
= 5,
40 VIEWER_GET_METADATA
= 6,
43 enum lttng_viewer_attach_return_code
{
44 VIEWER_ATTACH_OK
= 1, /* If the attach command succeeded. */
45 VIEWER_ATTACH_ALREADY
= 2, /* If a viewer is already attached. */
46 VIEWER_ATTACH_UNK
= 3, /* If the session ID is unknown. */
47 VIEWER_ATTACH_NOT_LIVE
= 4, /* If the session is not live. */
48 VIEWER_ATTACH_SEEK_ERR
= 5, /* Seek error. */
51 enum lttng_viewer_next_index_return_code
{
52 VIEWER_INDEX_OK
= 1, /* Index is available. */
53 VIEWER_INDEX_RETRY
= 2, /* Index not yet available. */
54 VIEWER_INDEX_HUP
= 3, /* Index closed (trace destroyed). */
55 VIEWER_INDEX_ERR
= 4, /* Unknow error. */
56 VIEWER_INDEX_INACTIVE
= 5, /* Inactive stream beacon. */
59 enum lttng_viewer_get_packet_return_code
{
60 VIEWER_GET_PACKET_OK
= 1,
61 VIEWER_GET_PACKET_RETRY
= 2,
62 VIEWER_GET_PACKET_ERR
= 3,
65 enum lttng_viewer_get_metadata_return_code
{
66 VIEWER_METADATA_OK
= 1,
67 VIEWER_NO_NEW_METADATA
= 2,
68 VIEWER_METADATA_ERR
= 3,
71 enum lttng_viewer_connection_type
{
72 VIEWER_CLIENT_COMMAND
= 1,
73 VIEWER_CLIENT_NOTIFICATION
= 2,
76 enum lttng_viewer_seek
{
77 VIEWER_SEEK_BEGINNING
= 1, /* Receive the trace packets from the beginning. */
78 VIEWER_SEEK_LAST
= 2, /* Receive the trace packets from now. */
81 struct lttng_viewer_session
{
83 char hostname
[LTTNG_VIEWER_HOST_NAME_MAX
];
84 char session_name
[LTTNG_VIEWER_NAME_MAX
];
87 } __attribute__((__packed__
));
89 struct lttng_viewer_stream
{
91 uint64_t ctf_trace_id
;
92 char path_name
[LTTNG_VIEWER_PATH_MAX
];
93 char channel_name
[LTTNG_VIEWER_NAME_MAX
];
95 } __attribute__((__packed__
));
97 struct lttng_viewer_cmd
{
98 uint64_t data_size
; /* data size following this header */
99 uint32_t cmd
; /* enum lttcomm_relayd_command */
100 uint32_t cmd_version
; /* command version */
101 } __attribute__((__packed__
));
106 struct lttng_viewer_connect
{
109 uint32_t type
; /* enum lttng_viewer_connection_type */
110 uint64_t viewer_session_id
; /* session ID assigned by the relay for command connections */
111 } __attribute__((__packed__
));
114 * VIEWER_LIST_SESSIONS payload.
116 struct lttng_viewer_list_sessions
{
117 uint32_t sessions_count
;
118 char session_list
[]; /* struct lttng_viewer_session */
119 } __attribute__((__packed__
));
122 * VIEWER_ATTACH_SESSION payload.
124 struct lttng_viewer_attach_session_request
{
126 uint32_t seek
; /* enum lttng_viewer_seek */
127 uint64_t offset
; /* unused for now */
128 } __attribute__((__packed__
));
130 struct lttng_viewer_attach_session_response
{
131 uint32_t status
; /* enum lttng_viewer_attach_return_code */
132 uint32_t streams_count
;
133 char stream_list
[]; /* struct lttng_viewer_stream */
134 } __attribute__((__packed__
));
137 * VIEWER_GET_NEXT_INDEX payload.
139 struct lttng_viewer_get_next_index
{
141 } __attribute__ ((__packed__
));
143 struct lttng_viewer_index
{
144 uint32_t status
; /* enum lttng_viewer_next_index_return_code */
146 uint64_t packet_size
;
147 uint64_t content_size
;
148 uint64_t timestamp_begin
;
149 uint64_t timestamp_end
;
150 uint64_t events_discarded
;
152 uint32_t flags
; /* LTTNG_VIEWER_FLAG_* */
153 } __attribute__ ((__packed__
));
156 * VIEWER_GET_PACKET payload.
158 struct lttng_viewer_get_packet
{
162 } __attribute__((__packed__
));
164 struct lttng_viewer_trace_packet
{
165 uint32_t status
; /* enum lttng_viewer_get_packet_return_code */
167 uint32_t flags
; /* LTTNG_VIEWER_FLAG_* */
169 } __attribute__((__packed__
));
172 * VIEWER_GET_METADATA payload.
174 struct lttng_viewer_get_metadata
{
176 } __attribute__((__packed__
));
178 struct lttng_viewer_metadata_packet
{
179 uint32_t status
; /* enum lttng_viewer_get_metadata_return_code */
182 } __attribute__((__packed__
));
184 #endif /* LTTNG_VIEWER_H */