+ struct lttng_dynamic_buffer buffer;
+ struct lttng_buffer_view view;
+ size_t context_len;
+ ssize_t sock_recv_len;
+ enum lttng_domain_type domain = cmd_ctx->lsm->domain.type;
+ struct ltt_session *session = cmd_ctx->session;
+ const char *channel_name = cmd_ctx->lsm->u.context.channel_name;
+
+ lttng_dynamic_buffer_init(&buffer);
+
+ context_len = (size_t) cmd_ctx->lsm->u.context.length;
+ ret = lttng_dynamic_buffer_set_size(&buffer, context_len);
+ if (ret) {
+ ret = LTTNG_ERR_NOMEM;
+ goto end;
+ }
+
+ sock_recv_len = lttcomm_recv_unix_sock(sock, buffer.data, context_len);
+ if (sock_recv_len < 0 || sock_recv_len != context_len) {
+ ERR("Failed to receive \"add context\" command payload");
+ ret = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ view = lttng_buffer_view_from_dynamic_buffer(&buffer, 0, -1);
+
+ if (lttng_event_context_create_from_buffer(&view, &ctx) !=
+ context_len) {
+ ERR("Invalid event context payload received in \"add context\" command");
+ ret = LTTNG_ERR_INVALID;
+ goto end;
+ }