1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 17:43:51 +01:00

gnrc ipv6: convenient function to get the header

This commit is contained in:
Oleg Hahm 2016-04-01 21:47:06 +02:00
parent ceab9bd9c3
commit a2b9defc8b
2 changed files with 24 additions and 0 deletions

View File

@ -137,6 +137,19 @@ kernel_pid_t gnrc_ipv6_init(void);
*/
void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *current, gnrc_pktsnip_t *pkt, uint8_t nh);
/**
* @brief Get the IPv6 header from a given list of @ref gnrc_pktsnip_t
*
* This function may be used with e.g. a pointer to a (full) UDP datagram.
*
* @param[in] pkt The pointer to the first @ref gnrc_pktsnip_t of the
* packet.
*
* @return A pointer to the @ref ipv6_hdr_t of the packet.
* @return NULL if the packet does not contain an IPv6 header.
*/
ipv6_hdr_t *gnrc_ipv6_get_header(gnrc_pktsnip_t *pkt);
#ifdef __cplusplus
}
#endif

View File

@ -208,6 +208,17 @@ void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *current, gnrc_pktsnip_t
gnrc_pktbuf_release(pkt);
}
ipv6_hdr_t *gnrc_ipv6_get_header(gnrc_pktsnip_t *pkt)
{
ipv6_hdr_t *hdr = NULL;
gnrc_pktsnip_t *tmp = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_IPV6);
if ((tmp) && ipv6_hdr_is(tmp->data)) {
hdr = ((ipv6_hdr_t*) tmp->data);
}
return hdr;
}
/* internal functions */
static void *_event_loop(void *args)
{