src.ctf.lttng-live: make queries output a bt2::Value
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.hpp
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #ifndef LTTNG_LIVE_VIEWER_CONNECTION_H
8 #define LTTNG_LIVE_VIEWER_CONNECTION_H
9
10 #include <string>
11
12 #include <glib.h>
13 #include <stdint.h>
14
15 #include <babeltrace2/babeltrace.h>
16
17 #include "compat/socket.hpp"
18 #include "cpp-common/bt2c/glib-up.hpp"
19 #include "cpp-common/bt2c/logging.hpp"
20
21 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
22
23 #define LTTNG_LIVE_MAJOR 2
24 #define LTTNG_LIVE_MINOR 4
25
26 enum lttng_live_viewer_status
27 {
28 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
29 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
30 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
31 };
32
33 enum lttng_live_get_one_metadata_status
34 {
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,
39 /*
40 * A critical error occurred when contacting the relay or while
41 * handling its response.
42 */
43 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
44
45 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
46
47 /* The metadata stream was not found on the relay. */
48 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
49 };
50
51 struct live_viewer_connection
52 {
53 using UP = std::unique_ptr<live_viewer_connection>;
54
55 explicit live_viewer_connection(const bt2c::Logger& parentLogger) :
56 logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"}
57 {
58 }
59
60 ~live_viewer_connection();
61
62 bt2c::Logger logger;
63
64 std::string url;
65
66 bt2c::GStringUP relay_hostname;
67 bt2c::GStringUP target_hostname;
68 bt2c::GStringUP session_name;
69 bt2c::GStringUP proto;
70
71 BT_SOCKET control_sock {};
72 int port = 0;
73
74 int32_t major = 0;
75 int32_t minor = 0;
76
77 bool in_query = false;
78 struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
79 };
80
81 struct packet_index_time
82 {
83 uint64_t timestamp_begin;
84 uint64_t timestamp_end;
85 };
86
87 struct packet_index
88 {
89 off_t offset; /* offset of the packet in the file, in bytes */
90 int64_t data_offset; /* offset of data within the packet, in bits */
91 uint64_t packet_size; /* packet size, in bits */
92 uint64_t content_size; /* content size, in bits */
93 uint64_t events_discarded;
94 uint64_t events_discarded_len; /* length of the field, in bits */
95 struct packet_index_time ts_cycles; /* timestamp in cycles */
96 struct packet_index_time ts_real; /* realtime timestamp */
97 /* CTF_INDEX 1.0 limit */
98 uint64_t stream_instance_id; /* ID of the channel instance */
99 uint64_t packet_seq_num; /* packet sequence number */
100 };
101
102 enum lttng_live_viewer_status
103 live_viewer_connection_create(const char *url, bool in_query,
104 struct lttng_live_msg_iter *lttng_live_msg_iter,
105 const bt2c::Logger& parentLogger, live_viewer_connection::UP& viewer);
106
107 enum lttng_live_viewer_status
108 lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
109
110 bt_component_class_query_method_status
111 live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection,
112 bt2::Value::Shared& user_result);
113
114 #endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */
This page took 0.037945 seconds and 4 git commands to generate.