Commit | Line | Data |
---|---|---|
434131e4 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
434131e4 | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
434131e4 | 5 | * |
434131e4 JG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_LOCATION_INTERNAL_H | |
9 | #define LTTNG_LOCATION_INTERNAL_H | |
10 | ||
11 | #include <lttng/location.h> | |
1e9f1cf8 JG |
12 | #include <common/dynamic-buffer.h> |
13 | #include <common/buffer-view.h> | |
434131e4 | 14 | #include <common/macros.h> |
89293443 | 15 | #include <sys/types.h> |
434131e4 JG |
16 | |
17 | struct lttng_trace_archive_location { | |
18 | enum lttng_trace_archive_location_type type; | |
19 | union { | |
20 | struct { | |
21 | char *absolute_path; | |
22 | } local; | |
23 | struct { | |
24 | char *host; | |
25 | enum lttng_trace_archive_location_relay_protocol_type protocol; | |
26 | struct { | |
27 | uint16_t control, data; | |
28 | } ports; | |
29 | char *relative_path; | |
30 | } relay; | |
31 | } types; | |
32 | }; | |
33 | ||
1e9f1cf8 JG |
34 | struct lttng_trace_archive_location_comm { |
35 | /* A value from enum lttng_trace_archive_location_type */ | |
36 | int8_t type; | |
37 | union { | |
38 | struct { | |
39 | /* Includes the trailing \0. */ | |
40 | uint32_t absolute_path_len; | |
41 | } LTTNG_PACKED local; | |
42 | struct { | |
43 | /* Includes the trailing \0. */ | |
44 | uint32_t hostname_len; | |
45 | /* | |
46 | * A value from | |
47 | * enum lttng_trace_archive_location_relay_protocol_type. | |
48 | */ | |
49 | int8_t protocol; | |
50 | struct { | |
51 | uint16_t control, data; | |
52 | } ports; | |
53 | /* Includes the trailing \0. */ | |
54 | uint32_t relative_path_len; | |
55 | } LTTNG_PACKED relay; | |
56 | } LTTNG_PACKED types; | |
57 | /* | |
58 | * Payload is composed of: | |
59 | * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL | |
60 | * - absolute path, including \0 | |
61 | * - LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY | |
62 | * - hostname, including \0 | |
63 | * - relative path, including \0 | |
64 | */ | |
65 | char payload[]; | |
66 | } LTTNG_PACKED; | |
67 | ||
68 | ||
434131e4 JG |
69 | LTTNG_HIDDEN |
70 | struct lttng_trace_archive_location *lttng_trace_archive_location_local_create( | |
71 | const char *path); | |
72 | ||
73 | LTTNG_HIDDEN | |
74 | struct lttng_trace_archive_location *lttng_trace_archive_location_relay_create( | |
75 | const char *host, | |
76 | enum lttng_trace_archive_location_relay_protocol_type protocol, | |
77 | uint16_t control_port, uint16_t data_port, | |
78 | const char *relative_path); | |
79 | ||
1e9f1cf8 JG |
80 | LTTNG_HIDDEN |
81 | ssize_t lttng_trace_archive_location_create_from_buffer( | |
82 | const struct lttng_buffer_view *buffer, | |
83 | struct lttng_trace_archive_location **location); | |
84 | ||
85 | LTTNG_HIDDEN | |
86 | ssize_t lttng_trace_archive_location_serialize( | |
87 | const struct lttng_trace_archive_location *location, | |
88 | struct lttng_dynamic_buffer *buffer); | |
89 | ||
434131e4 JG |
90 | LTTNG_HIDDEN |
91 | void lttng_trace_archive_location_destroy( | |
92 | struct lttng_trace_archive_location *location); | |
93 | ||
94 | #endif /* LTTNG_LOCATION_INTERNAL_H */ |