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
5db537fb
Commit
5db537fb
authored
9 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Patches
Plain Diff
ccn-lite: add shell function to remove FIB entry
parent
08a15b39
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/ccn-lite/ccn-lite-riot.h
+2
-0
2 additions, 0 deletions
pkg/ccn-lite/ccn-lite-riot.h
sys/shell/commands/sc_ccnl.c
+53
-15
53 additions, 15 deletions
sys/shell/commands/sc_ccnl.c
with
55 additions
and
15 deletions
pkg/ccn-lite/ccn-lite-riot.h
+
2
−
0
View file @
5db537fb
...
...
@@ -204,6 +204,8 @@ int ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout);
int
ccnl_fib_add_entry
(
struct
ccnl_relay_s
*
relay
,
struct
ccnl_prefix_s
*
pfx
,
struct
ccnl_face_s
*
face
);
int
ccnl_fib_rem_entry
(
struct
ccnl_relay_s
*
relay
,
struct
ccnl_prefix_s
*
pfx
,
struct
ccnl_face_s
*
face
);
/**
* @brief Prints the current CCN-Lite FIB
*
...
...
This diff is collapsed.
Click to expand it.
sys/shell/commands/sc_ccnl.c
+
53
−
15
View file @
5db537fb
...
...
@@ -145,15 +145,8 @@ int _ccnl_content(int argc, char **argv)
return
0
;
}
static
int
_intern_fib_add
(
char
*
pfx
,
char
*
addr_str
)
static
struct
ccnl_face_s
*
_intern_face_get
(
char
*
addr_str
)
{
int
suite
=
CCNL_SUITE_NDNTLV
;
struct
ccnl_prefix_s
*
prefix
=
ccnl_URItoPrefix
(
pfx
,
suite
,
NULL
,
0
);
if
(
!
prefix
)
{
puts
(
"Error: prefix could not be created!"
);
return
-
1
;
}
/* initialize address with 0xFF for broadcast */
size_t
addr_len
=
MAX_ADDR_LEN
;
uint8_t
relay_addr
[
MAX_ADDR_LEN
];
...
...
@@ -162,7 +155,7 @@ static int _intern_fib_add(char *pfx, char *addr_str)
addr_len
=
gnrc_netif_addr_from_str
(
relay_addr
,
sizeof
(
relay_addr
),
addr_str
);
if
(
addr_len
==
0
)
{
printf
(
"Error: %s is not a valid link layer address
\n
"
,
addr_str
);
return
-
1
;
return
NULL
;
}
sockunion
sun
;
...
...
@@ -173,6 +166,23 @@ static int _intern_fib_add(char *pfx, char *addr_str)
/* TODO: set correct interface instead of always 0 */
struct
ccnl_face_s
*
fibface
=
ccnl_get_face_or_create
(
&
ccnl_relay
,
0
,
&
sun
.
sa
,
sizeof
(
sun
.
linklayer
));
return
fibface
;
}
static
int
_intern_fib_add
(
char
*
pfx
,
char
*
addr_str
)
{
int
suite
=
CCNL_SUITE_NDNTLV
;
struct
ccnl_prefix_s
*
prefix
=
ccnl_URItoPrefix
(
pfx
,
suite
,
NULL
,
0
);
if
(
!
prefix
)
{
puts
(
"Error: prefix could not be created!"
);
return
-
1
;
}
struct
ccnl_face_s
*
fibface
=
_intern_face_get
(
addr_str
);
if
(
fibface
==
NULL
)
{
return
-
1
;
}
fibface
->
flags
|=
CCNL_FACE_FLAGS_STATIC
;
if
(
ccnl_fib_add_entry
(
&
ccnl_relay
,
prefix
,
fibface
)
!=
0
)
{
...
...
@@ -228,10 +238,16 @@ int _ccnl_interest(int argc, char **argv)
static
void
_ccnl_fib_usage
(
char
*
argv
)
{
printf
(
"usage: %s [<URI> <content>]
\n
"
"%% %s (prints the current FIB)
\n
"
"%% %s /riot/peter/schmerzl RIOT
\n
"
,
argv
,
argv
,
argv
);
printf
(
"usage: %s [<action> <options>]
\n
"
"prints the FIB if called without parameters:
\n
"
"%% %s
\n
"
"<action> may be one of the following
\n
"
" *
\"
add
\"
- adds an entry to the FIB, requires a prefix and a next-hop address, e.g.
\n
"
" %s add /riot/peter/schmerzl ab:cd:ef:01:23:45:67:89
\n
"
" *
\"
del
\"
- deletes an entry to the FIB, requires a prefix or a next-hop address, e.g.
\n
"
" %s del /riot/peter/schmerzl
\n
"
" %s del ab:cd:ef:01:23:45:67:89
\n
"
,
argv
,
argv
,
argv
,
argv
,
argv
);
}
int
_ccnl_fib
(
int
argc
,
char
**
argv
)
...
...
@@ -239,8 +255,30 @@ int _ccnl_fib(int argc, char **argv)
if
(
argc
<
2
)
{
ccnl_fib_show
(
&
ccnl_relay
);
}
else
if
(
argc
==
3
)
{
if
(
_intern_fib_add
(
argv
[
1
],
argv
[
2
])
<
0
)
{
else
if
((
argc
==
3
)
&&
(
strncmp
(
argv
[
1
],
"del"
,
3
)
==
0
))
{
int
suite
=
CCNL_SUITE_NDNTLV
;
if
(
strchr
(
argv
[
2
],
'/'
))
{
struct
ccnl_prefix_s
*
prefix
=
ccnl_URItoPrefix
(
argv
[
2
],
suite
,
NULL
,
0
);
if
(
!
prefix
)
{
puts
(
"Error: prefix could not be created!"
);
return
-
1
;
}
int
res
=
ccnl_fib_rem_entry
(
&
ccnl_relay
,
prefix
,
NULL
);
free_prefix
(
prefix
);
return
res
;
}
else
{
struct
ccnl_face_s
*
face
=
_intern_face_get
(
argv
[
2
]);
if
(
face
==
NULL
)
{
printf
(
"There is no face for address %s
\n
"
,
argv
[
1
]);
return
-
1
;
}
int
res
=
ccnl_fib_rem_entry
(
&
ccnl_relay
,
NULL
,
face
);
return
res
;
}
}
else
if
((
argc
==
4
)
&&
(
strncmp
(
argv
[
1
],
"add"
,
3
)
==
0
))
{
if
(
_intern_fib_add
(
argv
[
2
],
argv
[
3
])
<
0
)
{
_ccnl_fib_usage
(
argv
[
0
]);
return
-
1
;
}
...
...
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