]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Originating of network LSA.
authorOndrej Filip <feela@network.cz>
Tue, 2 May 2000 23:09:44 +0000 (23:09 +0000)
committerOndrej Filip <feela@network.cz>
Tue, 2 May 2000 23:09:44 +0000 (23:09 +0000)
proto/ospf/iface.c
proto/ospf/ospf.h
proto/ospf/topology.c

index c7dfa2f1febc9995484360da8b55e314f082537f..bce763e01cc263d21c35428882fc547af0130213 100644 (file)
@@ -111,7 +111,6 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
       if(ifa->state==OSPF_IS_WAITING)
       {
         bdr_election(ifa ,p);
-        originate_rt_lsa(ifa->oa,po);
       }
       break;
     case ISM_NEICH:
@@ -119,8 +118,8 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
         (ifa->state==OSPF_IS_BACKUP))
       {
         bdr_election(ifa ,p);
+        originate_rt_lsa(ifa->oa,po);
       }
-      originate_rt_lsa(ifa->oa,po);
       break;
     case ISM_DOWN:
       iface_chstate(ifa, OSPF_IS_DOWN);
index 9ce0be9a7041acfd83e9b28f1513cb502dfca147..7528921c0add4635dbdd6fd7b0d21ca86d2f7664 100644 (file)
@@ -102,6 +102,7 @@ struct ospf_iface {
 #define WAIT_DMH 3     /* Value of Wait timer - not found it in RFC 
                         * - using 3*HELLO
                         */
+  struct top_hash_entry *nlsa;
 };
 
 struct ospf_packet {
index a69c01a22b9e4a433f1d28516e37a204ebb4c0a4..0020b572f9224a34d42949cbf46288182d5fa619 100644 (file)
@@ -244,6 +244,62 @@ originate_rt_lsa(struct ospf_area *oa, struct proto_ospf *po)
   return en;
 }
 
+void *
+originate_net_lsa_body(struct ospf_iface *ifa, u16 *length,
+  struct proto_ospf *po)
+{
+  u16 i=1;
+  struct ospf_neighbor *n;
+  u32 *body;
+
+  WALK_LIST(n,ifa->neigh_list)
+  {
+    if(n->state==NEIGHBOR_FULL) i++;
+  }
+  body=mb_alloc(po->proto.pool,sizeof(u32)*i);
+  i=1;
+  *body=po->proto.cf->global->router_id;
+  WALK_LIST(n,ifa->neigh_list)
+  {
+    if(n->state==NEIGHBOR_FULL)
+    {
+      *(body+i)=n->rid;
+      i++;
+    }
+  }
+  *length=i*sizeof(u32)+sizeof(struct ospf_lsa_header);
+  return body;
+}
+
+struct top_hash_entry *
+originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
+{
+  struct ospf_lsa_header lsa;
+  u32 rtid=po->proto.cf->global->router_id;
+  struct top_hash_entry *en;
+  void *body;
+
+  DBG("%s: Originating Net lsa for iface \"%s\".\n", po->proto.name, ifa->iface->name);
+
+  lsa.age=0;
+  lsa.id=rtid;
+  lsa.type=LSA_T_NET;
+  lsa.rt=rtid;
+  if(ifa->nlsa==NULL)
+  {
+    lsa.sn=LSA_INITSEQNO;
+  }
+  else
+  {
+    lsa.sn=ifa->nlsa->lsa.sn+1;
+  }
+  body=originate_net_lsa_body(ifa, &lsa.length, po);
+  lsasum_calculate(&lsa,body,po);
+  en=lsa_install_new(&lsa, body, ifa->oa, &po->proto);
+  return en;
+}
+
+
   
 
 static void