From b6581289a2756d219855d05fb2077117a6de87a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 26 Jul 2017 23:22:01 +0200 Subject: [PATCH] pkg: ccn-lite: adapt to v2 --- Makefile.dep | 4 + examples/ccn-lite-relay/Makefile | 1 - makefiles/pseudomodules.inc.mk | 1 + pkg/ccn-lite/Makefile | 8 +- pkg/ccn-lite/Makefile.include | 5 +- pkg/ccn-lite/ccn-lite-riot.h | 302 ------------------ ...001-ccn-line-riot-port-to-gnrc_netif.patch | Bin 738 -> 0 bytes sys/shell/commands/sc_ccnl.c | 8 +- 8 files changed, 16 insertions(+), 313 deletions(-) delete mode 100644 pkg/ccn-lite/ccn-lite-riot.h delete mode 100644 pkg/ccn-lite/patches/0001-ccn-line-riot-port-to-gnrc_netif.patch diff --git a/Makefile.dep b/Makefile.dep index a8c5177afd..3b13db9cc6 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -664,6 +664,10 @@ ifneq (,$(filter nanocoap_%,$(USEMODULE))) USEMODULE += nanocoap endif +ifneq (,$(filter ccn-lite,$(USEPKG))) + USEMODULE += ccn-lite-utils +endif + # always select gpio (until explicit dependencies are sorted out) FEATURES_OPTIONAL += periph_gpio diff --git a/examples/ccn-lite-relay/Makefile b/examples/ccn-lite-relay/Makefile index 7d89a3ebc8..e31c500c8f 100644 --- a/examples/ccn-lite-relay/Makefile +++ b/examples/ccn-lite-relay/Makefile @@ -41,6 +41,5 @@ USEMODULE += prng_minstd USEPKG += tlsf USEPKG += ccn-lite -USEMODULE += ccn-lite-utils include $(RIOTBASE)/Makefile.include diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 1b499d1192..baf9e48542 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -2,6 +2,7 @@ PSEUDOMODULES += auto_init_gnrc_rpl PSEUDOMODULES += can_mbox PSEUDOMODULES += can_pm PSEUDOMODULES += can_raw +PSEUDOMODULES += ccn-lite-utils PSEUDOMODULES += cbor_ctime PSEUDOMODULES += cbor_float PSEUDOMODULES += cbor_semantic_tagging diff --git a/pkg/ccn-lite/Makefile b/pkg/ccn-lite/Makefile index df6d6813a9..4b77a3c259 100644 --- a/pkg/ccn-lite/Makefile +++ b/pkg/ccn-lite/Makefile @@ -1,6 +1,6 @@ PKG_NAME=ccn-lite PKG_URL=https://github.com/cn-uofbasel/ccn-lite/ -PKG_VERSION=7b973a737dba47fe6c1ee2d58e06dd9a22209fde +PKG_VERSION=0474080335aac08d3afa44a439ac9def92b9fcf3 PKG_LICENSE=ISC .PHONY: all @@ -8,9 +8,7 @@ PKG_LICENSE=ISC export RIOT_CFLAGS = ${CFLAGS} ${INCLUDES} all: git-download - "$(MAKE)" -BC $(PKG_BUILDDIR)/src lib-ccn-lite.a - "$(MAKE)" -BC $(PKG_BUILDDIR)/src lib-ccn-lite-utils.a - cp $(PKG_BUILDDIR)/src/lib-ccn-lite.a ${BINDIR}/ccn-lite.a - cp $(PKG_BUILDDIR)/src/lib-ccn-lite-utils.a ${BINDIR}/ccn-lite-utils.a + cd $(PKG_BUILDDIR)/src && cmake -DCCNL_RIOT=1 -DRIOT_CFLAGS="${RIOT_CFLAGS}" . && make + cp $(PKG_BUILDDIR)/src/lib/libccnl-riot.a ${BINDIR}/ccn-lite.a include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/ccn-lite/Makefile.include b/pkg/ccn-lite/Makefile.include index 8718a60edb..a91eba997a 100644 --- a/pkg/ccn-lite/Makefile.include +++ b/pkg/ccn-lite/Makefile.include @@ -1,4 +1,7 @@ -INCLUDES += -I$(RIOTPKG)/ccn-lite -I$(PKGDIRBASE)/ccn-lite/src +INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-riot/include +INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-core/include +INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-pkt/include +INCLUDES += -I$(PKGDIRBASE)/ccn-lite/src/ccnl-fwd/include INCLUDES += -I$(RIOTBASE)/sys/posix/include CFLAGS += -DCCNL_RIOT diff --git a/pkg/ccn-lite/ccn-lite-riot.h b/pkg/ccn-lite/ccn-lite-riot.h deleted file mode 100644 index 71aa14e253..0000000000 --- a/pkg/ccn-lite/ccn-lite-riot.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * 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 - * directory for more details. - */ - -#ifndef CCN_LITE_RIOT_H -#define CCN_LITE_RIOT_H - -/** - * @defgroup pkg_ccnlite CCN-Lite stack - * @ingroup pkg - * @ingroup net - * @brief Provides a NDN implementation - * - * This package provides the CCN-Lite stack as a port of NDN for RIOT. - * - * @{ - */ - -#include -#include "kernel_types.h" -#include "arpa/inet.h" -#include "net/packet.h" -#include "net/ethernet/hdr.h" -#include "sys/socket.h" -#include "ccnl-defs.h" -#include "ccnl-core.h" -#include "ccnl-headers.h" -#include "net/gnrc/netreg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Define the log level of the CCN-Lite stack - */ -#define LOG_LEVEL LOG_DEBUG -#include "log.h" - -/** - * @name Dynamic memory allocation used in CCN-Lite - * - * @{ - */ -#define ccnl_malloc(s) malloc(s) -#define ccnl_calloc(n,s) calloc(n,s) -#define ccnl_realloc(p,s) realloc(p,s) -#define ccnl_free(p) free(p) -/** - * @} - */ - -/** - * Closing an interface or socket from CCN-Lite - */ -#define ccnl_close_socket(s) close(s) - -/** - * @name Log levels used by CCN-Lite debugging - * - * @{ - */ -#define FATAL LOG_ERROR -#define ERROR LOG_ERROR -#define WARNING LOG_WARNING -#define INFO LOG_INFO -#define DEBUG LOG_DEBUG -#define TRACE LOG_DEBUG -#define VERBOSE LOG_ALL -/** - * @} - */ - -/** - * @name CCN-Lite's debugging macros - * - * @{ - */ -#define DEBUGMSG(LVL, ...) do { \ - if ((LVL)>debug_level) break; \ - LOG(LVL, __VA_ARGS__); \ - } while (0) - -#define DEBUGMSG_CORE(...) DEBUGMSG(__VA_ARGS__) -#define DEBUGMSG_CFWD(...) DEBUGMSG(__VA_ARGS__) -#define DEBUGMSG_CUTL(...) DEBUGMSG(__VA_ARGS__) -#define DEBUGMSG_PIOT(...) DEBUGMSG(__VA_ARGS__) - -#define DEBUGSTMT(LVL, ...) do { \ - if ((LVL)>debug_level) break; \ - __VA_ARGS__; \ - } while (0) - -#define TRACEIN(...) do {} while(0) -#define TRACEOUT(...) do {} while(0) -/** - * @} - */ - -/** - * @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 - */ -#define CONSTSTR(s) s - -/** - * Stack size for CCN-Lite event loop - */ -#define CCNL_STACK_SIZE (THREAD_STACKSIZE_MAIN) - -/** - * Size of the message queue of CCN-Lite's event loop - */ -#define CCNL_QUEUE_SIZE (8) - -/** - * @brief Data structure for interest packet - */ -typedef struct { - struct ccnl_prefix_s *prefix; /**< requested prefix */ - unsigned char *buf; /**< buffer to store the interest packet */ - size_t buflen; /**< size of the buffer */ -} ccnl_interest_t; - - -/** - * Maximum string length for prefix representation - */ -#define CCNL_PREFIX_BUFSIZE (50) - -/** - * Message type for signalling a timeout while waiting for a content chunk - */ -#define CCNL_MSG_TIMEOUT (0x1701) - -/** - * Message type for advancing the ageing timer - */ -#define CCNL_MSG_AGEING (0x1702) - -/** - * Maximum number of elements that can be cached - */ -#ifndef CCNL_CACHE_SIZE -#define CCNL_CACHE_SIZE (5) -#endif -#ifdef DOXYGEN -#define CCNL_CACHE_SIZE -#endif - -/** - * Struct holding CCN-Lite's central relay information - */ -extern struct ccnl_relay_s ccnl_relay; - -/** - * @brief Function pointer type for local producer function - */ -typedef int (*ccnl_producer_func)(struct ccnl_relay_s *relay, - struct ccnl_face_s *from, - struct ccnl_pkt_s *pkt); - -/** - * @brief Function pointer type for caching strategy function - */ -typedef int (*ccnl_cache_strategy_func)(struct ccnl_relay_s *relay, - struct ccnl_content_s *c); - -/** - * @brief Start the main CCN-Lite event-loop - * - * @return The PID of the event-loop's thread - */ -kernel_pid_t ccnl_start(void); - -/** - * @brief Opens a @ref net_gnrc_netif device for use with CCN-Lite - * - * @param[in] if_pid The pid of the @ref net_gnrc_netif device driver - * @param[in] netreg_type The @ref net_gnrc_nettype @p if_pid should be - * configured to use - * - * @return 0 on success, - * @return -EINVAL if eventloop could not be registered for @p netreg_type - */ -int ccnl_open_netif(kernel_pid_t if_pid, gnrc_nettype_t netreg_type); - -/** - * @brief Sends out an Interest - * - * @param[in] prefix The name that is requested - * @param[out] buf Buffer to write the content chunk to - * @param[in] buf_len Size of @p buf - * - * @return 0 on success - * @return -1 on failure - */ -int ccnl_send_interest(struct ccnl_prefix_s *prefix, - unsigned char *buf, size_t buf_len); - -/** - * @brief Wait for incoming content chunk - * - * @pre The thread has to register for CCNL_CONT_CHUNK in @ref net_gnrc_netreg - * first - * - * @post The thread should unregister from @ref net_gnrc_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 - */ -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 Remove entry from the CCN-Lite FIB - * - * @par[in] relay Local relay struct - * @par[in] pfx Prefix of the FIB entry, may be NULL - * @par[in] face Face for the FIB entry, may be NULL - * - * @return 0 on success - * @return -1 on error - */ -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 - * - * @par[in] relay Local relay struct - */ -void ccnl_fib_show(struct ccnl_relay_s *relay); - -/** - * @brief Set a local producer function - * - * Setting a local producer function allows to generate content on the fly or - * react otherwise on any kind of incoming interest. - * - * @param[in] func The function to be called first for any incoming interest - */ -void ccnl_set_local_producer(ccnl_producer_func func); - -/** - * @brief Set a function to control the caching strategy - * - * The given function will be called if the cache is full and a new content - * chunk arrives. It shall remove (at least) one entry from the cache. - * - * If the return value of @p func is 0, the default caching strategy will be - * applied by the CCN-lite stack. If the return value is 1, it is assumed that - * (at least) one entry has been removed from the cache. - * - * @param[in] func The function to be called for an incoming content chunk if - * the cache is full. - */ -void ccnl_set_cache_strategy_remove(ccnl_cache_strategy_func func); - -#ifdef __cplusplus -} -#endif -#endif /* CCN_LITE_RIOT_H */ -/** @} */ diff --git a/pkg/ccn-lite/patches/0001-ccn-line-riot-port-to-gnrc_netif.patch b/pkg/ccn-lite/patches/0001-ccn-line-riot-port-to-gnrc_netif.patch deleted file mode 100644 index 0db11bad206a162d6a99726574e681beb83b0865..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 738 zcmZvY-HzHY5QXpk6w^DR;B0;ffoxfU=%Tg)R23>!s;bCw#;n`mAjfGJb@$zCZ^X72 zM3L+{IrGirtaNjPlrf%6Se9hfG@VY#n+D@QaHda10+JI?5;cqx7%?pJ_3PLEQ1X|5+ zdcW!Y0f#4u!MEQc5VA(#4@@1f8roW_7VYwl8u*^8E37TcmeeDpl0pEb2Wf!aT;rD4 zR3dE(kC505%TW~se2U0p0Z|x^M z!Qdxqg>`X~RbfC1cNxA$WX>nFvJFe)p>UN);12=!u-4@;aE-Dpez96sgTCMMZV7c3 zDPZvCU)%*g%GSJ^EXcpO{xcoW6y@3NadEKTTM`FZFe2nHflags |= CCNL_CONTENT_FLAGS_STATIC; @@ -208,7 +208,7 @@ int _ccnl_interest(int argc, char **argv) struct ccnl_prefix_s *prefix = ccnl_URItoPrefix(argv[1], CCNL_SUITE_NDNTLV, NULL, 0); int res = ccnl_send_interest(prefix, _int_buf, BUF_SIZE); - free_prefix(prefix); + ccnl_prefix_free(prefix); return res; } @@ -241,7 +241,7 @@ int _ccnl_fib(int argc, char **argv) return -1; } int res = ccnl_fib_rem_entry(&ccnl_relay, prefix, NULL); - free_prefix(prefix); + ccnl_prefix_free(prefix); return res; } else {