if(n->state!=state)
{
ifa=n->ifa;
+ if(n->state==NEIGHBOR_FULL)
+ {
+ ifa->fadj++;
+ n->state=state;
+ originate_rt_lsa(ifa->oa,ifa->oa->po);
+ originate_net_lsa(ifa,ifa->oa->po);
+ }
p=(struct proto *)(ifa->proto);
debug("%s: Neigbor %I changes state from \"%s\" to \"%s\".\n",
p->name, n->rid, ospf_ns[n->state], ospf_ns[state]);
n->state=state;
+ if(state==NEIGHBOR_FULL)
+ {
+ ifa->fadj--;
+ originate_rt_lsa(n->ifa->oa,n->ifa->oa->po);
+ originate_net_lsa(ifa,ifa->oa->po);
+ }
}
}
break;
case INM_LOADDONE:
neigh_chstate(n,NEIGHBOR_FULL);
- originate_rt_lsa(n->ifa->oa,po);
break;
case INM_ADJOK:
switch(n->state)
ifa->oa=oa;
- oa->rt=originate_rt_lsa(oa,po);
+ originate_rt_lsa(oa,po);
DBG("RT LSA: rt: %I, id: %I, type: %u\n",oa->rt->lsa.rt,oa->rt->lsa.id,oa->rt->lsa.type);
flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa);
}
-struct top_hash_entry *
+void
originate_rt_lsa(struct ospf_area *oa, struct proto_ospf *po)
{
struct ospf_lsa_header lsa;
body=originate_rt_lsa_body(oa, &lsa.length, po);
lsasum_calculate(&lsa,body,po);
en=lsa_install_new(&lsa, body, oa, &po->proto);
- return en;
+ oa->rt=en;
+ flood_lsa(NULL,NULL,&oa->rt->lsa,po,NULL,oa);
}
void *
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);
+ body=mb_alloc(po->proto.pool,sizeof(u32)*ifa->fadj);
i=1;
*body=po->proto.cf->global->router_id;
WALK_LIST(n,ifa->neigh_list)
return body;
}
-struct top_hash_entry *
+void
originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
{
struct ospf_lsa_header lsa;
DBG("%s: Originating Net lsa for iface \"%s\".\n", po->proto.name, ifa->iface->name);
+ if(ifa->state!=OSPF_IS_DR) return;
+
+ if(ifa->fadj==0)
+ {
+ if(ifa->nlsa==NULL) return;
+
+ lsa.sn+=1;
+ lsa.age=LSA_MAXAGE;
+ flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa);
+ /* FIXME delete LSA */
+ ifa->nlsa=NULL;
+ return ;
+ }
+
lsa.age=0;
lsa.id=rtid;
lsa.type=LSA_T_NET;
}
else
{
- lsa.sn=ifa->nlsa->lsa.sn+1;
+ 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;
+ flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa);
}
-
-
-
static void
ospf_top_ht_alloc(struct top_graph *f)
{
struct top_hash_entry *ospf_hash_get(struct top_graph *, u32 lsa, u32 rtr, u32 type);
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
void addifa_rtlsa(struct ospf_iface *ifa);
-struct top_hash_entry *originate_rt_lsa(struct ospf_area *oa,
- struct proto_ospf *po);
+void originate_rt_lsa(struct ospf_area *oa,struct proto_ospf *po);
+void originate_net_lsa(struct ospf_iface *ifa,struct proto_ospf *po);
#endif /* _BIRD_OSPF_TOPOLOGY_H_ */