mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 17:43:51 +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 */
|
/* generate a random source UDP source port */
|
||||||
do {
|
do {
|
||||||
ctxt->src_port = (random_uint32() & 0xff) + GNRC_TFTP_DEFAULT_SRC_PORT;
|
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;
|
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,
|
int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
|
||||||
uint16_t cmd, gnrc_pktsnip_t *pkt)
|
uint16_t cmd, gnrc_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
int numof = 0;
|
int numof = gnrc_netreg_num(type, demux_ctx);
|
||||||
gnrc_netreg_entry_t *sendto = gnrc_netreg_lookup(type, demux_ctx);
|
|
||||||
|
|
||||||
while (sendto) {
|
if (numof != 0) {
|
||||||
if (numof != 0) {
|
gnrc_netreg_entry_t *sendto = gnrc_netreg_lookup(type, demux_ctx);
|
||||||
gnrc_pktbuf_hold(pkt, 1);
|
|
||||||
}
|
gnrc_pktbuf_hold(pkt, numof - 1);
|
||||||
|
|
||||||
|
while (sendto) {
|
||||||
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS)
|
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS)
|
||||||
int release = 0;
|
int release = 0;
|
||||||
switch (sendto->type) {
|
switch (sendto->type) {
|
||||||
case GNRC_NETREG_TYPE_DEFAULT:
|
case GNRC_NETREG_TYPE_DEFAULT:
|
||||||
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
||||||
/* unable to dispatch packet */
|
/* unable to dispatch packet */
|
||||||
release = 1;
|
release = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef MODULE_GNRC_NETAPI_MBOX
|
#ifdef MODULE_GNRC_NETAPI_MBOX
|
||||||
case GNRC_NETREG_TYPE_MBOX:
|
case GNRC_NETREG_TYPE_MBOX:
|
||||||
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
|
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
|
||||||
/* unable to dispatch packet */
|
/* unable to dispatch packet */
|
||||||
release = 1;
|
release = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_GNRC_NETAPI_CALLBACKS
|
#ifdef MODULE_GNRC_NETAPI_CALLBACKS
|
||||||
case GNRC_NETREG_TYPE_CB:
|
case GNRC_NETREG_TYPE_CB:
|
||||||
sendto->target.cbd->cb(cmd, pkt, sendto->target.cbd->ctx);
|
sendto->target.cbd->cb(cmd, pkt, sendto->target.cbd->ctx);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
/* unknown dispatch type */
|
/* unknown dispatch type */
|
||||||
release = 1;
|
release = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (release) {
|
if (release) {
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
if (_snd_rcv(sendto->target.pid, cmd, pkt) < 1) {
|
||||||
/* unable to dispatch packet */
|
/* unable to dispatch packet */
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
numof++;
|
sendto = gnrc_netreg_getnext(sendto);
|
||||||
sendto = gnrc_netreg_getnext(sendto);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return numof;
|
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 */
|
/* dispatch IPv6 extension header only once */
|
||||||
if (should_dispatch_current_type) {
|
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);
|
(!interested);
|
||||||
|
|
||||||
if (!should_release) {
|
if (!should_release) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user