sys/param.h is required for MAXNAMLEN on musl libc
[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>
a11871fa 28#include <sys/param.h>
5805251d 29#include "lttng-viewer-abi.h"
4a744367 30
4a744367
JD
31#define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
32
33#define LTTNG_LIVE_MAJOR 2
34#define LTTNG_LIVE_MINOR 4
35
220e0cbe
MD
36/*
37 * The lttng-live output file pointer is currently hardcoded to stdout,
38 * and is expected to be hardcoded to this by fflush() performed between
39 * each packet.
40 */
41#define LTTNG_LIVE_OUTPUT_FP stdout
42
4a744367 43struct lttng_live_ctx {
c648b799
MJ
44 char traced_hostname[MAXNAMLEN];
45 char session_name[MAXNAMLEN];
46 char relay_hostname[MAXNAMLEN];
4a744367 47 int control_sock;
b5a1fa45 48 int port;
0dfc7b62
JD
49 /* Protocol version to use for this connection. */
50 uint32_t major;
51 uint32_t minor;
4a744367 52 struct lttng_live_session *session;
2acdc547 53 struct bt_context *bt_ctx;
b5a1fa45 54 GArray *session_ids;
4a744367
JD
55};
56
57struct lttng_live_viewer_stream {
58 uint64_t id;
59 uint64_t mmap_size;
5805251d 60 uint64_t ctf_stream_id;
af701dc4
JD
61 FILE *metadata_fp_write;
62 ssize_t metadata_len;
4a744367 63 int metadata_flag;
5805251d 64 int data_pending;
4a744367
JD
65 struct lttng_live_session *session;
66 struct lttng_live_ctf_trace *ctf_trace;
5805251d 67 struct lttng_viewer_index current_index;
4a744367
JD
68 char path[PATH_MAX];
69};
70
71struct lttng_live_session {
72 uint64_t live_timer_interval;
73 uint64_t stream_count;
74 struct lttng_live_ctx *ctx;
75 struct lttng_live_viewer_stream *streams;
705105fc 76 /* HashTable mapping trace_ids to ptrs to struct lttng_live_ctf_trace */
4a744367
JD
77 GHashTable *ctf_traces;
78};
79
80struct lttng_live_ctf_trace {
81 uint64_t ctf_trace_id;
82 struct lttng_live_viewer_stream *metadata_stream;
83 GPtrArray *streams;
84 FILE *metadata_fp;
150595c4 85 struct bt_trace_handle *handle;
4a744367 86 int trace_id;
2acdc547 87 int in_use;
4a744367
JD
88};
89
b5a1fa45
JD
90/* Just used in listing. */
91struct lttng_live_relay_session {
92 uint32_t streams;
93 uint32_t clients;
94 uint32_t timer;
95 char *name;
96 char *hostname;
97};
98
99int lttng_live_connect_viewer(struct lttng_live_ctx *ctx);
4a744367
JD
100int lttng_live_establish_connection(struct lttng_live_ctx *ctx);
101int lttng_live_list_sessions(struct lttng_live_ctx *ctx, const char *path);
102int lttng_live_attach_session(struct lttng_live_ctx *ctx, uint64_t id);
23285bf3 103int lttng_live_read(struct lttng_live_ctx *ctx);
2acdc547 104int lttng_live_get_new_streams(struct lttng_live_ctx *ctx, uint64_t id);
8ace20bf 105int lttng_live_should_quit(void);
4a744367 106
c98627ca 107#endif /* _LTTNG_LIVE_H */
This page took 0.032452 seconds and 4 git commands to generate.