Skip to content

Commit

Permalink
more tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
p-avital committed Jul 11, 2023
1 parent 4b29c02 commit 3d9c435
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 161 deletions.
9 changes: 8 additions & 1 deletion include/zenoh-pico/protocol/codec/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

#include "zenoh-pico/protocol/definitions/transport.h"
#include "zenoh-pico/protocol/iobuf.h"
#define _ZENOH_PICO_FRAME_MESSAGES_VEC_SIZE 32

int8_t _z_scouting_message_encode(_z_wbuf_t *buf, const _z_scouting_message_t *msg);
int8_t _z_scouting_message_decode(_z_scouting_message_t *msg, _z_zbuf_t *buf);
int8_t _z_scouting_message_decode_na(_z_scouting_message_t *msg, _z_zbuf_t *buf);

int8_t _z_transport_message_encode(_z_wbuf_t *buf, const _z_transport_message_t *msg);
int8_t _z_transport_message_decode(_z_transport_message_t *msg, _z_zbuf_t *buf);
Expand All @@ -41,4 +42,10 @@ int8_t _z_keep_alive_decode(_z_t_msg_keep_alive_t *msg, _z_zbuf_t *zbf, uint8_t

int8_t _z_frame_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_frame_t *msg);
int8_t _z_frame_decode(_z_t_msg_frame_t *msg, _z_zbuf_t *zbf, uint8_t header);

int8_t _z_fragment_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_fragment_t *msg);
int8_t _z_fragment_decode(_z_t_msg_fragment_t *msg, _z_zbuf_t *zbf, uint8_t header);

int8_t _z_transport_message_encode(_z_wbuf_t *wbf, const _z_transport_message_t *msg);
int8_t _z_transport_message_decode(_z_transport_message_t *msg, _z_zbuf_t *zbf);
#endif /* INCLUDE_ZENOH_PICO_PROTOCOL_CODEC_TRANSPORT_H */
149 changes: 0 additions & 149 deletions include/zenoh-pico/protocol/msgcodec.h

This file was deleted.

1 change: 0 additions & 1 deletion include/zenoh-pico/transport/link/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define ZENOH_PICO_TRANSPORT_LINK_RX_H

#include "zenoh-pico/link/link.h"
#include "zenoh-pico/protocol/msgcodec.h"
#include "zenoh-pico/transport/transport.h"

/*------------------ Transmission and Reception helpers ------------------*/
Expand Down
1 change: 0 additions & 1 deletion src/protocol/codec/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "zenoh-pico/protocol/ext.h"
#include "zenoh-pico/protocol/iobuf.h"
#include "zenoh-pico/protocol/keyexpr.h"
#include "zenoh-pico/protocol/msgcodec.h"
#include "zenoh-pico/utils/logging.h"
#include "zenoh-pico/utils/result.h"

Expand Down
2 changes: 1 addition & 1 deletion src/protocol/codec/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "zenoh-pico/protocol/definitions/message.h"
#include "zenoh-pico/protocol/ext.h"
#include "zenoh-pico/protocol/iobuf.h"
#include "zenoh-pico/protocol/msgcodec.h"
#include "zenoh-pico/utils/logging.h"
#include "zenoh-pico/utils/result.h"

Expand Down Expand Up @@ -380,6 +379,7 @@ int8_t _z_response_decode(_z_n_msg_response_t *msg, _z_zbuf_t *zbf, uint8_t head
break;
}
default: {
_Z_ERROR("Unknown N_MID: %d\n", _Z_MID(inner_header));
ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED;
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/protocol/codec/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
// ZettaScale Zenoh Team, <[email protected]>
//

#include "zenoh-pico/protocol/definitions/transport.h"

#include <stddef.h>
#include <stdint.h>

#include "zenoh-pico/protocol/codec/core.h"
#include "zenoh-pico/protocol/codec/ext.h"
#include "zenoh-pico/protocol/codec/network.h"
#include "zenoh-pico/protocol/codec/transport.h"
#include "zenoh-pico/protocol/definitions/core.h"
#include "zenoh-pico/protocol/ext.h"
#include "zenoh-pico/protocol/iobuf.h"
#include "zenoh-pico/protocol/msgcodec.h"
#include "zenoh-pico/utils/logging.h"
#include "zenoh-pico/utils/result.h"
/*------------------ Join Message ------------------*/
Expand Down Expand Up @@ -94,6 +96,7 @@ int8_t _z_join_decode_ext(_z_msg_ext_t *extension, void *ctx) {
int8_t _z_join_decode(_z_t_msg_join_t *msg, _z_zbuf_t *zbf, uint8_t header) {
_Z_DEBUG("Decoding _Z_MID_T_JOIN\n");
int8_t ret = _Z_RES_OK;
*msg = (_z_t_msg_join_t){0};

ret |= _z_uint8_decode(&msg->_version, zbf);

Expand Down Expand Up @@ -172,6 +175,7 @@ int8_t _z_init_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_init_t *msg

int8_t _z_init_decode(_z_t_msg_init_t *msg, _z_zbuf_t *zbf, uint8_t header) {
_Z_DEBUG("Decoding _Z_MID_T_INIT\n");
*msg = (_z_t_msg_init_t){0};
int8_t ret = _Z_RES_OK;

ret |= _z_uint8_decode(&msg->_version, zbf);
Expand Down Expand Up @@ -238,6 +242,7 @@ int8_t _z_open_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_open_t *msg
int8_t _z_open_decode(_z_t_msg_open_t *msg, _z_zbuf_t *zbf, uint8_t header) {
_Z_DEBUG("Decoding _Z_MID_T_OPEN\n");
int8_t ret = _Z_RES_OK;
*msg = (_z_t_msg_open_t){0};

ret |= _z_zint_decode(&msg->_lease, zbf);
if ((ret == _Z_RES_OK) && (_Z_HAS_FLAG(header, _Z_FLAG_T_OPEN_T) == true)) {
Expand Down Expand Up @@ -275,6 +280,7 @@ int8_t _z_close_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_close_t *m
int8_t _z_close_decode(_z_t_msg_close_t *msg, _z_zbuf_t *zbf, uint8_t header) {
(void)(header);
int8_t ret = _Z_RES_OK;
*msg = (_z_t_msg_close_t){0};
_Z_DEBUG("Decoding _Z_MID_T_CLOSE\n");

ret |= _z_uint8_decode(&msg->_reason, zbf);
Expand All @@ -298,6 +304,7 @@ int8_t _z_keep_alive_decode(_z_t_msg_keep_alive_t *msg, _z_zbuf_t *zbf, uint8_t
(void)(msg);
(void)(zbf);
(void)(header);
*msg = (_z_t_msg_keep_alive_t){0};

int8_t ret = _Z_RES_OK;
_Z_DEBUG("Decoding _Z_MID_T_KEEP_ALIVE\n");
Expand Down Expand Up @@ -331,6 +338,7 @@ int8_t _z_frame_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_frame_t *m

int8_t _z_frame_decode(_z_t_msg_frame_t *msg, _z_zbuf_t *zbf, uint8_t header) {
int8_t ret = _Z_RES_OK;
*msg = (_z_t_msg_frame_t){0};

ret |= _z_zint_decode(&msg->_sn, zbf);
if ((ret == _Z_RES_OK) && (_Z_HAS_FLAG(header, _Z_FLAG_T_Z) == true)) {
Expand Down Expand Up @@ -381,6 +389,8 @@ int8_t _z_fragment_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_fragmen

int8_t _z_fragment_decode(_z_t_msg_fragment_t *msg, _z_zbuf_t *zbf, uint8_t header) {
int8_t ret = _Z_RES_OK;
*msg = (_z_t_msg_fragment_t){0};

_Z_DEBUG("Decoding _Z_TRANSPORT_FRAGMENT\n");
ret |= _z_zint_decode(&msg->_sn, zbf);

Expand Down Expand Up @@ -424,8 +434,6 @@ int8_t _z_extensions_decode(_z_msg_ext_vec_t *v_ext, _z_zbuf_t *zbf, uint8_t hea
int8_t _z_transport_message_encode(_z_wbuf_t *wbf, const _z_transport_message_t *msg) {
int8_t ret = _Z_RES_OK;

// Encode the decorators if present

uint8_t header = msg->_header;

_Z_RETURN_IF_ERR(_z_wbuf_write(wbf, header))
Expand Down
1 change: 0 additions & 1 deletion src/session/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "zenoh-pico/protocol/definitions/message.h"
#include "zenoh-pico/protocol/definitions/network.h"
#include "zenoh-pico/protocol/keyexpr.h"
#include "zenoh-pico/protocol/msgcodec.h"
#include "zenoh-pico/session/query.h"
#include "zenoh-pico/session/queryable.h"
#include "zenoh-pico/session/resource.h"
Expand Down
1 change: 0 additions & 1 deletion src/transport/unicast/link/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "zenoh-pico/protocol/codec/network.h"
#include "zenoh-pico/protocol/codec/transport.h"
#include "zenoh-pico/protocol/iobuf.h"
#include "zenoh-pico/protocol/msgcodec.h"
#include "zenoh-pico/transport/utils.h"
#include "zenoh-pico/utils/logging.h"

Expand Down
Loading

0 comments on commit 3d9c435

Please sign in to comment.