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
188c1a4c
Commit
188c1a4c
authored
10 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
shell: add support for nc iterators
parent
bbf57d16
Branches
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/shell/commands/sc_ipv6_nc.c
+123
-2
123 additions, 2 deletions
sys/shell/commands/sc_ipv6_nc.c
sys/shell/commands/shell_commands.c
+2
-0
2 additions, 0 deletions
sys/shell/commands/shell_commands.c
with
125 additions
and
2 deletions
sys/shell/commands/sc_ipv6_nc.c
+
123
−
2
View file @
188c1a4c
...
...
@@ -26,6 +26,64 @@
/* maximum length of L2 address */
#define MAX_L2_ADDR_LEN (8U)
static
void
_print_nc_state
(
ng_ipv6_nc_t
*
entry
)
{
switch
(
entry
->
flags
&
NG_IPV6_NC_STATE_MASK
)
{
case
NG_IPV6_NC_STATE_UNMANAGED
:
printf
(
"UNMANAGED"
);
break
;
case
NG_IPV6_NC_STATE_UNREACHABLE
:
printf
(
"UNREACHABLE"
);
break
;
case
NG_IPV6_NC_STATE_INCOMPLETE
:
printf
(
"INCOMPLETE"
);
break
;
case
NG_IPV6_NC_STATE_STALE
:
printf
(
"STALE"
);
break
;
case
NG_IPV6_NC_STATE_DELAY
:
printf
(
"DELAY"
);
break
;
case
NG_IPV6_NC_STATE_PROBE
:
printf
(
"PROBE"
);
break
;
case
NG_IPV6_NC_STATE_REACHABLE
:
printf
(
"REACHABLE"
);
break
;
default:
printf
(
"UNKNOWN"
);
break
;
}
}
static
void
_print_nc_type
(
ng_ipv6_nc_t
*
entry
)
{
switch
(
entry
->
flags
&
NG_IPV6_NC_TYPE_MASK
)
{
case
NG_IPV6_NC_TYPE_GC
:
printf
(
"GC"
);
break
;
case
NG_IPV6_NC_TYPE_TENTATIVE
:
printf
(
"T"
);
break
;
case
NG_IPV6_NC_TYPE_REGISTERED
:
printf
(
"R"
);
break
;
default:
printf
(
"-"
);
break
;
}
}
static
bool
_is_iface
(
kernel_pid_t
iface
)
{
#ifdef MODULE_NG_NETIF
...
...
@@ -44,6 +102,30 @@ static bool _is_iface(kernel_pid_t iface)
#endif
}
static
int
_ipv6_nc_list
(
void
)
{
char
ipv6_str
[
NG_IPV6_ADDR_MAX_STR_LEN
];
char
l2addr_str
[
3
*
MAX_L2_ADDR_LEN
];
puts
(
"IPv6 address if L2 address state type"
);
puts
(
"-----------------------------------------------------------------------------"
);
for
(
ng_ipv6_nc_t
*
entry
=
ng_ipv6_nc_get_next
(
NULL
);
entry
!=
NULL
;
entry
=
ng_ipv6_nc_get_next
(
entry
))
{
printf
(
"%-30s %2"
PRIkernel_pid
" %-24s "
,
ng_ipv6_addr_to_str
(
ipv6_str
,
&
entry
->
ipv6_addr
,
sizeof
(
ipv6_str
)),
entry
->
iface
,
ng_netif_addr_to_str
(
l2addr_str
,
sizeof
(
l2addr_str
),
entry
->
l2_addr
,
entry
->
l2_addr_len
));
_print_nc_state
(
entry
);
_print_nc_type
(
entry
);
puts
(
""
);
}
return
0
;
}
static
int
_ipv6_nc_add
(
kernel_pid_t
iface
,
char
*
ipv6_addr_str
,
char
*
l2_addr_str
)
{
...
...
@@ -88,6 +170,10 @@ static int _ipv6_nc_del(char *ipv6_addr_str)
int
_ipv6_nc_manage
(
int
argc
,
char
**
argv
)
{
if
((
argc
==
1
)
||
(
strcmp
(
"list"
,
argv
[
1
])
==
0
))
{
return
_ipv6_nc_list
();
}
if
(
argc
>
2
)
{
if
((
argc
>
4
)
&&
(
strcmp
(
"add"
,
argv
[
1
])
==
0
))
{
kernel_pid_t
iface
=
(
kernel_pid_t
)
atoi
(
argv
[
2
]);
...
...
@@ -105,11 +191,46 @@ int _ipv6_nc_manage(int argc, char **argv)
}
}
printf
(
"usage: %s add <iface pid> <ipv6_addr> <l2_addr>
\n
"
" or: %s del <ipv6_addr>
\n
"
,
argv
[
0
],
argv
[
0
]);
printf
(
"usage: %s [list]
\n
"
" or: %s add <iface pid> <ipv6_addr> <l2_addr>
\n
"
" or: %s del <ipv6_addr>
\n
"
,
argv
[
0
],
argv
[
0
],
argv
[
0
]);
return
1
;
}
int
_ipv6_nc_routers
(
int
argc
,
char
**
argv
)
{
kernel_pid_t
iface
=
KERNEL_PID_UNDEF
;
char
ipv6_str
[
NG_IPV6_ADDR_MAX_STR_LEN
];
if
(
argc
>
1
)
{
iface
=
atoi
(
argv
[
1
]);
if
(
!
_is_iface
(
iface
))
{
printf
(
"usage: %s [<iface pid>]
\n
"
,
argv
[
0
]);
return
1
;
}
}
puts
(
"if Router state type"
);
puts
(
"---------------------------------------------------"
);
for
(
ng_ipv6_nc_t
*
entry
=
ng_ipv6_nc_get_next_router
(
NULL
);
entry
!=
NULL
;
entry
=
ng_ipv6_nc_get_next_router
(
entry
))
{
if
((
iface
!=
KERNEL_PID_UNDEF
)
&&
(
iface
!=
entry
->
iface
))
{
continue
;
}
printf
(
"%2"
PRIkernel_pid
" %-30s "
,
entry
->
iface
,
ng_ipv6_addr_to_str
(
ipv6_str
,
&
entry
->
ipv6_addr
,
sizeof
(
ipv6_str
)));
_print_nc_state
(
entry
);
_print_nc_type
(
entry
);
puts
(
""
);
}
return
0
;
}
/**
* @}
*/
This diff is collapsed.
Click to expand it.
sys/shell/commands/shell_commands.c
+
2
−
0
View file @
188c1a4c
...
...
@@ -165,6 +165,7 @@ extern int _fib_route_handler(int argc, char **argv);
#ifdef MODULE_NG_IPV6_NC
extern
int
_ipv6_nc_manage
(
int
argc
,
char
**
argv
);
extern
int
_ipv6_nc_routers
(
int
argc
,
char
**
argv
);
#endif
const
shell_command_t
_shell_command_list
[]
=
{
...
...
@@ -273,6 +274,7 @@ const shell_command_t _shell_command_list[] = {
#endif
#ifdef MODULE_NG_IPV6_NC
{
"ncache"
,
"manage neighbor cache by hand"
,
_ipv6_nc_manage
},
{
"routers"
,
"IPv6 default router list"
,
_ipv6_nc_routers
},
#endif
{
NULL
,
NULL
,
NULL
}
};
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