src.ctf.lttng-live: make queries report errors with exceptions
[deliverable/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
c4f23e30 10#include <stdbool.h>
3c22a242 11#include <stdint.h>
7cdc2bab 12#include <stdio.h>
d6ed88fe 13#include <string>
3c22a242 14
7cdc2bab
MD
15#include <glib.h>
16
3c22a242
FD
17#include <babeltrace2/babeltrace.h>
18
91d81473 19#include "common/macros.h"
578e048b 20#include "compat/socket.h"
a5b34e0c 21#include "cpp-common/bt2/value.hpp"
2ec59b43 22#include "cpp-common/glib-up.hpp"
32845257 23#include "cpp-common/optional.hpp"
27a14e13 24#include "cpp-common/log-cfg.hpp"
7cdc2bab 25
4164020e 26#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
7cdc2bab 27
4164020e
SM
28#define LTTNG_LIVE_MAJOR 2
29#define LTTNG_LIVE_MINOR 4
7cdc2bab 30
4164020e
SM
31enum lttng_live_viewer_status
32{
33 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
34 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
35 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
f79c2d7a
FD
36};
37
4164020e
SM
38enum lttng_live_get_one_metadata_status
39{
40 /* The end of the metadata stream was reached. */
41 LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1,
42 /* One metadata packet was received and written to file. */
43 LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK,
44 /*
45 * A critical error occurred when contacting the relay or while
46 * handling its response.
47 */
48 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
49
50 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
51
52 /* The metadata stream was not found on the relay. */
53 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
f79c2d7a
FD
54};
55
4c66436f
MD
56struct lttng_live_component;
57
4164020e
SM
58struct live_viewer_connection
59{
772808ca
SM
60 using UP = std::unique_ptr<live_viewer_connection>;
61
27a14e13
SM
62 explicit live_viewer_connection(const bt2_common::LogCfg& logCfgParam) noexcept :
63 logCfg {logCfgParam}
64 {
65 }
66
9b245540
SM
67 ~live_viewer_connection();
68
27a14e13 69 const bt2_common::LogCfg logCfg;
7cdc2bab 70
d6ed88fe 71 std::string url;
7cdc2bab 72
2ec59b43
SM
73 bt2_common::GStringUP relay_hostname;
74 bt2_common::GStringUP target_hostname;
75 bt2_common::GStringUP session_name;
76 bt2_common::GStringUP proto;
94b828f3 77
6269f212
SM
78 BT_SOCKET control_sock {};
79 int port = 0;
7cdc2bab 80
6269f212
SM
81 int32_t major = 0;
82 int32_t minor = 0;
4c66436f 83
6269f212
SM
84 bool in_query = false;
85 struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
7cdc2bab
MD
86};
87
4164020e
SM
88struct packet_index_time
89{
90 uint64_t timestamp_begin;
91 uint64_t timestamp_end;
7cdc2bab
MD
92};
93
4164020e
SM
94struct packet_index
95{
96 off_t offset; /* offset of the packet in the file, in bytes */
97 int64_t data_offset; /* offset of data within the packet, in bits */
98 uint64_t packet_size; /* packet size, in bits */
99 uint64_t content_size; /* content size, in bits */
100 uint64_t events_discarded;
101 uint64_t events_discarded_len; /* length of the field, in bits */
102 struct packet_index_time ts_cycles; /* timestamp in cycles */
103 struct packet_index_time ts_real; /* realtime timestamp */
104 /* CTF_INDEX 1.0 limit */
105 uint64_t stream_instance_id; /* ID of the channel instance */
106 uint64_t packet_seq_num; /* packet sequence number */
7cdc2bab
MD
107};
108
772808ca
SM
109enum lttng_live_viewer_status
110live_viewer_connection_create(const char *url, bool in_query,
111 struct lttng_live_msg_iter *lttng_live_msg_iter,
112 const bt2_common::LogCfg& logCfg, live_viewer_connection::UP& viewer);
7cdc2bab 113
4164020e
SM
114enum lttng_live_viewer_status
115lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
36e94ad6 116
a5b34e0c
SM
117bt2::Value::Shared
118live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection);
7cdc2bab
MD
119
120#endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */
This page took 0.065348 seconds and 5 git commands to generate.