ng_nomac: use dispatch function
This commit is contained in:
parent
fb6440c397
commit
dae00a81fb
@ -39,24 +39,13 @@ static void _event_cb(ng_netdev_event_t event, void *data)
|
|||||||
/* NOMAC only understands the RX_COMPLETE event... */
|
/* NOMAC only understands the RX_COMPLETE event... */
|
||||||
if (event == NETDEV_EVENT_RX_COMPLETE) {
|
if (event == NETDEV_EVENT_RX_COMPLETE) {
|
||||||
ng_pktsnip_t *pkt;
|
ng_pktsnip_t *pkt;
|
||||||
ng_netreg_entry_t *sendto;
|
|
||||||
|
|
||||||
/* get pointer to the received packet */
|
/* get pointer to the received packet */
|
||||||
pkt = (ng_pktsnip_t *)data;
|
pkt = (ng_pktsnip_t *)data;
|
||||||
/* find out, who to send the packet to */
|
/* send the packet to everyone interested in it's type */
|
||||||
sendto = ng_netreg_lookup(pkt->type, NG_NETREG_DEMUX_CTX_ALL);
|
if (!ng_netapi_dispatch_receive(pkt->type, NG_NETREG_DEMUX_CTX_ALL, pkt)) {
|
||||||
/* throw away packet if no one is interested */
|
|
||||||
if (sendto == NULL) {
|
|
||||||
DEBUG("nomac: unable to forward packet of type %i\n", pkt->type);
|
DEBUG("nomac: unable to forward packet of type %i\n", pkt->type);
|
||||||
ng_pktbuf_release(pkt);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user