src.ctf.lttng-live: add live_viewer_connection destructor
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.hpp
CommitLineData
7cdc2bab 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
7cdc2bab 3 *
0235b0db 4 * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7cdc2bab
MD
5 */
6
0235b0db
MJ
7#ifndef LTTNG_LIVE_VIEWER_CONNECTION_H
8#define LTTNG_LIVE_VIEWER_CONNECTION_H
9
30d81897
SM
10#include <string>
11
c802cacb 12#include <glib.h>
3c22a242 13#include <stdint.h>
3c22a242 14
3c22a242
FD
15#include <babeltrace2/babeltrace.h>
16
2451f978 17#include "compat/socket.hpp"
198e7911 18#include "cpp-common/bt2c/glib-up.hpp"
0f5c5d5c 19#include "cpp-common/bt2c/logging.hpp"
7cdc2bab 20
4164020e 21#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
7cdc2bab 22
4164020e
SM
23#define LTTNG_LIVE_MAJOR 2
24#define LTTNG_LIVE_MINOR 4
7cdc2bab 25
4164020e
SM
26enum 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,
f79c2d7a
FD
31};
32
4164020e
SM
33enum 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,
f79c2d7a
FD
49};
50
4164020e
SM
51struct live_viewer_connection
52{
0f5c5d5c
SM
53 explicit live_viewer_connection(const bt2c::Logger& parentLogger) :
54 logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"}
55 {
56 }
57
277bcb7f
SM
58 ~live_viewer_connection();
59
0f5c5d5c 60 bt2c::Logger logger;
7cdc2bab 61
30d81897 62 std::string url;
7cdc2bab 63
198e7911
SM
64 bt2c::GStringUP relay_hostname;
65 bt2c::GStringUP target_hostname;
66 bt2c::GStringUP session_name;
67 bt2c::GStringUP proto;
94b828f3 68
afb0f12b
SM
69 BT_SOCKET control_sock {};
70 int port = 0;
7cdc2bab 71
afb0f12b
SM
72 int32_t major = 0;
73 int32_t minor = 0;
4c66436f 74
afb0f12b
SM
75 bool in_query = false;
76 struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
7cdc2bab
MD
77};
78
4164020e
SM
79struct packet_index_time
80{
81 uint64_t timestamp_begin;
82 uint64_t timestamp_end;
7cdc2bab
MD
83};
84
4164020e
SM
85struct packet_index
86{
87 off_t offset; /* offset of the packet in the file, in bytes */
88 int64_t data_offset; /* offset of data within the packet, in bits */
89 uint64_t packet_size; /* packet size, in bits */
90 uint64_t content_size; /* content size, in bits */
91 uint64_t events_discarded;
92 uint64_t events_discarded_len; /* length of the field, in bits */
93 struct packet_index_time ts_cycles; /* timestamp in cycles */
94 struct packet_index_time ts_real; /* realtime timestamp */
95 /* CTF_INDEX 1.0 limit */
96 uint64_t stream_instance_id; /* ID of the channel instance */
97 uint64_t packet_seq_num; /* packet sequence number */
7cdc2bab
MD
98};
99
0f5c5d5c
SM
100enum lttng_live_viewer_status live_viewer_connection_create(
101 const char *url, bool in_query, struct lttng_live_msg_iter *lttng_live_msg_iter,
102 const bt2c::Logger& parentLogger, struct live_viewer_connection **viewer);
7cdc2bab 103
4164020e
SM
104enum lttng_live_viewer_status
105lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
36e94ad6 106
4164020e
SM
107bt_component_class_query_method_status
108live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection,
109 const bt_value **user_result);
7cdc2bab
MD
110
111#endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */
This page took 0.099066 seconds and 4 git commands to generate.