Minor change in area list. Now I use MJ's lists.
This commit is contained in:
parent
394acced11
commit
8496b2e41a
6 changed files with 46 additions and 33 deletions
|
@ -86,6 +86,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
|
||||||
u32 area,nrid,myrid;
|
u32 area,nrid,myrid;
|
||||||
struct ospf_neighbor *n;
|
struct ospf_neighbor *n;
|
||||||
struct ospf_lsa_header *lsa;
|
struct ospf_lsa_header *lsa;
|
||||||
|
struct ospf_area *oa;
|
||||||
u16 length;
|
u16 length;
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
|
@ -108,15 +109,28 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
|
||||||
|
|
||||||
lsa=(struct ospf_lsa_header *)(ps+1);
|
lsa=(struct ospf_lsa_header *)(ps+1);
|
||||||
area=htonl(ps->ospf_packet.areaid);
|
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))
|
||||||
{
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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,
|
DBG("Processing update Type: %u ID: %u RT: %u\n",lsa->type,
|
||||||
ntohl(lsa->id), ntohl(lsa->rt));
|
ntohl(lsa->id), ntohl(lsa->rt));
|
||||||
/* FIXME Go on */
|
|
||||||
}
|
|
||||||
lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,3 +354,13 @@ find_neigh(struct ospf_iface *ifa, u32 rid)
|
||||||
return NULL;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,5 +18,6 @@ void tryadj(struct ospf_neighbor *n, struct proto *p);
|
||||||
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
|
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
|
||||||
void bdr_election(struct ospf_iface *ifa, struct proto *p);
|
void bdr_election(struct ospf_iface *ifa, struct proto *p);
|
||||||
struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
|
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_ */
|
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */
|
||||||
|
|
|
@ -16,15 +16,6 @@ ospf_start(struct proto *p)
|
||||||
|
|
||||||
p->if_notify=ospf_if_notify;
|
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;
|
return PS_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +43,12 @@ ospf_dump(struct proto *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oa=po->firstarea;
|
WALK_LIST(NODE oa,po->area_list)
|
||||||
while(oa!=NULL)
|
|
||||||
{
|
{
|
||||||
debug("\n%s: LSA graph dump for area \"%d\" start:\n", p->name,oa->areaid);
|
debug("\n%s: LSA graph dump for area \"%d\" start:\n", p->name,oa->areaid);
|
||||||
ospf_top_dump(oa->gr);
|
ospf_top_dump(oa->gr);
|
||||||
debug("%s: LSA graph dump for area \"%d\" finished\n\n", p->name,
|
debug("%s: LSA graph dump for area \"%d\" finished\n\n", p->name,
|
||||||
oa->areaid);
|
oa->areaid);
|
||||||
oa=oa->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,6 +63,7 @@ ospf_init(struct proto_config *c)
|
||||||
p->neigh_notify = NULL;
|
p->neigh_notify = NULL;
|
||||||
p->if_notify = NULL;
|
p->if_notify = NULL;
|
||||||
init_list(&(po->iface_list));
|
init_list(&(po->iface_list));
|
||||||
|
init_list(&(po->area_list));
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,7 +315,7 @@ struct ospf_neighbor
|
||||||
#define INM_LLDOWN 12 /* Line down */
|
#define INM_LLDOWN 12 /* Line down */
|
||||||
|
|
||||||
struct ospf_area {
|
struct ospf_area {
|
||||||
struct ospf_area *next;
|
node n;
|
||||||
u32 areaid;
|
u32 areaid;
|
||||||
struct top_graph *gr; /* LSA graph */
|
struct top_graph *gr; /* LSA graph */
|
||||||
slist lsal; /* List of all LSA's */
|
slist lsal; /* List of all LSA's */
|
||||||
|
@ -326,8 +326,8 @@ struct ospf_area {
|
||||||
struct proto_ospf {
|
struct proto_ospf {
|
||||||
struct proto proto;
|
struct proto proto;
|
||||||
list iface_list; /* Interfaces we really use */
|
list iface_list; /* Interfaces we really use */
|
||||||
|
list area_list;
|
||||||
int areano; /* Number of area I belong to */
|
int areano; /* Number of area I belong to */
|
||||||
struct ospf_area *firstarea;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ospf_start(struct proto *p);
|
static int ospf_start(struct proto *p);
|
||||||
|
|
|
@ -160,25 +160,22 @@ addifa_rtlsa(struct ospf_iface *ifa)
|
||||||
struct top_graph_rtlsa_link *li, *lih;
|
struct top_graph_rtlsa_link *li, *lih;
|
||||||
|
|
||||||
po=ifa->proto;
|
po=ifa->proto;
|
||||||
oa=po->firstarea;
|
|
||||||
rtid=po->proto.cf->global->router_id;
|
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;
|
if(oa->areaid==ifa->an) break;
|
||||||
oa=oa->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ifa->oa=oa;
|
if(EMPTY_LIST(po->area_list) || (oa->areaid!=ifa->an)) /* New area */
|
||||||
|
|
||||||
if(oa==NULL) /* New area */
|
|
||||||
{
|
{
|
||||||
struct ospf_lsa_header *lsa;
|
struct ospf_lsa_header *lsa;
|
||||||
|
|
||||||
oa=po->firstarea;
|
oa=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
|
||||||
po->firstarea=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
|
add_tail(&po->area_list,NODE oa);
|
||||||
po->firstarea->next=oa;
|
|
||||||
oa=po->firstarea;
|
|
||||||
oa->areaid=ifa->an;
|
oa->areaid=ifa->an;
|
||||||
oa->gr=ospf_top_new(po);
|
oa->gr=ospf_top_new(po);
|
||||||
s_init_list(&(oa->lsal));
|
s_init_list(&(oa->lsal));
|
||||||
|
@ -189,13 +186,14 @@ addifa_rtlsa(struct ospf_iface *ifa)
|
||||||
oa->rt->lsa_body=NULL;
|
oa->rt->lsa_body=NULL;
|
||||||
lsa->age=0;
|
lsa->age=0;
|
||||||
lsa->sn=LSA_INITSEQNO; /* FIXME Check it latter */
|
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);
|
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.length=make_rt_lsa(oa, po)+sizeof(struct ospf_lsa_header);
|
||||||
oa->rt->lsa.checksum=0;
|
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);
|
lsasum_calculate(&(oa->rt->lsa),oa->rt->lsa_body,po);
|
||||||
/*FIXME lsa_flood(oa->rt) */
|
/*FIXME lsa_flood(oa->rt) */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue