void ccnl_do_ageing(void *ptr, void *dummy) { (void) dummy; struct ccnl_relay_s *relay = (struct ccnl_relay_s*) ptr; struct ccnl_content_s *c = relay->contents; struct ccnl_interest_s *i = relay->pit; struct ccnl_face_s *f = relay->faces; time_t t = CCNL_NOW(); DEBUGMSG_CORE(TRACE, "ageing t=%d\n", (int)t); while (c) { if ((c->last_used + CCNL_CONTENT_TIMEOUT) <= t && !(c->flags & CCNL_CONTENT_FLAGS_STATIC)){ DEBUGMSG_CORE(TRACE, "AGING: CONTENT REMOVE %p\n", (void*) c); c = ccnl_content_remove(relay, c); } else c = c->next; } while (i) { // CONFORM: "Entries in the PIT MUST timeout rather // than being held indefinitely." if ((i->last_used + CCNL_INTEREST_TIMEOUT) <= t || i->retries > CCNL_MAX_INTEREST_RETRANSMIT) { DEBUGMSG_CORE(TRACE, "AGING: INTEREST REMOVE %p\n", (void*) i); DEBUGMSG_CORE(DEBUG, " timeout: remove interest 0x%p <%s>\n", (void*)i, ccnl_prefix_to_path(i->pkt->pfx)); i = ccnl_nfn_interest_remove(relay, i); } else { // CONFORM: "A node MUST retransmit Interest Messages // periodically for pending PIT entries." DEBUGMSG_CORE(DEBUG, " retransmit %d <%s>\n", i->retries, ccnl_prefix_to_path(i->pkt->pfx)); #ifdef USE_NFN if (i->flags & CCNL_PIT_COREPROPAGATES){ #endif DEBUGMSG_CORE(TRACE, "AGING: PROPAGATING INTEREST %p\n", (void*) i); ccnl_interest_propagate(relay, i); #ifdef USE_NFN } #endif i->retries++; i = i->next; } } while (f) { if (!(f->flags & CCNL_FACE_FLAGS_STATIC) && (f->last_used + CCNL_FACE_TIMEOUT) <= t){ DEBUGMSG_CORE(TRACE, "AGING: FACE REMOVE %p\n", (void*) f); f = ccnl_face_remove(relay, f); } else f = f->next; } }
struct ccnl_face_s* ccnl_face_remove(struct ccnl_relay_s *ccnl, struct ccnl_face_s *f) { struct ccnl_face_s *f2; struct ccnl_interest_s *pit; struct ccnl_forward_s **ppfwd; DEBUGMSG_CORE(DEBUG, "face_remove relay=%p face=%p\n", (void*)ccnl, (void*)f); ccnl_sched_destroy(f->sched); ccnl_frag_destroy(f->frag); DEBUGMSG_CORE(TRACE, "face_remove: cleaning PIT\n"); for (pit = ccnl->pit; pit; ) { struct ccnl_pendint_s **ppend, *pend; if (pit->from == f) pit->from = NULL; for (ppend = &pit->pending; *ppend;) { if ((*ppend)->face == f) { pend = *ppend; *ppend = pend->next; ccnl_free(pend); } else ppend = &(*ppend)->next; } if (pit->pending) pit = pit->next; else { DEBUGMSG_CORE(TRACE, "before NFN interest_remove 0x%p\n", (void*)pit); pit = ccnl_nfn_interest_remove(ccnl, pit); } } DEBUGMSG_CORE(TRACE, "face_remove: cleaning fwd table\n"); for (ppfwd = &ccnl->fib; *ppfwd;) { if ((*ppfwd)->face == f) { struct ccnl_forward_s *pfwd = *ppfwd; free_prefix(pfwd->prefix); *ppfwd = pfwd->next; ccnl_free(pfwd); } else ppfwd = &(*ppfwd)->next; } DEBUGMSG_CORE(TRACE, "face_remove: cleaning pkt queue\n"); while (f->outq) { struct ccnl_buf_s *tmp = f->outq->next; ccnl_free(f->outq); f->outq = tmp; } DEBUGMSG_CORE(TRACE, "face_remove: unlinking1 %p %p\n", (void*)f->next, (void*)f->prev); f2 = f->next; DEBUGMSG_CORE(TRACE, "face_remove: unlinking2\n"); DBL_LINKED_LIST_REMOVE(ccnl->faces, f); DEBUGMSG_CORE(TRACE, "face_remove: unlinking3\n"); ccnl_free(f); TRACEOUT(); return f2; }
void ccnl_do_ageing(void *ptr, void *dummy) { struct ccnl_relay_s *relay = (struct ccnl_relay_s*) ptr; struct ccnl_content_s *c = relay->contents; struct ccnl_interest_s *i = relay->pit; struct ccnl_face_s *f = relay->faces; time_t t = CCNL_NOW(); char *bufp = NULL; DEBUGMSG_CORE(INFO, " ICNIoT: ageing t=%d\n", (int)t); while (c) { if ((c->last_used + CCNL_CONTENT_TIMEOUT) <= t && !(c->flags & CCNL_CONTENT_FLAGS_STATIC)){ DEBUGMSG_CORE(INFO, " ICNIoT: AGING: CONTENT REMOVE %p\n", (void*) c); c = ccnl_content_remove(relay, c); } else{ //akhila 29-10-2015 // check if it is the n th time instant. If yes then save the content store if ((((int)t)%CS_SAVE_PERIOD == 0) && !(c->flags & CCNL_CONTENT_FLAGS_STATIC)){ bufp = ccnl_prefix_to_path((c->pkt)->pfx); DEBUGMSG_CORE(INFO, " ICNIoT: ContentStoreItem :%s\n",bufp); ccnl_free(bufp); } c = c->next; } } if (((int)t)%CS_SAVE_PERIOD == 0){ DEBUGMSG_CORE(INFO, " ICNIoT: ContentStoreItem contentCount:%d\n",relay->contentcnt); } while (i) { // CONFORM: "Entries in the PIT MUST timeout rather // than being held indefinitely." if ((i->last_used + CCNL_INTEREST_TIMEOUT) <= t){ // if it has timed out either resend it or remove it based on MAX_RETRIES if(i->retries >= CCNL_MAX_INTEREST_RETRANSMIT){ DEBUGMSG_CORE(INFO, " ICNIoT: AGING: INTEREST REMOVE %p\n", (void*) i); // DEBUGMSG_CORE(DEBUG, " timeout: remove interest 0x%p <%s>\n",(void*)i,ccnl_prefix_to_path(i->pkt->pfx)); i = ccnl_nfn_interest_remove(relay, i); } else { // CONFORM: "A node MUST retransmit Interest Messages // periodically for pending PIT entries." DEBUGMSG_CORE(INFO, " ICNIoT: retransmit %d \n", i->retries); // ccnl_prefix_to_path(i->pkt->pfx)); #ifdef USE_NFN if (i->flags & CCNL_PIT_COREPROPAGATES){ #endif DEBUGMSG_CORE(INFO, " ICNIoT: AGING: PROPAGATING INTEREST %p\n", (void*) i); ccnl_interest_propagate(relay, i); #ifdef USE_NFN } #endif i->retries++; i = i->next; } } else{ // The interest has not timed out yet, so leave it alone ! // DEBUGMSG_CORE(INFO, " ICNIoT: AGING: DO NOTHING %p\n", (void*) i); i = i->next; } } // DEBUGMSG_CORE(INFO, " ICNIoT: PITcount %d\n",relay->pitcnt); while (f) { if (!(f->flags & CCNL_FACE_FLAGS_STATIC) && (f->last_used + CCNL_FACE_TIMEOUT) <= t){ DEBUGMSG_CORE(TRACE, "AGING: FACE REMOVE %p\n", (void*) f); f = ccnl_face_remove(relay, f); } else f = f->next; } }