Skip to content
Snippets Groups Projects
Commit 587a435a authored by Oleg Hahm's avatar Oleg Hahm
Browse files

pkg ccn-lite: adapt to updated CCN-Lite version

parent 8ef719b4
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment