]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Router LSA & area adding.
authorOndrej Filip <feela@network.cz>
Fri, 25 Feb 2000 19:19:41 +0000 (19:19 +0000)
committerOndrej Filip <feela@network.cz>
Fri, 25 Feb 2000 19:19:41 +0000 (19:19 +0000)
proto/ospf/ospf.c
proto/ospf/ospf.h
proto/ospf/topology.c
proto/ospf/topology.h

index 8eae39e34824a03107e85be6b1d645c7b2c0195c..670ca7350582a3a3e34918045c6717dbd6ed9984 100644 (file)
@@ -38,7 +38,7 @@ ospf_dump(struct proto *p)
   struct proto_ospf *po=(struct proto_ospf *)p;
   struct ospf_area *oa;
 
-  debug("%s: AreaID: %u\n", p->name, c->area );
+  debug("%s: Area number: %d\n", p->name, po->areano);
 
   WALK_LIST(ifa, po->iface_list)
   {
index 647debad95a0d7ec055b65094d8677c166915562..c161deaa2d701bb82466245bacb24800e02932d8 100644 (file)
@@ -213,6 +213,8 @@ struct ospf_area {
   struct ospf_area *next;
   u32 areaid;
   struct top_graph *gr;                /* LSA graph */
+  struct top_hash_entry *rt;   /* My own router LSA */
+  slab *rtlinks;
 };
 
 struct proto_ospf {
index 7de749de257b00175a07cedbce8a1594c0b8edb0..1f86014a0b0a7976ce1d570a3fcb4a7c3a5c3d35 100644 (file)
@@ -1,8 +1,8 @@
 /*
  *     BIRD -- OSPF Topological Database
  *
- *     (c) 1999 Martin Mares <mj@ucw.cz>
- *     (c) 1999 Ondrej Filip <feela@network.cz>
+ *     (c) 1999        Martin Mares <mj@ucw.cz>
+ *     (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -28,9 +28,13 @@ addifa_rtlsa(struct ospf_iface *ifa)
 {
   struct ospf_area *oa;
   struct proto_ospf *po;
+  u32 rtid;
+  struct top_graph_rtlsa *rt;
+  struct top_graph_rtlsa_link *li, *lih;
 
   po=ifa->proto;
   oa=po->firstarea;
+  rtid=po->proto.cf->global->router_id;
 
   while(oa!=NULL)
   {
@@ -38,22 +42,45 @@ addifa_rtlsa(struct ospf_iface *ifa)
     oa=oa->next;
   }
  
-  if(oa!=NULL) /* Known area */
+  if(oa==NULL) /* New area */
   {
-    /**/;
-  }
-  else /* New area */
-  {
-    po->areano++;
     oa=po->firstarea;
     po->firstarea=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
     po->firstarea->next=oa;
-    po->firstarea->areaid=ifa->area;
-    po->firstarea->gr=ospf_top_new(po);
+    oa=po->firstarea;
+    oa->areaid=ifa->area;
+    oa->gr=ospf_top_new(po);
+    oa->rtlinks=sl_new(po->proto.pool,
+      sizeof(struct top_graph_rtlsa_link));
+    oa->rt=ospf_hash_get(oa->gr, rtid, rtid, LSA_T_RT);
+    DBG("XXXXXX %x XXXXXXX\n", oa->rt);
+    rt=mb_alloc(po->proto.pool, sizeof(struct top_graph_rtlsa));
+    oa->rt->vertex=(void *)rt;
+    oa->rt->lsage=0;
+    oa->rt->lsseqno=LSA_INITSEQNO;     /* FIXME Check it latter */
+    rt->Vbit=0;
+    rt->Ebit= (po->areano++ ? 0 : 1);  /* If it's 1st area set 0 */
+    rt->Bbit=0;                                /* FIXME Could read config */
     DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->area);
-  }
 
-  /* FIXME Go on, change router lsa, bits and so on... */
+    if(po->areano==2)  /* We are attached to more than 2 areas! */
+    {
+      oa=po->firstarea;
+
+      while(oa!=NULL)
+      {
+        rt=(struct top_graph_rtlsa *)oa->rt->vertex;
+       rt->Ebit=1;
+        /*FIXME lsa_flood(oa->rt) */
+       
+        oa=oa->next;
+      }
+    }
+    else
+    {
+      /*FIXME lsa_flood(oa->rt) */;
+    }
+  }
 }
 
   
@@ -174,6 +201,8 @@ ospf_hash_get(struct top_graph *f, u32 lsa, u32 rtr, u32 type)
   e->rtr_id = rtr;
   e->lsa_type = type;
   e->vertex = NULL;
+  e->next=*ee;         /* MJ you forgot this :-) */
+  *ee=e;
   if (f->hash_entries++ > f->hash_entries_max)
     ospf_top_rehash(f, HASH_HI_STEP);
   return e;
@@ -204,14 +233,17 @@ void
 ospf_top_dump(struct top_graph *f)
 {
   unsigned int i;
+  debug("Hash entries: %d\n", f->hash_entries);
 
   for(i=0; i<f->hash_size; i++)
     {
       struct top_hash_entry *e = f->hash_table[i];
       while (e)
        {
-         debug("%04x %08x %08x %p\n", e->lsa_type, e->lsa_id, e->rtr_id, e->vertex);
+         debug("\t%04x %08x %08x %p\n", e->lsa_type, e->lsa_id,
+            e->rtr_id, e->vertex);
          e = e->next;
        }
     }
 }
+
index ec0704cdd5251a0a0f7d3bc8d567100d18df1954..e2021b004fcb1d09926733abc6f444cc40a539f6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- OSPF
  *
- *     (c) 1999 Ondrej Filip <feela@network.cz>
+ *     (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -14,9 +14,19 @@ struct top_hash_entry {  /* Index for fast mapping (type,rtrid,LSid)->vertex */
   struct top_vertex *vertex;
   u32 lsa_id, rtr_id;
   u8 lsa_type;
+#define LSA_T_RT 1
+#define LSA_T_NET 2
+#define LSA_T_SUM_NET 3
+#define LSA_T_SUM_RT 4
+#define LSA_T_EXT 5
   u8 options;
   u16 lsage;
+#define LSA_MAXAGE 3600                        /* 1 hour */
+#define LSA_CHECKAGE 300               /* 5 minutes */
+#define LSA_MAXAGEDIFF 900             /* 15 minutes */
   u32 lsseqno;
+#define LSA_INITSEQNO 0x80000001
+#define LSA_MAXSEQNO 0x7fffffff
 };
 
 struct top_graph {