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