src.ctf.lttng-live: make component class handle interruptions
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.h
CommitLineData
7cdc2bab
MD
1#ifndef LTTNG_LIVE_VIEWER_CONNECTION_H
2#define LTTNG_LIVE_VIEWER_CONNECTION_H
3
4/*
5 * Copyright 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
c4f23e30 26#include <stdbool.h>
3c22a242 27#include <stdint.h>
7cdc2bab 28#include <stdio.h>
3c22a242 29
7cdc2bab
MD
30#include <glib.h>
31
3c22a242
FD
32#include <babeltrace2/babeltrace.h>
33
91d81473 34#include "common/macros.h"
578e048b 35#include "compat/socket.h"
7cdc2bab 36
7cdc2bab
MD
37#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
38
39#define LTTNG_LIVE_MAJOR 2
40#define LTTNG_LIVE_MINOR 4
41
f79c2d7a
FD
42enum lttng_live_viewer_status {
43 LTTNG_LIVE_VIEWER_STATUS_OK = 0,
44 LTTNG_LIVE_VIEWER_STATUS_ERROR = -1,
45 LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED = -2,
46};
47
48enum lttng_live_get_one_metadata_status {
49 /* The end of the metadata stream was reached. */
50 LTTNG_LIVE_GET_ONE_METADATA_STATUS_END = 1,
51 /* One metadata packet was received and written to file. */
52 LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK = LTTNG_LIVE_VIEWER_STATUS_OK,
53 /*
54 * A critical error occurred when contacting the relay or while
55 * handling its response.
56 */
57 LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR = LTTNG_LIVE_VIEWER_STATUS_ERROR,
58
59 LTTNG_LIVE_GET_ONE_METADATA_STATUS_INTERRUPTED = LTTNG_LIVE_VIEWER_STATUS_INTERRUPTED,
60
61 /* The metadata stream was not found on the relay. */
62 LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED = -3,
63};
64
4c66436f
MD
65struct lttng_live_component;
66
14f28187 67struct live_viewer_connection {
c01594de 68 bt_logging_level log_level;
2ece7dd0 69 bt_self_component *self_comp;
1419db2b 70 bt_self_component_class *self_comp_class;
7cdc2bab 71
7cdc2bab
MD
72 GString *url;
73
94b828f3
MD
74 GString *relay_hostname;
75 GString *target_hostname;
76 GString *session_name;
77
1cb3cdd7 78 BT_SOCKET control_sock;
7cdc2bab
MD
79 int port;
80
81 int32_t major;
82 int32_t minor;
4c66436f 83
14f28187
FD
84 bool in_query;
85 struct lttng_live_msg_iter *lttng_live_msg_iter;
7cdc2bab
MD
86};
87
88struct packet_index_time {
14f28187
FD
89 uint64_t timestamp_begin;
90 uint64_t timestamp_end;
7cdc2bab
MD
91};
92
93struct packet_index {
94 off_t offset; /* offset of the packet in the file, in bytes */
95 int64_t data_offset; /* offset of data within the packet, in bits */
96 uint64_t packet_size; /* packet size, in bits */
97 uint64_t content_size; /* content size, in bits */
98 uint64_t events_discarded;
99 uint64_t events_discarded_len; /* length of the field, in bits */
100 struct packet_index_time ts_cycles; /* timestamp in cycles */
101 struct packet_index_time ts_real; /* realtime timestamp */
102 /* CTF_INDEX 1.0 limit */
103 uint64_t stream_instance_id; /* ID of the channel instance */
104 uint64_t packet_seq_num; /* packet sequence number */
105};
106
f79c2d7a 107enum lttng_live_viewer_status live_viewer_connection_create(
1419db2b
FD
108 bt_self_component *self_comp,
109 bt_self_component_class *self_comp_class,
f79c2d7a
FD
110 bt_logging_level log_level,
111 const char *url, bool in_query,
112 struct lttng_live_msg_iter *lttng_live_msg_iter,
113 struct live_viewer_connection **viewer_connection);
7cdc2bab 114
14f28187
FD
115void live_viewer_connection_destroy(
116 struct live_viewer_connection *conn);
7cdc2bab 117
d24d5663 118bt_component_class_query_method_status live_viewer_connection_list_sessions(
14f28187
FD
119 struct live_viewer_connection *viewer_connection,
120 const bt_value **user_result);
7cdc2bab
MD
121
122#endif /* LTTNG_LIVE_VIEWER_CONNECTION_H */
This page took 0.059777 seconds and 4 git commands to generate.