1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/net/gnrc/sock: cleanup & fix aux handling

The logic used to check whether the RX timestamp was provided in the GNRC
implementation of `sock_ip_recv_buf_aux()` is incorrect: It still uses in-band
signalling via a timestamp of zero, but a dedicated flag was added to allow for
timestamps of zero.

Additionally, it is not necessary to check if a bit is set only to clear it -
clearing it unconditionally is faster and smaller.
This commit is contained in:
Marian Buschsieweke 2021-01-12 21:12:46 +01:00
parent 3fdf9f925e
commit 8f24cc840c
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
2 changed files with 5 additions and 15 deletions

View File

@ -158,18 +158,13 @@ ssize_t sock_ip_recv_buf_aux(sock_ip_t *sock, void **data, void **buf_ctx,
return -EPROTO;
}
#if IS_USED(MODULE_SOCK_AUX_LOCAL)
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_LOCAL)) {
if (aux != NULL) {
aux->flags &= ~(SOCK_AUX_GET_LOCAL);
}
#endif
#if IS_USED(MODULE_SOCK_AUX_TIMESTAMP)
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_TIMESTAMP)) {
/* check if network interface did provide a timestamp; this depends on
* hardware support. A timestamp of zero is used to indicate a missing
* timestamp */
if (aux->timestamp > 0) {
aux->flags &= ~SOCK_AUX_GET_TIMESTAMP;
}
if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP)) {
aux->flags &= ~(SOCK_AUX_GET_TIMESTAMP);
}
#endif
*data = pkt->data;

View File

@ -258,13 +258,8 @@ ssize_t sock_udp_recv_buf_aux(sock_udp_t *sock, void **data, void **buf_ctx,
}
#endif
#if IS_USED(MODULE_SOCK_AUX_TIMESTAMP)
if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_TIMESTAMP)) {
/* check if network interface did provide a timestamp; this depends on
* hardware support. A timestamp of zero is used to indicate a missing
* timestamp */
if (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP) {
aux->flags &= ~SOCK_AUX_GET_TIMESTAMP;
}
if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP)) {
aux->flags &= ~SOCK_AUX_GET_TIMESTAMP;
}
#endif
*data = pkt->data;