Hello timer implemented.

This commit is contained in:
Ondrej Filip 1999-04-27 12:56:52 +00:00
parent 93bde8dce2
commit 6376a96133
2 changed files with 38 additions and 11 deletions

View file

@ -115,6 +115,28 @@ ospf_iface_clasify(struct iface *ifa)
return OSPF_IT_PTP; return OSPF_IT_PTP;
} }
void
hello_timer_hook(timer *timer)
{
struct ospf_iface *ifa;
ifa=(struct ospf_iface *)timer->data;
debug(" OSPF: Hello timer fired on interface %s.\n",
ifa->iface->name);
}
void
add_hello_timer(struct ospf_iface *ifa)
{
if(ifa->helloint==0) ifa->helloint=HELLOINT_D;
ifa->timer->hook=hello_timer_hook;
ifa->timer->recurrent=ifa->helloint;
ifa->timer->expires=0;
tm_start(ifa->timer,0);
DBG(" OSPF: Installing hello timer.\n");
}
void void
wait_timer_hook(timer *timer) wait_timer_hook(timer *timer)
{ {
@ -141,7 +163,7 @@ wait_timer_hook(timer *timer)
debug(" OSPF: Changing state into DROTHER.\n"); debug(" OSPF: Changing state into DROTHER.\n");
ifa->state=OSPF_IS_DROTHER; ifa->state=OSPF_IS_DROTHER;
} }
/* FIXME: Add hello timer */ add_hello_timer(ifa);
} }
/* FIXME: Destroy timer */ /* FIXME: Destroy timer */
} }
@ -149,18 +171,21 @@ wait_timer_hook(timer *timer)
void void
add_wait_timer(struct ospf_iface *ifa,pool *pool, int wait) add_wait_timer(struct ospf_iface *ifa,pool *pool, int wait)
{ {
DBG(" OSPF: add_wait_timer called.\n"); ifa->timer=tm_new(pool);
ifa->timer->data=ifa;
ifa->timer->randomize=1;
if((ifa->type!=OSPF_IT_PTP)) if((ifa->type!=OSPF_IT_PTP))
{ {
ifa->wait_timer=tm_new(pool); ifa->timer->hook=wait_timer_hook;
ifa->wait_timer->hook=wait_timer_hook; ifa->timer->recurrent=0;
ifa->wait_timer->data=ifa; ifa->timer->expires=0;
ifa->wait_timer->randomize=0; tm_start(ifa->timer,(wait!=0 ? wait : WAIT_D));
ifa->wait_timer->recurrent=0;
ifa->wait_timer->expires=0;
tm_start(ifa->wait_timer,(wait!=0 ? wait : WAIT_D));
DBG(" OSPF: Installing wait timer.\n"); DBG(" OSPF: Installing wait timer.\n");
} }
else
{
add_hello_timer(ifa);
}
} }
void void
@ -217,6 +242,7 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface
ifa->iface=new; ifa->iface=new;
add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa); add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa);
ospf_iface_default(ifa); ospf_iface_default(ifa);
/* FIXME: This should read config */
add_wait_timer(ifa,p->pool,0); add_wait_timer(ifa,p->pool,0);
init_list(&(ifa->sk_list)); init_list(&(ifa->sk_list));
if((mcsk=ospf_open_socket(p, ifa))!=NULL) if((mcsk=ospf_open_socket(p, ifa))!=NULL)

View file

@ -14,7 +14,7 @@
#define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */ #define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */
#define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */ #define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */
#else #else
#error Multicast address not defined #error Multicast address not defined in IPv6
#endif #endif
@ -55,7 +55,8 @@ struct ospf_iface {
#define OSPF_IS_DROTHER 3 /* I'm on BCAST or NBMA and I'm not DR */ #define OSPF_IS_DROTHER 3 /* I'm on BCAST or NBMA and I'm not DR */
#define OSPF_IS_BACKUP 4 /* I'm BDR */ #define OSPF_IS_BACKUP 4 /* I'm BDR */
#define OSPF_IS_DR 5 /* I'm DR */ #define OSPF_IS_DR 5 /* I'm DR */
timer *wait_timer; /* One shot Wait timer - used after DOWN->UP */ timer *timer; /* One shot Wait timer - used after DOWN->UP
* And timer for hello */
/* Default values for interface parameters */ /* Default values for interface parameters */
#define COST_D 10 #define COST_D 10