diff --git a/sys/net/gnrc/netif/hdr/gnrc_netif_hdr.c b/sys/net/gnrc/netif/hdr/gnrc_netif_hdr.c index a97885e8cf3ffbc4dd803b1701131c9a115142df..abdfa1e64680acbcb4cc7c5e5bbd255e19c711d0 100644 --- a/sys/net/gnrc/netif/hdr/gnrc_netif_hdr.c +++ b/sys/net/gnrc/netif/hdr/gnrc_netif_hdr.c @@ -40,59 +40,43 @@ gnrc_pktsnip_t *gnrc_netif_hdr_build(uint8_t *src, uint8_t src_len, uint8_t *dst uint8_t gnrc_netif_hdr_get_flag(gnrc_pktsnip_t* pkt) { - gnrc_netif_hdr_t* netif_hdr; - assert(pkt != NULL); + pkt = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_NETIF); - if (pkt) { - netif_hdr = pkt->data; - if (netif_hdr) { - return netif_hdr->flags; - } + if (pkt && pkt->data) { + gnrc_netif_hdr_t *netif_hdr = pkt->data; + return netif_hdr->flags; } - return 0U; } int gnrc_netif_hdr_get_dstaddr(gnrc_pktsnip_t* pkt, uint8_t** pointer_to_addr) { - int res; - gnrc_netif_hdr_t* netif_hdr; - assert(pkt != NULL); + pkt = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_NETIF); - if (pkt) { - netif_hdr = pkt->data; - if (netif_hdr) { - if ((res = netif_hdr->dst_l2addr_len) <= 0) { - return -ENOENT; - } + if (pkt && pkt->data) { + gnrc_netif_hdr_t *netif_hdr = pkt->data; + if (netif_hdr->dst_l2addr_len > 0) { *pointer_to_addr = gnrc_netif_hdr_get_dst_addr(netif_hdr); - return res; + return netif_hdr->dst_l2addr_len; } } - return -ENOENT; } int gnrc_netif_hdr_get_srcaddr(gnrc_pktsnip_t* pkt, uint8_t** pointer_to_addr) { - int res; - gnrc_netif_hdr_t* netif_hdr; - assert(pkt != NULL); + pkt = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_NETIF); - if (pkt) { - netif_hdr = pkt->data; - if (netif_hdr) { - if ((res = netif_hdr->src_l2addr_len) <= 0) { - return -ENOENT; - } + if (pkt && pkt->data) { + gnrc_netif_hdr_t *netif_hdr = pkt->data; + if (netif_hdr->src_l2addr_len > 0) { *pointer_to_addr = gnrc_netif_hdr_get_src_addr(netif_hdr); - return res; + return netif_hdr->src_l2addr_len; } } - return -ENOENT; }