diff --git a/sys/net/gnrc/sock/gnrc_sock.c b/sys/net/gnrc/sock/gnrc_sock.c index aabee4c349..b70928ccb2 100644 --- a/sys/net/gnrc/sock/gnrc_sock.c +++ b/sys/net/gnrc/sock/gnrc_sock.c @@ -174,6 +174,12 @@ ssize_t gnrc_sock_recv(gnrc_sock_reg_t *reg, gnrc_pktsnip_t **pkt_out, } } #endif /* MODULE_SOCK_AUX_TIMESTAMP */ +#if IS_USED(MODULE_SOCK_AUX_RSSI) + if ((aux->rssi) && (netif_hdr->rssi != GNRC_NETIF_HDR_NO_RSSI)) { + aux->flags |= GNRC_SOCK_RECV_AUX_FLAG_RSSI; + *aux->rssi = netif_hdr->rssi; + } +#endif /* MODULE_SOCK_AUX_RSSI */ } *pkt_out = pkt; /* set out parameter */ diff --git a/sys/net/gnrc/sock/include/gnrc_sock_internal.h b/sys/net/gnrc/sock/include/gnrc_sock_internal.h index 485278f742..550a0e164a 100644 --- a/sys/net/gnrc/sock/include/gnrc_sock_internal.h +++ b/sys/net/gnrc/sock/include/gnrc_sock_internal.h @@ -72,6 +72,9 @@ typedef struct { #endif #if IS_USED(MODULE_SOCK_AUX_TIMESTAMP) || DOXYGEN uint64_t *timestamp; /**< timestamp PDU was received at in nanoseconds */ +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) || DOXYGEN + int16_t *rssi; /**< RSSI value of received PDU */ #endif /** * @brief Flags @@ -80,6 +83,7 @@ typedef struct { } gnrc_sock_recv_aux_t; #define GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP 0x01 /**< Timestamp valid */ +#define GNRC_SOCK_RECV_AUX_FLAG_RSSI 0x02 /**< RSSI valid */ /** * @brief Internal helper functions for GNRC diff --git a/sys/net/gnrc/sock/ip/gnrc_sock_ip.c b/sys/net/gnrc/sock/ip/gnrc_sock_ip.c index ee3de88fdf..ac649d3c54 100644 --- a/sys/net/gnrc/sock/ip/gnrc_sock_ip.c +++ b/sys/net/gnrc/sock/ip/gnrc_sock_ip.c @@ -139,6 +139,11 @@ ssize_t sock_ip_recv_buf_aux(sock_ip_t *sock, void **data, void **buf_ctx, if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_TIMESTAMP)) { _aux.timestamp = &aux->timestamp; } +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) + if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_RSSI)) { + _aux.rssi = &aux->rssi; + } #endif res = gnrc_sock_recv((gnrc_sock_reg_t *)sock, &pkt, timeout, &tmp, &_aux); if (res < 0) { @@ -166,6 +171,11 @@ ssize_t sock_ip_recv_buf_aux(sock_ip_t *sock, void **data, void **buf_ctx, if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP)) { aux->flags &= ~(SOCK_AUX_GET_TIMESTAMP); } +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) + if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_RSSI)) { + aux->flags &= ~(SOCK_AUX_GET_RSSI); + } #endif *data = pkt->data; *buf_ctx = pkt; diff --git a/sys/net/gnrc/sock/udp/gnrc_sock_udp.c b/sys/net/gnrc/sock/udp/gnrc_sock_udp.c index caf03da1e8..b9d91dea9f 100644 --- a/sys/net/gnrc/sock/udp/gnrc_sock_udp.c +++ b/sys/net/gnrc/sock/udp/gnrc_sock_udp.c @@ -228,6 +228,11 @@ ssize_t sock_udp_recv_buf_aux(sock_udp_t *sock, void **data, void **buf_ctx, if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_TIMESTAMP)) { _aux.timestamp = &aux->timestamp; } +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) + if ((aux != NULL) && (aux->flags & SOCK_AUX_GET_RSSI)) { + _aux.rssi = &aux->rssi; + } #endif res = gnrc_sock_recv((gnrc_sock_reg_t *)sock, &pkt, timeout, &tmp, &_aux); if (res < 0) { @@ -261,6 +266,11 @@ ssize_t sock_udp_recv_buf_aux(sock_udp_t *sock, void **data, void **buf_ctx, if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_TIMESTAMP)) { aux->flags &= ~SOCK_AUX_GET_TIMESTAMP; } +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) + if ((aux != NULL) && (_aux.flags & GNRC_SOCK_RECV_AUX_FLAG_RSSI)) { + aux->flags &= ~SOCK_AUX_GET_RSSI; + } #endif *data = pkt->data; *buf_ctx = pkt;