Skip to content

Commit

Permalink
[SQUASH ME] ng_icmpv6: dependency related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Mar 27, 2015
1 parent d8e083a commit 6ae135e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
1 change: 1 addition & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions sys/net/network_layer/ng_icmpv6/ng_icmpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 13 additions & 9 deletions sys/net/network_layer/ng_ipv6/ng_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 */
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6ae135e

Please sign in to comment.