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