diff --git a/sys/include/net/gnrc/netif/hdr.h b/sys/include/net/gnrc/netif/hdr.h index 28d871d1f51fb5fafdeb311dc784ce5896187f39..5e7675466f9a6306ec0f6223133fe74de8ae1463 100644 --- a/sys/include/net/gnrc/netif/hdr.h +++ b/sys/include/net/gnrc/netif/hdr.h @@ -26,6 +26,7 @@ #include "net/gnrc/pkt.h" #include "net/gnrc/pktbuf.h" +#include "net/gnrc/netif.h" #ifdef __cplusplus extern "C" { @@ -212,6 +213,23 @@ static inline void gnrc_netif_hdr_set_dst_addr(gnrc_netif_hdr_t *hdr, uint8_t *a */ gnrc_pktsnip_t *gnrc_netif_hdr_build(uint8_t *src, uint8_t src_len, uint8_t *dst, uint8_t dst_len); +/** + * @brief Convenience function to get the corresponding interface struct for + * a given interface header + * + * @pre `hdr != NULL` + * + * @param[in] hdr Header to read interface from. + * + * @return The @ref gnrc_netif_t representation of the interface on success + * @return NULL, on error. + */ +static inline gnrc_netif_t *gnrc_netif_hdr_get_netif(const gnrc_netif_hdr_t *hdr) +{ + assert(hdr != NULL); + return gnrc_netif_get_by_pid(hdr->if_pid); +} + /** * @brief Outputs a generic interface header to stdout. *