summaryrefslogtreecommitdiff
path: root/proto/ospf/ospf.c
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>1999-04-27 12:56:52 +0000
committerOndrej Filip <feela@network.cz>1999-04-27 12:56:52 +0000
commit6376a961332552e2bc178d647f1e5cfa01a1ac32 (patch)
treeadc2de5ce15a3ec6173aeffe0aba1961239a8910 /proto/ospf/ospf.c
parent93bde8dce23ae10476263a84cc40bbe186263fdc (diff)
Hello timer implemented.
Diffstat (limited to 'proto/ospf/ospf.c')
-rw-r--r--proto/ospf/ospf.c44
1 files changed, 35 insertions, 9 deletions
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
@@ -116,6 +116,28 @@ ospf_iface_clasify(struct iface *ifa)
}
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)
{
struct ospf_iface *ifa;
@@ -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)