mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
gnrc ipv6: convenient function to get the header
This commit is contained in:
parent
ceab9bd9c3
commit
a2b9defc8b
@ -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);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -208,6 +208,17 @@ void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *current, gnrc_pktsnip_t
|
|||||||
gnrc_pktbuf_release(pkt);
|
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 */
|
/* internal functions */
|
||||||
static void *_event_loop(void *args)
|
static void *_event_loop(void *args)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user