]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Hello timer implemented.
authorOndrej Filip <feela@network.cz>
Tue, 27 Apr 1999 12:56:52 +0000 (12:56 +0000)
committerOndrej Filip <feela@network.cz>
Tue, 27 Apr 1999 12:56:52 +0000 (12:56 +0000)
proto/ospf/ospf.c
proto/ospf/ospf.h

index 1facfab6f5dfd851626c4cb2951b072e05cff57e..97355bc87f0dc1f4b8006fa806ab05fe68e883f4 100644 (file)
@@ -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)
index ae4bba733a0c454660fa32c6775114b7e3bc2e29..26d201a0524b9904f5e8d0e5ed40b8d9fefcf364 100644 (file)
@@ -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