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