diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/lsalib.c | 8 | ||||
-rw-r--r-- | proto/ospf/neighbor.c | 12 | ||||
-rw-r--r-- | proto/ospf/neighbor.h | 1 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 1 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 10 | ||||
-rw-r--r-- | proto/ospf/rt.c | 67 | ||||
-rw-r--r-- | proto/ospf/rt.h | 5 | ||||
-rw-r--r-- | proto/ospf/topology.c | 1 | ||||
-rw-r--r-- | proto/ospf/topology.h | 3 |
9 files changed, 84 insertions, 24 deletions
diff --git a/proto/ospf/lsalib.c b/proto/ospf/lsalib.c index aa7e1f9f..9ad56840 100644 --- a/proto/ospf/lsalib.c +++ b/proto/ospf/lsalib.c @@ -87,7 +87,7 @@ htonlsab(void *h, void *n, u8 type, u16 len) hs=h; ns=n; - ns->netmask=htonl(hs->netmask); + ns->netmask=ipa_hton(hs->netmask); hn=(struct ospf_lsa_summ_net *)(hs+1); nn=(struct ospf_lsa_summ_net *)(ns+1); @@ -109,7 +109,7 @@ htonlsab(void *h, void *n, u8 type, u16 len) he=h; ne=n; - ne->netmask=htonl(he->netmask); + ne->netmask=ipa_hton(he->netmask); ht=(struct ospf_lsa_ext_tos *)(he+1); nt=(struct ospf_lsa_ext_tos *)(ne+1); @@ -181,7 +181,7 @@ ntohlsab(void *n, void *h, u8 type, u16 len) hs=h; ns=n; - hs->netmask=ntohl(ns->netmask); + hs->netmask=ipa_ntoh(ns->netmask); hn=(struct ospf_lsa_summ_net *)(hs+1); nn=(struct ospf_lsa_summ_net *)(ns+1); @@ -203,7 +203,7 @@ ntohlsab(void *n, void *h, u8 type, u16 len) he=h; ne=n; - he->netmask=ntohl(ne->netmask); + he->netmask=ipa_ntoh(ne->netmask); ht=(struct ospf_lsa_ext_tos *)(he+1); nt=(struct ospf_lsa_ext_tos *)(ne+1); diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index 9f3f2681..4a450c1d 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -368,6 +368,18 @@ find_neigh(struct ospf_iface *ifa, u32 rid) return NULL; } +struct ospf_neighbor * +find_neigh_noifa(struct proto_ospf *po, u32 rid) +{ + struct ospf_neighbor *n; + struct ospf_iface *ifa; + + WALK_LIST (ifa, po->iface_list) + if((n=find_neigh(ifa, rid))!=NULL) + return n; + return NULL; +} + struct ospf_area * ospf_find_area(struct proto_ospf *po, u32 aid) { diff --git a/proto/ospf/neighbor.h b/proto/ospf/neighbor.h index 64b163a4..501b9654 100644 --- a/proto/ospf/neighbor.h +++ b/proto/ospf/neighbor.h @@ -18,6 +18,7 @@ void tryadj(struct ospf_neighbor *n, struct proto *p); void ospf_neigh_sm(struct ospf_neighbor *n, int event); 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_noifa(struct proto_ospf *po, u32 rid); struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid); #endif /* _BIRD_OSPF_NEIGHBOR_H_ */ diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 9c432b4d..860714e1 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -50,6 +50,7 @@ ospf_dump(struct proto *p) debug("%s: LSA graph dump for area \"%I\" finished\n\n", p->name, oa->areaid); } + neigh_dump_all(); } diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 39f59bde..bd45392f 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -32,6 +32,7 @@ #define OSPF_VERSION 2 #define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */ #define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */ +#define DEFAULTDES ipa_from_u32(0) #else #error Multicast address not defined in IPv6 #endif @@ -40,8 +41,7 @@ #define LSREFRESHTIME 1800 /* 30 minutes */ #define MINLSINTERVAL 5 #define MINLSARRIVAL 1 -#define LSINFINITY 0xffffff -/*#define DEFAULTDES 0.0.0.0 FIXME: How to define it? */ +#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */ struct ospf_config { struct proto_config c; @@ -203,11 +203,11 @@ struct ospf_lsa_rt_link_tos { /* Actually we ignore TOS. This is useless */ }; struct ospf_lsa_net { - u32 netmask; + ip_addr netmask; }; struct ospf_lsa_summ { - u32 netmask; + ip_addr netmask; }; struct ospf_lsa_summ_net { @@ -217,7 +217,7 @@ struct ospf_lsa_summ_net { }; struct ospf_lsa_ext { - u32 netmask; + ip_addr netmask; }; struct ospf_lsa_ext_tos { diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 2d923ea1..e950cf31 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -40,7 +40,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p) { struct top_hash_entry *act,*tmp; node *n; - struct ospf_lsa_net *net; + struct ospf_lsa_net *netw; n=HEAD(oa->cand); act=SKIP_BACK(struct top_hash_entry, cn, n); @@ -72,21 +72,53 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p) log("Unknown link type in router lsa.\n"); break; } - add_cand(&oa->cand,tmp,act,act->dist+rtl->metric); + add_cand(&oa->cand,tmp,act,act->dist+rtl->metric,p); } break; case LSA_T_NET: - net=(struct ospf_lsa_net *)act->lsa_body; - rts=(u32 *)(net+1); + netw=(struct ospf_lsa_net *)act->lsa_body; + rts=(u32 *)(netw+1); for(i=0;i<(act->lsa.length-sizeof(struct ospf_lsa_header)- sizeof(struct ospf_lsa_net))/sizeof(u32);i++) { tmp=ospf_hash_find(oa->gr, *rts, *rts, LSA_T_RT); - add_cand(&oa->cand,tmp,act,act->dist); + add_cand(&oa->cand,tmp,act,act->dist,p); } break; } /* FIXME Now modify rt for this entry */ + if((act->lsa.type==LSA_T_NET)&&(act->nhi!=NULL)) + { + net *ne; + rte *e; + ip_addr ip; + struct ospf_lsa_net *ln=en->lsa_body; + + a0.proto=p; + a0.source=RTS_OSPF; + a0.scope=SCOPE_UNIVERSE; /* What's this good for? */ + a0.cast=RTC_UNICAST; + a0.dest=RTD_ROUTER; /* FIXME */ + a0.flags=0; + a0.iface=act->nhi; + a0.gw=act->nh; + ip=ipa_from_u32(act->lsa.id); + + + ne=net_get(p->table, ip, ipa_mklen(ln->netmask)); + e=rte_get_temp(&a0); + e->u.ospf.metric1=en->dist; + e->u.ospf.metric2=0; + e->u.ospf.tag=0; /* FIXME Some config? */ + + rte_update(p->table, ne, p, e); + + //a0.from=act->lsa.rt; + } + + + + } /* Now calculate routes to stub networks */ @@ -121,7 +153,7 @@ ospf_rt_spfa(struct ospf_area *oa, struct proto *p) void add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par, - u16 dist) + u16 dist, struct proto *p) { node *prev,*n; int flag=0; @@ -137,8 +169,10 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par, * FIXME The line above is not a bug, but we don't support * multiple next hops. I'll start as soon as nest will */ + + en->nhi=NULL; - en->nh=calc_next_hop(par); + calc_next_hop(par,en,p); if(en->color==CANDIDATE) /* We found shorter path */ { @@ -166,12 +200,21 @@ add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par, } -struct top_hash_entry * -calc_next_hop(struct top_hash_entry *par) +void +calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en, + struct proto *p) { - if(par->nh==NULL) + struct ospf_neighbor *neigh; + struct proto_ospf *po=(struct proto_ospf *)p; + if(par->nhi==NULL) { - if(par->lsa.type!=LSA_T_RT) return NULL; + neighbor *nn; + if(par->lsa.type!=LSA_T_RT) return; + if((neigh=find_neigh_noifa(po,en->lsa.rt))==NULL) bug("XXX\n"); + nn=neigh_find(p,&neigh->ip,0); + en->nh=nn->addr; + en->nhi=nn->iface; } - return par; + en->nh=par->nh; + en->nhi=par->nhi; } diff --git a/proto/ospf/rt.h b/proto/ospf/rt.h index eb8c43cf..9539751c 100644 --- a/proto/ospf/rt.h +++ b/proto/ospf/rt.h @@ -12,7 +12,8 @@ void ospf_rt_spfa(struct ospf_area *oa, struct proto *p); void add_cand(list *l, struct top_hash_entry *en, struct top_hash_entry *par, - u16 dist); -struct top_hash_entry *calc_next_hop(struct top_hash_entry *par); + u16 dist, struct proto *p); +void calc_next_hop(struct top_hash_entry *par, struct top_hash_entry *en, + struct proto *p); #endif /* _BIRD_OSPF_RT_H_ */ diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index 687b889e..db15f63c 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -349,6 +349,7 @@ ospf_hash_get(struct top_graph *f, u32 lsa, u32 rtr, u32 type) e->lsa.rt = rtr; e->lsa.type = type; e->lsa_body = NULL; + e->nhi=NULL; e->next=*ee; /* MJ you forgot this :-) */ *ee=e; if (f->hash_entries++ > f->hash_entries_max) diff --git a/proto/ospf/topology.h b/proto/ospf/topology.h index 1c3e9ea5..5514f5e9 100644 --- a/proto/ospf/topology.h +++ b/proto/ospf/topology.h @@ -16,7 +16,8 @@ struct top_hash_entry { /* Index for fast mapping (type,rtrid,LSid)->vertex */ struct ospf_lsa_header lsa; void *lsa_body; bird_clock_t inst_t; /* Time of installation into DB */ - struct top_hash_entry *nh; /* Next hop */ + ip_addr nh; /* Next hop */ + struct iface *nhi; u16 dist; /* Distance from the root */ u8 color; #define OUTSPF 0 |