From de30342f97490e3a3626c4a5fbf3352d1d0aa9c8 Mon Sep 17 00:00:00 2001 From: Ondrej Filip Date: Fri, 25 Feb 2000 19:19:41 +0000 Subject: [PATCH] Router LSA & area adding. --- proto/ospf/ospf.c | 2 +- proto/ospf/ospf.h | 2 ++ proto/ospf/topology.c | 58 +++++++++++++++++++++++++++++++++---------- proto/ospf/topology.h | 12 ++++++++- 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 8eae39e3..670ca735 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -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) { diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 647debad..c161deaa 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -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 { diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index 7de749de..1f86014a 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -1,8 +1,8 @@ /* * BIRD -- OSPF Topological Database * - * (c) 1999 Martin Mares - * (c) 1999 Ondrej Filip + * (c) 1999 Martin Mares + * (c) 1999 - 2000 Ondrej Filip * * 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; ihash_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; } } } + diff --git a/proto/ospf/topology.h b/proto/ospf/topology.h index ec0704cd..e2021b00 100644 --- a/proto/ospf/topology.h +++ b/proto/ospf/topology.h @@ -1,7 +1,7 @@ /* * BIRD -- OSPF * - * (c) 1999 Ondrej Filip + * (c) 1999 - 2000 Ondrej Filip * * 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 {