diff --git a/tests/gnrc_sock_ip/Makefile b/tests/gnrc_sock_ip/Makefile index 737b60e7fb..212af52183 100644 --- a/tests/gnrc_sock_ip/Makefile +++ b/tests/gnrc_sock_ip/Makefile @@ -2,6 +2,7 @@ include ../Makefile.tests_common AUX_LOCAL ?= 1 AUX_TIMESTAMP ?= 1 +AUX_RSSI ?= 1 ifeq (1, $(AUX_LOCAL)) USEMODULE += sock_aux_local @@ -11,6 +12,10 @@ ifeq (1, $(AUX_TIMESTAMP)) USEMODULE += sock_aux_timestamp endif +ifeq (1, $(AUX_RSSI)) + USEMODULE += sock_aux_rssi +endif + USEMODULE += sock_ip USEMODULE += gnrc_ipv6 USEMODULE += ps diff --git a/tests/gnrc_sock_ip/main.c b/tests/gnrc_sock_ip/main.c index fb8c3ae66b..ec69bf92eb 100644 --- a/tests/gnrc_sock_ip/main.c +++ b/tests/gnrc_sock_ip/main.c @@ -352,7 +352,7 @@ static void test_sock_ip_recv__aux(void) static const inject_aux_t inject_aux = { .timestamp = 42 }; sock_ip_ep_t result; sock_ip_aux_rx_t aux = { - .flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP + .flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP | SOCK_AUX_GET_RSSI }; expect(0 == sock_ip_create(&_sock, &local, NULL, _TEST_PROTO, @@ -376,6 +376,12 @@ static void test_sock_ip_recv__aux(void) expect(aux.timestamp == inject_aux.timestamp); #else expect(aux.flags & SOCK_AUX_GET_TIMESTAMP); +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) + expect(!(aux.flags & SOCK_AUX_GET_RSSI)); + expect(aux.rssi == inject_aux.rssi); +#else + expect(aux.flags & SOCK_AUX_GET_RSSI); #endif expect(_check_net()); } diff --git a/tests/gnrc_sock_ip/stack.c b/tests/gnrc_sock_ip/stack.c index 5fa35c787f..3f23ffccd3 100644 --- a/tests/gnrc_sock_ip/stack.c +++ b/tests/gnrc_sock_ip/stack.c @@ -72,6 +72,7 @@ static gnrc_pktsnip_t *_build_ipv6_packet(const ipv6_addr_t *src, netif_hdr->if_pid = (kernel_pid_t)netif; if (aux) { gnrc_netif_hdr_set_timestamp(netif_hdr, aux->timestamp); + netif_hdr->rssi = aux->rssi; } return gnrc_pkt_append(payload, netif_hdr_snip); } diff --git a/tests/gnrc_sock_ip/stack.h b/tests/gnrc_sock_ip/stack.h index b2e3e804dc..75484ae631 100644 --- a/tests/gnrc_sock_ip/stack.h +++ b/tests/gnrc_sock_ip/stack.h @@ -44,6 +44,7 @@ void _prepare_send_checks(void); */ typedef struct { uint64_t timestamp; /**< Timestamp of reception */ + int16_t rssi; /**< Fake RSSI value */ } inject_aux_t; /** diff --git a/tests/gnrc_sock_udp/Makefile b/tests/gnrc_sock_udp/Makefile index 749135a2b4..caa22a1f4c 100644 --- a/tests/gnrc_sock_udp/Makefile +++ b/tests/gnrc_sock_udp/Makefile @@ -2,6 +2,7 @@ include ../Makefile.tests_common AUX_LOCAL ?= 1 AUX_TIMESTAMP ?= 1 +AUX_RSSI ?= 1 ifeq (1, $(AUX_LOCAL)) USEMODULE += sock_aux_local @@ -11,6 +12,10 @@ ifeq (1, $(AUX_TIMESTAMP)) USEMODULE += sock_aux_timestamp endif +ifeq (1, $(AUX_RSSI)) + USEMODULE += sock_aux_rssi +endif + USEMODULE += gnrc_sock_check_reuse USEMODULE += sock_udp USEMODULE += gnrc_ipv6 diff --git a/tests/gnrc_sock_udp/main.c b/tests/gnrc_sock_udp/main.c index c12e06d893..b367b97e1e 100644 --- a/tests/gnrc_sock_udp/main.c +++ b/tests/gnrc_sock_udp/main.c @@ -429,10 +429,10 @@ static void test_sock_udp_recv__aux(void) static const ipv6_addr_t dst_addr = { .u8 = _TEST_ADDR_LOCAL }; static const sock_udp_ep_t local = { .family = AF_INET6, .port = _TEST_PORT_LOCAL }; - static const inject_aux_t inject_aux = { .timestamp = 1337 }; + static const inject_aux_t inject_aux = { .timestamp = 1337, .rssi = -11 }; sock_udp_ep_t result; sock_udp_aux_rx_t aux = { - .flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP + .flags = SOCK_AUX_GET_LOCAL | SOCK_AUX_GET_TIMESTAMP | SOCK_AUX_GET_RSSI }; expect(0 == sock_udp_create(&_sock, &local, NULL, SOCK_FLAGS_REUSE_EP)); @@ -458,6 +458,12 @@ static void test_sock_udp_recv__aux(void) expect(inject_aux.timestamp == aux.timestamp); #else expect(aux.flags & SOCK_AUX_GET_TIMESTAMP); +#endif +#if IS_USED(MODULE_SOCK_AUX_RSSI) + expect(!(aux.flags & SOCK_AUX_GET_RSSI)); + expect(inject_aux.rssi == aux.rssi); +#else + expect(aux.flags & SOCK_AUX_GET_RSSI); #endif expect(_check_net()); } diff --git a/tests/gnrc_sock_udp/stack.c b/tests/gnrc_sock_udp/stack.c index a5c7556117..f3957f5b8f 100644 --- a/tests/gnrc_sock_udp/stack.c +++ b/tests/gnrc_sock_udp/stack.c @@ -95,6 +95,7 @@ static gnrc_pktsnip_t *_build_udp_packet(const ipv6_addr_t *src, netif_hdr->if_pid = (kernel_pid_t)netif; if (aux) { gnrc_netif_hdr_set_timestamp(netif_hdr, aux->timestamp); + netif_hdr->rssi = aux->rssi; } return gnrc_pkt_append(udp, netif_hdr_snip); } diff --git a/tests/gnrc_sock_udp/stack.h b/tests/gnrc_sock_udp/stack.h index 6975c1c01e..e8adc5d7c4 100644 --- a/tests/gnrc_sock_udp/stack.h +++ b/tests/gnrc_sock_udp/stack.h @@ -44,6 +44,7 @@ void _prepare_send_checks(void); */ typedef struct { uint64_t timestamp; /**< Timestamp of reception */ + int16_t rssi; /**< Fake RSSI value */ } inject_aux_t; /**