Skip to content

Commit

Permalink
move qos functions back to header and remove usage of designated init…
Browse files Browse the repository at this point in the history
…ializers
  • Loading branch information
DenisBiryukov91 committed Feb 24, 2024
1 parent 8e37ab8 commit cac8b3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
17 changes: 13 additions & 4 deletions include/zenoh-pico/protocol/definitions/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,19 @@

typedef _z_qos_t _z_n_qos_t;

_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority);
z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos);
z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos);
_Bool _z_n_qos_get_express(_z_n_qos_t n_qos);
static inline _z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) {
_z_n_qos_t ret;
_Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1;
ret._val = (uint8_t)((express << 4) | (nodrop << 3) | priority);
return ret;
}
static inline z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) {
return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */);
}
static inline z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) {
return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP;
}
static inline _Bool _z_n_qos_get_express(_z_n_qos_t n_qos) { return (_Bool)(n_qos._val & 0x10 /* 0b10000 */); }
#define _z_n_qos_make(express, nodrop, priority) \
_z_n_qos_create((_Bool)express, nodrop ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP, \
(z_priority_t)priority)
Expand Down
9 changes: 0 additions & 9 deletions src/protocol/definitions/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,3 @@ void _z_msg_fix_mapping(_z_zenoh_message_t *msg, uint16_t mapping) {
break;
}
}
_z_qos_t _z_n_qos_create(_Bool express, z_congestion_control_t congestion_control, z_priority_t priority) {
_Bool nodrop = congestion_control == Z_CONGESTION_CONTROL_DROP ? 0 : 1;
_z_n_qos_t ret = {._val = (uint8_t)((express << 4) | (nodrop << 3) | priority)};
return ret;
}
z_priority_t _z_n_qos_get_priority(_z_n_qos_t n_qos) { return (z_priority_t)(n_qos._val & 0x07 /* 0b111 */); }
z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t n_qos) {
return (n_qos._val & 0x08 /* 0b1000 */) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP;
}

0 comments on commit cac8b3d

Please sign in to comment.