465a097cfbcdac0b0530372b63eedc95b329cef6
[lttng-tools.git] / src / common / payload.h
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 of zero-ing the payload structure.
28 */
29 LTTNG_HIDDEN
30 void lttng_payload_init(struct lttng_payload *payload);
31
32 /* Copy a payload. */
33 LTTNG_HIDDEN
34 int lttng_payload_copy(const struct lttng_payload *src_payload,
35 struct lttng_payload *dst_payload);
36
37 /* Release any memory used by the payload. */
38 LTTNG_HIDDEN
39 void lttng_payload_reset(struct lttng_payload *payload);
40
41 /**
42 * Add an fd to the payload.
43 * No ownership of the file descriptor is assumed by the payload.
44 *
45 * @payload Payload instance
46 * @fd File descriptor to add to the payload
47 *
48 * Returns 0 on success, -1 on allocation error.
49 */
50 LTTNG_HIDDEN
51 int lttng_payload_push_fd(struct lttng_payload *payload, int fd);
52
53 #endif /* LTTNG_PAYLOAD_H */
This page took 0.029266 seconds and 3 git commands to generate.