mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/ccn-lite:enable CS dump and rename shell command
This commit is contained in:
parent
d7bf2c112e
commit
86c319aea7
@ -15,12 +15,13 @@ RIOT provides three shell to interact with the CCN-Lite stack:
|
|||||||
If the second parameter is omitted, the Interest will be
|
If the second parameter is omitted, the Interest will be
|
||||||
broadcasted. You may call it like this:
|
broadcasted. You may call it like this:
|
||||||
`ccnl_int /riot/peter/schmerzl b6:e5:94:26:ab:da`
|
`ccnl_int /riot/peter/schmerzl b6:e5:94:26:ab:da`
|
||||||
* `ccnl_cont` - generates and populates content. The command expects one
|
* `ccnl_cs` - dumps CS or generates and populates content. If the command is
|
||||||
mandatory and one optional parameter. The first parameter
|
called without parameters, it will print all content items in
|
||||||
specifies the name of the content to be created, the second
|
the cache. Otherwise, the command expects two parameters. The
|
||||||
parameter specifies the content itself. The second parameter
|
first parameter specifies the name of the content to be created,
|
||||||
may include spaces, e.g. you can call:
|
the second parameter specifies the content itself. The second
|
||||||
`ccnl_cont /riot/peter/schmerzl Hello World! Hello RIOT!`
|
parameter may include spaces, e.g. you can call:
|
||||||
|
`ccnl_cont /riot/peter/schmerzl Hello World! Hello RIOT!`
|
||||||
* `ccnl_fib` - modifies the FIB or shows its current state. If the command is
|
* `ccnl_fib` - modifies the FIB or shows its current state. If the command is
|
||||||
called without parameters, it will print the current state of
|
called without parameters, it will print the current state of
|
||||||
the FIB. It can also be called with the action parameters `add`
|
the FIB. It can also be called with the action parameters `add`
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
static unsigned char _int_buf[BUF_SIZE];
|
static unsigned char _int_buf[BUF_SIZE];
|
||||||
|
|
||||||
static const char *_default_content = "Start the RIOT!";
|
|
||||||
static unsigned char _out[CCNL_MAX_PACKET_SIZE];
|
static unsigned char _out[CCNL_MAX_PACKET_SIZE];
|
||||||
|
|
||||||
/* usage for open command */
|
/* usage for open command */
|
||||||
@ -75,44 +74,45 @@ int _ccnl_open(int argc, char **argv)
|
|||||||
|
|
||||||
static void _content_usage(char *argv)
|
static void _content_usage(char *argv)
|
||||||
{
|
{
|
||||||
printf("usage: %s <URI> [content]\n"
|
printf("usage: %s [URI] [content]\n"
|
||||||
"%% %s /riot/peter/schmerzl (default content)\n"
|
"prints the CS if called without parameters:\n"
|
||||||
"%% %s /riot/peter/schmerzl RIOT\n",
|
"%% %s /riot/peter/schmerzl RIOT\n",
|
||||||
argv, argv, argv);
|
argv, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _ccnl_content(int argc, char **argv)
|
int _ccnl_content(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
ccnl_cs_dump(&ccnl_relay);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (argc == 2) {
|
||||||
_content_usage(argv[0]);
|
_content_usage(argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int arg_len;
|
int arg_len;
|
||||||
char *body = (char*) _default_content;
|
|
||||||
char buf[BUF_SIZE+1]; /* add one extra space to fit trailing '\0' */
|
char buf[BUF_SIZE+1]; /* add one extra space to fit trailing '\0' */
|
||||||
|
|
||||||
if (argc > 2) {
|
unsigned pos = 0;
|
||||||
unsigned pos = 0;
|
for (int i = 2; (i < argc) && (pos < BUF_SIZE); ++i) {
|
||||||
for (int i = 2; (i < argc) && (pos < BUF_SIZE); ++i) {
|
arg_len = strlen(argv[i]);
|
||||||
arg_len = strlen(argv[i]);
|
if ((pos + arg_len) > BUF_SIZE) {
|
||||||
if ((pos + arg_len) > BUF_SIZE) {
|
arg_len = BUF_SIZE - pos;
|
||||||
arg_len = BUF_SIZE - pos;
|
|
||||||
}
|
|
||||||
strncpy(&buf[pos], argv[i], arg_len);
|
|
||||||
pos += arg_len;
|
|
||||||
/* increment pos _after_ adding ' ' */
|
|
||||||
buf[pos++] = ' ';
|
|
||||||
}
|
}
|
||||||
/* decrement pos _before_ to overwrite last ' ' with '\0' */
|
strncpy(&buf[pos], argv[i], arg_len);
|
||||||
buf[--pos] = '\0';
|
pos += arg_len;
|
||||||
body = buf;
|
/* increment pos _after_ adding ' ' */
|
||||||
|
buf[pos++] = ' ';
|
||||||
}
|
}
|
||||||
arg_len = strlen(body);
|
/* decrement pos _before_ to overwrite last ' ' with '\0' */
|
||||||
|
buf[--pos] = '\0';
|
||||||
|
|
||||||
|
arg_len = strlen(buf);
|
||||||
|
|
||||||
struct ccnl_prefix_s *prefix = ccnl_URItoPrefix(argv[1], CCNL_SUITE_NDNTLV, NULL, NULL);
|
struct ccnl_prefix_s *prefix = ccnl_URItoPrefix(argv[1], CCNL_SUITE_NDNTLV, NULL, NULL);
|
||||||
int offs = CCNL_MAX_PACKET_SIZE;
|
int offs = CCNL_MAX_PACKET_SIZE;
|
||||||
arg_len = ccnl_ndntlv_prependContent(prefix, (unsigned char*) body, arg_len, NULL, NULL, &offs, _out);
|
arg_len = ccnl_ndntlv_prependContent(prefix, (unsigned char*) buf, arg_len, NULL, NULL, &offs, _out);
|
||||||
|
|
||||||
ccnl_prefix_free(prefix);
|
ccnl_prefix_free(prefix);
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ const shell_command_t _shell_command_list[] = {
|
|||||||
#ifdef MODULE_CCN_LITE_UTILS
|
#ifdef MODULE_CCN_LITE_UTILS
|
||||||
{ "ccnl_open", "opens an interface or socket", _ccnl_open },
|
{ "ccnl_open", "opens an interface or socket", _ccnl_open },
|
||||||
{ "ccnl_int", "sends an interest", _ccnl_interest },
|
{ "ccnl_int", "sends an interest", _ccnl_interest },
|
||||||
{ "ccnl_cont", "create content and populated it", _ccnl_content },
|
{ "ccnl_cs", "shows CS or creates content and populates it", _ccnl_content },
|
||||||
{ "ccnl_fib", "shows or modifies the CCN-Lite FIB", _ccnl_fib },
|
{ "ccnl_fib", "shows or modifies the CCN-Lite FIB", _ccnl_fib },
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_SNTP
|
#ifdef MODULE_SNTP
|
||||||
|
Loading…
Reference in New Issue
Block a user