cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[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"
5ad6219b 18#include "cpp-common/bt2/value.hpp"
198e7911 19#include "cpp-common/bt2c/glib-up.hpp"
0f5c5d5c 20#include "cpp-common/bt2c/logging.hpp"
7cdc2bab 21
4164020e 22#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
7cdc2bab 23
4164020e
SM
24#define LTTNG_LIVE_MAJOR 2
25#define LTTNG_LIVE_MINOR 4
7cdc2bab 26
4164020e
SM
27enum lttng_live_viewer_status
28{
29 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
30 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
31 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
f79c2d7a
FD
32};
33
4164020e
SM
34enum lttng_live_get_one_metadata_status
35{
36 /* The end of the metadata stream was reached. */
37 LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1,
38 /* One metadata packet was received and written to file. */
39 LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK,
40 /*
41 * A critical error occurred when contacting the relay or while
42 * handling its response.
43 */
44 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
45
46 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
47
48 /* The metadata stream was not found on the relay. */
49 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
f79c2d7a
FD
50};
51
4164020e
SM
52struct live_viewer_connection
53{
d721bef8
SM
54 using UP = std::unique_ptr<live_viewer_connection>;
55
0f5c5d5c
SM
56 explicit live_viewer_connection(const bt2c::Logger& parentLogger) :
57 logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"}
58 {
59 }
60
277bcb7f
SM
61 ~live_viewer_connection();
62
0f5c5d5c 63 bt2c::Logger logger;
7cdc2bab 64
30d81897 65 std::string url;
7cdc2bab 66
198e7911
SM
67 bt2c::GStringUP relay_hostname;
68 bt2c::GStringUP target_hostname;
69 bt2c::GStringUP session_name;
70 bt2c::GStringUP proto;
94b828f3 71
afb0f12b
SM
72 BT_SOCKET control_sock {};
73 int port = 0;
7cdc2bab 74
afb0f12b
SM
75 int32_t major = 0;
76 int32_t minor = 0;
4c66436f 77
afb0f12b
SM
78 bool in_query = false;
79 struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
7cdc2bab
MD
80};
81
4164020e
SM
82struct packet_index_time
83{
84 uint64_t timestamp_begin;
85 uint64_t timestamp_end;
7cdc2bab
MD
86};
87
4164020e
SM
88struct packet_index
89{
90 off_t offset; /* offset of the packet in the file, in bytes */
91 int64_t data_offset; /* offset of data within the packet, in bits */
92 uint64_t packet_size; /* packet size, in bits */
93 uint64_t content_size; /* content size, in bits */
94 uint64_t events_discarded;
95 uint64_t events_discarded_len; /* length of the field, in bits */
96 struct packet_index_time ts_cycles; /* timestamp in cycles */
97 struct packet_index_time ts_real; /* realtime timestamp */
98 /* CTF_INDEX 1.0 limit */
99 uint64_t stream_instance_id; /* ID of the channel instance */
100 uint64_t packet_seq_num; /* packet sequence number */
7cdc2bab
MD
101};
102
d721bef8
SM
103enum lttng_live_viewer_status
104live_viewer_connection_create(const char *url, bool in_query,
105 struct lttng_live_msg_iter *lttng_live_msg_iter,
106 const bt2c::Logger& parentLogger, live_viewer_connection::UP& viewer);
7cdc2bab 107
4164020e
SM
108enum lttng_live_viewer_status
109lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
36e94ad6 110
5ad6219b
SM
111bt2::Value::Shared
112live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection);
7cdc2bab
MD
113
114#endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */
This page took 0.100703 seconds and 4 git commands to generate.