]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Minor change in area list. Now I use MJ's lists.
authorOndrej Filip <feela@network.cz>
Mon, 3 Apr 2000 22:31:07 +0000 (22:31 +0000)
committerOndrej Filip <feela@network.cz>
Mon, 3 Apr 2000 22:31:07 +0000 (22:31 +0000)
proto/ospf/lsupd.c
proto/ospf/neighbor.c
proto/ospf/neighbor.h
proto/ospf/ospf.c
proto/ospf/ospf.h
proto/ospf/topology.c

index 2fa013781de0c32a4a1edf72cee294d7ca65d200..5c0d836dd9fd493bd9c60075f229c7719aeb3f94 100644 (file)
@@ -86,6 +86,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
   u32 area,nrid,myrid;
   struct ospf_neighbor *n;
   struct ospf_lsa_header *lsa;
+  struct ospf_area *oa;
   u16 length;
   u8 i;
 
@@ -108,15 +109,28 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
 
   lsa=(struct ospf_lsa_header *)(ps+1);
   area=htonl(ps->ospf_packet.areaid);
-  for(i=0;i<ntohl(ps->lsano);i++)
+  oa=ospf_find_area((struct proto_ospf *)p,area);
+  for(i=0;i<ntohl(ps->lsano);i++,
+    lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length)))
   {
-    if(lsa->checksum==lsasum_check(lsa,NULL,(struct proto_ospf *)p))
+    if(lsa->checksum!=lsasum_check(lsa,NULL,(struct proto_ospf *)p))
     {
-      DBG("Processing update Type: %u ID: %u RT: %u\n",lsa->type,
-        ntohl(lsa->id), ntohl(lsa->rt));
-      /* FIXME Go on */
+      log("Received bad lsa checksum from %u\n",n->rid);
+      continue;
+    }
+    if((lsa->type<LSA_T_RT)||(lsa->type>LSA_T_EXT))
+    {
+      log("Unknown LSA type from %u\n",n->rid);
+      continue;
     }
-    lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length));
+    if((lsa->type==LSA_T_EXT)&&oa->stub)
+    {
+      log("Received External LSA in stub area from %u\n",n->rid);
+      continue;
+    }
+      /* FIXME Go on */
+    DBG("Processing update Type: %u ID: %u RT: %u\n",lsa->type,
+        ntohl(lsa->id), ntohl(lsa->rt));
   }
 }
 
index b07262360285c8e14c3f0818b992827d14fa5ecb..ae415e134206095136413b11f419b9fbf3205a93 100644 (file)
@@ -354,3 +354,13 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
   return NULL;
 }
 
+struct ospf_area *
+ospf_find_area(struct proto_ospf *po, u32 aid)
+{
+  struct ospf_area *oa;
+  WALK_LIST(NODE oa,po->area_list)
+    if(((struct ospf_area *)oa)->areaid==aid) return oa;
+  return NULL;
+}
+
+
index 26992cac1b4f01557fc5fb158d98a5fea6b58843..64b163a471f6fd35e78d17a8e7bb847c2f69d5bf 100644 (file)
@@ -18,5 +18,6 @@ void tryadj(struct ospf_neighbor *n, struct proto *p);
 void ospf_neigh_sm(struct ospf_neighbor *n, int event);
 void bdr_election(struct ospf_iface *ifa, struct proto *p);
 struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
+struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
 
 #endif /* _BIRD_OSPF_NEIGHBOR_H_ */
index 670ca7350582a3a3e34918045c6717dbd6ed9984..a806de691bf1d200ae20e98ed604d3068564596b 100644 (file)
@@ -16,15 +16,6 @@ ospf_start(struct proto *p)
 
   p->if_notify=ospf_if_notify;
 
-  /* Create graph of LSA's */
-  po->areano=1;                /* FIXME should respect config! */
-  po->firstarea=(struct ospf_area *)cfg_alloc(sizeof(struct ospf_area));
-  po->firstarea->gr=ospf_top_new(po);
-  po->firstarea->next=NULL;
-  po->firstarea->areaid=0;
-
-  po->areano=0;                /* Waiting for interfaces comming up */
-  po->firstarea=NULL;
   return PS_UP;
 }
 
@@ -52,14 +43,12 @@ ospf_dump(struct proto *p)
     }
   }
 
-  oa=po->firstarea;
-  while(oa!=NULL)
+  WALK_LIST(NODE oa,po->area_list)
   {
     debug("\n%s: LSA graph dump for area \"%d\" start:\n", p->name,oa->areaid);
     ospf_top_dump(oa->gr);
     debug("%s: LSA graph dump for area \"%d\" finished\n\n", p->name,
       oa->areaid);
-    oa=oa->next;
   }
 
 }
@@ -74,6 +63,7 @@ ospf_init(struct proto_config *c)
   p->neigh_notify = NULL;
   p->if_notify = NULL;
   init_list(&(po->iface_list));
+  init_list(&(po->area_list));
 
   return p;
 }
index c2db08d1eea51972d0b4f666235a129489b1adf9..ee94f10d8de8f92f1fb82f630bdaebf00293944c 100644 (file)
@@ -315,7 +315,7 @@ struct ospf_neighbor
 #define INM_LLDOWN 12  /* Line down */
 
 struct ospf_area {
-  struct ospf_area *next;
+  node n;
   u32 areaid;
   struct top_graph *gr;                /* LSA graph */
   slist lsal;                  /* List of all LSA's */
@@ -326,8 +326,8 @@ struct ospf_area {
 struct proto_ospf {
   struct proto proto;
   list iface_list;             /* Interfaces we really use */
+  list area_list;
   int areano;                  /* Number of area I belong to */
-  struct ospf_area *firstarea;
 };
 
 static int ospf_start(struct proto *p);
index 66a155362c1b7bfe375132ae987a9a3a0d6e0f84..e4982c272094d27732d195f0ed957f4c2406695c 100644 (file)
@@ -160,25 +160,22 @@ addifa_rtlsa(struct ospf_iface *ifa)
   struct top_graph_rtlsa_link *li, *lih;
 
   po=ifa->proto;
-  oa=po->firstarea;
   rtid=po->proto.cf->global->router_id;
+  DBG("%s: New OSPF area \"%d\" adding.\n", po->proto.name, ifa->an);
+  oa=NULL;
 
-  while(oa!=NULL)
+
+  WALK_LIST(NODE oa,po->area_list)
   {
     if(oa->areaid==ifa->an) break;
-    oa=oa->next;
   }
 
-  ifa->oa=oa;
-  if(oa==NULL) /* New area */
+  if(EMPTY_LIST(po->area_list) || (oa->areaid!=ifa->an))       /* New area */
   {
     struct ospf_lsa_header *lsa;
 
-    oa=po->firstarea;
-    po->firstarea=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
-    po->firstarea->next=oa;
-    oa=po->firstarea;
+    oa=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
+    add_tail(&po->area_list,NODE oa);
     oa->areaid=ifa->an;
     oa->gr=ospf_top_new(po);
     s_init_list(&(oa->lsal));
@@ -189,13 +186,14 @@ addifa_rtlsa(struct ospf_iface *ifa)
     oa->rt->lsa_body=NULL;
     lsa->age=0;
     lsa->sn=LSA_INITSEQNO;     /* FIXME Check it latter */
-    ifa->oa=oa;
+    po->areano++;
     DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an);
-
   }
+
+  ifa->oa=oa;
   oa->rt->lsa.length=make_rt_lsa(oa, po)+sizeof(struct ospf_lsa_header);
   oa->rt->lsa.checksum=0;
-  /*oa->rt->lsa.checksum=ipsum_calculate(&(oa->rt->lsa.options),sizeof(struct ospf_lsa_header)-2,oa->rt->lsa_body,oa->rt->lsa.length-sizeof(struct ospf_lsa_header),NULL);*/
   lsasum_calculate(&(oa->rt->lsa),oa->rt->lsa_body,po);
   /*FIXME lsa_flood(oa->rt) */
 }