Skip to content

Commit

Permalink
Merge pull request #119 from cgundogan/pr/riot_interest_to_local_cache
Browse files Browse the repository at this point in the history
ccn-lite-riot.c: reuse ccnl_ndntlv_forwarder to send interests
  • Loading branch information
blacksheeep authored May 10, 2017
2 parents d429771 + ef47513 commit 36de664
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/ccn-lite-riot.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,14 @@ ccnl_wait_for_chunk(void *buf, size_t buf_len, uint64_t timeout)
/* TODO: move everything below here to ccn-lite-core-utils */

/* generates and send out an interest */
struct ccnl_interest_s
*ccnl_send_interest(struct ccnl_prefix_s *prefix, unsigned char *buf, size_t buf_len)
int
ccnl_send_interest(struct ccnl_prefix_s *prefix, unsigned char *buf, size_t buf_len)
{
int ret = -1;

if (_ccnl_suite != CCNL_SUITE_NDNTLV) {
DEBUGMSG(WARNING, "Suite not supported by RIOT!");
return NULL;
return ret;
}

ccnl_mkInterestFunc mkInterest;
Expand All @@ -590,14 +592,14 @@ struct ccnl_interest_s

if (!mkInterest || !isContent) {
DEBUGMSG(WARNING, "No functions for this suite were found!");
return NULL;
return ret;
}

DEBUGMSG(INFO, "interest for chunk number: %u\n", (prefix->chunknum == NULL) ? 0 : *prefix->chunknum);

if (!prefix) {
DEBUGMSG(ERROR, "prefix could not be created!\n");
return NULL;
return ret;
}

int nonce = random_uint32();
Expand All @@ -615,17 +617,15 @@ struct ccnl_interest_s
/* TODO: support other suites */
if (ccnl_ndntlv_dehead(&data, &len, (int*) &typ, &int_len) || (int) int_len > len) {
DEBUGMSG(WARNING, " invalid packet format\n");
return NULL;
return ret;
}
pkt = ccnl_ndntlv_bytes2pkt(NDN_TLV_Interest, start, &data, &len);

struct ccnl_interest_s *i = ccnl_interest_new(&ccnl_relay, loopback_face, &pkt);
if (i) {
ccnl_interest_append_pending(i, loopback_face);
ccnl_interest_propagate(&ccnl_relay, i);
}
ret = ccnl_fwd_handleInterest(&ccnl_relay, loopback_face, &pkt, ccnl_ndntlv_cMatch);

free_packet(pkt);

return i;
return ret;
}

void
Expand Down

0 comments on commit 36de664

Please sign in to comment.