2 * SPDX-License-Identifier: MIT
4 * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 #ifndef LTTNG_LIVE_VIEWER_CONNECTION_H
8 #define LTTNG_LIVE_VIEWER_CONNECTION_H
15 #include <babeltrace2/babeltrace.h>
17 #include "compat/socket.hpp"
18 #include "cpp-common/bt2c/glib-up.hpp"
19 #include "cpp-common/bt2c/logging.hpp"
21 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
23 #define LTTNG_LIVE_MAJOR 2
24 #define LTTNG_LIVE_MINOR 4
26 enum lttng_live_viewer_status
28 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
29 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
30 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
33 enum lttng_live_get_one_metadata_status
35 /* The end of the metadata stream was reached. */
36 LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1,
37 /* One metadata packet was received and written to file. */
38 LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK,
40 * A critical error occurred when contacting the relay or while
41 * handling its response.
43 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
45 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
47 /* The metadata stream was not found on the relay. */
48 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
51 struct live_viewer_connection
53 explicit live_viewer_connection(const bt2c::Logger& parentLogger) :
54 logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"}
62 bt2c::GStringUP relay_hostname;
63 bt2c::GStringUP target_hostname;
64 bt2c::GStringUP session_name;
65 bt2c::GStringUP proto;
67 BT_SOCKET control_sock {};
73 bool in_query = false;
74 struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
77 struct packet_index_time
79 uint64_t timestamp_begin;
80 uint64_t timestamp_end;
85 off_t offset; /* offset of the packet in the file, in bytes */
86 int64_t data_offset; /* offset of data within the packet, in bits */
87 uint64_t packet_size; /* packet size, in bits */
88 uint64_t content_size; /* content size, in bits */
89 uint64_t events_discarded;
90 uint64_t events_discarded_len; /* length of the field, in bits */
91 struct packet_index_time ts_cycles; /* timestamp in cycles */
92 struct packet_index_time ts_real; /* realtime timestamp */
93 /* CTF_INDEX 1.0 limit */
94 uint64_t stream_instance_id; /* ID of the channel instance */
95 uint64_t packet_seq_num; /* packet sequence number */
98 enum lttng_live_viewer_status live_viewer_connection_create(
99 const char *url, bool in_query, struct lttng_live_msg_iter *lttng_live_msg_iter,
100 const bt2c::Logger& parentLogger, struct live_viewer_connection **viewer);
102 void live_viewer_connection_destroy(struct live_viewer_connection *conn);
104 enum lttng_live_viewer_status
105 lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
107 bt_component_class_query_method_status
108 live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection,
109 const bt_value **user_result);
111 #endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */