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 | ||
11 | #include <common/dynamic-buffer.h> | |
12 | #include <common/dynamic-array.h> | |
13 | ||
14 | /* | |
15 | * An lttng_payload encompasses the 'data' (bytes) and any passed file | |
16 | * descriptors as part of a message between liblttng-ctl and the session | |
17 | * daemon. | |
18 | */ | |
19 | struct lttng_payload { | |
20 | struct lttng_dynamic_buffer buffer; | |
21 | /* private */ | |
22 | struct lttng_dynamic_array _fds; | |
23 | }; | |
24 | ||
25 | /* | |
26 | * Initialize a payload. This performs no allocation and is meant | |
27 | * to be used instead. | |
28 | */ | |
29 | LTTNG_HIDDEN | |
30 | void lttng_payload_init(struct lttng_payload *payload); | |
31 | ||
32 | /* Release any memory used by the payload. */ | |
33 | LTTNG_HIDDEN | |
34 | void lttng_payload_reset(struct lttng_payload *payload); | |
35 | ||
36 | /** | |
37 | * Add an fd to the payload. | |
38 | * No ownership of the file descriptor is assumed by the payload. | |
39 | * | |
40 | * @payload Payload instance | |
41 | * @fd File descriptor to add to the payload | |
42 | * | |
43 | * Returns 0 on success, -1 on allocation error. | |
44 | */ | |
45 | LTTNG_HIDDEN | |
46 | int lttng_payload_push_fd(struct lttng_payload *payload, int fd); | |
47 | ||
48 | #endif /* LTTNG_PAYLOAD_H */ |