Skip to content

Commit

Permalink
interest: fix timeout calculation for suite != NDN-TLV
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundogan committed Feb 25, 2019
1 parent 3a6d238 commit 0c86bf2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/ccnl-core/include/ccnl-pkt-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <stdint.h>
#include <stddef.h>

#include "ccnl-pkt.h"

uint8_t
ccnl_isSuite(int suite);

Expand Down Expand Up @@ -52,4 +54,14 @@ ccnl_pkt2suite(uint8_t *data, size_t len, size_t *skip);
int
ccnl_cmp2int(unsigned char *cmp, size_t cmplen);

/**
* Return the Interest lifetime
*
* @param[in] pkt Pointer to the Interest packet
*
* @return The interest lifetime
*/
uint64_t
ccnl_pkt_interest_lifetime(const struct ccnl_pkt_s *pkt);

#endif
3 changes: 2 additions & 1 deletion src/ccnl-core/src/ccnl-interest.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ ccnl_interest_new(struct ccnl_relay_s *ccnl, struct ccnl_face_s *from,
return NULL;
i->pkt = *pkt;
/* currently, the aging function relies on seconds rather than on milli seconds */
i->lifetime = (*pkt)->s.ndntlv.interestlifetime / 1000;
i->lifetime = ccnl_pkt_interest_lifetime(*pkt);

*pkt = NULL;
i->from = from;
i->last_used = CCNL_NOW();
Expand Down
20 changes: 20 additions & 0 deletions src/ccnl-core/src/ccnl-pkt-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,23 @@ ccnl_cmp2int(unsigned char *cmp, size_t cmplen)

return 0;
}

uint64_t
ccnl_pkt_interest_lifetime(const struct ccnl_pkt_s *pkt)
{
switch(pkt->suite) {
#ifdef USE_SUITE_CCNTLV
case CCNL_SUITE_CCNTLV:
/* CCN-TLV parser does not support lifetime parsing, yet. */
return CCNL_INTEREST_TIMEOUT;
#endif
#ifdef USE_SUITE_NDNTLV
case CCNL_SUITE_NDNTLV:
return (pkt->s.ndntlv.interestlifetime / 1000);
#endif
default:
break;
}

return CCNL_INTEREST_TIMEOUT;
}

0 comments on commit 0c86bf2

Please sign in to comment.