From dae00a81fba428bfedbdeed5ea14641baa076072 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 1 Jul 2015 13:41:15 +0200 Subject: [PATCH] ng_nomac: use dispatch function --- sys/net/link_layer/ng_nomac/ng_nomac.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sys/net/link_layer/ng_nomac/ng_nomac.c b/sys/net/link_layer/ng_nomac/ng_nomac.c index 107d916907..70326652a9 100644 --- a/sys/net/link_layer/ng_nomac/ng_nomac.c +++ b/sys/net/link_layer/ng_nomac/ng_nomac.c @@ -39,24 +39,13 @@ static void _event_cb(ng_netdev_event_t event, void *data) /* NOMAC only understands the RX_COMPLETE event... */ if (event == NETDEV_EVENT_RX_COMPLETE) { ng_pktsnip_t *pkt; - ng_netreg_entry_t *sendto; /* get pointer to the received packet */ pkt = (ng_pktsnip_t *)data; - /* find out, who to send the packet to */ - sendto = ng_netreg_lookup(pkt->type, NG_NETREG_DEMUX_CTX_ALL); - /* throw away packet if no one is interested */ - if (sendto == NULL) { + /* send the packet to everyone interested in it's type */ + if (!ng_netapi_dispatch_receive(pkt->type, NG_NETREG_DEMUX_CTX_ALL, pkt)) { DEBUG("nomac: unable to forward packet of type %i\n", pkt->type); ng_pktbuf_release(pkt); - return; - } - /* send the packet to everyone interested in it's type */ - ng_pktbuf_hold(pkt, ng_netreg_num(pkt->type, NG_NETREG_DEMUX_CTX_ALL) - 1); - while (sendto != NULL) { - DEBUG("nomac: sending pkt %p to PID %u\n", (void*)pkt, sendto->pid); - ng_netapi_receive(sendto->pid, pkt); - sendto = ng_netreg_getnext(sendto); } } }