Fix: Use list rather than ptr array for trace streams
[babeltrace.git] / formats / lttng-live / lttng-live.h
CommitLineData
c98627ca
MD
1#ifndef _LTTNG_LIVE_H
2#define _LTTNG_LIVE_H
4a744367
JD
3
4/*
5 * Copyright 2013 Julien Desfossez <julien.desfossez@efficios.com>
6 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27#include <stdint.h>
d1368cd1 28#include <sys/param.h>
21fe3eb3 29#include <babeltrace/list.h>
fb6b45aa 30#include "lttng-viewer-abi.h"
4a744367 31
4a744367
JD
32#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
33
34#define LTTNG_LIVE_MAJOR 2
35#define LTTNG_LIVE_MINOR 4
36
857eaa68
MD
37/*
38 * The lttng-live output file pointer is currently hardcoded to stdout,
39 * and is expected to be hardcoded to this by fflush() performed between
40 * each packet.
41 */
42#define LTTNG_LIVE_OUTPUT_FP stdout
43
4a744367 44struct lttng_live_ctx {
0206bb4a
MJ
45 char traced_hostname[MAXNAMLEN];
46 char session_name[MAXNAMLEN];
47 char relay_hostname[MAXNAMLEN];
4a744367 48 int control_sock;
b5a1fa45 49 int port;
9aa155c5
JD
50 /* Protocol version to use for this connection. */
51 uint32_t major;
52 uint32_t minor;
4a744367 53 struct lttng_live_session *session;
2acdc547 54 struct bt_context *bt_ctx;
b5a1fa45 55 GArray *session_ids;
4a744367
JD
56};
57
58struct lttng_live_viewer_stream {
59 uint64_t id;
60 uint64_t mmap_size;
fb6b45aa 61 uint64_t ctf_stream_id;
af701dc4
JD
62 FILE *metadata_fp_write;
63 ssize_t metadata_len;
4a744367 64 int metadata_flag;
fb6b45aa 65 int data_pending;
4a744367
JD
66 struct lttng_live_session *session;
67 struct lttng_live_ctf_trace *ctf_trace;
fb6b45aa 68 struct lttng_viewer_index current_index;
bb35f032
MD
69 struct bt_list_head session_stream_node; /* Owns stream. */
70 struct bt_list_head trace_stream_node;
71 int in_trace;
4a744367
JD
72 char path[PATH_MAX];
73};
74
75struct lttng_live_session {
76 uint64_t live_timer_interval;
77 uint64_t stream_count;
78 struct lttng_live_ctx *ctx;
bb35f032 79 /* The session stream list owns the lttng_live_viewer_stream object. */
21fe3eb3 80 struct bt_list_head stream_list;
4a744367
JD
81 GHashTable *ctf_traces;
82};
83
84struct lttng_live_ctf_trace {
85 uint64_t ctf_trace_id;
86 struct lttng_live_viewer_stream *metadata_stream;
bb35f032
MD
87 /* The trace has a list of streams, but it has no ownership on them. */
88 struct bt_list_head stream_list;
4a744367 89 FILE *metadata_fp;
150595c4 90 struct bt_trace_handle *handle;
4a744367 91 int trace_id;
2acdc547 92 int in_use;
4a744367
JD
93};
94
b5a1fa45
JD
95/* Just used in listing. */
96struct lttng_live_relay_session {
97 uint32_t streams;
98 uint32_t clients;
99 uint32_t timer;
100 char *name;
101 char *hostname;
102};
103
104int lttng_live_connect_viewer(struct lttng_live_ctx *ctx);
4a744367
JD
105int lttng_live_establish_connection(struct lttng_live_ctx *ctx);
106int lttng_live_list_sessions(struct lttng_live_ctx *ctx, const char *path);
107int lttng_live_attach_session(struct lttng_live_ctx *ctx, uint64_t id);
28756729 108int lttng_live_read(struct lttng_live_ctx *ctx);
2acdc547 109int lttng_live_get_new_streams(struct lttng_live_ctx *ctx, uint64_t id);
8ace20bf 110int lttng_live_should_quit(void);
4a744367 111
c98627ca 112#endif /* _LTTNG_LIVE_H */
This page took 0.029778 seconds and 4 git commands to generate.