diff --git a/sys/include/net/ndp.h b/sys/include/net/ndp.h index 01751bb380..fd43a05cd0 100644 --- a/sys/include/net/ndp.h +++ b/sys/include/net/ndp.h @@ -334,10 +334,27 @@ typedef struct __attribute__((packed)) { } ndp_opt_mtu_t; /** - * @brief Recursive DNS server option format + * @brief Recursive DNS server option format without payload * @extends ndp_opt_t * * @see [RFC 8106, section 5.1](https://tools.ietf.org/html/rfc8106#section-5.1) + * @see ndp_opt_rdnss_impl_t + */ +typedef struct __attribute__((packed)) { + uint8_t type; /**< option type */ + uint8_t len; /**< length in units of 8 octets */ + network_uint16_t resv; /**< reserved field */ + network_uint32_t ltime; /**< lifetime in seconds */ +} ndp_opt_rdnss_t; + +#ifndef __cplusplus +/** + * @brief Recursive DNS server option format with payload + * @extends ndp_opt_rdnss_t + * @details Auxiliary struct that contains a zero-length array as convenience + * pointer to the addresses. Only for use in C, invalid in ISO-C++. + * + * @see [RFC 8106, section 5.1](https://tools.ietf.org/html/rfc8106#section-5.1) */ typedef struct __attribute__((packed)) { uint8_t type; /**< option type */ @@ -345,7 +362,8 @@ typedef struct __attribute__((packed)) { network_uint16_t resv; /**< reserved field */ network_uint32_t ltime; /**< lifetime in seconds */ ipv6_addr_t addrs[]; /**< addresses of IPv6 recursive DNS servers */ -} ndp_opt_rdnss_t; +} ndp_opt_rdnss_impl_t; +#endif #ifdef __cplusplus } diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib.c b/sys/net/gnrc/network_layer/ipv6/nib/nib.c index 793ad3ac50..1ef481ed9c 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c @@ -413,7 +413,7 @@ static void _handle_mtuo(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, const ndp_opt_mtu_t *mtuo); #if GNRC_IPV6_NIB_CONF_DNS static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, - const ndp_opt_rdnss_t *rdnsso); + const ndp_opt_rdnss_impl_t *rdnsso); #endif #if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, @@ -732,7 +732,7 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6, case NDP_OPT_RDNSS: next_timeout = _min(_handle_rdnsso(netif, (icmpv6_hdr_t *)rtr_adv, - (ndp_opt_rdnss_t *)opt), + (ndp_opt_rdnss_impl_t *)opt), next_timeout); break; #endif @@ -1352,7 +1352,7 @@ static void _handle_mtuo(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, #if GNRC_IPV6_NIB_CONF_DNS static uint32_t _handle_rdnsso(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, - const ndp_opt_rdnss_t *rdnsso) + const ndp_opt_rdnss_impl_t *rdnsso) { uint32_t ltime = UINT32_MAX; const ipv6_addr_t *addr; diff --git a/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c b/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c index c42477cfee..5110065529 100644 --- a/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c +++ b/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c @@ -234,7 +234,7 @@ gnrc_pktsnip_t *gnrc_ndp_opt_rdnss_build(uint32_t ltime, ipv6_addr_t *addrs, gnrc_pktsnip_t *pkt = gnrc_ndp_opt_build(NDP_OPT_RDNSS, opt_size, next); if (pkt != NULL) { - ndp_opt_rdnss_t *rdnss_opt = pkt->data; + ndp_opt_rdnss_impl_t *rdnss_opt = pkt->data; rdnss_opt->resv.u16 = 0; rdnss_opt->ltime = byteorder_htonl(ltime); for (unsigned i = 0; i < addrs_num; i++) {