diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 1facfab6..97355bc8 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -115,6 +115,28 @@ ospf_iface_clasify(struct iface *ifa) 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 wait_timer_hook(timer *timer) { @@ -141,7 +163,7 @@ wait_timer_hook(timer *timer) debug(" OSPF: Changing state into DROTHER.\n"); ifa->state=OSPF_IS_DROTHER; } - /* FIXME: Add hello timer */ + add_hello_timer(ifa); } /* FIXME: Destroy timer */ } @@ -149,18 +171,21 @@ wait_timer_hook(timer *timer) void 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)) { - ifa->wait_timer=tm_new(pool); - ifa->wait_timer->hook=wait_timer_hook; - ifa->wait_timer->data=ifa; - ifa->wait_timer->randomize=0; - ifa->wait_timer->recurrent=0; - ifa->wait_timer->expires=0; - tm_start(ifa->wait_timer,(wait!=0 ? wait : WAIT_D)); + ifa->timer->hook=wait_timer_hook; + ifa->timer->recurrent=0; + ifa->timer->expires=0; + tm_start(ifa->timer,(wait!=0 ? wait : WAIT_D)); DBG(" OSPF: Installing wait timer.\n"); } + else + { + add_hello_timer(ifa); + } } void @@ -217,6 +242,7 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *new, struct iface ifa->iface=new; add_tail(&((struct proto_ospf *)p)->iface_list, NODE ifa); ospf_iface_default(ifa); + /* FIXME: This should read config */ add_wait_timer(ifa,p->pool,0); init_list(&(ifa->sk_list)); if((mcsk=ospf_open_socket(p, ifa))!=NULL) diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index ae4bba73..26d201a0 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -14,7 +14,7 @@ #define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */ #define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */ #else -#error Multicast address not defined +#error Multicast address not defined in IPv6 #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_BACKUP 4 /* I'm BDR */ #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 */ #define COST_D 10