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
1168b102
You need to sign in or sign up before continuing.
Commit
1168b102
authored
9 years ago
by
Cenk Gündoğan
Browse files
Options
Downloads
Patches
Plain Diff
ng_fib: pretty print ipv6 addresses
parent
b256b9c2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/net/network_layer/fib/fib.c
+32
-1
32 additions, 1 deletion
sys/net/network_layer/fib/fib.c
with
32 additions
and
1 deletion
sys/net/network_layer/fib/fib.c
+
32
−
1
View file @
1168b102
...
@@ -30,6 +30,24 @@
...
@@ -30,6 +30,24 @@
#include
"ng_fib.h"
#include
"ng_fib.h"
#include
"ng_fib/ng_fib_table.h"
#include
"ng_fib/ng_fib_table.h"
#ifdef MODULE_NG_IPV6_ADDR
#include
"net/ng_ipv6/addr.h"
static
char
addr_str
[
NG_IPV6_ADDR_MAX_STR_LEN
];
#endif
#ifdef MODULE_NG_IPV6_ADDR
#define NG_FIB_ADDR_PRINT_LEN 39
#else
#define NG_FIB_ADDR_PRINT_LEN 32
#if NG_FIB_ADDR_PRINT_LEN != (UNIVERSAL_ADDRESS_SIZE * 2)
#error "NG_FIB_ADDR_PRINT_LEN MUST BE (UNIVERSAL_ADDRESS_SIZE * 2)"
#endif
#endif
#define NG_FIB_ADDR_PRINT_LENS1(X) #X
#define NG_FIB_ADDR_PRINT_LENS2(X) NG_FIB_ADDR_PRINT_LENS1(X)
#define NG_FIB_ADDR_PRINT_LENS NG_FIB_ADDR_PRINT_LENS2(NG_FIB_ADDR_PRINT_LEN)
/**
/**
* @brief access mutex to control exclusive operations on calls
* @brief access mutex to control exclusive operations on calls
*/
*/
...
@@ -625,6 +643,13 @@ static void fib_print_address(universal_address_container_t *entry)
...
@@ -625,6 +643,13 @@ static void fib_print_address(universal_address_container_t *entry)
uint8_t
*
ret
=
universal_address_get_address
(
entry
,
address
,
&
addr_size
);
uint8_t
*
ret
=
universal_address_get_address
(
entry
,
address
,
&
addr_size
);
if
(
ret
==
address
)
{
if
(
ret
==
address
)
{
#ifdef MODULE_NG_IPV6_ADDR
if
(
addr_size
==
sizeof
(
ng_ipv6_addr_t
))
{
printf
(
"%-"
NG_FIB_ADDR_PRINT_LENS
"s"
,
ng_ipv6_addr_to_str
(
addr_str
,
(
ng_ipv6_addr_t
*
)
address
,
sizeof
(
addr_str
)));
return
;
}
#endif
for
(
size_t
i
=
0
;
i
<
UNIVERSAL_ADDRESS_SIZE
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
UNIVERSAL_ADDRESS_SIZE
;
++
i
)
{
if
(
i
<=
addr_size
)
{
if
(
i
<=
addr_size
)
{
printf
(
"%02x"
,
address
[
i
]);
printf
(
"%02x"
,
address
[
i
]);
...
@@ -633,13 +658,19 @@ static void fib_print_address(universal_address_container_t *entry)
...
@@ -633,13 +658,19 @@ static void fib_print_address(universal_address_container_t *entry)
printf
(
" "
);
printf
(
" "
);
}
}
}
}
#ifdef MODULE_NG_IPV6_ADDR
/* print trailing whitespaces */
for
(
size_t
i
=
0
;
i
<
NG_FIB_ADDR_PRINT_LEN
-
(
UNIVERSAL_ADDRESS_SIZE
*
2
);
++
i
)
{
printf
(
" "
);
}
#endif
}
}
}
}
void
fib_print_routes
(
void
)
void
fib_print_routes
(
void
)
{
{
mutex_lock
(
&
mtx_access
);
mutex_lock
(
&
mtx_access
);
printf
(
"%-
32s %-6s %-32
s %-6s %-16s Interface
\n
"
printf
(
"%-
"
NG_FIB_ADDR_PRINT_LENS
"s %-6s %-"
NG_FIB_ADDR_PRINT_LENS
"
s %-6s %-16s Interface
\n
"
,
"Destination"
,
"Flags"
,
"Next Hop"
,
"Flags"
,
"Expires"
);
,
"Destination"
,
"Flags"
,
"Next Hop"
,
"Flags"
,
"Expires"
);
timex_t
now
;
timex_t
now
;
...
...
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