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.
*
*
* $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
@ -550,8 +550,8 @@ tcpip_ipv6_output(void)
uip_nd6_io_ns_output(NULL, NULL, &nbc->ipaddr);
}
timer_set(&(nbc->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
stimer_set(&(nbc->last_send),
uip_netif_physical_if.retrans_timer / 1000);
nbc->count_send = 1;
} else {
if (nbc->state == INCOMPLETE){
@ -570,13 +570,13 @@ tcpip_ipv6_output(void)
if (nbc->state == STALE){
nbc->state = DELAY;
timer_set(&(nbc->reachable),
UIP_ND6_DELAY_FIRST_PROBE_TIME*CLOCK_SECOND);
stimer_set(&(nbc->reachable),
UIP_ND6_DELAY_FIRST_PROBE_TIME);
PRINTF("tcpip_ipv6_output: neighbor cache entry stale moving to delay\n");
}
timer_set(&(nbc->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
stimer_set(&(nbc->last_send),
uip_netif_physical_if.retrans_timer / 1000);
tcpip_output(&(nbc->lladdr));

View file

@ -526,7 +526,7 @@ uip_nd6_io_na_input(void)
neighbor->state = REACHABLE;
/* reachable time is stored in ms*/
stimer_set(&(neighbor->reachable),
(uip_netif_physical_if.reachable_time / 1000) * CLOCK_SECOND);
uip_netif_physical_if.reachable_time / 1000);
} else {
neighbor->state = STALE;
@ -557,7 +557,7 @@ uip_nd6_io_na_input(void)
neighbor->state = REACHABLE;
/* reachable time is stored in ms*/
stimer_set(&(neighbor->reachable),
(uip_netif_physical_if.reachable_time / 1000) * CLOCK_SECOND);
uip_netif_physical_if.reachable_time / 1000);
} else {
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){
prefix = uip_nd6_prefix_add(&(nd6_opt_prefix_info[i])->prefix,
(nd6_opt_prefix_info[i])->preflen,
ntohl((nd6_opt_prefix_info[i])->validlt)*CLOCK_SECOND);
ntohl((nd6_opt_prefix_info[i])->validlt));
} else {
prefix = uip_nd6_prefix_add(&(nd6_opt_prefix_info[i])->prefix,
(nd6_opt_prefix_info[i])->preflen,
@ -779,8 +779,8 @@ uip_nd6_io_ra_input(void) {
default:
PRINTF("Updating timer of prefix");
PRINT6ADDR(prefix);
PRINTF("new value %lu\n", ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND);
stimer_set(&prefix->vlifetime, 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));
/*in case the prefix lifetime was previously infinite */
prefix->is_infinite = 0;
break;
@ -798,19 +798,17 @@ uip_nd6_io_ra_input(void) {
if((nd6_opt_prefix_info[i])->validlt != UIP_ND6_INFINITE_LIFETIME) {
/* The processing below is defined in RFC4862 section 5.5.3 e */
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");
PRINT6ADDR(&ifaddr->ipaddr);
PRINTF("new value %lu\n", ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND);
stimer_set(&ifaddr->vlifetime, 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));
} else {
/** \TODO below overflows on raven, i.e. when times are on
16 bits */
stimer_set(&ifaddr->vlifetime, 2 * 60 * 60 * CLOCK_SECOND);
stimer_set(&ifaddr->vlifetime, 2 * 60 * 60);
PRINTF("Updating timer of address ");
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 */
ifaddr->is_infinite = 0;
@ -823,7 +821,7 @@ uip_nd6_io_ra_input(void) {
/* Add an address with FINITE lifetime */
uip_netif_addr_add(&(nd6_opt_prefix_info[i])->prefix,
(nd6_opt_prefix_info[i])->preflen,
ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND,
ntohl((nd6_opt_prefix_info[i])->validlt),
AUTOCONF);
} else {
/* Add an address with INFINITE lifetime */
@ -883,9 +881,9 @@ uip_nd6_io_ra_input(void) {
neighbor->isrouter = 1;
}
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 {
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 {
/* 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 ");
PRINT6ADDR(&prefix->ipaddr);
PRINTF("length %u, vlifetime * CLOCK_SECOND %lu\n", length, interval);
PRINTF("length %u, vlifetime%lu\n", length, interval);
if(interval != 0){
stimer_set(&(prefix->vlifetime),interval);
@ -404,7 +404,7 @@ uip_nd6_periodic(void)
PRINTF("INCOMPLETE: NS %u\n",neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, NULL, &neighbor->ipaddr);
stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
uip_netif_physical_if.retrans_timer / 1000);
neighbor->count_send++;
}
break;
@ -425,7 +425,7 @@ uip_nd6_periodic(void)
PRINTF("DELAY: moving to PROBE + NS %u\n", neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr);
stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
uip_netif_physical_if.retrans_timer / 1000);
neighbor->count_send++;
}
break;
@ -445,7 +445,7 @@ uip_nd6_periodic(void)
PRINTF("PROBE: NS %u\n",neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr);
stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
uip_netif_physical_if.retrans_timer / 1000);
neighbor->count_send++;
}
break;