1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

gnrc_ipv6: dispatch ext. headers to external interested parties

This way e.g. a raw socket listening for an extension headers protocol
number also get's it.
This commit is contained in:
Martine Lenders 2018-10-24 18:03:39 +02:00 committed by Martine Lenders
parent e4fa14370f
commit 0580fa5852
2 changed files with 22 additions and 0 deletions

View File

@ -41,6 +41,9 @@ extern "C" {
/**
* @brief Demultiplex an extension header according to @p nh.
*
* This includes dispatching it to interested parties in the
* @ref net_gnrc_netreg.
*
* @param[in] pkt A packet with the first snip pointing to the extension
* header to process.
* @param[in] nh Protocol number of @p pkt.

View File

@ -19,6 +19,7 @@
#include "utlist.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/pktbuf.h"
#include "net/gnrc/icmpv6/error.h"
#include "net/gnrc/ipv6.h"
@ -258,6 +259,24 @@ gnrc_pktsnip_t *gnrc_ipv6_ext_demux(gnrc_pktsnip_t *pkt, unsigned nh)
gnrc_pktbuf_release(pkt);
return NULL;
}
if (gnrc_netreg_num(GNRC_NETTYPE_IPV6, nh) > 0) {
gnrc_pktsnip_t *sub_pkt;
/* enforce duplication so we can dispatch packet to subscriber(s) and
* handle the packet */
gnrc_pktbuf_hold(pkt, 1);
sub_pkt = gnrc_pktbuf_start_write(pkt);
if (sub_pkt != NULL) {
/* check in case subscriber unregistered in the meantime */
if (gnrc_netapi_dispatch_receive(GNRC_NETTYPE_IPV6, nh, sub_pkt) == 0) {
gnrc_pktbuf_release(sub_pkt);
};
}
else {
gnrc_pktbuf_release(pkt);
/* try to keep handling, the sockets aren't *that* important anyway :-P */
}
}
switch (nh) {
case PROTNUM_IPV6_EXT_RH:
#ifdef MODULE_GNRC_RPL_SRH