diff --git a/Makefile.dep b/Makefile.dep index f96fdfbb9c4e..d8127b5cb76d 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -58,6 +58,7 @@ ifneq (,$(filter ng_ipv6_router,$(USEMODULE))) endif ifneq (,$(filter ng_ipv6,$(USEMODULE))) + USEMODULE += ng_icmpv6 USEMODULE += ng_ipv6_addr USEMODULE += ng_ipv6_nc USEMODULE += ng_ipv6_netif diff --git a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c index cd4535f8b78d..34bdeacc183f 100644 --- a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c +++ b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c @@ -69,22 +69,10 @@ void ng_icmpv6_demux(ng_pktsnip_t *pkt) LL_SEARCH_SCALAR(pkt, icmpv6, type, NG_NETTYPE_ICMPV6); - if (icmpv6 == NULL) { - DEBUG("icmpv6: received packet has no payload\n"); - /* don't release: IPv6 does this */ - return; - } - /* there can be extension headers between IPv6 and ICMPv6 header so we have * to search it */ LL_SEARCH_SCALAR(icmpv6, ipv6, type, NG_NETTYPE_IPV6); - if (ipv6 == NULL) { - DEBUG("ipv6: received packet has no IPv6 header\n"); - /* don't release: IPv6 does this */ - return; - } - hdr = (ng_icmpv6_hdr_t *)icmpv6->data; if (_icmpv6_inet_csum((ng_ipv6_hdr_t *)(ipv6->data), hdr, icmpv6->size) != 0xffff) { diff --git a/sys/net/network_layer/ng_ipv6/ng_ipv6.c b/sys/net/network_layer/ng_ipv6/ng_ipv6.c index 1aecc5e8ba6c..dd04ee5730c8 100644 --- a/sys/net/network_layer/ng_ipv6/ng_ipv6.c +++ b/sys/net/network_layer/ng_ipv6/ng_ipv6.c @@ -76,8 +76,16 @@ static void _dispatch_received(ng_nettype_t type, uint32_t demux_ctx, while (entry) { DEBUG("ipv6: Send receive command for %p to %" PRIu16 "\n", (void *)pkt, entry->pid); - msg_send(&msg, entry->pid); - entry = ng_netreg_getnext(entry); + + if ((type == NG_NETTYPE_ICMPV6) && (entry->pid == thread_getpid())) { + /* might happen because IPv6 are also registered to ICMPv6 */ + ng_pktbuf_release(pkt); + } + else { + msg_send(&msg, entry->pid); + entry = ng_netreg_getnext(entry); + } + } } @@ -127,13 +135,10 @@ static void _handle_send(ng_pktsnip_t *pkt, bool redirect, bool set_src) if (!redirect) { if (hdr->nh == NG_PROTNUM_RESERVED) { switch (payload->type) { -#ifdef MODULE_NG_ICMPV6 - case NG_NETTYPE_ICMPV6: DEBUG("ipv6: Set next header to ICMPv6.\n"); hdr->nh = NG_PROTNUM_ICMPV6; break; -#endif #ifdef MODULE_NG_TCP case NG_NETTYPE_TCP: @@ -271,6 +276,7 @@ static void _handle_send(ng_pktsnip_t *pkt, bool redirect, bool set_src) ng_ipv6_addr_to_str(addr_str, src, sizeof(addr_str))); memcpy(&hdr->src, src, sizeof(ng_ipv6_addr_t)); } + /* Otherwise leave unspecified */ } @@ -637,8 +643,9 @@ static void *_ipv6_thread(void *args) me_reg.demux_ctx = NG_NETREG_DEMUX_CTX_ALL; me_reg.pid = thread_getpid(); - /* register interest in all IPv6 packets */ + /* register interest in all IPv6 and ICMPv6 packets */ ng_netreg_register(NG_NETTYPE_IPV6, &me_reg); + ng_netreg_register(NG_NETTYPE_ICMPV6, &me_reg); /* preinitialize ACK */ reply.type = NG_NETAPI_MSG_TYPE_ACK; @@ -682,15 +689,12 @@ static void *_ipv6_thread(void *args) ng_nettype_t ng_ipv6_demux(ng_pktsnip_t *pkt, uint8_t nh) { switch (nh) { -#ifdef MODULE_NG_ICMPV6 - case NG_PROTNUM_ICMPV6: DEBUG("ipv6: Received ICMPv6 packet.\n"); pkt->type = NG_NETTYPE_ICMPV6; /* preset needed for further * handling*/ ng_icmpv6_demux(pkt); return NG_NETTYPE_ICMPV6; -#endif #ifdef MODULE_NG_TCP case NG_PROTNUM_TCP: