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
13 #include <babeltrace2/babeltrace.h>
15 #include "compat/socket.hpp"
17 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
19 #define LTTNG_LIVE_MAJOR 2
20 #define LTTNG_LIVE_MINOR 4
22 enum lttng_live_viewer_status
24 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
25 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
26 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
29 enum lttng_live_get_one_metadata_status
31 /* The end of the metadata stream was reached. */
32 LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1,
33 /* One metadata packet was received and written to file. */
34 LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK,
36 * A critical error occurred when contacting the relay or while
37 * handling its response.
39 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
41 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
43 /* The metadata stream was not found on the relay. */
44 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
47 struct live_viewer_connection
49 bt_logging_level log_level = (bt_logging_level) 0;
50 bt_self_component *self_comp = nullptr;
51 bt_self_component_class *self_comp_class = nullptr;
53 GString *url = nullptr;
55 GString *relay_hostname = nullptr;
56 GString *target_hostname = nullptr;
57 GString *session_name = nullptr;
58 GString *proto = nullptr;
60 BT_SOCKET control_sock {};
66 bool in_query = false;
67 struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
70 struct packet_index_time
72 uint64_t timestamp_begin;
73 uint64_t timestamp_end;
78 off_t offset; /* offset of the packet in the file, in bytes */
79 int64_t data_offset; /* offset of data within the packet, in bits */
80 uint64_t packet_size; /* packet size, in bits */
81 uint64_t content_size; /* content size, in bits */
82 uint64_t events_discarded;
83 uint64_t events_discarded_len; /* length of the field, in bits */
84 struct packet_index_time ts_cycles; /* timestamp in cycles */
85 struct packet_index_time ts_real; /* realtime timestamp */
86 /* CTF_INDEX 1.0 limit */
87 uint64_t stream_instance_id; /* ID of the channel instance */
88 uint64_t packet_seq_num; /* packet sequence number */
91 enum lttng_live_viewer_status
92 live_viewer_connection_create(bt_self_component *self_comp,
93 bt_self_component_class *self_comp_class, bt_logging_level log_level,
94 const char *url, bool in_query,
95 struct lttng_live_msg_iter *lttng_live_msg_iter,
96 struct live_viewer_connection **viewer_connection);
98 void live_viewer_connection_destroy(struct live_viewer_connection *conn);
100 enum lttng_live_viewer_status
101 lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
103 bt_component_class_query_method_status
104 live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection,
105 const bt_value **user_result);
107 #endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */