changed timer to stimer for neighbor, prefix, default router, address list

This commit is contained in:
julienabeille 2009-02-19 16:42:41 +00:00
parent 264529708e
commit 710e5c621c
5 changed files with 57 additions and 61 deletions

View File

@ -525,8 +525,8 @@ uip_nd6_io_na_input(void)
if(is_solicited) {
neighbor->state = REACHABLE;
/* reachable time is stored in ms*/
timer_set(&(neighbor->reachable),
uip_netif_physical_if.reachable_time * CLOCK_SECOND / 1000);
stimer_set(&(neighbor->reachable),
(uip_netif_physical_if.reachable_time / 1000) * CLOCK_SECOND);
} else {
neighbor->state = STALE;
@ -556,8 +556,8 @@ uip_nd6_io_na_input(void)
if(is_solicited) {
neighbor->state = REACHABLE;
/* reachable time is stored in ms*/
timer_set(&(neighbor->reachable),
uip_netif_physical_if.reachable_time*CLOCK_SECOND/1000);
stimer_set(&(neighbor->reachable),
(uip_netif_physical_if.reachable_time / 1000) * CLOCK_SECOND);
} else {
if(nd6_opt_llao != 0 && is_llchange) {
@ -680,7 +680,7 @@ uip_nd6_io_ra_input(void) {
*/
if(UIP_ND6_RA_BUF->cur_ttl != 0) {
uip_netif_physical_if.cur_hop_limit = UIP_ND6_RA_BUF->cur_ttl;
PRINTF("uip_netif_physical_if.cur_hop_limit %d\n", uip_netif_physical_if.cur_hop_limit);
PRINTF("uip_netif_physical_if.cur_hop_limit %u\n", uip_netif_physical_if.cur_hop_limit);
}
/*
* As per RFC4861 section 6.3.4, if reachable time field is non zero
@ -777,7 +777,10 @@ uip_nd6_io_ra_input(void) {
prefix->is_infinite = 1;
break;
default:
timer_set(&prefix->vlifetime, ntohl((nd6_opt_prefix_info[i])->validlt)*CLOCK_SECOND);
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);
/*in case the prefix lifetime was previously infinite */
prefix->is_infinite = 0;
break;
@ -795,18 +798,19 @@ 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 > timer_remaining(&ifaddr->vlifetime))) {
(ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND > stimer_remaining(&ifaddr->vlifetime))) {
PRINTF("Updating timer of address");
PRINT6ADDR(&ifaddr->ipaddr);
PRINTF("new value %d\n", ntohl((nd6_opt_prefix_info[i])->validlt));
timer_set(&ifaddr->vlifetime, ntohl((nd6_opt_prefix_info[i])->validlt) * CLOCK_SECOND);
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);
} else {
/** \TODO below overflows on raven, i.e. when times are on
16 bits */
timer_set(&ifaddr->vlifetime, 2 * 60 * 60 * CLOCK_SECOND);
stimer_set(&ifaddr->vlifetime, 2 * 60 * 60 * CLOCK_SECOND);
PRINTF("Updating timer of address ");
PRINT6ADDR(&ifaddr->ipaddr);
PRINTF("new value %d\n", 2 * 60 * 60);
PRINTF("new value %lu\n", (unsigned long)(2 * 60 * 60 * CLOCK_SECOND));
}
/*in case the address lifetime was previously infinite */
ifaddr->is_infinite = 0;
@ -819,7 +823,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) * CLOCK_SECOND,
AUTOCONF);
} else {
/* Add an address with INFINITE lifetime */
@ -879,9 +883,9 @@ uip_nd6_io_ra_input(void) {
neighbor->isrouter = 1;
}
if((router = uip_nd6_defrouter_lookup(neighbor)) == NULL) {
uip_nd6_defrouter_add(neighbor, ntohs(UIP_ND6_RA_BUF->router_lifetime)*CLOCK_SECOND);
uip_nd6_defrouter_add(neighbor, (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime)) * (CLOCK_SECOND));
} else {
timer_set(&(router->lifetime), ntohs(UIP_ND6_RA_BUF->router_lifetime)*CLOCK_SECOND);
stimer_set(&(router->lifetime), (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime)) * CLOCK_SECOND);
}
} else {
/* delete router entry*/

View File

@ -192,13 +192,13 @@ uip_nd6_nbrcache_add(uip_ipaddr_t *ipaddr, uip_lladdr_t *lladdr,
PRINT6ADDR(ipaddr);
PRINTF("link addr");
PRINTLLADDR((&(neighbor->lladdr)));
PRINTF("state %d\n", state);
PRINTF("state %u\n", state);
neighbor->isrouter = isrouter;
neighbor->state = state;
/* timers are set separately, for now we put them in expired state */
timer_set(&(neighbor->reachable),0);
timer_set(&(neighbor->last_send),0);
stimer_set(&(neighbor->reachable),0);
stimer_set(&(neighbor->last_send),0);
neighbor->count_send = 0;
neighbor->used = 1;
return neighbor;
@ -260,7 +260,7 @@ uip_nd6_defrouter_rm(struct uip_nd6_defrouter *router)
}
struct uip_nd6_defrouter *
uip_nd6_defrouter_add(struct uip_nd6_neighbor *neighbor, clock_time_t interval)
uip_nd6_defrouter_add(struct uip_nd6_neighbor *neighbor, unsigned long interval)
{
router = NULL;
@ -281,7 +281,7 @@ uip_nd6_defrouter_add(struct uip_nd6_neighbor *neighbor, clock_time_t interval)
PRINT6ADDR(&neighbor->ipaddr);
PRINTF("\n");
timer_set(&(router->lifetime),interval);
stimer_set(&(router->lifetime),interval);
uip_nd6_defrouter_list[i].used = 1;
return router;
@ -321,7 +321,7 @@ uip_nd6_prefix_lookup(uip_ipaddr_t *ipaddr)
}
struct uip_nd6_prefix *
uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t interval){
uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, unsigned long interval){
prefix = NULL;
@ -349,10 +349,10 @@ uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t interval){
PRINTF("Adding prefix ");
PRINT6ADDR(&prefix->ipaddr);
PRINTF("length %d, vlifetime * CLOCK_SECOND %d\n", length, (u16_t)interval);
PRINTF("length %u, vlifetime * CLOCK_SECOND %lu\n", length, interval);
if(interval != 0){
timer_set(&(prefix->vlifetime),interval);
stimer_set(&(prefix->vlifetime),interval);
prefix->is_infinite = 0;
} else {
prefix->is_infinite = 1;
@ -366,7 +366,7 @@ uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t interval){
void uip_nd6_prefix_rm(struct uip_nd6_prefix *prefix) {
PRINTF("Removing prefix ");
PRINT6ADDR(&prefix->ipaddr);
PRINTF("length %d\n", prefix->length);
PRINTF("length %u\n", prefix->length);
prefix->used = 0;
}
@ -383,19 +383,11 @@ uip_nd6_periodic(void)
if(uip_nd6_defrouter_list[i].used == 1) {
router = &(uip_nd6_defrouter_list[i]);
/* XXX when run on a platform with a 16-bit clock_time_t, the
timer_expired() below causes the default route to be immediately
be removed causing communucation problems. We comment it out as
a quick-fix to this problem on the Atmel RAven platform, but
since this is needed for IPv6 compliance, we will solve the
problem by making clock_time_t 32 bits instead after the uIPv6
snapshot release.
if(timer_expired(&(router->lifetime))) {
uip_nd6_defrouter_rm(router);
if(stimer_expired(&(router->lifetime))) {
uip_nd6_defrouter_rm(router);
}
*/
}
}
/*PERIODIC PROCESSING FOR NEIGHBOR CACHE*/
@ -408,16 +400,16 @@ uip_nd6_periodic(void)
if(neighbor->count_send >= UIP_ND6_MAX_MULTICAST_SOLICIT) {
uip_nd6_nbrcache_list[i].used = 0;
}
else if(timer_expired(&(neighbor->last_send))) {
PRINTF("INCOMPLETE: NS %d\n",neighbor->count_send+1);
else if(stimer_expired(&(neighbor->last_send))) {
PRINTF("INCOMPLETE: NS %u\n",neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, NULL, &neighbor->ipaddr);
timer_set(&(neighbor->last_send),
stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
neighbor->count_send++;
}
break;
case REACHABLE:
if(timer_expired(&(neighbor->reachable))) {
if(stimer_expired(&(neighbor->reachable))) {
PRINTF("REACHABLE: moving to STALE (");
PRINT6ADDR(&neighbor->ipaddr);
PRINTF(")\n");
@ -427,12 +419,12 @@ uip_nd6_periodic(void)
}
break;
case DELAY:
if(timer_expired(&(neighbor->reachable))) {
if(stimer_expired(&(neighbor->reachable))) {
neighbor->state = PROBE;
neighbor->count_send = 0;
PRINTF("DELAY: moving to PROBE + NS %d\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);
timer_set(&(neighbor->last_send),
stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
neighbor->count_send++;
}
@ -449,10 +441,10 @@ uip_nd6_periodic(void)
uip_nd6_nbrcache_rm(neighbor);
continue;
}
if(timer_expired(&(neighbor->last_send))){
PRINTF("PROBE: NS %d\n",neighbor->count_send+1);
if(stimer_expired(&(neighbor->last_send))){
PRINTF("PROBE: NS %u\n",neighbor->count_send+1);
uip_nd6_io_ns_output(NULL, &neighbor->ipaddr, &neighbor->ipaddr);
timer_set(&(neighbor->last_send),
stimer_set(&(neighbor->last_send),
uip_netif_physical_if.retrans_timer/1000*CLOCK_SECOND);
neighbor->count_send++;
}
@ -472,7 +464,7 @@ uip_nd6_periodic(void)
if(uip_nd6_prefix_list[i].used == 1) {
prefix = &(uip_nd6_prefix_list[i]);
if((prefix->is_infinite == 0) &&
(timer_expired(&(prefix->vlifetime)))) {
(stimer_expired(&(prefix->vlifetime)))) {
/* remove prefix */
uip_nd6_prefix_rm(prefix);
}

View File

@ -46,7 +46,7 @@
#define __UIP_ND6_H__
#include "net/uip.h"
#include "sys/stimer.h"
/**
* \name General
* @{
@ -176,12 +176,12 @@ struct uip_nd6_neighbor{
uip_lladdr_t lladdr;
u8_t isrouter;
uip_neighbor_state state;
struct timer reachable;
struct timer last_send; /**< last time a ND message was sent */
struct stimer reachable;
struct stimer last_send; /**< last time a ND message was sent */
u8_t count_send; /**< how many ND message were already sent */
u8_t used; /**< brief is this neighbor currently used */
#if UIP_CONF_IPV6_QUEUE_PKT
u8_t queue_buf[UIP_BUFSIZE - UIP_LLH_LEN];
u8_t queue_buf[UIP_BUFSIZE - UIP_LLH_LEN];
/**< buffer to hold one packet during address resolution */
u8_t queue_buf_len;
/**< length of the pkt in buffer, used as "boolean" as well*/
@ -192,7 +192,7 @@ struct uip_nd6_neighbor{
/** \brief An entry in the default router list */
struct uip_nd6_defrouter {
struct uip_nd6_neighbor *nb;
struct timer lifetime;
struct stimer lifetime;
/**< the lifetime contained in RA corresponds to the interval field
* of the timer
*/
@ -206,7 +206,7 @@ struct uip_nd6_prefix {
/**< we do not use preferred lifetime, which is always smaller than
* valid lifetime (for addr, preferred->deprecated)
*/
struct timer vlifetime;
struct stimer vlifetime;
u8_t is_infinite; /**< Is the prefix lifetime INFINITE */
u8_t used; /**< Is this prefix entry currently used */
};
@ -388,7 +388,7 @@ void uip_nd6_defrouter_rm(struct uip_nd6_defrouter *router);
* \return the new or updated defrouter entry
*/
struct uip_nd6_defrouter *
uip_nd6_defrouter_add(struct uip_nd6_neighbor *neighbor, clock_time_t interval);
uip_nd6_defrouter_add(struct uip_nd6_neighbor *neighbor, unsigned long interval);
/**
* \brief Check if an IP address in on-link by looking at prefix list
@ -413,7 +413,7 @@ uip_nd6_prefix_lookup(uip_ipaddr_t *ipaddr);
* \return the new or updated prefix entry
*/
struct uip_nd6_prefix *
uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t interval);
uip_nd6_prefix_add(uip_ipaddr_t *ipaddr, u8_t length, unsigned long interval);
/**
* \brief Remove a prefix from th eprefix list

View File

@ -143,7 +143,7 @@ uip_netif_periodic(void) {
for(i = 1; i < UIP_CONF_NETIF_MAX_ADDRESSES; i++) {
if((uip_netif_physical_if.addresses[i].state != NOT_USED) &&
(uip_netif_physical_if.addresses[i].is_infinite != 1) &&
(timer_expired(&uip_netif_physical_if.addresses[i].vlifetime))) {
(stimer_expired(&uip_netif_physical_if.addresses[i].vlifetime))) {
uip_netif_addr_rm((&uip_netif_physical_if.addresses[i]));
}
}
@ -183,7 +183,7 @@ uip_netif_addr_lookup(uip_ipaddr_t *ipaddr, u8_t length, uip_netif_type type) {
/*---------------------------------------------------------------------------*/
void
uip_netif_addr_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t vlifetime, uip_netif_type type) {
uip_netif_addr_add(uip_ipaddr_t *ipaddr, u8_t length, unsigned long vlifetime, uip_netif_type type) {
/* check prefix has the right length if we are doing autoconf */
if((type == AUTOCONF) && (length != UIP_DEFAULT_PREFIX_LEN)) {
@ -211,7 +211,7 @@ uip_netif_addr_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t vlifetime, ui
uip_netif_physical_if.addresses[i].type = type;
/* setting lifetime timer if lieftime is not infinite */
if(vlifetime != 0) {
timer_set(&(uip_netif_physical_if.addresses[i].vlifetime), vlifetime);
stimer_set(&(uip_netif_physical_if.addresses[i].vlifetime), vlifetime);
uip_netif_physical_if.addresses[i].is_infinite = 0;
} else {
uip_netif_physical_if.addresses[i].is_infinite = 1;
@ -380,7 +380,7 @@ uip_netif_dad(void)
PRINTF("END of DAD\n");
for(i = 0; i < UIP_CONF_NETIF_MAX_ADDRESSES; i ++){
if(uip_netif_physical_if.addresses[i].state != NOT_USED){
PRINTF("address %d : ",i);
PRINTF("address %u : ",i);
PRINT6ADDR(&(uip_netif_physical_if.addresses[i].ipaddr));
PRINTF("\n");
}
@ -431,12 +431,12 @@ void
uip_netif_send_rs(void)
{
if((uip_nd6_choose_defrouter() == NULL) && (rs_count < UIP_ND6_MAX_RTR_SOLICITATIONS)){
//PRINTF("Sending RS %d\n", rs_count);
PRINTF("Sending RS %u\n", rs_count);
uip_nd6_io_rs_output();
rs_count++;
etimer_set(&uip_netif_timer_rs, UIP_ND6_RTR_SOLICITATION_INTERVAL * CLOCK_SECOND);
} else {
PRINTF("Router found ? (boolean): %d\n", (uip_nd6_choose_defrouter() != NULL));
PRINTF("Router found ? (boolean): %u\n", (uip_nd6_choose_defrouter() != NULL));
etimer_stop(&uip_netif_timer_rs);
rs_count = 0;
}

View File

@ -77,7 +77,7 @@ typedef enum {
struct uip_netif_addr {
uip_ipaddr_t ipaddr;
uip_netif_state state;
struct timer vlifetime;
struct stimer vlifetime;
u8_t is_infinite;
uip_netif_type type;
};
@ -140,7 +140,7 @@ u8_t uip_netif_is_addr_my_solicited(uip_ipaddr_t *ipaddr);
* non 0 otherwise
* \param type AUTOCONF or MANUAL or DHCP
*/
void uip_netif_addr_add(uip_ipaddr_t *ipaddr, u8_t length, clock_time_t vlifetime, uip_netif_type type);
void uip_netif_addr_add(uip_ipaddr_t *ipaddr, u8_t length, unsigned long vlifetime, uip_netif_type type);
/**
* \brief Set the 8 last bytes of the IP address