Commit | Line | Data |
---|---|---|
c0a66c84 JG |
1 | /* |
2 | * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com> | |
3 | * | |
4 | * SPDX-License-Identifier: LGPL-2.1-only | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef LTTNG_PAYLOAD_H | |
9 | #define LTTNG_PAYLOAD_H | |
10 | ||
c9e313bc SM |
11 | #include <common/dynamic-buffer.hpp> |
12 | #include <common/dynamic-array.hpp> | |
13 | #include <common/fd-handle.hpp> | |
c0a66c84 JG |
14 | |
15 | /* | |
16 | * An lttng_payload encompasses the 'data' (bytes) and any passed file | |
17 | * descriptors as part of a message between liblttng-ctl and the session | |
18 | * daemon. | |
19 | */ | |
20 | struct lttng_payload { | |
21 | struct lttng_dynamic_buffer buffer; | |
22 | /* private */ | |
fe489250 | 23 | struct lttng_dynamic_pointer_array _fd_handles; |
c0a66c84 JG |
24 | }; |
25 | ||
26 | /* | |
27 | * Initialize a payload. This performs no allocation and is meant | |
de837173 | 28 | * to be used instead of zero-ing the payload structure. |
c0a66c84 | 29 | */ |
c0a66c84 JG |
30 | void lttng_payload_init(struct lttng_payload *payload); |
31 | ||
e368fb43 | 32 | /* Copy a payload. */ |
e368fb43 JG |
33 | int lttng_payload_copy(const struct lttng_payload *src_payload, |
34 | struct lttng_payload *dst_payload); | |
35 | ||
fe489250 | 36 | /* Release any memory and references held by the payload. */ |
c0a66c84 JG |
37 | void lttng_payload_reset(struct lttng_payload *payload); |
38 | ||
fe489250 JG |
39 | /* |
40 | * Empty the contents of a payload, releasing all references held. | |
41 | * This should be used to put a payload in a re-usable state. | |
42 | * | |
43 | * lttng_payload_reset must still be called on an lttng_payload to | |
44 | * free all allocated memory. | |
45 | */ | |
fe489250 JG |
46 | void lttng_payload_clear(struct lttng_payload *payload); |
47 | ||
c0a66c84 JG |
48 | /** |
49 | * Add an fd to the payload. | |
fe489250 | 50 | * The payload acquires a reference to the fd_handle. |
c0a66c84 JG |
51 | * |
52 | * @payload Payload instance | |
fe489250 | 53 | * @fd_handle File descriptor handle to add to the payload |
c0a66c84 JG |
54 | * |
55 | * Returns 0 on success, -1 on allocation error. | |
56 | */ | |
fe489250 JG |
57 | int lttng_payload_push_fd_handle(struct lttng_payload *payload, |
58 | struct fd_handle *fd_handle); | |
c0a66c84 JG |
59 | |
60 | #endif /* LTTNG_PAYLOAD_H */ |