From 8ef719b42c4353841906a62b532272b2fba60639 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 23 Mar 2016 12:14:45 +0100 Subject: [PATCH 1/9] pkg ccn-lite: update ccn-lite version --- pkg/ccn-lite/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ccn-lite/Makefile b/pkg/ccn-lite/Makefile index a842f6510c..25b211db3a 100644 --- a/pkg/ccn-lite/Makefile +++ b/pkg/ccn-lite/Makefile @@ -1,6 +1,6 @@ PKG_NAME=ccn-lite -PKG_URL=https://github.com/OlegHahm/ccn-lite/ -PKG_VERSION=39b1406c11de9de364220909488eebabe7e81613 +PKG_URL=https://github.com/cn-uofbasel/ccn-lite/ +PKG_VERSION=9e48d328e162e97f091d913ada0bf50f58d1d3d7 .PHONY: all From 587a435a711b054652de5cd0d519c0d443989b3a Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 6 Jan 2016 15:17:40 +0100 Subject: [PATCH 2/9] pkg ccn-lite: adapt to updated CCN-Lite version --- pkg/ccn-lite/ccn-lite-riot.h | 47 ++++++++++++++++++++++++++++++------ sys/shell/commands/sc_ccnl.c | 6 ++--- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/pkg/ccn-lite/ccn-lite-riot.h b/pkg/ccn-lite/ccn-lite-riot.h index b9144dba8c..cc544712fb 100644 --- a/pkg/ccn-lite/ccn-lite-riot.h +++ b/pkg/ccn-lite/ccn-lite-riot.h @@ -105,6 +105,22 @@ extern "C" { * @} */ +/** + * @brief Some macro definitions + * @{ + */ +#define free_2ptr_list(a,b) ccnl_free(a), ccnl_free(b) +#define free_3ptr_list(a,b,c) ccnl_free(a), ccnl_free(b), ccnl_free(c) +#define free_4ptr_list(a,b,c,d) ccnl_free(a), ccnl_free(b), ccnl_free(c), ccnl_free(d); +#define free_5ptr_list(a,b,c,d,e) ccnl_free(a), ccnl_free(b), ccnl_free(c), ccnl_free(d), ccnl_free(e); + +/** + * Frees all memory directly and indirectly allocated for prefix information + */ +#define free_prefix(p) do{ if(p) \ + free_5ptr_list(p->bytes,p->comp,p->complen,p->chunknum,p); } while(0) + + /** * Constant string */ @@ -123,7 +139,7 @@ extern "C" { /** * Struct holding CCN-Lite's central relay information */ -extern struct ccnl_relay_s theRelay; +extern struct ccnl_relay_s ccnl_relay; /** * @brief Start the main CCN-Lite event-loop @@ -149,8 +165,6 @@ int ccnl_open_netif(kernel_pid_t if_pid, gnrc_nettype_t netreg_type); * * @param[in] suite CCN packet format * @param[in] name The name that is requested - * @param[in] addr The relay's address to send to - * @param[in] addr_len Length of @p addr * @param[in] chunknum Number of the requested content chunk * @param[out] buf Buffer to write the content chunk to * @param[in] buf_len Size of @p buf @@ -158,9 +172,8 @@ int ccnl_open_netif(kernel_pid_t if_pid, gnrc_nettype_t netreg_type); * @return 0 on successfully sent Interest * @return -1 if Interested couldn't be sent */ -int ccnl_send_interest(int suite, char *name, uint8_t *addr, size_t addr_len, - unsigned int *chunknum, unsigned char *buf, - size_t buf_len); +int ccnl_send_interest(int suite, char *name, unsigned int *chunknum, + unsigned char *buf, size_t buf_len); /** * @brief Waits for incoming content chunk @@ -168,7 +181,27 @@ int ccnl_send_interest(int suite, char *name, uint8_t *addr, size_t addr_len, * @return 0 if a content was received * @return -ETIMEDOUT if no chunk was received until timeout */ -int ccnl_wait_for_chunk(void *buf, size_t buf_len); +int ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout); + +/** + * @brief Add entry to the CCN-Lite FIB + * + * @par[in] relay Local relay struct + * @par[in] pfx Prefix of the FIB entry + * @par[in] face Face for the FIB entry + * + * @return 0 on success + * @return -1 on error + */ +int ccnl_fib_add_entry(struct ccnl_relay_s *relay, struct ccnl_prefix_s *pfx, + struct ccnl_face_s *face); + +/** + * @brief Prints the current CCN-Lite FIB + * + * @par[in] relay Local relay struct + */ +void ccnl_fib_show(struct ccnl_relay_s *relay); #ifdef __cplusplus } diff --git a/sys/shell/commands/sc_ccnl.c b/sys/shell/commands/sc_ccnl.c index b4388b090a..7fc6322877 100644 --- a/sys/shell/commands/sc_ccnl.c +++ b/sys/shell/commands/sc_ccnl.c @@ -138,8 +138,8 @@ int _ccnl_content(int argc, char **argv) struct ccnl_content_s *c = 0; struct ccnl_pkt_s *pk = ccnl_ndntlv_bytes2pkt(typ, olddata, &data, &arg_len); - c = ccnl_content_new(&theRelay, &pk); - ccnl_content_add2cache(&theRelay, c); + c = ccnl_content_new(&ccnl_relay, &pk); + ccnl_content_add2cache(&ccnl_relay, c); c->flags |= CCNL_CONTENT_FLAGS_STATIC; return 0; @@ -171,7 +171,7 @@ int _ccnl_interest(int argc, char **argv) memset(_cont_buf, '\0', BUF_SIZE); for (int cnt = 0; cnt < CCNL_INTEREST_RETRIES; cnt++) { ccnl_send_interest(CCNL_SUITE_NDNTLV, argv[1], relay_addr, addr_len, NULL, _int_buf, BUF_SIZE); - if (ccnl_wait_for_chunk(_cont_buf, BUF_SIZE) > 0) { + if (ccnl_wait_for_chunk(_cont_buf, BUF_SIZE, 0) > 0) { printf("Content received: %s\n", _cont_buf); return 0; } From 279de8ebe6abbac26bc992de62e71f41f8be2de9 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 6 Jan 2016 15:18:02 +0100 Subject: [PATCH 3/9] pkg ccn-lite: added CCN-Lite FIB shell command --- sys/shell/commands/sc_ccnl.c | 78 ++++++++++++++++++++++++----- sys/shell/commands/shell_commands.c | 2 + 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/sys/shell/commands/sc_ccnl.c b/sys/shell/commands/sc_ccnl.c index 7fc6322877..e10ee3450b 100644 --- a/sys/shell/commands/sc_ccnl.c +++ b/sys/shell/commands/sc_ccnl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 INRIA. + * Copyright (C) 2015, 2016 INRIA. * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -23,7 +23,7 @@ #include "ccn-lite-riot.h" #include "ccnl-pkt-ndntlv.h" -#define MAX_CONTENT (64) +#define BUF_SIZE (64) /** * Maximum number of Interest retransmissions @@ -32,11 +32,10 @@ #define MAX_ADDR_LEN (8U) -#define BUF_SIZE (128) static unsigned char _int_buf[BUF_SIZE]; static unsigned char _cont_buf[BUF_SIZE]; -static char *_default_content = "Start the RIOT!"; +static const char *_default_content = "Start the RIOT!"; static unsigned char _out[CCNL_MAX_PACKET_SIZE]; /* check for one-time initialization */ @@ -94,7 +93,7 @@ static void _content_usage(char *argv) int _ccnl_content(int argc, char **argv) { - char *body = _default_content; + char *body = (char*) _default_content; int arg_len = strlen(_default_content) + 1; int offs = CCNL_MAX_PACKET_SIZE; if (argc < 2) { @@ -103,13 +102,13 @@ int _ccnl_content(int argc, char **argv) } if (argc > 2) { - char buf[MAX_CONTENT]; - memset(buf, ' ', MAX_CONTENT); + char buf[BUF_SIZE]; + memset(buf, ' ', BUF_SIZE); char *buf_ptr = buf; - for (int i = 2; (i < argc) && (buf_ptr < (buf + MAX_CONTENT)); i++) { + for (int i = 2; (i < argc) && (buf_ptr < (buf + BUF_SIZE)); i++) { arg_len = strlen(argv[i]); - if ((buf_ptr + arg_len) > (buf + MAX_CONTENT)) { - arg_len = (buf + MAX_CONTENT) - buf_ptr; + if ((buf_ptr + arg_len) > (buf + BUF_SIZE)) { + arg_len = (buf + BUF_SIZE) - buf_ptr; } strncpy(buf_ptr, argv[i], arg_len); buf_ptr += arg_len + 1; @@ -148,8 +147,9 @@ int _ccnl_content(int argc, char **argv) static void _interest_usage(char *arg) { printf("usage: %s [relay]\n" - "%% %s /riot/peter/schmerzl (classic lookup)\n", - arg, arg); + "%% %s /riot/peter/schmerzl (classic lookup)\n" + "%% %s /riot/peter/schmerzl 01:02:03:04:05:06\n", + arg, arg, arg); } int _ccnl_interest(int argc, char **argv) @@ -180,3 +180,57 @@ int _ccnl_interest(int argc, char **argv) return -1; } + +static void _ccnl_fib_usage(char *argv) +{ + printf("usage: %s [ ]\n" + "%% %s (prints the current FIB)\n" + "%% %s /riot/peter/schmerzl RIOT\n", + argv, argv, argv); +} + +int _ccnl_fib(int argc, char **argv) +{ + if (argc < 2) { + ccnl_show_fib(&ccnl_relay); + } + else if (argc == 3) { + size_t addr_len = MAX_ADDR_LEN; + uint8_t relay_addr[MAX_ADDR_LEN]; + int suite = CCNL_SUITE_NDNTLV; + memset(relay_addr, UINT8_MAX, MAX_ADDR_LEN); + addr_len = gnrc_netif_addr_from_str(relay_addr, sizeof(relay_addr), argv[2]); + + if (addr_len == 0) { + printf("Error: %s is not a valid link layer address\n", argv[2]); + return -1; + } + + struct ccnl_prefix_s *prefix = ccnl_URItoPrefix(argv[1], suite, NULL, 0); + + if (!prefix) { + puts("Error: prefix could not be created!"); + return -1; + } + + sockunion sun; + sun.sa.sa_family = AF_PACKET; + memcpy(&(sun.linklayer.sll_addr), relay_addr, addr_len); + sun.linklayer.sll_halen = addr_len; + sun.linklayer.sll_protocol = htons(ETHERTYPE_NDN); + + /* 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)); + fibface->flags |= CCNL_FACE_FLAGS_STATIC; + + if (ccnl_add_fib_entry(&ccnl_relay, prefix, fibface) != 0) { + printf("Error adding (%s : %s) to the FIB\n", argv[1], argv[2]); + return -1; + } + } + else { + _ccnl_fib_usage(argv[0]); + return -1; + } + return 0; +} diff --git a/sys/shell/commands/shell_commands.c b/sys/shell/commands/shell_commands.c index 5ff81b1082..39125e34af 100644 --- a/sys/shell/commands/shell_commands.c +++ b/sys/shell/commands/shell_commands.c @@ -126,6 +126,7 @@ extern int _gnrc_6ctx(int argc, char **argv); extern int _ccnl_open(int argc, char **argv); extern int _ccnl_content(int argc, char **argv); extern int _ccnl_interest(int argc, char **argv); +extern int _ccnl_fib(int argc, char **argv); #endif const shell_command_t _shell_command_list[] = { @@ -211,6 +212,7 @@ const shell_command_t _shell_command_list[] = { { "ccnl_open", "opens an interface or socket", _ccnl_open}, { "ccnl_int", "sends an interest", _ccnl_interest}, { "ccnl_cont", "create content and populated it", _ccnl_content}, + { "ccnl_fib", "shows or modifies the CCN-Lite FIB", _ccnl_fib}, #endif {NULL, NULL, NULL} }; From d3ddbf322305e7d367b62db28ea92bf1795fbce9 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Tue, 26 Jan 2016 17:42:53 +0100 Subject: [PATCH 4/9] shell: adapt ccnl commands to changed API Also removes some code duplication --- sys/shell/commands/sc_ccnl.c | 97 +++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/sys/shell/commands/sc_ccnl.c b/sys/shell/commands/sc_ccnl.c index e10ee3450b..6ecb397341 100644 --- a/sys/shell/commands/sc_ccnl.c +++ b/sys/shell/commands/sc_ccnl.c @@ -19,6 +19,7 @@ */ #include "random.h" +#include "sched.h" #include "net/gnrc/netif.h" #include "ccn-lite-riot.h" #include "ccnl-pkt-ndntlv.h" @@ -144,12 +145,49 @@ int _ccnl_content(int argc, char **argv) return 0; } +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; + } + + /* initialize address with 0xFF for broadcast */ + size_t addr_len = MAX_ADDR_LEN; + uint8_t relay_addr[MAX_ADDR_LEN]; + memset(relay_addr, UINT8_MAX, MAX_ADDR_LEN); + + 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; + } + + sockunion sun; + sun.sa.sa_family = AF_PACKET; + memcpy(&(sun.linklayer.sll_addr), relay_addr, addr_len); + sun.linklayer.sll_halen = addr_len; + sun.linklayer.sll_protocol = htons(ETHERTYPE_NDN); + + /* 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)); + fibface->flags |= CCNL_FACE_FLAGS_STATIC; + + if (ccnl_fib_add_entry(&ccnl_relay, prefix, fibface) != 0) { + printf("Error adding (%s : %s) to the FIB\n", pfx, addr_str); + return -1; + } + + return 0; +} + static void _interest_usage(char *arg) { printf("usage: %s [relay]\n" - "%% %s /riot/peter/schmerzl (classic lookup)\n" - "%% %s /riot/peter/schmerzl 01:02:03:04:05:06\n", - arg, arg, arg); + "%% %s /riot/peter/schmerzl (classic lookup)\n", + arg, arg); } int _ccnl_interest(int argc, char **argv) @@ -159,22 +197,29 @@ int _ccnl_interest(int argc, char **argv) return -1; } - /* initialize address with 0xFF for broadcast */ - size_t addr_len = MAX_ADDR_LEN; - uint8_t relay_addr[MAX_ADDR_LEN]; - memset(relay_addr, UINT8_MAX, MAX_ADDR_LEN); if (argc > 2) { - addr_len = gnrc_netif_addr_from_str(relay_addr, sizeof(relay_addr), argv[2]); + if (_intern_fib_add(argv[1], argv[2]) < 0) { + _interest_usage(argv[0]); + return -1; + } } memset(_int_buf, '\0', BUF_SIZE); memset(_cont_buf, '\0', BUF_SIZE); for (int cnt = 0; cnt < CCNL_INTEREST_RETRIES; cnt++) { - ccnl_send_interest(CCNL_SUITE_NDNTLV, argv[1], relay_addr, addr_len, NULL, _int_buf, BUF_SIZE); + gnrc_netreg_entry_t _ne; + /* register for content chunks */ + _ne.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL; + _ne.pid = sched_active_pid; + gnrc_netreg_register(GNRC_NETTYPE_CCN_CHUNK, &_ne); + + ccnl_send_interest(CCNL_SUITE_NDNTLV, argv[1], NULL, _int_buf, BUF_SIZE); if (ccnl_wait_for_chunk(_cont_buf, BUF_SIZE, 0) > 0) { + gnrc_netreg_unregister(GNRC_NETTYPE_CCN_CHUNK, &_ne); printf("Content received: %s\n", _cont_buf); return 0; } + gnrc_netreg_unregister(GNRC_NETTYPE_CCN_CHUNK, &_ne); } printf("Timeout! No content received in response to the Interest for %s.\n", argv[1]); @@ -192,39 +237,11 @@ static void _ccnl_fib_usage(char *argv) int _ccnl_fib(int argc, char **argv) { if (argc < 2) { - ccnl_show_fib(&ccnl_relay); + ccnl_fib_show(&ccnl_relay); } else if (argc == 3) { - size_t addr_len = MAX_ADDR_LEN; - uint8_t relay_addr[MAX_ADDR_LEN]; - int suite = CCNL_SUITE_NDNTLV; - memset(relay_addr, UINT8_MAX, MAX_ADDR_LEN); - addr_len = gnrc_netif_addr_from_str(relay_addr, sizeof(relay_addr), argv[2]); - - if (addr_len == 0) { - printf("Error: %s is not a valid link layer address\n", argv[2]); - return -1; - } - - struct ccnl_prefix_s *prefix = ccnl_URItoPrefix(argv[1], suite, NULL, 0); - - if (!prefix) { - puts("Error: prefix could not be created!"); - return -1; - } - - sockunion sun; - sun.sa.sa_family = AF_PACKET; - memcpy(&(sun.linklayer.sll_addr), relay_addr, addr_len); - sun.linklayer.sll_halen = addr_len; - sun.linklayer.sll_protocol = htons(ETHERTYPE_NDN); - - /* 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)); - fibface->flags |= CCNL_FACE_FLAGS_STATIC; - - if (ccnl_add_fib_entry(&ccnl_relay, prefix, fibface) != 0) { - printf("Error adding (%s : %s) to the FIB\n", argv[1], argv[2]); + if (_intern_fib_add(argv[1], argv[2]) < 0) { + _ccnl_fib_usage(argv[0]); return -1; } } From 08a15b3920eea75217452a24911dfc620898451b Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 3 Feb 2016 15:09:23 +0100 Subject: [PATCH 5/9] pkg ccn-lite: update documentation --- pkg/ccn-lite/ccn-lite-riot.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/ccn-lite/ccn-lite-riot.h b/pkg/ccn-lite/ccn-lite-riot.h index cc544712fb..297eec46c9 100644 --- a/pkg/ccn-lite/ccn-lite-riot.h +++ b/pkg/ccn-lite/ccn-lite-riot.h @@ -176,7 +176,15 @@ int ccnl_send_interest(int suite, char *name, unsigned int *chunknum, unsigned char *buf, size_t buf_len); /** - * @brief Waits for incoming content chunk + * @brief Wait for incoming content chunk + * + * @pre The thread has to register for CCNL_CONT_CHUNK in @ref netreg first + * + * @post The thread should unregister from @ref netreg after this function returns + * + * @param[out] buf Buffer to stores the received content + * @param[in] buf_len Size of @p buf + * @param[in] timeout Maximum to wait for the chunk, set to a default value if 0 * * @return 0 if a content was received * @return -ETIMEDOUT if no chunk was received until timeout From 5db537fbabb93e81edea17910a6aaf709f69a216 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 3 Feb 2016 16:46:28 +0100 Subject: [PATCH 6/9] ccn-lite: add shell function to remove FIB entry --- pkg/ccn-lite/ccn-lite-riot.h | 2 ++ sys/shell/commands/sc_ccnl.c | 68 ++++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/pkg/ccn-lite/ccn-lite-riot.h b/pkg/ccn-lite/ccn-lite-riot.h index 297eec46c9..11ac9d5372 100644 --- a/pkg/ccn-lite/ccn-lite-riot.h +++ b/pkg/ccn-lite/ccn-lite-riot.h @@ -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 * diff --git a/sys/shell/commands/sc_ccnl.c b/sys/shell/commands/sc_ccnl.c index 6ecb397341..1c1dde0828 100644 --- a/sys/shell/commands/sc_ccnl.c +++ b/sys/shell/commands/sc_ccnl.c @@ -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 [ ]\n" - "%% %s (prints the current FIB)\n" - "%% %s /riot/peter/schmerzl RIOT\n", - argv, argv, argv); + printf("usage: %s [ ]\n" + "prints the FIB if called without parameters:\n" + "%% %s\n" + " 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; } From 37879d515f9597e43ff4286fbe46a693d28860b9 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sun, 7 Feb 2016 19:04:10 +0100 Subject: [PATCH 7/9] pkg ccn-lite: set CCNL_RIOT define in Makefile --- Makefile.dep | 5 +++++ pkg/ccn-lite/ccn-lite-riot.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.dep b/Makefile.dep index bdb81e4c8d..398808c669 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -6,6 +6,11 @@ ifneq (,$(filter libcoap,$(USEPKG))) USEMODULE += gnrc_conn_udp endif +ifneq (,$(filter ccn-lite,$(USEPKG))) + export CFLAGS += -DCCNL_RIOT +endif + + ifneq (,$(filter nhdp,$(USEMODULE))) USEMODULE += conn_udp USEMODULE += xtimer diff --git a/pkg/ccn-lite/ccn-lite-riot.h b/pkg/ccn-lite/ccn-lite-riot.h index 11ac9d5372..be164bfe1e 100644 --- a/pkg/ccn-lite/ccn-lite-riot.h +++ b/pkg/ccn-lite/ccn-lite-riot.h @@ -19,11 +19,6 @@ * @{ */ -/** - * Use RIOT specific configuration in CCN-Lite - */ -#define CCNL_RIOT - #include #include "kernel_types.h" #include "arpa/inet.h" From b64f850ee80ec797af9772f1accde80c2900cfca Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 23 Mar 2016 13:47:55 +0100 Subject: [PATCH 8/9] example ccn-lite: updated and extended README --- examples/ccn-lite-relay/README.md | 65 +++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/examples/ccn-lite-relay/README.md b/examples/ccn-lite-relay/README.md index b053cba468..52f8560534 100644 --- a/examples/ccn-lite-relay/README.md +++ b/examples/ccn-lite-relay/README.md @@ -16,19 +16,31 @@ RIOT provides three shell to interact with the CCN-Lite stack: incorrect ID, you should get an error message.) You have to call this command, before you can actually send or receive anything. -* `ccnl_int` - generates and sends out an Interest. The command expects one - mandatory and one optional parameter. The first parameter - specifies the exact name (or a prefix) to request, the second - parameter specifies the link-layer address of the relay to use. - If the second parameter is omitted, the Interest will be - broadcasted. You may call it like this: - `ccnl_int /riot/peter/schmerzl b6:e5:94:26:ab:da` -* `ccnl_cont` - generates and populates Content. The command expects one - mandatory and one optional parameter. The first parameter - specifies the name of the content to be created, the second - parameter specifies the content itself. The second parameter may - include spaces, e.g. you can call: - `ccnl_cont /riot/peter/schmerzl Hello World! Hello RIOT!` +* `ccnl_int` - generates and sends out an Interest. The command expects one + mandatory and one optional parameter. The first parameter + specifies the exact name (or a prefix) to request, the second + parameter specifies the link-layer address of the relay to use. + If the second parameter is omitted, the Interest will be + broadcasted. You may call it like this: + `ccnl_int /riot/peter/schmerzl b6:e5:94:26:ab:da` +* `ccnl_cont` - generates and populates content. The command expects one + mandatory and one optional parameter. The first parameter + specifies the name of the content to be created, the second + parameter specifies the content itself. The second 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 + called without parameters, it will print the current state of + the FIB. It can also be called with the action parameters `add` + or `del` to add or delete an entry from the FIB, e.g. + `ccnl_fib add /riot/peter/schmerzl ab:cd:ef:01:23:45:67:89` + will add an entry for `/riot/peter/schmerzl` with + `ab:cd:ef:01:23:45:67:89` as a next hop and + `ccnl_fib del /riot/peter/schmerzl` + will remove the entry for `/riot/peter/schmerzl` and + `ccnl_fib del ab:cd:ef:01:23:45:67:89` + will remove all entries with `ab:cd:ef:01:23:45:67:89` as a + next hop. ## Example setup @@ -39,11 +51,32 @@ An example usage of this application could be setup like this: windows. 3. Call `make -B clean all term` in the first terminal and `PORT=tap1 make term` in the second one. -4. Enter `open 3` in both terminals. +4. Enter `ccnl_open 3` in both terminals. 5. Enter `ccnl_cont /riot/peter/schmerzl Hello World! Hello RIOT!` on the first terminal. -6. Enter `ccnl_int /riot/peter/schmerzl` in the second terminal. -7. See the content being displayed. Be happy! +6. Add a FIB entry for this prefix on the second node, e.g. using the broadcast + address: `ccnl_fib add /riot/peter/schmerzl ff:ff:ff:ff:ff:ff` +7. Enter `ccnl_int /riot/peter/schmerzl` in the second terminal. +8. See the content being displayed. Be happy! + +## Makefile configuration + +The ccn-lite package provides several configuration options through defines +that can be set in the application Makefile. The following options are +mandatory for now: +* `CFLAGS += -DUSE_LINKLAYER` - use CCN directly over the link layer +* `CFLAGS += -DCCNL_UAPI_H_` - tell ccn-lite to use the UAPI +* `CFLAGS += -DUSE_SUITE_NDNTLV` - use NDNTLV packet format +* `CFLAGS += -DNEEDS_PREFIX_MATCHING` - enables prefix matching +* `CFLAGS += -DNEEDS_PACKET_CRAFTING` - enable userspace packet creation +Here's a list of some additional interesting options: +* `CFLAGS += -DUSE_RONR` - enable Reactive Optimistic Name-based + Routing (RONR) +* `CFLAGS += -DUSE_STATS` - enable statistics +* `CFLAGS += -DUSE_DUP_CHECK` - enable duplicate checks when forwarding +* `CFLAGS += -DUSE_HMAC256` - HMAC256 signed packets for CCNx1.0 + encoding + ## Wireshark dissector From 82046155d921f997c666650511e3eae8b6c7cdaf Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 23 Mar 2016 13:48:11 +0100 Subject: [PATCH 9/9] example ccn-lite: minor Makefile cleanup --- examples/ccn-lite-relay/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/ccn-lite-relay/Makefile b/examples/ccn-lite-relay/Makefile index c4c44f64d0..c328d94a42 100644 --- a/examples/ccn-lite-relay/Makefile +++ b/examples/ccn-lite-relay/Makefile @@ -11,12 +11,10 @@ RIOTBASE ?= $(CURDIR)/../.. CFLAGS += -DDEVELHELP CFLAGS += -DUSE_LINKLAYER -CFLAGS += -DUSE_IPV6 CFLAGS += -DCCNL_UAPI_H_ CFLAGS += -DUSE_SUITE_NDNTLV CFLAGS += -DNEEDS_PREFIX_MATCHING CFLAGS += -DNEEDS_PACKET_CRAFTING -CFLAGS += -DUSE_HMAC256 # Change this to 0 show compiler invocation lines by default: QUIET ?= 1