From e439767f457db6ef038df7ad4974c55383452e77 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 5 Jul 2024 11:01:58 +0200 Subject: [PATCH] Add missed z_query_reply_options_t fields (#509) --- include/zenoh-pico/api/types.h | 8 ++++++++ include/zenoh-pico/net/primitives.h | 3 ++- src/api/api.c | 7 ++++++- src/net/primitives.c | 9 ++++++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/zenoh-pico/api/types.h b/include/zenoh-pico/api/types.h index fad6ca960..c6e1a9cab 100644 --- a/include/zenoh-pico/api/types.h +++ b/include/zenoh-pico/api/types.h @@ -242,10 +242,18 @@ typedef struct { * * Members: * z_owned_encoding_t *encoding: The encoding of the payload. + * z_congestion_control_t congestion_control: The congestion control to apply when routing this message. + * z_priority_t priority: The priority of this message when routed. + * z_timestamp_t *timestamp: The API level timestamp (e.g. of the data when it was created). + * _Bool is_express: If true, Zenoh will not wait to batch this operation with others to reduce the bandwith. * z_owned_bytes_t *attachment: An optional attachment to the response. */ typedef struct { z_owned_encoding_t *encoding; + z_congestion_control_t congestion_control; + z_priority_t priority; + z_timestamp_t *timestamp; + _Bool is_express; z_owned_bytes_t *attachment; } z_query_reply_options_t; diff --git a/include/zenoh-pico/net/primitives.h b/include/zenoh-pico/net/primitives.h index 2d7ecffa8..38da173f5 100644 --- a/include/zenoh-pico/net/primitives.h +++ b/include/zenoh-pico/net/primitives.h @@ -201,7 +201,8 @@ int8_t _z_undeclare_queryable(_z_queryable_t *qle); * attachment: An optional attachment to the reply. */ int8_t _z_send_reply(const _z_query_t *query, const _z_keyexpr_t keyexpr, const _z_value_t payload, - const z_sample_kind_t kind, const _z_bytes_t attachment); + const z_sample_kind_t kind, const z_congestion_control_t cong_ctrl, z_priority_t priority, + _Bool is_express, const _z_timestamp_t *timestamp, const _z_bytes_t attachment); #endif #if Z_FEATURE_QUERY == 1 diff --git a/src/api/api.c b/src/api/api.c index 32fd0aa14..21f88ec7f 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -1205,6 +1205,10 @@ int8_t z_undeclare_queryable(z_owned_queryable_t *queryable) { void z_query_reply_options_default(z_query_reply_options_t *options) { options->encoding = NULL; + options->priority = Z_PRIORITY_DEFAULT; + options->encoding = NULL; + options->timestamp = NULL; + options->is_express = false; options->attachment = NULL; } @@ -1221,7 +1225,8 @@ int8_t z_query_reply(const z_loaned_query_t *query, const z_loaned_keyexpr_t *ke .encoding = _z_encoding_from_owned(opts.encoding)}; int8_t ret = - _z_send_reply(&query->in->val, *keyexpr, value, Z_SAMPLE_KIND_PUT, _z_bytes_from_owned_bytes(opts.attachment)); + _z_send_reply(&query->in->val, *keyexpr, value, Z_SAMPLE_KIND_PUT, opts.congestion_control, opts.priority, + opts.is_express, opts.timestamp, _z_bytes_from_owned_bytes(opts.attachment)); if (payload != NULL) { z_bytes_drop(payload); } diff --git a/src/net/primitives.c b/src/net/primitives.c index c3ae63d69..570866e75 100644 --- a/src/net/primitives.c +++ b/src/net/primitives.c @@ -307,7 +307,8 @@ int8_t _z_undeclare_queryable(_z_queryable_t *qle) { } int8_t _z_send_reply(const _z_query_t *query, _z_keyexpr_t keyexpr, const _z_value_t payload, - const z_sample_kind_t kind, const _z_bytes_t att) { + const z_sample_kind_t kind, const z_congestion_control_t cong_ctrl, z_priority_t priority, + _Bool is_express, const _z_timestamp_t *timestamp, const _z_bytes_t att) { int8_t ret = _Z_RES_OK; _z_keyexpr_t q_ke; @@ -337,14 +338,16 @@ int8_t _z_send_reply(const _z_query_t *query, _z_keyexpr_t keyexpr, const _z_val z_msg._body._response._key = ke; z_msg._body._response._ext_responder._zid = zid; z_msg._body._response._ext_responder._eid = 0; - z_msg._body._response._ext_qos = _Z_N_QOS_DEFAULT; + z_msg._body._response._ext_qos = + _z_n_qos_make(is_express, cong_ctrl == Z_CONGESTION_CONTROL_BLOCK, priority); z_msg._body._response._ext_timestamp = _z_timestamp_null(); z_msg._body._response._tag = _Z_RESPONSE_BODY_REPLY; z_msg._body._response._body._reply._consolidation = Z_CONSOLIDATION_MODE_DEFAULT; z_msg._body._response._body._reply._body._is_put = true; z_msg._body._response._body._reply._body._body._put._payload = payload.payload; z_msg._body._response._body._reply._body._body._put._encoding = payload.encoding; - z_msg._body._response._body._reply._body._body._put._commons._timestamp = _z_timestamp_null(); + z_msg._body._response._body._reply._body._body._put._commons._timestamp = + (timestamp != NULL) ? *timestamp : _z_timestamp_null(); z_msg._body._response._body._reply._body._body._put._commons._source_info = _z_source_info_null(); z_msg._body._response._body._reply._body._body._put._attachment = att; break;