Cleanup of code. Some arguments of functions were useless.
This commit is contained in:
parent
ad5453b540
commit
a02c6c184b
5 changed files with 24 additions and 19 deletions
|
@ -17,8 +17,9 @@ flush_lsa(struct top_hash_entry *en)
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_age(struct top_hash_entry *en, bird_clock_t delta, int flush,
|
ospf_age(struct top_hash_entry *en, bird_clock_t delta, int flush,
|
||||||
struct proto *p)
|
struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
|
struct proto *p=&oa->po->proto;
|
||||||
if(en->lsa.age==LSA_MAXAGE)
|
if(en->lsa.age==LSA_MAXAGE)
|
||||||
{
|
{
|
||||||
if(flush) flush_lsa(en);
|
if(flush) flush_lsa(en);
|
||||||
|
@ -391,7 +392,7 @@ lsa_install_new(struct ospf_lsa_header *lsa, void *body, struct ospf_area *oa,
|
||||||
if(oa->rt!=NULL)
|
if(oa->rt!=NULL)
|
||||||
{
|
{
|
||||||
DBG("Starting routing table calculation.\n");
|
DBG("Starting routing table calculation.\n");
|
||||||
ospf_rt_spfa(oa, p);
|
ospf_rt_spfa(oa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,6 @@ int lsa_comp(struct ospf_lsa_header *l1, struct ospf_lsa_header *l2);
|
||||||
struct top_hash_entry *lsa_install_new(struct ospf_lsa_header *lsa, void *body,
|
struct top_hash_entry *lsa_install_new(struct ospf_lsa_header *lsa, void *body,
|
||||||
struct ospf_area *oa, struct proto *p);
|
struct ospf_area *oa, struct proto *p);
|
||||||
void ospf_age(struct top_hash_entry *en, bird_clock_t delta, int flush,
|
void ospf_age(struct top_hash_entry *en, bird_clock_t delta, int flush,
|
||||||
struct proto *p);
|
struct ospf_area *oa);
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_LSALIB_H_ */
|
#endif /* _BIRD_OSPF_LSALIB_H_ */
|
||||||
|
|
|
@ -18,7 +18,7 @@ init_stub_fib(struct fib_node *fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
ospf_rt_spfa(struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
struct top_hash_entry *en, *nx;
|
struct top_hash_entry *en, *nx;
|
||||||
u32 i,*rts;
|
u32 i,*rts;
|
||||||
|
@ -28,6 +28,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
struct stub_fib *sf;
|
struct stub_fib *sf;
|
||||||
bird_clock_t delta;
|
bird_clock_t delta;
|
||||||
int age=0,flush=0;
|
int age=0,flush=0;
|
||||||
|
struct proto *p=&oa->po->proto;
|
||||||
|
|
||||||
/* FIXME if I'm not in LOADING or EXCHANGE set flush=1 */
|
/* FIXME if I'm not in LOADING or EXCHANGE set flush=1 */
|
||||||
if((delta=now-oa->lage)>=AGINGDELTA)
|
if((delta=now-oa->lage)>=AGINGDELTA)
|
||||||
|
@ -40,7 +41,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
{
|
{
|
||||||
en->color=OUTSPF;
|
en->color=OUTSPF;
|
||||||
en->dist=LSINFINITY;
|
en->dist=LSINFINITY;
|
||||||
if(age) ospf_age(en,delta,flush,p);
|
if(age) ospf_age(en,delta,flush,oa);
|
||||||
}
|
}
|
||||||
|
|
||||||
init_list(&oa->cand); /* Empty list of candidates */
|
init_list(&oa->cand); /* Empty list of candidates */
|
||||||
|
@ -99,7 +100,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
log("Unknown link type in router lsa.\n");
|
log("Unknown link type in router lsa.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
add_cand(&oa->cand,tmp,act,act->dist+rtl->metric,p,oa);
|
add_cand(&oa->cand,tmp,act,act->dist+rtl->metric,oa);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LSA_T_NET:
|
case LSA_T_NET:
|
||||||
|
@ -112,7 +113,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
tmp=ospf_hash_find(oa->gr, *(rts+i), *(rts+i), LSA_T_RT);
|
tmp=ospf_hash_find(oa->gr, *(rts+i), *(rts+i), LSA_T_RT);
|
||||||
if(tmp!=NULL) DBG("Found :-)\n");
|
if(tmp!=NULL) DBG("Found :-)\n");
|
||||||
else DBG("Fuck!\n");
|
else DBG("Fuck!\n");
|
||||||
add_cand(&oa->cand,tmp,act,act->dist,p,oa);
|
add_cand(&oa->cand,tmp,act,act->dist,oa);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +200,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
if(sf->metric>(en->dist+rtl->metric))
|
if(sf->metric>(en->dist+rtl->metric))
|
||||||
{
|
{
|
||||||
sf->metric=en->dist+rtl->metric;
|
sf->metric=en->dist+rtl->metric;
|
||||||
calc_next_hop_fib(en,sf,p,oa);
|
calc_next_hop_fib(en,sf,oa);
|
||||||
if(sf->nhi!=NULL)
|
if(sf->nhi!=NULL)
|
||||||
{
|
{
|
||||||
net *ne;
|
net *ne;
|
||||||
|
@ -240,11 +241,12 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p)
|
||||||
|
|
||||||
void
|
void
|
||||||
add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
u16 dist, struct proto *p, struct ospf_area *oa)
|
u16 dist, struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
node *prev,*n;
|
node *prev,*n;
|
||||||
int flag=0,added=0;
|
int flag=0,added=0;
|
||||||
struct top_hash_entry *act;
|
struct top_hash_entry *act;
|
||||||
|
struct proto *p=&oa->po->proto;
|
||||||
|
|
||||||
if(en==NULL) return;
|
if(en==NULL) return;
|
||||||
if(en->lsa.age==LSA_MAXAGE) return;
|
if(en->lsa.age==LSA_MAXAGE) return;
|
||||||
|
@ -260,7 +262,7 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
|
|
||||||
en->nhi=NULL;
|
en->nhi=NULL;
|
||||||
|
|
||||||
calc_next_hop(par,en,p,oa);
|
calc_next_hop(par,en,oa);
|
||||||
|
|
||||||
if(en->color==CANDIDATE) /* We found a shorter path */
|
if(en->color==CANDIDATE) /* We found a shorter path */
|
||||||
{
|
{
|
||||||
|
@ -302,10 +304,11 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
|
|
||||||
void
|
void
|
||||||
calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
||||||
struct proto *p, struct ospf_area *oa)
|
struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
struct ospf_neighbor *neigh;
|
struct ospf_neighbor *neigh;
|
||||||
struct proto_ospf *po=(struct proto_ospf *)p;
|
struct proto *p=&oa->po->proto;
|
||||||
|
struct proto_ospf *po=oa->po;
|
||||||
DBG(" Next hop called\n");
|
DBG(" Next hop called\n");
|
||||||
if(par==oa->rt) return;
|
if(par==oa->rt) return;
|
||||||
if(par->nhi==NULL)
|
if(par->nhi==NULL)
|
||||||
|
@ -327,10 +330,11 @@ calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
||||||
|
|
||||||
void
|
void
|
||||||
calc_next_hop_fib(struct top_hash_entry *par, struct stub_fib *en,
|
calc_next_hop_fib(struct top_hash_entry *par, struct stub_fib *en,
|
||||||
struct proto *p, struct ospf_area *oa)
|
struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
struct ospf_neighbor *neigh;
|
struct ospf_neighbor *neigh;
|
||||||
struct proto_ospf *po=(struct proto_ospf *)p;
|
struct proto *p=&oa->po->proto;
|
||||||
|
struct proto_ospf *po=oa->po;
|
||||||
DBG(" Next hop called\n");
|
DBG(" Next hop called\n");
|
||||||
if(par==oa->rt) return;
|
if(par==oa->rt) return;
|
||||||
if(par->nhi==NULL)
|
if(par->nhi==NULL)
|
||||||
|
|
|
@ -18,12 +18,12 @@ struct stub_fib {
|
||||||
struct iface *nhi;
|
struct iface *nhi;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ospf_rt_spfa(struct ospf_area *oa, struct proto *p);
|
void ospf_rt_spfa(struct ospf_area *oa);
|
||||||
void add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
void add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par,
|
||||||
u16 dist, struct proto *p, struct ospf_area *oa);
|
u16 dist, struct ospf_area *oa);
|
||||||
void calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
void calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en,
|
||||||
struct proto *p, struct ospf_area *oa);
|
struct ospf_area *oa);
|
||||||
void calc_next_hop_fib(struct top_hash_entry *par, struct stub_fib *en,
|
void calc_next_hop_fib(struct top_hash_entry *par, struct stub_fib *en,
|
||||||
struct proto *p, struct ospf_area *oa);
|
struct ospf_area *oa);
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_RT_H_ */
|
#endif /* _BIRD_OSPF_RT_H_ */
|
||||||
|
|
|
@ -163,7 +163,7 @@ age_timer_hook(timer *timer)
|
||||||
|
|
||||||
if((delta=now-oa->lage)>=AGINGDELTA)
|
if((delta=now-oa->lage)>=AGINGDELTA)
|
||||||
{
|
{
|
||||||
WALK_SLIST_DELSAFE(en,nxt,oa->lsal) ospf_age(en,delta,flush,&oa->po->proto);
|
WALK_SLIST_DELSAFE(en,nxt,oa->lsal) ospf_age(en,delta,flush,oa);
|
||||||
oa->lage=now;
|
oa->lage=now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue