Add condition-targeting error query
[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 #include <common/fd-handle.h>
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 */
23 struct lttng_dynamic_pointer_array _fd_handles;
24 };
25
26 /*
27 * Initialize a payload. This performs no allocation and is meant
28 * to be used instead of zero-ing the payload structure.
29 */
30 LTTNG_HIDDEN
31 void lttng_payload_init(struct lttng_payload *payload);
32
33 /* Copy a payload. */
34 LTTNG_HIDDEN
35 int lttng_payload_copy(const struct lttng_payload *src_payload,
36 struct lttng_payload *dst_payload);
37
38 /* Release any memory and references held by the payload. */
39 LTTNG_HIDDEN
40 void lttng_payload_reset(struct lttng_payload *payload);
41
42 /*
43 * Empty the contents of a payload, releasing all references held.
44 * This should be used to put a payload in a re-usable state.
45 *
46 * lttng_payload_reset must still be called on an lttng_payload to
47 * free all allocated memory.
48 */
49 LTTNG_HIDDEN
50 void lttng_payload_clear(struct lttng_payload *payload);
51
52 /**
53 * Add an fd to the payload.
54 * The payload acquires a reference to the fd_handle.
55 *
56 * @payload Payload instance
57 * @fd_handle File descriptor handle to add to the payload
58 *
59 * Returns 0 on success, -1 on allocation error.
60 */
61 LTTNG_HIDDEN
62 int lttng_payload_push_fd_handle(struct lttng_payload *payload,
63 struct fd_handle *fd_handle);
64
65 #endif /* LTTNG_PAYLOAD_H */
This page took 0.030676 seconds and 4 git commands to generate.