#include <common/macros.h>
#include <common/buffer-view.h>
#include <common/dynamic-buffer.h>
-#include <common/sessiond-comm/payload-view.h>
-#include <common/sessiond-comm/payload.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
#include <stdbool.h>
#include <sys/types.h>
#include <urcu/ref.h>
#include <lttng/condition/condition.h>
#include <common/macros.h>
-#include <common/sessiond-comm/payload-view.h>
-#include <common/sessiond-comm/payload.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
#include <stdbool.h>
#include <urcu/list.h>
#include <stdint.h>
#include "common/compat/socket.h"
#include "common/dynamic-buffer.h"
#include "common/dynamic-array.h"
-#include "common/sessiond-comm/payload.h"
-#include "common/sessiond-comm/payload-view.h"
+#include "common/payload.h"
+#include "common/payload-view.h"
#include "common/sessiond-comm/sessiond-comm.h"
#include "lttng/lttng-error.h"
#include "lttng/tracker.h"
*/
#include "bin/lttng-sessiond/tracker.h"
-#include "common/sessiond-comm/payload.h"
#include "lttng/lttng-error.h"
#include "lttng/tracker.h"
#define _LGPL_SOURCE
#include <common/kernel-ctl/kernel-ctl.h>
#include <common/dynamic-buffer.h>
#include <common/buffer-view.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <common/trace-chunk.h>
#include <lttng/location-internal.h>
#include <lttng/trigger/trigger-internal.h>
#include <urcu/wfcqueue.h>
#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/payload.h>
+#include <common/payload.h>
#include <common/compat/poll.h>
#include <common/compat/socket.h>
#include <common/uuid.h>
mi-lttng.c mi-lttng.h \
notification.c \
optional.h \
+ payload.c payload.h \
+ payload-view.c payload-view.h \
pipe.c pipe.h \
readwrite.c readwrite.h \
runas.c runas.h \
#include <assert.h>
#include <common/dynamic-array.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <common/error.h>
#include <common/macros.h>
#include <lttng/action/action-internal.h>
#include <common/error.h>
#include <common/macros.h>
#include <common/snapshot.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/snapshot-session-internal.h>
#include <lttng/action/snapshot-session.h>
#include <lttng/condition/evaluation-internal.h>
#include <lttng/condition/condition.h>
#include <lttng/condition/evaluation.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <assert.h>
LTTNG_HIDDEN
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <common/buffer-view.h>
+#include "payload-view.h"
+#include "payload.h"
+#include <stddef.h>
+
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_payload(
+ const struct lttng_payload *payload, size_t offset,
+ ptrdiff_t len)
+{
+ return (struct lttng_payload_view) {
+ .buffer = lttng_buffer_view_from_dynamic_buffer(
+ &payload->buffer, offset, len),
+ ._fds = payload->_fds,
+ };
+}
+
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_view(
+ struct lttng_payload_view *view, size_t offset,
+ ptrdiff_t len)
+{
+ return (struct lttng_payload_view) {
+ .buffer = lttng_buffer_view_from_view(
+ &view->buffer, offset, len),
+ ._fds = view->_fds,
+ ._iterator.p_fds_position = &view->_iterator.fds_position,
+ };
+}
+
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
+ const struct lttng_dynamic_buffer *buffer, size_t offset,
+ ptrdiff_t len)
+{
+ return (struct lttng_payload_view) {
+ .buffer = lttng_buffer_view_from_dynamic_buffer(
+ buffer, offset, len)
+ };
+}
+
+LTTNG_HIDDEN
+int lttng_payload_view_pop_fd(struct lttng_payload_view *view)
+{
+ int ret = 0;
+ size_t fd_count;
+ size_t *pos;
+
+ if (!view) {
+ ret = -1;
+ goto end;
+ }
+
+ fd_count = lttng_dynamic_array_get_count(&view->_fds);
+ pos = view->_iterator.p_fds_position ? view->_iterator.p_fds_position :
+ &view->_iterator.fds_position;
+
+ if (*pos >= fd_count) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = *((int *) lttng_dynamic_array_get_element(
+ &view->_fds, *pos));
+ (*pos)++;
+end:
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_VIEW_H
+#define LTTNG_PAYLOAD_VIEW_H
+
+#include <common/buffer-view.h>
+#include <common/dynamic-array.h>
+
+struct lttng_payload;
+
+/*
+ * An lttng_payload_view references a payload and allows code to share
+ * a `const` version of a subset of a payload.
+ *
+ * A payload view is invalidated whenever its source (a payload, or another
+ * payload view) is modified.
+ *
+ * While a payload view does not allow users to modify the underlying bytes
+ * of the payload, it can be used to 'pop' file descriptors using an iterator
+ * belonging to the top-level payload view.
+ *
+ * Hence, a payload view created from a payload or a dynamic buffer contains
+ * an implicit file descriptor iterator. Any payload view created from another
+ * payload view will share the same underlying file descriptor iterator.
+ *
+ * The rationale for this is that a payload is never consumed directly, it
+ * must be consumed through a payload view.
+ *
+ * Typically, a payload view will be used to rebuild a previously serialized
+ * object hierarchy. Sharing an underlying iterator allows aggregate objects
+ * to provide a restricted view of the payload to their members, which will
+ * report the number of bytes consumed and `pop` the file descriptors they
+ * should own. In return, those objects can create an even narrower view for
+ * their children, allowing them to also consume file descriptors.
+ *
+ * Note that a payload view never assumes any ownership of the underlying
+ * payload.
+ */
+struct lttng_payload_view {
+ struct lttng_buffer_view buffer;
+ /* private */
+ const struct lttng_dynamic_array _fds;
+ struct {
+ size_t *p_fds_position;
+ size_t fds_position;
+ } _iterator;
+};
+
+/**
+ * Return a payload view referencing a subset of a payload.
+ *
+ * @payload Source payload to reference
+ * @offset Offset to apply to the payload's buffer
+ * @len Length of the contents to reference. Passing -1 will
+ * cause the view to reference the whole payload from the
+ * offset provided.
+ */
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_payload(
+ const struct lttng_payload *payload, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a payload referenced by
+ * another payload view.
+ *
+ * @view Source payload view to reference
+ * @offset Offset to apply to the payload view's buffer view
+ * @len Length of the contents to reference. Passing -1 will
+ * cause the payload view to reference the whole payload view's
+ * buffer view from the offset provided.
+ */
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_view(
+ struct lttng_payload_view *view, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a dynamic buffer.
+ *
+ * Meant as an adapter for code paths that need to create a payload view
+ * from an existing dynamic buffer.
+ *
+ * @src Source dynamic buffer to reference
+ * @offset Offset to apply to the payload's buffer
+ * @len Length of the buffer contents to reference. Passing -1 will
+ * cause the payload view to reference the whole payload from the
+ * offset provided.
+ */
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
+ const struct lttng_dynamic_buffer *buffer, size_t offset,
+ ptrdiff_t len);
+
+/**
+ * Pop an fd from a payload view.
+ * No ownership of the file descriptor is assumed by the payload.
+ *
+ * @payload Payload instance
+ *
+ * Returns a file descriptor on success, -1 on error.
+ */
+LTTNG_HIDDEN
+int lttng_payload_view_pop_fd(struct lttng_payload_view *payload_view);
+
+#endif /* LTTNG_PAYLOAD_VIEW_H */
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include "payload.h"
+
+LTTNG_HIDDEN
+void lttng_payload_init(struct lttng_payload *payload)
+{
+ assert(payload);
+ lttng_dynamic_buffer_init(&payload->buffer);
+ lttng_dynamic_array_init(&payload->_fds, sizeof(int), NULL);
+}
+
+LTTNG_HIDDEN
+void lttng_payload_reset(struct lttng_payload *payload)
+{
+ if (!payload) {
+ return;
+ }
+
+ lttng_dynamic_buffer_reset(&payload->buffer);
+ lttng_dynamic_array_reset(&payload->_fds);
+}
+
+LTTNG_HIDDEN
+int lttng_payload_push_fd(struct lttng_payload *payload, int fd)
+{
+ int ret;
+
+ if (!payload) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = lttng_dynamic_array_add_element(&payload->_fds, &fd);
+end:
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_H
+#define LTTNG_PAYLOAD_H
+
+#include <common/dynamic-buffer.h>
+#include <common/dynamic-array.h>
+
+/*
+ * 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 */
libsessiond_comm_la_SOURCES = sessiond-comm.c sessiond-comm.h \
inet.c inet.h inet6.c inet6.h \
- relayd.h agent.h payload.h \
- payload.c payload-view.h payload-view.c
+ relayd.h agent.h
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <common/buffer-view.h>
-#include "payload-view.h"
-#include "payload.h"
-#include <stddef.h>
-
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_payload(
- const struct lttng_payload *payload, size_t offset,
- ptrdiff_t len)
-{
- return (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_from_dynamic_buffer(
- &payload->buffer, offset, len),
- ._fds = payload->_fds,
- };
-}
-
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_view(
- struct lttng_payload_view *view, size_t offset,
- ptrdiff_t len)
-{
- return (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_from_view(
- &view->buffer, offset, len),
- ._fds = view->_fds,
- ._iterator.p_fds_position = &view->_iterator.fds_position,
- };
-}
-
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
- const struct lttng_dynamic_buffer *buffer, size_t offset,
- ptrdiff_t len)
-{
- return (struct lttng_payload_view) {
- .buffer = lttng_buffer_view_from_dynamic_buffer(
- buffer, offset, len)
- };
-}
-
-LTTNG_HIDDEN
-int lttng_payload_view_pop_fd(struct lttng_payload_view *view)
-{
- int ret = 0;
- size_t fd_count;
- size_t *pos;
-
- if (!view) {
- ret = -1;
- goto end;
- }
-
- fd_count = lttng_dynamic_array_get_count(&view->_fds);
- pos = view->_iterator.p_fds_position ? view->_iterator.p_fds_position :
- &view->_iterator.fds_position;
-
- if (*pos >= fd_count) {
- ret = -1;
- goto end;
- }
-
- ret = *((int *) lttng_dynamic_array_get_element(
- &view->_fds, *pos));
- (*pos)++;
-end:
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_VIEW_H
-#define LTTNG_PAYLOAD_VIEW_H
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-
-struct lttng_payload;
-
-/*
- * An lttng_payload_view references a payload and allows code to share
- * a `const` version of a subset of a payload.
- *
- * A payload view is invalidated whenever its source (a payload, or another
- * payload view) is modified.
- *
- * While a payload view does not allow users to modify the underlying bytes
- * of the payload, it can be used to 'pop' file descriptors using an iterator
- * belonging to the top-level payload view.
- *
- * Hence, a payload view created from a payload or a dynamic buffer contains
- * an implicit file descriptor iterator. Any payload view created from another
- * payload view will share the same underlying file descriptor iterator.
- *
- * The rationale for this is that a payload is never consumed directly, it
- * must be consumed through a payload view.
- *
- * Typically, a payload view will be used to rebuild a previously serialized
- * object hierarchy. Sharing an underlying iterator allows aggregate objects
- * to provide a restricted view of the payload to their members, which will
- * report the number of bytes consumed and `pop` the file descriptors they
- * should own. In return, those objects can create an even narrower view for
- * their children, allowing them to also consume file descriptors.
- *
- * Note that a payload view never assumes any ownership of the underlying
- * payload.
- */
-struct lttng_payload_view {
- struct lttng_buffer_view buffer;
- /* private */
- const struct lttng_dynamic_array _fds;
- struct {
- size_t *p_fds_position;
- size_t fds_position;
- } _iterator;
-};
-
-/**
- * Return a payload view referencing a subset of a payload.
- *
- * @payload Source payload to reference
- * @offset Offset to apply to the payload's buffer
- * @len Length of the contents to reference. Passing -1 will
- * cause the view to reference the whole payload from the
- * offset provided.
- */
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_payload(
- const struct lttng_payload *payload, size_t offset,
- ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a payload referenced by
- * another payload view.
- *
- * @view Source payload view to reference
- * @offset Offset to apply to the payload view's buffer view
- * @len Length of the contents to reference. Passing -1 will
- * cause the payload view to reference the whole payload view's
- * buffer view from the offset provided.
- */
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_view(
- struct lttng_payload_view *view, size_t offset,
- ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a dynamic buffer.
- *
- * Meant as an adapter for code paths that need to create a payload view
- * from an existing dynamic buffer.
- *
- * @src Source dynamic buffer to reference
- * @offset Offset to apply to the payload's buffer
- * @len Length of the buffer contents to reference. Passing -1 will
- * cause the payload view to reference the whole payload from the
- * offset provided.
- */
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
- const struct lttng_dynamic_buffer *buffer, size_t offset,
- ptrdiff_t len);
-
-/**
- * Pop an fd from a payload view.
- * No ownership of the file descriptor is assumed by the payload.
- *
- * @payload Payload instance
- *
- * Returns a file descriptor on success, -1 on error.
- */
-LTTNG_HIDDEN
-int lttng_payload_view_pop_fd(struct lttng_payload_view *payload_view);
-
-#endif /* LTTNG_PAYLOAD_VIEW_H */
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include "payload.h"
-
-LTTNG_HIDDEN
-void lttng_payload_init(struct lttng_payload *payload)
-{
- assert(payload);
- lttng_dynamic_buffer_init(&payload->buffer);
- lttng_dynamic_array_init(&payload->_fds, sizeof(int), NULL);
-}
-
-LTTNG_HIDDEN
-void lttng_payload_reset(struct lttng_payload *payload)
-{
- if (!payload) {
- return;
- }
-
- lttng_dynamic_buffer_reset(&payload->buffer);
- lttng_dynamic_array_reset(&payload->_fds);
-}
-
-LTTNG_HIDDEN
-int lttng_payload_push_fd(struct lttng_payload *payload, int fd)
-{
- int ret;
-
- if (!payload) {
- ret = -1;
- goto end;
- }
-
- ret = lttng_dynamic_array_add_element(&payload->_fds, &fd);
-end:
- return ret;
-}
+++ /dev/null
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_H
-#define LTTNG_PAYLOAD_H
-
-#include <common/dynamic-buffer.h>
-#include <common/dynamic-array.h>
-
-/*
- * 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 */
*
*/
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <common/snapshot.h>
#include <lttng/snapshot-internal.h>
#include <lttng/snapshot.h>
#include <lttng/trigger/trigger-internal.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/action/action-internal.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <common/error.h>
#include <assert.h>
#include <common/compat/string.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <fcntl.h>
#include <lttng/constant.h>
#include <lttng/userspace-probe-internal.h>
#include <common/compat/string.h>
#include <common/defaults.h>
#include <common/dynamic-buffer.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <common/sessiond-comm/sessiond-comm.h>
#include <common/tracker.h>
#include <common/uri.h>
*
*/
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
#include <tap/tap.h>
static const int TEST_COUNT = 5;