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
a767f66d
Commit
a767f66d
authored
10 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
ipv6_nc: add iterators
parent
56f5a836
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/include/net/ng_ipv6/nc.h
+18
-0
18 additions, 0 deletions
sys/include/net/ng_ipv6/nc.h
sys/net/network_layer/ng_ipv6/nc/ng_ipv6_nc.c
+48
-10
48 additions, 10 deletions
sys/net/network_layer/ng_ipv6/nc/ng_ipv6_nc.c
with
66 additions
and
10 deletions
sys/include/net/ng_ipv6/nc.h
+
18
−
0
View file @
a767f66d
...
@@ -175,6 +175,24 @@ void ng_ipv6_nc_remove(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr);
...
@@ -175,6 +175,24 @@ void ng_ipv6_nc_remove(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr);
*/
*/
ng_ipv6_nc_t
*
ng_ipv6_nc_get
(
kernel_pid_t
iface
,
const
ng_ipv6_addr_t
*
ipv6_addr
);
ng_ipv6_nc_t
*
ng_ipv6_nc_get
(
kernel_pid_t
iface
,
const
ng_ipv6_addr_t
*
ipv6_addr
);
/**
* @brief Gets next entry in neighbor cache after @p prev.
*
* @param[in] prev Previous entry. NULL to start iteration.
*
* @return The next entry in neighbor cache.
*/
ng_ipv6_nc_t
*
ng_ipv6_nc_get_next
(
ng_ipv6_nc_t
*
prev
);
/**
* @brief Gets next reachable router entry in neighbor cache after @p prev.
*
* @param[in] prev Previous router entry. NULL to start iteration.
*
* @return The next reachable router entry in neighbor cache.
*/
ng_ipv6_nc_t
*
ng_ipv6_nc_get_next_router
(
ng_ipv6_nc_t
*
prev
);
/**
/**
* @brief Searches for any neighbor cache entry fitting the @p ipv6_addr,
* @brief Searches for any neighbor cache entry fitting the @p ipv6_addr,
* where you currently can send a packet to (do not confuse with
* where you currently can send a packet to (do not confuse with
...
...
This diff is collapsed.
Click to expand it.
sys/net/network_layer/ng_ipv6/nc/ng_ipv6_nc.c
+
48
−
10
View file @
a767f66d
...
@@ -136,6 +136,50 @@ ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
...
@@ -136,6 +136,50 @@ ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
return
NULL
;
return
NULL
;
}
}
ng_ipv6_nc_t
*
ng_ipv6_nc_get_next
(
ng_ipv6_nc_t
*
prev
)
{
if
(
prev
==
NULL
)
{
prev
=
ncache
;
}
else
{
prev
++
;
/* get next entry */
}
while
(
prev
<
(
ncache
+
NG_IPV6_NC_SIZE
))
{
/* while not reached end */
if
(
!
ng_ipv6_addr_is_unspecified
(
&
(
prev
->
ipv6_addr
)))
{
return
prev
;
}
prev
++
;
}
return
NULL
;
}
static
inline
bool
_is_reachable
(
ng_ipv6_nc_t
*
entry
)
{
switch
((
entry
->
flags
&
NG_IPV6_NC_STATE_MASK
)
>>
NG_IPV6_NC_STATE_POS
)
{
case
NG_IPV6_NC_STATE_UNREACHABLE
:
case
NG_IPV6_NC_STATE_INCOMPLETE
:
return
false
;
default:
return
true
;
}
}
ng_ipv6_nc_t
*
ng_ipv6_nc_get_next_router
(
ng_ipv6_nc_t
*
prev
)
{
for
(
ng_ipv6_nc_t
*
router
=
ng_ipv6_nc_get_next
(
prev
);
router
!=
NULL
;
router
=
ng_ipv6_nc_get_next
(
router
))
{
if
(
router
->
flags
&
NG_IPV6_NC_IS_ROUTER
)
{
return
router
;
}
}
return
NULL
;
}
ng_ipv6_nc_t
*
ng_ipv6_nc_get_reachable
(
kernel_pid_t
iface
,
ng_ipv6_nc_t
*
ng_ipv6_nc_get_reachable
(
kernel_pid_t
iface
,
const
ng_ipv6_addr_t
*
ipv6_addr
)
const
ng_ipv6_addr_t
*
ipv6_addr
)
{
{
...
@@ -148,17 +192,11 @@ ng_ipv6_nc_t *ng_ipv6_nc_get_reachable(kernel_pid_t iface,
...
@@ -148,17 +192,11 @@ ng_ipv6_nc_t *ng_ipv6_nc_get_reachable(kernel_pid_t iface,
return
NULL
;
return
NULL
;
}
}
switch
((
entry
->
flags
&
NG_IPV6_NC_STATE_MASK
)
>>
NG_IPV6_NC_STATE_POS
)
{
if
(
_is_reachable
(
entry
))
{
case
NG_IPV6_NC_STATE_UNREACHABLE
:
return
entry
;
case
NG_IPV6_NC_STATE_INCOMPLETE
:
DEBUG
(
"ipv6_nc: Entry %s is unreachable (flags = 0x%02x)
\n
"
,
ng_ipv6_addr_to_str
(
addr_str
,
ipv6_addr
,
sizeof
(
addr_str
)),
entry
->
flags
);
return
NULL
;
default:
return
entry
;
}
}
return
NULL
;
}
}
ng_ipv6_nc_t
*
ng_ipv6_nc_still_reachable
(
const
ng_ipv6_addr_t
*
ipv6_addr
)
ng_ipv6_nc_t
*
ng_ipv6_nc_still_reachable
(
const
ng_ipv6_addr_t
*
ipv6_addr
)
...
...
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