Skip to content

Commit

Permalink
fix: use z_reliability enum type to set flag (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland authored May 29, 2024
1 parent aa46390 commit cfd8a89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions include/zenoh-pico/protocol/definitions/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,12 @@ _z_transport_message_t _z_t_msg_make_open_syn(_z_zint_t lease, _z_zint_t initial
_z_transport_message_t _z_t_msg_make_open_ack(_z_zint_t lease, _z_zint_t initial_sn);
_z_transport_message_t _z_t_msg_make_close(uint8_t reason, _Bool link_only);
_z_transport_message_t _z_t_msg_make_keep_alive(void);
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, _Bool is_reliable);
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliable);
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, _Bool is_reliable, _Bool is_last);
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_bytes_t messages, _Bool is_reliable, _Bool is_last);
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages,
z_reliability_t reliability);
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, z_reliability_t reliability);
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, z_reliability_t reliability, _Bool is_last);
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_bytes_t messages, z_reliability_t reliability,
_Bool is_last);

/*------------------ Copy ------------------*/
void _z_t_msg_copy(_z_transport_message_t *clone, _z_transport_message_t *msg);
Expand Down
18 changes: 10 additions & 8 deletions src/protocol/definitions/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,13 @@ _z_transport_message_t _z_t_msg_make_keep_alive(void) {
return msg;
}

_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages, _Bool is_reliable) {
_z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_t messages,
z_reliability_t reliability) {
_z_transport_message_t msg;
msg._header = _Z_MID_T_FRAME;

msg._body._frame._sn = sn;
if (is_reliable == true) {
if (reliability == Z_RELIABILITY_RELIABLE) {
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAME_R);
}

Expand All @@ -218,12 +219,12 @@ _z_transport_message_t _z_t_msg_make_frame(_z_zint_t sn, _z_network_message_vec_
}

/*------------------ Frame Message ------------------*/
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliable) {
_z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, z_reliability_t reliability) {
_z_transport_message_t msg;
msg._header = _Z_MID_T_FRAME;

msg._body._frame._sn = sn;
if (is_reliable == true) {
if (reliability == Z_RELIABILITY_RELIABLE) {
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAME_R);
}

Expand All @@ -233,16 +234,17 @@ _z_transport_message_t _z_t_msg_make_frame_header(_z_zint_t sn, _Bool is_reliabl
}

/*------------------ Fragment Message ------------------*/
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, _Bool is_reliable, _Bool is_last) {
return _z_t_msg_make_fragment(sn, _z_bytes_empty(), is_reliable, is_last);
_z_transport_message_t _z_t_msg_make_fragment_header(_z_zint_t sn, z_reliability_t reliability, _Bool is_last) {
return _z_t_msg_make_fragment(sn, _z_bytes_empty(), reliability, is_last);
}
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_bytes_t payload, _Bool is_reliable, _Bool is_last) {
_z_transport_message_t _z_t_msg_make_fragment(_z_zint_t sn, _z_bytes_t payload, z_reliability_t reliability,
_Bool is_last) {
_z_transport_message_t msg;
msg._header = _Z_MID_T_FRAGMENT;
if (is_last == false) {
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAGMENT_M);
}
if (is_reliable == true) {
if (reliability == Z_RELIABILITY_RELIABLE) {
_Z_SET_FLAG(msg._header, _Z_FLAG_T_FRAGMENT_R);
}

Expand Down

0 comments on commit cfd8a89

Please sign in to comment.