X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fpayload.h;fp=src%2Fcommon%2Fpayload.h;h=3f1aa8cfdf3573e1ee41f5b5ee5043fd50fd2870;hp=0000000000000000000000000000000000000000;hb=9e620ea7b016fc3fd4e08b5d094ffa40b36b50f6;hpb=5fe3e097f121a17b37c098f87cba2b4a51d6208b diff --git a/src/common/payload.h b/src/common/payload.h new file mode 100644 index 000000000..3f1aa8cfd --- /dev/null +++ b/src/common/payload.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 Jérémie Galarneau + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#ifndef LTTNG_PAYLOAD_H +#define LTTNG_PAYLOAD_H + +#include +#include + +/* + * An lttng_payload encompasses the 'data' (bytes) and any passed file + * descriptors as part of a message between liblttng-ctl and the session + * daemon. + */ +struct lttng_payload { + struct lttng_dynamic_buffer buffer; + /* private */ + struct lttng_dynamic_array _fds; +}; + +/* + * Initialize a payload. This performs no allocation and is meant + * to be used instead. + */ +LTTNG_HIDDEN +void lttng_payload_init(struct lttng_payload *payload); + +/* Release any memory used by the payload. */ +LTTNG_HIDDEN +void lttng_payload_reset(struct lttng_payload *payload); + +/** + * Add an fd to the payload. + * No ownership of the file descriptor is assumed by the payload. + * + * @payload Payload instance + * @fd File descriptor to add to the payload + * + * Returns 0 on success, -1 on allocation error. + */ +LTTNG_HIDDEN +int lttng_payload_push_fd(struct lttng_payload *payload, int fd); + +#endif /* LTTNG_PAYLOAD_H */