Skip to content

Commit

Permalink
[SQUASH ME] fixes to receive
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Feb 20, 2015
1 parent 569b0e1 commit db2208e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions sys/net/network_layer/ng_ipv6/ng_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,18 @@ static inline bool _pkt_not_for_me(ng_ipv6_hdr_t *hdr)
return (ng_ipv6_netif_find_addr(&out, &hdr->dest) == KERNEL_PID_UNDEF);
}

static _dispatch_received(ng_netreg_entry_t receiver, kernel_pid_t netif,
ng_pktsnip_t *pkt)
static _dispatch_received(ng_nettype_t type, uint16_t demux_ctx,
kernel_pid_t netif, ng_pktsnip_t *pkt)
{
msg_t msg;
ng_netreg_entry_t *entry = ng_netreg_lookup(type, demux);

msg.content.type = NG_NETAPI_MSG_TYPE_RCV;
msg.content.ptr = (char *)pkt;

pktbuf_hold(pkt, ng_netreg_num(receiver) - 1); /* IPv6 is not interested
* anymore so `- 1` */

while (receiver) {
msg_send(&msg, receiver->pid);
receiver = ng_netreg_getnext(receiver);
while (entry) {
msg_send(&msg, entry->pid);
entry = ng_netreg_getnext(entry);
}
}

Expand All @@ -99,7 +97,7 @@ void _handle_receive(kernel_pid_t netif, ng_pktsnip_t *pkt)
{
ng_pktsnip_t *ipv6, *payload;
ng_ipv6_hdr_t *hdr;
ng_netreg_entry_t *receiver = NULL;
ng_nettype_t receiver_type = NG_NETTYPE_UNDEF;

LL_SEARCH_SCALAR(pkt, payload, type, NG_NETTYPE_UNDEF);

Expand Down Expand Up @@ -153,39 +151,41 @@ void _handle_receive(kernel_pid_t netif, ng_pktsnip_t *pkt)

case NG_PROTNUM_ICMPV6:
DEBUG("ipv6: Received ICMPv6 packet.\n");
receiver = ng_netreg_lookup(NG_NETTYPE_ICMPV6, 0);
receiver_type = NG_NETTYPE_ICMPV6;
/* TODO: handle ICMPv6 packet */
break;
#endif
#ifdef MODULE_NG_TCP

case NG_PROTNUM_TCP:
DEBUG("ipv6: Received TCP packet.\n");
receiver = ng_netreg_lookup(NG_NETTYPE_TCP, 0);
receiver_type = NG_NETTYPE_TCP;
break;
#endif
#ifdef MODULE_NG_UDP

case NG_PROTNUM_UDP:
DEBUGF("ipv6: Received UDP packet.\n");
receiver = ng_netreg_lookup(NG_NETTYPE_UDP, 0);
receiver_type = NG_NETTYPE_UDP;
break;
#endif

case NG_PROTNUM_IPV6:
DEBUGF("ipv6: Received encapsulated IPv6 packet.\n");
receiver_type = NG_NETTYPE_IPV6;
_handle_receive(netif, payload);
break;

default:
break;
}

_dispatch_received(receiver, netif, pkt);

receiver = ng_netreg_lookup(NG_NETTYPE_IPV6, hdr->nh);

_dispatch_received(receiver, netif, pkt);
pktbuf_hold(pkt, ng_netreg_num(receiver_type, 0) +
ng_netreg_num(NG_NETTYPE_IPV6, hd->nh) - 1);
/* IPv6 is not interested anymore so `- 1` */
_dispatch_received(receiver_type, 0, netif, pkt);
_dispatch_received(NG_NETTYPE_IPV6, hd->nh, netif, pkt);
}

int _handle_set(ng_netapi_opt_t *conf)
Expand Down

0 comments on commit db2208e

Please sign in to comment.