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 | |
4164020e | 21 | #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344 |
7cdc2bab | 22 | |
4164020e SM |
23 | #define LTTNG_LIVE_MAJOR 2 |
24 | #define LTTNG_LIVE_MINOR 4 | |
7cdc2bab | 25 | |
4164020e SM |
26 | enum lttng_live_viewer_status |
27 | { | |
28 | LTTNG_LIVE_VIEWER_STATUS_OK = 0, | |
29 | LTTNG_LIVE_VIEWER_STATUS_ERROR = -1, | |
30 | LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2, | |
f79c2d7a FD |
31 | }; |
32 | ||
4164020e SM |
33 | enum lttng_live_get_one_metadata_status |
34 | { | |
35 | /* The end of the metadata stream was reached. */ | |
36 | LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1, | |
37 | /* One metadata packet was received and written to file. */ | |
38 | LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK, | |
39 | /* | |
40 | * A critical error occurred when contacting the relay or while | |
41 | * handling its response. | |
42 | */ | |
43 | LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR, | |
44 | ||
45 | LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED, | |
46 | ||
47 | /* The metadata stream was not found on the relay. */ | |
48 | LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3, | |
f79c2d7a FD |
49 | }; |
50 | ||
4c66436f MD |
51 | struct lttng_live_component; |
52 | ||
4164020e SM |
53 | struct live_viewer_connection |
54 | { | |
55 | bt_logging_level log_level; | |
56 | bt_self_component *self_comp; | |
57 | bt_self_component_class *self_comp_class; | |
7cdc2bab | 58 | |
4164020e | 59 | GString *url; |
7cdc2bab | 60 | |
4164020e SM |
61 | GString *relay_hostname; |
62 | GString *target_hostname; | |
63 | GString *session_name; | |
64 | GString *proto; | |
94b828f3 | 65 | |
4164020e SM |
66 | BT_SOCKET control_sock; |
67 | int port; | |
7cdc2bab | 68 | |
4164020e SM |
69 | int32_t major; |
70 | int32_t minor; | |
4c66436f | 71 | |
4164020e SM |
72 | bool in_query; |
73 | struct lttng_live_msg_iter *lttng_live_msg_iter; | |
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 | ||
4164020e SM |
97 | enum lttng_live_viewer_status |
98 | live_viewer_connection_create(bt_self_component *self_comp, | |
99 | bt_self_component_class *self_comp_class, bt_logging_level log_level, | |
100 | const char *url, bool in_query, | |
101 | struct lttng_live_msg_iter *lttng_live_msg_iter, | |
102 | struct live_viewer_connection **viewer_connection); | |
7cdc2bab | 103 | |
4164020e | 104 | void live_viewer_connection_destroy(struct live_viewer_connection *conn); |
7cdc2bab | 105 | |
4164020e SM |
106 | enum lttng_live_viewer_status |
107 | lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter); | |
36e94ad6 | 108 | |
4164020e SM |
109 | bt_component_class_query_method_status |
110 | live_viewer_connection_list_sessions(struct live_viewer_connection *viewer_connection, | |
111 | const bt_value **user_result); | |
7cdc2bab MD |
112 | |
113 | #endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */ |