예제 #1
0
void
ccnl_core_cleanup(struct ccnl_relay_s *ccnl)
{
    int k;

    DEBUGMSG_CORE(TRACE, "ccnl_core_cleanup %p\n", (void *) ccnl);

    while (ccnl->pit)
        ccnl_interest_remove(ccnl, ccnl->pit);
    while (ccnl->faces)
        ccnl_face_remove(ccnl, ccnl->faces); // removes allmost all FWD entries
    while (ccnl->fib) {
        struct ccnl_forward_s *fwd = ccnl->fib->next;
        ccnl_prefix_free(ccnl->fib->prefix);
        ccnl_free(ccnl->fib);
        ccnl->fib = fwd;
    }
    while (ccnl->contents)
        ccnl_content_remove(ccnl, ccnl->contents);
    while (ccnl->nonces) {
        struct ccnl_buf_s *tmp = ccnl->nonces->next;
        ccnl_free(ccnl->nonces);
        ccnl->nonces = tmp;
    }
    for (k = 0; k < ccnl->ifcount; k++)
        ccnl_interface_cleanup(ccnl->ifs + k);
}
예제 #2
0
파일: ccnl-core.c 프로젝트: AnonMall/RIOT
void ccnl_core_cleanup(struct ccnl_relay_s *ccnl)
{
    int k;
    DEBUGMSG(99, "ccnl_core_cleanup %p\n", (void *) ccnl);

    while (ccnl->pit) {
        ccnl_interest_remove(ccnl, ccnl->pit);
    }

    while (ccnl->faces) {
        ccnl_face_remove(ccnl, ccnl->faces);    // also removes all FWD entries
    }

    while (ccnl->contents) {
        ccnl_content_remove(ccnl, ccnl->contents);
    }

    while (ccnl->nonces) {
        ccnl_nonce_remove(ccnl, ccnl->nonces);
    }

    for (k = 0; k < ccnl->ifcount; k++) {
        ccnl_interface_cleanup(ccnl->ifs + k);
    }
}
예제 #3
0
파일: ccnl-core.c 프로젝트: AnonMall/RIOT
void ccnl_do_ageing(void *ptr, void *dummy)
{

    (void) dummy; /* unused */

    struct ccnl_relay_s *relay = (struct ccnl_relay_s *) ptr;
    struct ccnl_interest_s *i = relay->pit;
    struct ccnl_content_s *c = relay->contents;

    struct ccnl_face_s *f = relay->faces;
    struct timeval now;
    ccnl_get_timeval(&now);
    //DEBUGMSG(999, "ccnl_do_ageing %ld:%ld\n", now.tv_sec, now.tv_usec);

    while (i) {
        if (ccnl_is_timed_out(&now, &i->last_used, CCNL_INTEREST_TIMEOUT_SEC,
                CCNL_INTEREST_TIMEOUT_USEC)) {
            if (i->from->ifndx == RIOT_MSG_IDX) {
                /* this interest was requested by an app from this node */
                /* inform this app about this problem */
                riot_send_nack(i->from->faceid);
            }
            i = ccnl_interest_remove(relay, i);
        }
        else {
            i = i->next;
        }
    }

    while (c) {
        if (ccnl_is_timed_out(&now, &c->last_used, CCNL_CONTENT_TIMEOUT_SEC, CCNL_CONTENT_TIMEOUT_USEC)
            && !(c->flags & CCNL_CONTENT_FLAGS_STATIC)) {
            c = ccnl_content_remove(relay, c);
        }
        else {
            c = c->next;
        }
    }

    while (f) {
        if (!(f->flags & CCNL_FACE_FLAGS_STATIC)
            && ccnl_is_timed_out(&now, &f->last_used, CCNL_FACE_TIMEOUT_SEC, CCNL_FACE_TIMEOUT_USEC)) {
            f = ccnl_face_remove(relay, f);
        }
        else {
            f = f->next;
        }
    }

    struct ccnl_forward_s *fwd = relay->fib;
    while (fwd) {
        if (!(fwd->flags & CCNL_FORWARD_FLAGS_STATIC)
            && ccnl_is_timed_out(&now, &fwd->last_used, CCNL_FWD_TIMEOUT_SEC, CCNL_FWD_TIMEOUT_USEC)) {
            fwd = ccnl_forward_remove(relay, fwd);
        }
        else {
            fwd = fwd->next;
        }
    }
}
예제 #4
0
파일: ccnl-core.c 프로젝트: nevvi/D0020E
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;
    }
}
int
ccnl_nfn_RX_result(struct ccnl_relay_s *relay, struct ccnl_face_s *from,
                   struct ccnl_content_s *c)
{
    struct ccnl_interest_s *i_it = NULL;
    int found = 0;

    TRACEIN();
#ifdef USE_NACK
    if (ccnl_nfnprefix_contentIsNACK(c)) {
        ccnl_nfn_nack_local_computation(relay, c->pkt->buf, c->pkt->pfx,
                                        from, c->pkt->pfx->suite);
        return -1;
    }
#endif // USE_NACK
    for (i_it = relay->pit; i_it;/* i_it = i_it->next*/) {
        //Check if prefix match and it is a nfn request
        if (!ccnl_prefix_cmp(c->pkt->pfx, NULL, i_it->pkt->pfx, CMP_EXACT) &&
                                        i_it->from && i_it->from->faceid < 0) {
            struct ccnl_face_s *from = i_it->from;
            int faceid = - from->faceid;

            DEBUGMSG(TRACE, "  interest faceid=%d\n", i_it->from->faceid);

            ccnl_content_add2cache(relay, c);
            DEBUGMSG(DEBUG, "Continue configuration for configid: %d with prefix: %s\n",
                  faceid, ccnl_prefix_to_path(c->pkt->pfx));
            i_it->flags |= CCNL_PIT_COREPROPAGATES;
            i_it->from = NULL;
            ccnl_nfn_continue_computation(relay, faceid, 0);
            i_it = ccnl_interest_remove(relay, i_it);
            ccnl_face_remove(relay, from);
            ++found;
            //goto Done;
        } else
            i_it = i_it->next;
    }
    TRACEOUT();
    return found > 0;
}
예제 #6
0
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;
    }
}