669347e2ebbca28f18b6c82a463d2f2aa992a493
[lttng-tools.git] / include / lttng / location-internal.hpp
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_LOCATION_INTERNAL_H
9 #define LTTNG_LOCATION_INTERNAL_H
10
11 #include <common/buffer-view.hpp>
12 #include <common/dynamic-buffer.hpp>
13 #include <common/macros.hpp>
14
15 #include <lttng/location.h>
16
17 #include <sys/types.h>
18 #include <urcu/ref.h>
19
20 /*
21 * The public API assumes that trace archive locations are always
22 * provided as "constant". This means that the user of liblttng-ctl never
23 * has to destroy a trace archive location. Hence, users of liblttng-ctl
24 * have no visibility of the reference counting of archive locations.
25 */
26 struct lttng_trace_archive_location {
27 struct urcu_ref ref;
28 enum lttng_trace_archive_location_type type;
29 union {
30 struct {
31 char *absolute_path;
32 } local;
33 struct {
34 char *host;
35 enum lttng_trace_archive_location_relay_protocol_type protocol;
36 struct {
37 uint16_t control, data;
38 } ports;
39 char *relative_path;
40 } relay;
41 } types;
42 };
43
44 struct lttng_trace_archive_location_comm {
45 /* A value from enum lttng_trace_archive_location_type */
46 int8_t type;
47 union {
48 struct {
49 /* Includes the trailing \0. */
50 uint32_t absolute_path_len;
51 } LTTNG_PACKED local;
52 struct {
53 /* Includes the trailing \0. */
54 uint32_t hostname_len;
55 /*
56 * A value from
57 * enum lttng_trace_archive_location_relay_protocol_type.
58 */
59 int8_t protocol;
60 struct {
61 uint16_t control, data;
62 } ports;
63 /* Includes the trailing \0. */
64 uint32_t relative_path_len;
65 } LTTNG_PACKED relay;
66 } LTTNG_PACKED types;
67 /*
68 * Payload is composed of:
69 * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL
70 * - absolute path, including \0
71 * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY
72 * - hostname, including \0
73 * - relative path, including \0
74 */
75 char payload[];
76 } LTTNG_PACKED;
77
78 struct lttng_trace_archive_location *lttng_trace_archive_location_local_create(const char *path);
79
80 struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create(
81 const char *host,
82 enum lttng_trace_archive_location_relay_protocol_type protocol,
83 uint16_t control_port,
84 uint16_t data_port,
85 const char *relative_path);
86
87 ssize_t
88 lttng_trace_archive_location_create_from_buffer(const struct lttng_buffer_view *buffer,
89 struct lttng_trace_archive_location **location);
90
91 ssize_t lttng_trace_archive_location_serialize(const struct lttng_trace_archive_location *location,
92 struct lttng_dynamic_buffer *buffer);
93
94 void lttng_trace_archive_location_get(struct lttng_trace_archive_location *location);
95
96 void lttng_trace_archive_location_put(struct lttng_trace_archive_location *location);
97
98 #endif /* LTTNG_LOCATION_INTERNAL_H */
This page took 0.042064 seconds and 4 git commands to generate.