Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
573b6dc9
Commit
573b6dc9
authored
7 years ago
by
Sebastian Meiling
Browse files
Options
Downloads
Patches
Plain Diff
gnrc/netreg: optimize lookup and getnext
parent
ff946556
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/net/gnrc/netreg/gnrc_netreg.c
+25
-17
25 additions, 17 deletions
sys/net/gnrc/netreg/gnrc_netreg.c
with
25 additions
and
17 deletions
sys/net/gnrc/netreg/gnrc_netreg.c
+
25
−
17
View file @
573b6dc9
...
@@ -65,19 +65,37 @@ void gnrc_netreg_unregister(gnrc_nettype_t type, gnrc_netreg_entry_t *entry)
...
@@ -65,19 +65,37 @@ void gnrc_netreg_unregister(gnrc_nettype_t type, gnrc_netreg_entry_t *entry)
LL_DELETE
(
netreg
[
type
],
entry
);
LL_DELETE
(
netreg
[
type
],
entry
);
}
}
gnrc_netreg_entry_t
*
gnrc_netreg_lookup
(
gnrc_nettype_t
type
,
uint32_t
demux_ctx
)
/**
* @brief Searches the next entry in the registry that matches given
* parameters, start lookup from beginning or given entry.
*
* @param[in] from A registry entry to lookup from or NULL to start fresh
* @param[in] type Type of the protocol.
* @param[in] demux_ctx The demultiplexing context for the registered thread.
* See gnrc_netreg_entry_t::demux_ctx.
*
* @return The first entry fitting the given parameters on success
* @return NULL if no entry can be found.
*/
static
gnrc_netreg_entry_t
*
_netreg_lookup
(
gnrc_netreg_entry_t
*
from
,
gnrc_nettype_t
type
,
uint32_t
demux_ctx
)
{
{
gnrc_netreg_entry_t
*
res
;
gnrc_netreg_entry_t
*
res
=
NULL
;
if
(
_INVALID_TYPE
(
type
))
{
if
(
from
||
!
_INVALID_TYPE
(
type
))
{
return
NULL
;
gnrc_netreg_entry_t
*
head
=
(
from
)
?
from
->
next
:
netreg
[
type
];
LL_SEARCH_SCALAR
(
head
,
res
,
demux_ctx
,
demux_ctx
);
}
}
LL_SEARCH_SCALAR
(
netreg
[
type
],
res
,
demux_ctx
,
demux_ctx
);
return
res
;
return
res
;
}
}
gnrc_netreg_entry_t
*
gnrc_netreg_lookup
(
gnrc_nettype_t
type
,
uint32_t
demux_ctx
)
{
return
_netreg_lookup
(
NULL
,
type
,
demux_ctx
);
}
int
gnrc_netreg_num
(
gnrc_nettype_t
type
,
uint32_t
demux_ctx
)
int
gnrc_netreg_num
(
gnrc_nettype_t
type
,
uint32_t
demux_ctx
)
{
{
int
num
=
0
;
int
num
=
0
;
...
@@ -102,17 +120,7 @@ int gnrc_netreg_num(gnrc_nettype_t type, uint32_t demux_ctx)
...
@@ -102,17 +120,7 @@ int gnrc_netreg_num(gnrc_nettype_t type, uint32_t demux_ctx)
gnrc_netreg_entry_t
*
gnrc_netreg_getnext
(
gnrc_netreg_entry_t
*
entry
)
gnrc_netreg_entry_t
*
gnrc_netreg_getnext
(
gnrc_netreg_entry_t
*
entry
)
{
{
uint32_t
demux_ctx
;
return
(
entry
?
_netreg_lookup
(
entry
,
0
,
entry
->
demux_ctx
)
:
NULL
);
if
(
entry
==
NULL
)
{
return
NULL
;
}
demux_ctx
=
entry
->
demux_ctx
;
LL_SEARCH_SCALAR
(
entry
->
next
,
entry
,
demux_ctx
,
demux_ctx
);
return
entry
;
}
}
int
gnrc_netreg_calc_csum
(
gnrc_pktsnip_t
*
hdr
,
gnrc_pktsnip_t
*
pseudo_hdr
)
int
gnrc_netreg_calc_csum
(
gnrc_pktsnip_t
*
hdr
,
gnrc_pktsnip_t
*
pseudo_hdr
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment