src.ctf.lttng-live: make live_viewer_connection::{relay_hostname,target_hostname...
[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"
2ec59b43 21#include "cpp-common/glib-up.hpp"
27a14e13 22#include "cpp-common/log-cfg.hpp"
7cdc2bab 23
4164020e 24#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
7cdc2bab 25
4164020e
SM
26#define LTTNG_LIVE_MAJOR 2
27#define LTTNG_LIVE_MINOR 4
7cdc2bab 28
4164020e
SM
29enum lttng_live_viewer_status
30{
31 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
32 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
33 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
f79c2d7a
FD
34};
35
4164020e
SM
36enum lttng_live_get_one_metadata_status
37{
38 /* The end of the metadata stream was reached. */
39 LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1,
40 /* One metadata packet was received and written to file. */
41 LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK,
42 /*
43 * A critical error occurred when contacting the relay or while
44 * handling its response.
45 */
46 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
47
48 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
49
50 /* The metadata stream was not found on the relay. */
51 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
f79c2d7a
FD
52};
53
4c66436f
MD
54struct lttng_live_component;
55
4164020e
SM
56struct live_viewer_connection
57{
27a14e13
SM
58 explicit live_viewer_connection(const bt2_common::LogCfg& logCfgParam) noexcept :
59 logCfg {logCfgParam}
60 {
61 }
62
63 const bt2_common::LogCfg logCfg;
7cdc2bab 64
d6ed88fe 65 std::string url;
7cdc2bab 66
2ec59b43
SM
67 bt2_common::GStringUP relay_hostname;
68 bt2_common::GStringUP target_hostname;
69 bt2_common::GStringUP session_name;
70 bt2_common::GStringUP proto;
94b828f3 71
6269f212
SM
72 BT_SOCKET control_sock {};
73 int port = 0;
7cdc2bab 74
6269f212
SM
75 int32_t major = 0;
76 int32_t minor = 0;
4c66436f 77
6269f212
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
27a14e13
SM
103enum lttng_live_viewer_status live_viewer_connection_create(
104 const char *url, bool in_query, struct lttng_live_msg_iter *lttng_live_msg_iter,
105 const bt2_common::LogCfg& logCfg, struct live_viewer_connection **viewer);
7cdc2bab 106
4164020e 107void live_viewer_connection_destroy(struct live_viewer_connection *conn);
7cdc2bab 108
4164020e
SM
109enum lttng_live_viewer_status
110lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
36e94ad6 111
4164020e
SM
112bt_component_class_query_method_status
113live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection,
114 const bt_value **user_result);
7cdc2bab
MD
115
116#endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */
This page took 0.060928 seconds and 5 git commands to generate.