/*---------------------------------------------------------------------------*/ void uip_ds6_periodic(struct net_buf *buf) { uip_ds6_addr_t *locaddr; uip_ds6_prefix_t *locprefix; /* Periodic processing on unicast addresses */ for(locaddr = uip_ds6_if.addr_list; locaddr < uip_ds6_if.addr_list + UIP_DS6_ADDR_NB; locaddr++) { if(locaddr->isused) { if((!locaddr->isinfinite) && (stimer_expired(&locaddr->vlifetime))) { uip_ds6_addr_rm(locaddr); #if UIP_ND6_DEF_MAXDADNS > 0 } else if((locaddr->state == ADDR_TENTATIVE) && (locaddr->dadnscount <= uip_ds6_if.maxdadns) && (timer_expired(&locaddr->dadtimer))) { uip_ds6_dad(NULL, locaddr); #endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } } } /* Periodic processing on default routers */ uip_ds6_defrt_periodic(); /* for(locdefrt = uip_ds6_defrt_list; locdefrt < uip_ds6_defrt_list + UIP_DS6_DEFRT_NB; locdefrt++) { if((locdefrt->isused) && (!locdefrt->isinfinite) && (stimer_expired(&(locdefrt->lifetime)))) { uip_ds6_defrt_rm(locdefrt); } }*/ #if !UIP_CONF_ROUTER /* Periodic processing on prefixes */ for(locprefix = uip_ds6_prefix_list; locprefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; locprefix++) { if(locprefix->isused && !locprefix->isinfinite && stimer_expired(&(locprefix->vlifetime))) { uip_ds6_prefix_rm(locprefix); } } #endif /* !UIP_CONF_ROUTER */ uip_ds6_neighbor_periodic(buf); #if UIP_CONF_ROUTER && UIP_ND6_SEND_RA /* Periodic RA sending */ if(stimer_expired(&uip_ds6_timer_ra) && (uip_len == 0)) { uip_ds6_send_ra_periodic(); } #endif /* UIP_CONF_ROUTER && UIP_ND6_SEND_RA */ etimer_reset(&uip_ds6_timer_periodic); return; }
/*---------------------------------------------------------------------------*/ void uip_ds6_periodic(void) { /* Periodic processing on unicast addresses */ for(locaddr = uip_ds6_if.addr_list; locaddr < uip_ds6_if.addr_list + UIP_DS6_ADDR_NB; locaddr++) { if(locaddr->isused) { if((!locaddr->isinfinite) && (stimer_expired(&locaddr->vlifetime))) { uip_ds6_addr_rm(locaddr); #if UIP_ND6_DEF_MAXDADNS > 0 } else if((locaddr->state == ADDR_TENTATIVE) && (locaddr->dadnscount <= uip_ds6_if.maxdadns) && (timer_expired(&locaddr->dadtimer)) && (uip_len == 0)) { uip_ds6_dad(locaddr); #endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } } } /* Periodic processing on default routers */ for(locdefrt = uip_ds6_defrt_list; locdefrt < uip_ds6_defrt_list + UIP_DS6_DEFRT_NB; locdefrt++) { if((locdefrt->isused) && (!locdefrt->isinfinite) && (stimer_expired(&(locdefrt->lifetime)))) { uip_ds6_defrt_rm(locdefrt); } } #if !UIP_CONF_ROUTER /* Periodic processing on prefixes */ for(locprefix = uip_ds6_prefix_list; locprefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; locprefix++) { if(locprefix->isused && !locprefix->isinfinite && stimer_expired(&(locprefix->vlifetime))) { uip_ds6_prefix_rm(locprefix); } } #endif /* !UIP_CONF_ROUTER */ /* Periodic processing on neighbors */ for(locnbr = uip_ds6_nbr_cache; locnbr < uip_ds6_nbr_cache + UIP_DS6_NBR_NB; locnbr++) { if(locnbr->isused) { switch(locnbr->state) { case NBR_INCOMPLETE: if(locnbr->nscount >= UIP_ND6_MAX_MULTICAST_SOLICIT) { uip_ds6_nbr_rm(locnbr); } else if(stimer_expired(&locnbr->sendns) && (uip_len == 0)) { locnbr->nscount++; PRINTF("NBR_INCOMPLETE: NS %u\n", locnbr->nscount); uip_nd6_ns_output(NULL, NULL, &locnbr->ipaddr); stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000); } break; case NBR_REACHABLE: if(stimer_expired(&locnbr->reachable)) { PRINTF("REACHABLE: moving to STALE ("); PRINT6ADDR(&locnbr->ipaddr); PRINTF(")\n"); locnbr->state = NBR_STALE; } break; case NBR_DELAY: if(stimer_expired(&locnbr->reachable)) { locnbr->state = NBR_PROBE; locnbr->nscount = 0; PRINTF("DELAY: moving to PROBE\n"); stimer_set(&locnbr->sendns, 0); } break; case NBR_PROBE: if(locnbr->nscount >= UIP_ND6_MAX_UNICAST_SOLICIT) { PRINTF("PROBE END\n"); if((locdefrt = uip_ds6_defrt_lookup(&locnbr->ipaddr)) != NULL) { if (!locdefrt->isinfinite) { uip_ds6_defrt_rm(locdefrt); } } uip_ds6_nbr_rm(locnbr); } else if(stimer_expired(&locnbr->sendns) && (uip_len == 0)) { locnbr->nscount++; PRINTF("PROBE: NS %u\n", locnbr->nscount); uip_nd6_ns_output(NULL, &locnbr->ipaddr, &locnbr->ipaddr); stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000); } break; default: break; } } } #if UIP_CONF_ROUTER & UIP_ND6_SEND_RA /* Periodic RA sending */ if(stimer_expired(&uip_ds6_timer_ra) && (uip_len == 0)) { uip_ds6_send_ra_periodic(); } #endif /* UIP_CONF_ROUTER & UIP_ND6_SEND_RA */ etimer_reset(&uip_ds6_timer_periodic); return; }
/*---------------------------------------------------------------------------*/ void uip_ds6_periodic(void) { #if CONF_6LOWPAN_ND_OPTI_START && UIP_CONF_6L_ROUTER /* Start RPL only when the device has global IPv6 */ if(!rpl_started && uip_ds6_get_global(ADDR_PREFERRED)) { rpl_init(); rpl_started = 1; } #endif /* CONF_6LOWPAN_ND_OPTI_START && UIP_CONF_6L_ROUTER */ /* Periodic processing on unicast addresses */ for(locaddr = uip_ds6_if.addr_list; locaddr < uip_ds6_if.addr_list + UIP_DS6_ADDR_NB; locaddr++) { if(locaddr->isused) { if((!locaddr->isinfinite) && (stimer_expired(&locaddr->vlifetime))) { uip_ds6_addr_rm(locaddr); #if UIP_ND6_DEF_MAXDADNS > 0 } else if((locaddr->state == ADDR_TENTATIVE) && (locaddr->dadnscount <= uip_ds6_if.maxdadns) && (timer_expired(&locaddr->dadtimer)) && (uip_len == 0)) { uip_ds6_dad(locaddr); #endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } } } /* Periodic processing on default routers */ uip_ds6_defrt_periodic(); /* for(locdefrt = uip_ds6_defrt_list; locdefrt < uip_ds6_defrt_list + UIP_DS6_DEFRT_NB; locdefrt++) { if((locdefrt->isused) && (!locdefrt->isinfinite) && (stimer_expired(&(locdefrt->lifetime)))) { uip_ds6_defrt_rm(locdefrt); } }*/ #if CONF_6LOWPAN_ND /* Periodic processing on context prefixes */ for(loccontext = uip_ds6_context_pref_list; loccontext < uip_ds6_context_pref_list + UIP_DS6_CONTEXT_PREF_NB; loccontext++) { if(loccontext->state != CONTEXT_PREF_ST_FREE) { #if UIP_CONF_6LBR if(stimer_expired(&loccontext->lifetime) && loccontext->br->state != BR_ST_NEW_VERSION) { switch(loccontext->state) { case CONTEXT_PREF_ST_RM: /* Valid lifetime expired, so remove */ loccontext->state = CONTEXT_PREF_ST_FREE; break; case CONTEXT_PREF_ST_ADD: /* before c=0, now c=1 */ loccontext->state = CONTEXT_PREF_ST_COMPRESS; stimer_set(&loccontext->lifetime, loccontext->vlifetime * 60); break; } } #else /* UIP_CONF_6LBR */ if(stimer_expired(&loccontext->lifetime)) { switch(loccontext->state) { case CONTEXT_PREF_ST_UNCOMPRESSONLY: case CONTEXT_PREF_ST_RM: /* Valid lifetime expired, so remove */ loccontext->state = CONTEXT_PREF_ST_FREE; break; case CONTEXT_PREF_ST_SENDING: /* receive-only mode for a period of twice the default Router Lifetime */ loccontext->state = CONTEXT_PREF_ST_UNCOMPRESSONLY; stimer_set(&loccontext->lifetime, loccontext->router_lifetime * 2); break; case CONTEXT_PREF_ST_ADD: /* before c=0, now c=1 */ loccontext->state = CONTEXT_PREF_ST_COMPRESS; stimer_set(&loccontext->lifetime, loccontext->vlifetime * 60); break; } } else if(is_timeout_percent(&loccontext->lifetime, UIP_DS6_RS_PERCENT_LIFETIME_RETRAN, UIP_DS6_RS_MINLIFETIME_RETRAN) && loccontext->state == CONTEXT_PREF_ST_COMPRESS) { if(loccontext->br->state != BR_ST_SENDING_RS) { loccontext->br->state = BR_ST_MUST_SEND_RS; } loccontext->state = CONTEXT_PREF_ST_SENDING; } #endif /* UIP_CONF_6LBR */ } } #endif /* CONF_6LOWPAN_ND */ #if !UIP_CONF_ROUTER /* Periodic processing on prefixes */ for(locprefix = uip_ds6_prefix_list; locprefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; locprefix++) { if(locprefix->isused && !locprefix->isinfinite) { if(stimer_expired(&(locprefix->vlifetime))) { uip_ds6_prefix_rm(locprefix); #if UIP_CONF_6LR || UIP_CONF_6LN } else if(is_timeout_percent(&locprefix->vlifetime, UIP_DS6_RS_PERCENT_LIFETIME_RETRAN, UIP_DS6_RS_MINLIFETIME_RETRAN)) { if(locprefix->br->state != BR_ST_SENDING_RS) { locprefix->br->state = BR_ST_MUST_SEND_RS; } #endif /* UIP_CONF_6LR || UIP_CONF_6LN */ } } } #endif /* !UIP_CONF_ROUTER */ /* Periodic processing on border router */ #if CONF_6LOWPAN_ND uip_ds6_br_periodic(); #endif /* CONF_6LOWPAN_ND */ /* Periodic processing on Duplication Address*/ #if UIP_CONF_6LBR for(locdad = uip_ds6_dup_addr_list; locdad < uip_ds6_dup_addr_list + UIP_DS6_DUPADDR_NB; locdad++) { if(locdad->isused && stimer_expired(&locdad->lifetime)) { uip_ds6_dup_addr_rm(locdad); } } #endif /* UIP_CONF_6LBR */ uip_ds6_neighbor_periodic(); #if UIP_CONF_ROUTER & UIP_ND6_SEND_RA #if !CONF_6LOWPAN_ND || UIP_ND6_RA_PERIODIC /* Periodic RA sending */ if(stimer_expired(&uip_ds6_timer_ra) && (uip_len == 0)) { uip_ds6_send_ra_periodic(); } #endif /* !CONF_6LOWPAN_ND || UIP_ND6_RA_PERIODIC */ #endif /* UIP_CONF_ROUTER & UIP_ND6_SEND_RA */ etimer_reset(&uip_ds6_timer_periodic); return; }