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