diff --git a/include/zenoh-pico/protocol/codec/message.h b/include/zenoh-pico/protocol/codec/message.h index c40f2824a..1ad2de4ba 100644 --- a/include/zenoh-pico/protocol/codec/message.h +++ b/include/zenoh-pico/protocol/codec/message.h @@ -18,6 +18,9 @@ #include "zenoh-pico/protocol/definitions/network.h" #include "zenoh-pico/protocol/iobuf.h" +int8_t _z_push_body_encode(_z_wbuf_t *wbf, const _z_push_body_t *pshb); +int8_t _z_push_body_decode(_z_push_body_t *body, _z_zbuf_t *zbf, uint8_t header); + int8_t _z_query_encode(_z_wbuf_t *wbf, const _z_msg_query_t *query); int8_t _z_query_decode(_z_msg_query_t *query, _z_zbuf_t *zbf, uint8_t header); @@ -27,9 +30,6 @@ int8_t _z_reply_decode(_z_msg_reply_t *reply, _z_zbuf_t *zbf, uint8_t header); int8_t _z_err_encode(_z_wbuf_t *wbf, const _z_msg_err_t *err); int8_t _z_err_decode(_z_msg_err_t *err, _z_zbuf_t *zbf, uint8_t header); -int8_t _z_push_body_encode(_z_wbuf_t *wbf, const _z_push_body_t *pshb); -int8_t _z_push_body_decode(_z_push_body_t *body, _z_zbuf_t *zbf, uint8_t header); - int8_t _z_put_encode(_z_wbuf_t *wbf, const _z_msg_put_t *put); int8_t _z_put_decode(_z_msg_put_t *put, _z_zbuf_t *zbf, uint8_t header); diff --git a/include/zenoh-pico/protocol/definitions/network.h b/include/zenoh-pico/protocol/definitions/network.h index 55fad899b..94d7736c8 100644 --- a/include/zenoh-pico/protocol/definitions/network.h +++ b/include/zenoh-pico/protocol/definitions/network.h @@ -183,14 +183,10 @@ typedef struct { enum { _Z_RESPONSE_BODY_REPLY, _Z_RESPONSE_BODY_ERR, - _Z_RESPONSE_BODY_PUT, - _Z_RESPONSE_BODY_DEL, } _tag; union { _z_msg_reply_t _reply; _z_msg_err_t _err; - _z_msg_put_t _put; - _z_msg_del_t _del; } _body; } _z_n_msg_response_t; void _z_n_msg_response_clear(_z_n_msg_response_t *msg); diff --git a/src/protocol/codec/network.c b/src/protocol/codec/network.c index 2c60d2f4c..53d534e6f 100644 --- a/src/protocol/codec/network.c +++ b/src/protocol/codec/network.c @@ -298,14 +298,6 @@ int8_t _z_response_encode(_z_wbuf_t *wbf, const _z_n_msg_response_t *msg) { _Z_RETURN_IF_ERR(_z_err_encode(wbf, &msg->_body._err)); break; } - case _Z_RESPONSE_BODY_PUT: { - _Z_RETURN_IF_ERR(_z_put_encode(wbf, &msg->_body._put)); - break; - } - case _Z_RESPONSE_BODY_DEL: { - _Z_RETURN_IF_ERR(_z_del_encode(wbf, &msg->_body._del)); - break; - } } return ret; @@ -368,16 +360,6 @@ int8_t _z_response_decode(_z_n_msg_response_t *msg, _z_zbuf_t *zbf, uint8_t head ret = _z_err_decode(&msg->_body._err, zbf, inner_header); break; } - case _Z_MID_Z_PUT: { - msg->_tag = _Z_RESPONSE_BODY_PUT; - ret = _z_put_decode(&msg->_body._put, zbf, inner_header); - break; - } - case _Z_MID_Z_DEL: { - msg->_tag = _Z_RESPONSE_BODY_DEL; - ret = _z_del_decode(&msg->_body._del, zbf, inner_header); - break; - } default: { _Z_ERROR("Unknown N_MID: %d", _Z_MID(inner_header)); ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; diff --git a/src/protocol/definitions/network.c b/src/protocol/definitions/network.c index 3ba4df67e..9836113cb 100644 --- a/src/protocol/definitions/network.c +++ b/src/protocol/definitions/network.c @@ -97,13 +97,6 @@ void _z_n_msg_response_clear(_z_n_msg_response_t *msg) { _z_msg_err_clear(&msg->_body._err); break; } - case _Z_RESPONSE_BODY_PUT: { - _z_msg_put_clear(&msg->_body._put); - break; - } - case _Z_RESPONSE_BODY_DEL: { - break; - } } } diff --git a/src/session/rx.c b/src/session/rx.c index 7f5b6e209..451ed1551 100644 --- a/src/session/rx.c +++ b/src/session/rx.c @@ -152,33 +152,6 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint _Z_ERROR("Received Err for query %zu: message=%.*s", response._request_id, (int)payload.len, payload.start); } break; - case _Z_RESPONSE_BODY_PUT: { - _z_msg_put_t put = response._body._put; -#if Z_FEATURE_SUBSCRIPTION == 1 -#if Z_FEATURE_ATTACHMENT == 1 - z_attachment_t att = _z_encoded_as_attachment(&put._attachment); -#endif - ret = _z_trigger_subscriptions(zn, response._key, put._payload, put._encoding, Z_SAMPLE_KIND_PUT, - put._commons._timestamp -#if Z_FEATURE_ATTACHMENT == 1 - , - att -#endif - ); -#endif - } break; - case _Z_RESPONSE_BODY_DEL: { - _z_msg_del_t del = response._body._del; -#if Z_FEATURE_SUBSCRIPTION == 1 - ret = _z_trigger_subscriptions(zn, response._key, _z_bytes_empty(), z_encoding_default(), - Z_SAMPLE_KIND_DELETE, del._commons._timestamp -#if Z_FEATURE_ATTACHMENT == 1 - , - z_attachment_null() -#endif - ); -#endif - } break; } } break; case _Z_N_RESPONSE_FINAL: { diff --git a/tests/z_msgcodec_test.c b/tests/z_msgcodec_test.c index 586cee3e5..cd7f562f1 100644 --- a/tests/z_msgcodec_test.c +++ b/tests/z_msgcodec_test.c @@ -1283,26 +1283,16 @@ _z_n_msg_response_t gen_response(void) { ._ext_timestamp = gen_bool() ? gen_timestamp() : _z_timestamp_null(), ._ext_responder = {._eid = gen_uint16(), ._zid = gen_zid()}, }; - switch (gen_uint() % 3) { + switch (gen_uint() % 2) { case 0: { ret._tag = _Z_RESPONSE_BODY_ERR; ret._body._err = gen_err(); } break; - case 1: { + case 1: + default: { ret._tag = _Z_RESPONSE_BODY_REPLY; ret._body._reply = gen_reply(); } break; - case 2: - default: { - _z_push_body_t body = gen_push_body(); - if (body._is_put) { - ret._tag = _Z_RESPONSE_BODY_PUT; - ret._body._put = body._body._put; - } else { - ret._tag = _Z_RESPONSE_BODY_DEL; - ret._body._del = body._body._del; - } - } break; } return ret; } @@ -1321,14 +1311,7 @@ void assert_eq_response(const _z_n_msg_response_t *left, const _z_n_msg_response } break; case _Z_RESPONSE_BODY_ERR: { assert_eq_err(&left->_body._err, &right->_body._err); - } break; - case _Z_RESPONSE_BODY_PUT: { - assert_eq_push_body(&(_z_push_body_t){._is_put = true, ._body._put = left->_body._put}, - &(_z_push_body_t){._is_put = true, ._body._put = right->_body._put}); - } break; - case _Z_RESPONSE_BODY_DEL: { - assert_eq_push_body(&(_z_push_body_t){._is_put = false, ._body._del = left->_body._del}, - &(_z_push_body_t){._is_put = false, ._body._del = right->_body._del}); + } break; } }