mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
ng_netreg: Allow registration of NG_NETTYPE_UNDEF
This commit is contained in:
parent
b2beba5d35
commit
09b1abcb4e
@ -20,10 +20,10 @@
|
||||
#include "net/ng_nettype.h"
|
||||
#include "utlist.h"
|
||||
|
||||
#define _INVALID_TYPE(type) (((type) <= NG_NETTYPE_UNDEF) || ((type) >= NG_NETTYPE_NUMOF))
|
||||
#define _INVALID_TYPE(type) (((type) < NG_NETTYPE_UNDEF) || ((type) >= NG_NETTYPE_NUMOF))
|
||||
|
||||
/* The registry as lookup table by ng_nettype_t */
|
||||
static ng_netreg_entry_t *netreg[NG_NETTYPE_NUMOF - 1]; /* leave out NG_NETTYPE_UNDEF */
|
||||
static ng_netreg_entry_t *netreg[NG_NETTYPE_NUMOF];
|
||||
|
||||
void ng_netreg_init(void)
|
||||
{
|
||||
@ -37,7 +37,7 @@ int ng_netreg_register(ng_nettype_t type, ng_netreg_entry_t *entry)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
LL_PREPEND(netreg[type - 1], entry);
|
||||
LL_PREPEND(netreg[type], entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -48,7 +48,7 @@ void ng_netreg_unregister(ng_nettype_t type, ng_netreg_entry_t *entry)
|
||||
return;
|
||||
}
|
||||
|
||||
LL_DELETE(netreg[type - 1], entry);
|
||||
LL_DELETE(netreg[type], entry);
|
||||
}
|
||||
|
||||
ng_netreg_entry_t *ng_netreg_lookup(ng_nettype_t type, uint32_t demux_ctx)
|
||||
@ -59,7 +59,7 @@ ng_netreg_entry_t *ng_netreg_lookup(ng_nettype_t type, uint32_t demux_ctx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LL_SEARCH_SCALAR(netreg[type - 1], res, demux_ctx, demux_ctx);
|
||||
LL_SEARCH_SCALAR(netreg[type], res, demux_ctx, demux_ctx);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -73,7 +73,7 @@ int ng_netreg_num(ng_nettype_t type, uint32_t demux_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry = netreg[type - 1];
|
||||
entry = netreg[type];
|
||||
|
||||
while (entry != NULL) {
|
||||
if (entry->demux_ctx == demux_ctx) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user