Removed CLOCK_SECOND from stimers in uIPv6, stimers are already in seconds

This commit is contained in:
julienabeille 2009-02-20 07:59:35 +00:00
parent 47a6eb5210
commit 10deaa6fc6
4 changed files with 27 additions and 29 deletions

View File

@ -29,7 +29,7 @@
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* *
* $Id: tcpip.c,v 1.17 2008/11/10 21:00:53 oliverschmidt Exp $ * $Id: tcpip.c,v 1.18 2009/02/20 07:59:36 julienabeille Exp $
*/ */
/** /**
* \file * \file
@ -550,8 +550,8 @@ tcpip_ipv6_output(void)
uip_nd6_io_ns_output(NULL, NULL, &nbc->ipaddr); uip_nd6_io_ns_output(NULL, NULL, &nbc->ipaddr);
} }
timer_set(&(nbc->last_send), stimer_set(&(nbc->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND); uip_netif_physical_if.retrans_timer / 1000);
nbc->count_send = 1; nbc->count_send = 1;
} else { } else {
if (nbc->state == INCOMPLETE){ if (nbc->state == INCOMPLETE){
@ -570,13 +570,13 @@ tcpip_ipv6_output(void)
if (nbc->state == STALE){ if (nbc->state == STALE){
nbc->state = DELAY; nbc->state = DELAY;
timer_set(&(nbc->reachable), stimer_set(&(nbc->reachable),
UIP_ND6_DELAY_FIRST_PROBE_TIME*CLOCK_SECOND); UIP_ND6_DELAY_FIRST_PROBE_TIME);
PRINTF("tcpip_ipv6_output: neighbor cache entry stale moving to delay\n"); PRINTF("tcpip_ipv6_output: neighbor cache entry stale moving to delay\n");
} }
timer_set(&(nbc->last_send), stimer_set(&(nbc->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND); uip_netif_physical_if.retrans_timer / 1000);
tcpip_output(&(nbc->lladdr)); tcpip_output(&(nbc->lladdr));

View File

@ -526,7 +526,7 @@ uip_nd6_io_na_input(void)
neighbor->state = REACHABLE; neighbor->state = REACHABLE;
/* reachable time is stored in ms*/ /* reachable time is stored in ms*/
stimer_set(&(neighbor->reachable), stimer_set(&(neighbor->reachable),
(uip_netif_physical_if.reachable_time / 1000) * CLOCK_SECOND); uip_netif_physical_if.reachable_time / 1000);
} else { } else {
neighbor->state = STALE; neighbor->state = STALE;
@ -557,7 +557,7 @@ uip_nd6_io_na_input(void)
neighbor->state = REACHABLE; neighbor->state = REACHABLE;
/* reachable time is stored in ms*/ /* reachable time is stored in ms*/
stimer_set(&(neighbor->reachable), stimer_set(&(neighbor->reachable),
(uip_netif_physical_if.reachable_time / 1000) * CLOCK_SECOND); uip_netif_physical_if.reachable_time / 1000);
} else { } else {
if(nd6_opt_llao != 0 && is_llchange) { if(nd6_opt_llao != 0 && is_llchange) {
@ -760,7 +760,7 @@ uip_nd6_io_ra_input(void) {
if((nd6_opt_prefix_info[i])->validlt != UIP_ND6_INFINITE_LIFETIME){ if((nd6_opt_prefix_info[i])->validlt != UIP_ND6_INFINITE_LIFETIME){
prefix = uip_nd6_prefix_add(&(nd6_opt_prefix_info[i])->prefix, prefix = uip_nd6_prefix_add(&(nd6_opt_prefix_info[i])->prefix,
(nd6_opt_prefix_info[i])->preflen, (nd6_opt_prefix_info[i])->preflen,
ntohl((nd6_opt_prefix_info[i])->validlt)*CLOCK_SECOND); ntohl((nd6_opt_prefix_info[i])->validlt));
} else { } else {
prefix = uip_nd6_prefix_add(&(nd6_opt_prefix_info[i])->prefix, prefix = uip_nd6_prefix_add(&(nd6_opt_prefix_info[i])->prefix,
(nd6_opt_prefix_info[i])->preflen, (nd6_opt_prefix_info[i])->preflen,
@ -779,8 +779,8 @@ uip_nd6_io_ra_input(void) {
default: default:
PRINTF("Updating timer of prefix"); PRINTF("Updating timer of prefix");
PRINT6ADDR(prefix); PRINT6ADDR(prefix);
PRINTF("new value %lu\n", ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND); PRINTF("new value %lu\n", ntohl((nd6_opt_prefix_info[i])->validlt));
stimer_set(&prefix->vlifetime, ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND); stimer_set(&prefix->vlifetime, ntohl((nd6_opt_prefix_info[i])->validlt));
/*in case the prefix lifetime was previously infinite */ /*in case the prefix lifetime was previously infinite */
prefix->is_infinite = 0; prefix->is_infinite = 0;
break; break;
@ -798,19 +798,17 @@ uip_nd6_io_ra_input(void) {
if((nd6_opt_prefix_info[i])->validlt != UIP_ND6_INFINITE_LIFETIME) { if((nd6_opt_prefix_info[i])->validlt != UIP_ND6_INFINITE_LIFETIME) {
/* The processing below is defined in RFC4862 section 5.5.3 e */ /* The processing below is defined in RFC4862 section 5.5.3 e */
if((ntohl((nd6_opt_prefix_info[i])->validlt) > 2 * 60 * 60) || if((ntohl((nd6_opt_prefix_info[i])->validlt) > 2 * 60 * 60) ||
(ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND > stimer_remaining(&ifaddr->vlifetime))) { (ntohl((nd6_opt_prefix_info[i])->validlt)> stimer_remaining(&ifaddr->vlifetime))) {
PRINTF("Updating timer of address"); PRINTF("Updating timer of address");
PRINT6ADDR(&ifaddr->ipaddr); PRINT6ADDR(&ifaddr->ipaddr);
PRINTF("new value %lu\n", ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND); PRINTF("new value %lu\n", ntohl((nd6_opt_prefix_info[i])->validlt));
stimer_set(&ifaddr->vlifetime, ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND); stimer_set(&ifaddr->vlifetime, ntohl((nd6_opt_prefix_info[i])->validlt));
} else { } else {
/** \TODO below overflows on raven, i.e. when times are on stimer_set(&ifaddr->vlifetime, 2 * 60 * 60);
16 bits */
stimer_set(&ifaddr->vlifetime, 2 * 60 * 60 * CLOCK_SECOND);
PRINTF("Updating timer of address "); PRINTF("Updating timer of address ");
PRINT6ADDR(&ifaddr->ipaddr); PRINT6ADDR(&ifaddr->ipaddr);
PRINTF("new value %lu\n", (unsigned long)(2 * 60 * 60 * CLOCK_SECOND)); PRINTF("new value %lu\n", (unsigned long)(2 * 60 * 60));
} }
/*in case the address lifetime was previously infinite */ /*in case the address lifetime was previously infinite */
ifaddr->is_infinite = 0; ifaddr->is_infinite = 0;
@ -823,7 +821,7 @@ uip_nd6_io_ra_input(void) {
/* Add an address with FINITE lifetime */ /* Add an address with FINITE lifetime */
uip_netif_addr_add(&(nd6_opt_prefix_info[i])->prefix, uip_netif_addr_add(&(nd6_opt_prefix_info[i])->prefix,
(nd6_opt_prefix_info[i])->preflen, (nd6_opt_prefix_info[i])->preflen,
ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND, ntohl((nd6_opt_prefix_info[i])->validlt),
AUTOCONF); AUTOCONF);
} else { } else {
/* Add an address with INFINITE lifetime */ /* Add an address with INFINITE lifetime */
@ -883,9 +881,9 @@ uip_nd6_io_ra_input(void) {
neighbor->isrouter = 1; neighbor->isrouter = 1;
} }
if((router = uip_nd6_defrouter_lookup(neighbor)) == NULL) { if((router = uip_nd6_defrouter_lookup(neighbor)) == NULL) {
uip_nd6_defrouter_add(neighbor, (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime)) * (CLOCK_SECOND)); uip_nd6_defrouter_add(neighbor, (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime)));
} else { } else {
stimer_set(&(router->lifetime), (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime)) * CLOCK_SECOND); stimer_set(&(router->lifetime), (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime)));
} }
} else { } else {
/* delete router entry*/ /* delete router entry*/

View File

@ -349,7 +349,7 @@ uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, unsigned long interval){
PRINTF("Adding prefix "); PRINTF("Adding prefix ");
PRINT6ADDR(&prefix->ipaddr); PRINT6ADDR(&prefix->ipaddr);
PRINTF("length %u, vlifetime * CLOCK_SECOND %lu\n", length, interval); PRINTF("length %u, vlifetime%lu\n", length, interval);
if(interval != 0){ if(interval != 0){
stimer_set(&(prefix->vlifetime),interval); stimer_set(&(prefix->vlifetime),interval);
@ -404,7 +404,7 @@ uip_nd6_periodic(void)
PRINTF("INCOMPLETE: NS %u\n",neighbor->count_send+1); PRINTF("INCOMPLETE: NS %u\n",neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, NULL, &neighbor->ipaddr); uip_nd6_io_ns_output(NULL, NULL, &neighbor->ipaddr);
stimer_set(&(neighbor->last_send), stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND); uip_netif_physical_if.retrans_timer / 1000);
neighbor->count_send++; neighbor->count_send++;
} }
break; break;
@ -425,7 +425,7 @@ uip_nd6_periodic(void)
PRINTF("DELAY: moving to PROBE + NS %u\n", neighbor->count_send+1); PRINTF("DELAY: moving to PROBE + NS %u\n", neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr); uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr);
stimer_set(&(neighbor->last_send), stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND); uip_netif_physical_if.retrans_timer / 1000);
neighbor->count_send++; neighbor->count_send++;
} }
break; break;
@ -445,7 +445,7 @@ uip_nd6_periodic(void)
PRINTF("PROBE: NS %u\n",neighbor->count_send+1); PRINTF("PROBE: NS %u\n",neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr); uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr);
stimer_set(&(neighbor->last_send), stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND); uip_netif_physical_if.retrans_timer / 1000);
neighbor->count_send++; neighbor->count_send++;
} }
break; break;

View File

@ -333,7 +333,7 @@ uip_netif_sched_dad(struct uip_netif_addr *ifaddr)
PRINT6ADDR(&dad_ifaddr->ipaddr); PRINT6ADDR(&dad_ifaddr->ipaddr);
PRINTF("\n"); PRINTF("\n");
etimer_set(&uip_netif_timer_dad, random_rand()%(UIP_ND6_MAX_RTR_SOLICITATION_DELAY*CLOCK_SECOND)); etimer_set(&uip_netif_timer_dad, random_rand()%(UIP_ND6_MAX_RTR_SOLICITATION_DELAY * CLOCK_SECOND));
} }
@ -354,7 +354,7 @@ uip_netif_dad(void)
if(dad_ns < uip_netif_physical_if.dup_addr_detect_transmit) { if(dad_ns < uip_netif_physical_if.dup_addr_detect_transmit) {
uip_nd6_io_ns_output(NULL, NULL, &dad_ifaddr->ipaddr); uip_nd6_io_ns_output(NULL, NULL, &dad_ifaddr->ipaddr);
dad_ns++; dad_ns++;
etimer_set(&uip_netif_timer_dad, uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND); etimer_set(&uip_netif_timer_dad, uip_netif_physical_if.retrans_timer / 1000 * CLOCK_SECOND);
return; return;
} }
/* /*
@ -420,7 +420,7 @@ uip_netif_sched_send_rs(void)
transmission for a random amount of time between 0 and transmission for a random amount of time between 0 and
UIP_ND6_MAX_RTR_SOLICITATION_DELAY. */ UIP_ND6_MAX_RTR_SOLICITATION_DELAY. */
if(rs_count == 0){ if(rs_count == 0){
etimer_set(&uip_netif_timer_rs, random_rand()%(UIP_ND6_MAX_RTR_SOLICITATION_DELAY*CLOCK_SECOND)); etimer_set(&uip_netif_timer_rs, random_rand()%(UIP_ND6_MAX_RTR_SOLICITATION_DELAY * CLOCK_SECOND));
PRINTF("Scheduling RS\n"); PRINTF("Scheduling RS\n");
} }
} }