mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-14 17:13:50 +01:00
Revert "gnrc/netreg: remove usages of gnrc_netreg_num"
This reverts commit c2b403f4ad0fda2e196be248406f2c04d626cf26.
This commit is contained in:
parent
2757f1d7dd
commit
dbda759b40
@ -367,7 +367,7 @@ int _tftp_init_ctxt(ipv6_addr_t *addr, const char *file_name,
|
||||
/* generate a random source UDP source port */
|
||||
do {
|
||||
ctxt->src_port = (random_uint32() & 0xff) + GNRC_TFTP_DEFAULT_SRC_PORT;
|
||||
} while (gnrc_netreg_lookup(GNRC_NETTYPE_UDP, ctxt->src_port));
|
||||
} while (gnrc_netreg_num(GNRC_NETTYPE_UDP, ctxt->src_port));
|
||||
|
||||
return TS_FINISHED;
|
||||
}
|
||||
|
||||
@ -94,52 +94,54 @@ static inline int _snd_rcv_mbox(mbox_t *mbox, uint16_t type, gnrc_pktsnip_t *pkt
|
||||
int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||
uint16_t cmd, gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
int numof = 0;
|
||||
gnrc_netreg_entry_t *sendto = gnrc_netreg_lookup(type, demux_ctx);
|
||||
int numof = gnrc_netreg_num(type, demux_ctx);
|
||||
|
||||
while (sendto) {
|
||||
if (numof != 0) {
|
||||
gnrc_pktbuf_hold(pkt, 1);
|
||||
}
|
||||
if (numof != 0) {
|
||||
gnrc_netreg_entry_t *sendto = gnrc_netreg_lookup(type, demux_ctx);
|
||||
|
||||
gnrc_pktbuf_hold(pkt, numof - 1);
|
||||
|
||||
while (sendto) {
|
||||
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS)
|
||||
int release = 0;
|
||||
switch (sendto->type) {
|
||||
case GNRC_NETREG_TYPE_DEFAULT:
|
||||
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
||||
/* unable to dispatch packet */
|
||||
release = 1;
|
||||
}
|
||||
break;
|
||||
int release = 0;
|
||||
switch (sendto->type) {
|
||||
case GNRC_NETREG_TYPE_DEFAULT:
|
||||
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
||||
/* unable to dispatch packet */
|
||||
release = 1;
|
||||
}
|
||||
break;
|
||||
#ifdef MODULE_GNRC_NETAPI_MBOX
|
||||
case GNRC_NETREG_TYPE_MBOX:
|
||||
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
|
||||
/* unable to dispatch packet */
|
||||
release = 1;
|
||||
}
|
||||
break;
|
||||
case GNRC_NETREG_TYPE_MBOX:
|
||||
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
|
||||
/* unable to dispatch packet */
|
||||
release = 1;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef MODULE_GNRC_NETAPI_CALLBACKS
|
||||
case GNRC_NETREG_TYPE_CB:
|
||||
sendto->target.cbd->cb(cmd, pkt, sendto->target.cbd->ctx);
|
||||
break;
|
||||
case GNRC_NETREG_TYPE_CB:
|
||||
sendto->target.cbd->cb(cmd, pkt, sendto->target.cbd->ctx);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* unknown dispatch type */
|
||||
release = 1;
|
||||
break;
|
||||
}
|
||||
if (release) {
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
default:
|
||||
/* unknown dispatch type */
|
||||
release = 1;
|
||||
break;
|
||||
}
|
||||
if (release) {
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
#else
|
||||
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
||||
/* unable to dispatch packet */
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
||||
/* unable to dispatch packet */
|
||||
gnrc_pktbuf_release(pkt);
|
||||
}
|
||||
#endif
|
||||
numof++;
|
||||
sendto = gnrc_netreg_getnext(sendto);
|
||||
sendto = gnrc_netreg_getnext(sendto);
|
||||
}
|
||||
}
|
||||
|
||||
return numof;
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +219,7 @@ static void _dispatch_next_header(gnrc_pktsnip_t *current, gnrc_pktsnip_t *pkt,
|
||||
|
||||
/* dispatch IPv6 extension header only once */
|
||||
if (should_dispatch_current_type) {
|
||||
bool should_release = (!gnrc_netreg_lookup(GNRC_NETTYPE_IPV6, nh)) &&
|
||||
bool should_release = (gnrc_netreg_num(GNRC_NETTYPE_IPV6, nh) == 0) &&
|
||||
(!interested);
|
||||
|
||||
if (!should_release) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user