1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_ipv6: remove special handling for encapsulated IPv6 headers

Since the packet is now guaranteed to be preparsed, the currently
handled IPv6 header will always be in the first snip. Because of this
the packet parser can't get confused anymore which IPv6 header is the
one to be handled so we don't need to remove the more outer ones.
Because of this we can just use the normal packet dispatching (which is
already used by other `GNRC_NETTYPE_*`-known protocol numbers such as
UDP).

This also reverts d54ac38f84.
This commit is contained in:
Martine Lenders 2018-11-08 12:52:48 +01:00
parent 2b280f867e
commit 3fde0ef8f8

View File

@ -72,9 +72,6 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr);
/* Main event loop for IPv6 */
static void *_event_loop(void *args);
/* Handles encapsulated IPv6 packets: http://tools.ietf.org/html/rfc2473 */
static void _decapsulate(gnrc_pktsnip_t *pkt);
kernel_pid_t gnrc_ipv6_init(void)
{
if (gnrc_ipv6_pid == KERNEL_PID_UNDEF) {
@ -128,11 +125,6 @@ void gnrc_ipv6_demux(gnrc_netif_t *netif, gnrc_pktsnip_t *current,
break;
#endif
case PROTNUM_IPV6:
assert(current == pkt);
interested = true;
break;
default:
(void)netif;
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC_NHC
@ -181,10 +173,6 @@ void gnrc_ipv6_demux(gnrc_netif_t *netif, gnrc_pktsnip_t *current,
return;
#endif
case PROTNUM_IPV6:
DEBUG("ipv6: handle encapsulated IPv6 packet (nh = %u)\n", nh);
_decapsulate(pkt);
return;
default:
assert(false);
break;
@ -213,11 +201,9 @@ static void _dispatch_next_header(gnrc_pktsnip_t *current, gnrc_pktsnip_t *pkt,
{
#ifdef MODULE_GNRC_IPV6_EXT
const bool should_dispatch_current_type = ((current->type != GNRC_NETTYPE_IPV6_EXT) ||
(current->next->type == GNRC_NETTYPE_IPV6)) &&
(current->type != GNRC_NETTYPE_IPV6);
(current->next->type == GNRC_NETTYPE_IPV6));
#else
const bool should_dispatch_current_type = (current->next->type == GNRC_NETTYPE_IPV6) &&
(current->type != GNRC_NETTYPE_IPV6);
const bool should_dispatch_current_type = (current->next->type == GNRC_NETTYPE_IPV6);
#endif
DEBUG("ipv6: forward nh = %u to other threads\n", nh);
@ -880,24 +866,4 @@ static void _receive(gnrc_pktsnip_t *pkt)
gnrc_ipv6_demux(netif, pkt, pkt, hdr->nh);
}
static void _decapsulate(gnrc_pktsnip_t *pkt)
{
gnrc_pktsnip_t *ptr = pkt;
pkt->type = GNRC_NETTYPE_UNDEF; /* prevent payload (the encapsulated packet)
* from being removed */
/* Remove encapsulating IPv6 header */
while ((ptr->next != NULL) && (ptr->next->type == GNRC_NETTYPE_IPV6)) {
gnrc_pktbuf_remove_snip(pkt, pkt->next);
}
pkt->type = GNRC_NETTYPE_IPV6;
if (gnrc_netapi_dispatch_receive(GNRC_NETTYPE_IPV6,
GNRC_NETREG_DEMUX_CTX_ALL, pkt) == 0) {
gnrc_pktbuf_release(pkt);
}
}
/** @} */