static
int lttng_condition_buffer_usage_serialize(
const struct lttng_condition *condition,
- struct lttng_dynamic_buffer *buf)
+ struct lttng_payload *payload)
{
int ret;
struct lttng_condition_buffer_usage *usage;
usage_comm.threshold = val;
}
- ret = lttng_dynamic_buffer_append(buf, &usage_comm,
+ ret = lttng_dynamic_buffer_append(&payload->buffer, &usage_comm,
sizeof(usage_comm));
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buf, usage->session_name,
+
+ ret = lttng_dynamic_buffer_append(&payload->buffer, usage->session_name,
session_name_len);
if (ret) {
goto end;
}
- ret = lttng_dynamic_buffer_append(buf, usage->channel_name,
+
+ ret = lttng_dynamic_buffer_append(&payload->buffer, usage->channel_name,
channel_name_len);
if (ret) {
goto end;
}
static
-ssize_t init_condition_from_buffer(struct lttng_condition *condition,
- const struct lttng_buffer_view *src_view)
+ssize_t init_condition_from_payload(struct lttng_condition *condition,
+ struct lttng_payload_view *src_view)
{
ssize_t ret, condition_size;
enum lttng_condition_status status;
enum lttng_domain_type domain_type;
- const struct lttng_condition_buffer_usage_comm *condition_comm;
const char *session_name, *channel_name;
struct lttng_buffer_view names_view;
+ const struct lttng_condition_buffer_usage_comm *condition_comm;
+ const struct lttng_payload_view condition_comm_view =
+ lttng_payload_view_from_view(
+ src_view, 0, sizeof(*condition_comm));
- if (src_view->size < sizeof(*condition_comm)) {
+ if (!lttng_payload_view_is_valid(&condition_comm_view)) {
ERR("Failed to initialize from malformed condition buffer: buffer too short to contain header");
ret = -1;
goto end;
}
- condition_comm = (const struct lttng_condition_buffer_usage_comm *) src_view->data;
- names_view = lttng_buffer_view_from_view(src_view,
+ condition_comm = (typeof(condition_comm)) condition_comm_view.buffer.data;
+ names_view = lttng_buffer_view_from_view(&src_view->buffer,
sizeof(*condition_comm), -1);
if (condition_comm->session_name_len > LTTNG_NAME_MAX ||
condition,
fixed_to_double(condition_comm->threshold));
}
+
if (status != LTTNG_CONDITION_STATUS_OK) {
ERR("Failed to initialize buffer usage condition threshold");
ret = -1;
}
LTTNG_HIDDEN
-ssize_t lttng_condition_buffer_usage_low_create_from_buffer(
- const struct lttng_buffer_view *view,
+ssize_t lttng_condition_buffer_usage_low_create_from_payload(
+ struct lttng_payload_view *view,
struct lttng_condition **_condition)
{
ssize_t ret;
goto error;
}
- ret = init_condition_from_buffer(condition, view);
+ ret = init_condition_from_payload(condition, view);
if (ret < 0) {
goto error;
}
}
LTTNG_HIDDEN
-ssize_t lttng_condition_buffer_usage_high_create_from_buffer(
- const struct lttng_buffer_view *view,
+ssize_t lttng_condition_buffer_usage_high_create_from_payload(
+ struct lttng_payload_view *view,
struct lttng_condition **_condition)
{
ssize_t ret;
goto error;
}
- ret = init_condition_from_buffer(condition, view);
+ ret = init_condition_from_payload(condition, view);
if (ret < 0) {
goto error;
}
}
static
-struct lttng_evaluation *create_evaluation_from_buffer(
+struct lttng_evaluation *create_evaluation_from_payload(
enum lttng_condition_type type,
- const struct lttng_buffer_view *view)
+ struct lttng_payload_view *view)
{
const struct lttng_evaluation_buffer_usage_comm *comm =
- (const struct lttng_evaluation_buffer_usage_comm *) view->data;
+ (typeof(comm)) view->buffer.data;
struct lttng_evaluation *evaluation = NULL;
- if (view->size < sizeof(*comm)) {
+ if (view->buffer.size < sizeof(*comm)) {
goto end;
}
}
LTTNG_HIDDEN
-ssize_t lttng_evaluation_buffer_usage_low_create_from_buffer(
- const struct lttng_buffer_view *view,
+ssize_t lttng_evaluation_buffer_usage_low_create_from_payload(
+ struct lttng_payload_view *view,
struct lttng_evaluation **_evaluation)
{
ssize_t ret;
goto error;
}
- evaluation = create_evaluation_from_buffer(
+ evaluation = create_evaluation_from_payload(
LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW, view);
if (!evaluation) {
ret = -1;
}
LTTNG_HIDDEN
-ssize_t lttng_evaluation_buffer_usage_high_create_from_buffer(
- const struct lttng_buffer_view *view,
+ssize_t lttng_evaluation_buffer_usage_high_create_from_payload(
+ struct lttng_payload_view *view,
struct lttng_evaluation **_evaluation)
{
ssize_t ret;
goto error;
}
- evaluation = create_evaluation_from_buffer(
+ evaluation = create_evaluation_from_payload(
LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH, view);
if (!evaluation) {
ret = -1;
static
int lttng_evaluation_buffer_usage_serialize(
const struct lttng_evaluation *evaluation,
- struct lttng_dynamic_buffer *buf)
+ struct lttng_payload *payload)
{
struct lttng_evaluation_buffer_usage *usage;
struct lttng_evaluation_buffer_usage_comm comm;
comm.buffer_use = usage->buffer_use;
comm.buffer_capacity = usage->buffer_capacity;
- return lttng_dynamic_buffer_append(buf, &comm, sizeof(comm));
+ return lttng_dynamic_buffer_append(
+ &payload->buffer, &comm, sizeof(comm));
}
static