Skip to content

Commit 587a435

Browse files
committed
pkg ccn-lite: adapt to updated CCN-Lite version
1 parent 8ef719b commit 587a435

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

pkg/ccn-lite/ccn-lite-riot.h

+40-7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ extern "C" {
105105
* @}
106106
*/
107107

108+
/**
109+
* @brief Some macro definitions
110+
* @{
111+
*/
112+
#define free_2ptr_list(a,b) ccnl_free(a), ccnl_free(b)
113+
#define free_3ptr_list(a,b,c) ccnl_free(a), ccnl_free(b), ccnl_free(c)
114+
#define free_4ptr_list(a,b,c,d) ccnl_free(a), ccnl_free(b), ccnl_free(c), ccnl_free(d);
115+
#define free_5ptr_list(a,b,c,d,e) ccnl_free(a), ccnl_free(b), ccnl_free(c), ccnl_free(d), ccnl_free(e);
116+
117+
/**
118+
* Frees all memory directly and indirectly allocated for prefix information
119+
*/
120+
#define free_prefix(p) do{ if(p) \
121+
free_5ptr_list(p->bytes,p->comp,p->complen,p->chunknum,p); } while(0)
122+
123+
108124
/**
109125
* Constant string
110126
*/
@@ -123,7 +139,7 @@ extern "C" {
123139
/**
124140
* Struct holding CCN-Lite's central relay information
125141
*/
126-
extern struct ccnl_relay_s theRelay;
142+
extern struct ccnl_relay_s ccnl_relay;
127143

128144
/**
129145
* @brief Start the main CCN-Lite event-loop
@@ -149,26 +165,43 @@ int ccnl_open_netif(kernel_pid_t if_pid, gnrc_nettype_t netreg_type);
149165
*
150166
* @param[in] suite CCN packet format
151167
* @param[in] name The name that is requested
152-
* @param[in] addr The relay's address to send to
153-
* @param[in] addr_len Length of @p addr
154168
* @param[in] chunknum Number of the requested content chunk
155169
* @param[out] buf Buffer to write the content chunk to
156170
* @param[in] buf_len Size of @p buf
157171
*
158172
* @return 0 on successfully sent Interest
159173
* @return -1 if Interested couldn't be sent
160174
*/
161-
int ccnl_send_interest(int suite, char *name, uint8_t *addr, size_t addr_len,
162-
unsigned int *chunknum, unsigned char *buf,
163-
size_t buf_len);
175+
int ccnl_send_interest(int suite, char *name, unsigned int *chunknum,
176+
unsigned char *buf, size_t buf_len);
164177

165178
/**
166179
* @brief Waits for incoming content chunk
167180
*
168181
* @return 0 if a content was received
169182
* @return -ETIMEDOUT if no chunk was received until timeout
170183
*/
171-
int ccnl_wait_for_chunk(void *buf, size_t buf_len);
184+
int ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout);
185+
186+
/**
187+
* @brief Add entry to the CCN-Lite FIB
188+
*
189+
* @par[in] relay Local relay struct
190+
* @par[in] pfx Prefix of the FIB entry
191+
* @par[in] face Face for the FIB entry
192+
*
193+
* @return 0 on success
194+
* @return -1 on error
195+
*/
196+
int ccnl_fib_add_entry(struct ccnl_relay_s *relay, struct ccnl_prefix_s *pfx,
197+
struct ccnl_face_s *face);
198+
199+
/**
200+
* @brief Prints the current CCN-Lite FIB
201+
*
202+
* @par[in] relay Local relay struct
203+
*/
204+
void ccnl_fib_show(struct ccnl_relay_s *relay);
172205

173206
#ifdef __cplusplus
174207
}

sys/shell/commands/sc_ccnl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ int _ccnl_content(int argc, char **argv)
138138

139139
struct ccnl_content_s *c = 0;
140140
struct ccnl_pkt_s *pk = ccnl_ndntlv_bytes2pkt(typ, olddata, &data, &arg_len);
141-
c = ccnl_content_new(&theRelay, &pk);
142-
ccnl_content_add2cache(&theRelay, c);
141+
c = ccnl_content_new(&ccnl_relay, &pk);
142+
ccnl_content_add2cache(&ccnl_relay, c);
143143
c->flags |= CCNL_CONTENT_FLAGS_STATIC;
144144

145145
return 0;
@@ -171,7 +171,7 @@ int _ccnl_interest(int argc, char **argv)
171171
memset(_cont_buf, '\0', BUF_SIZE);
172172
for (int cnt = 0; cnt < CCNL_INTEREST_RETRIES; cnt++) {
173173
ccnl_send_interest(CCNL_SUITE_NDNTLV, argv[1], relay_addr, addr_len, NULL, _int_buf, BUF_SIZE);
174-
if (ccnl_wait_for_chunk(_cont_buf, BUF_SIZE) > 0) {
174+
if (ccnl_wait_for_chunk(_cont_buf, BUF_SIZE, 0) > 0) {
175175
printf("Content received: %s\n", _cont_buf);
176176
return 0;
177177
}

0 commit comments

Comments
 (0)