diff options
-rw-r--r-- | proto/ospf/ospf.c | 22 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 4 | ||||
-rw-r--r-- | proto/ospf/topology.c | 60 |
3 files changed, 84 insertions, 2 deletions
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 17149927..7e04a518 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -68,6 +68,7 @@ ospf_init(struct proto_config *c) init_list(&(po->iface_list)); init_list(&(po->area_list)); p->import_control = ospf_import_control; + p->rt_notify = ospf_rt_notify; return p; } @@ -120,7 +121,6 @@ ospf_postconfig(struct proto_config *c) int ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool) { - int i; rte *e=*new; struct proto_ospf *po=(struct proto_ospf *)p; @@ -129,6 +129,26 @@ ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool return 0; } +void +ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old, ea_list *attrs) +{ + struct proto_ospf *po=(struct proto_ospf *)p; + + debug("%s: Got route %I/%d %s\n", p->name, n->n.prefix, + n->n.pxlen, new ? "up" : "down"); + + if(new) /* Got some new route */ + { + int i; + /* Originate new external LSA */ + } + else + { + int i; + /* Flush some old external LSA */ + } +} + struct protocol proto_ospf = { name: "OSPF", template: "ospf%d", diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index c7b48d02..4aea135b 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -351,7 +351,9 @@ static void ospf_preconfig(struct protocol *p, struct config *c); static void ospf_postconfig(struct proto_config *c); static int ospf_rte_better(struct rte *new, struct rte *old); static int ospf_rte_same(struct rte *new, struct rte *old); -int ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool); +int ospf_import_control(struct proto *p, rte **new, ea_list **attrs, + struct linpool *pool); +void ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old,ea_list *attrs); #include "proto/ospf/hello.h" #include "proto/ospf/packet.h" diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c index d80d3c8d..c02b0b79 100644 --- a/proto/ospf/topology.c +++ b/proto/ospf/topology.c @@ -319,6 +319,66 @@ originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po) flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa); } +void * +originate_ext_lsa_body(net *n, rte *e, struct proto_ospf *po) +{ + struct proto *p=&po->proto; + struct ospf_lsa_ext *ext; + struct ospf_lsa_ext_tos *et; + neighbor *nn; + + ext=mb_alloc(p->pool,sizeof(struct ospf_lsa_ext)+ + sizeof(struct ospf_lsa_ext_tos)); + ext->netmask=ipa_mkmask(n->n.pxlen); + + et=(struct ospf_lsa_ext_tos *)(ext+1); + if(e->u.ospf.metric2!=0) + { + et->etos=0; + et->metric=e->u.ospf.metric1; + } + else + { + et->etos=1; + et->metric=e->u.ospf.metric2; + } + et->padding=0; + et->tag=e->u.ospf.tag; + if(1) et->fwaddr= ipa_from_u32(0); /* FIXME if e->attrs->iface is not in my AS*/ + else et->fwaddr=e->attrs->gw; + return ext; +} + +void +originate_ext_lsa(net *n, rte *e, u16 *len, struct proto_ospf *po) +{ + struct ospf_lsa_header lsa; + u32 rtid=po->proto.cf->global->router_id; + struct top_hash_entry *en=NULL; + void *body=NULL; + struct ospf_iface *ifa; + + debug("%s: Originating Ext lsa for %I/%d.\n", po->proto.name, n->n.prefix, + n->n.pxlen); + + lsa.age=0; + lsa.id=ipa_to_u32(n->n.prefix); + lsa.type=LSA_T_EXT; + lsa.rt=rtid; + lsa.sn=LSA_INITSEQNO; + body=originate_ext_lsa_body(n, e, po); + lsa.length=sizeof(struct ospf_lsa_ext)+sizeof(struct ospf_lsa_ext_tos)+ + sizeof(struct ospf_lsa_header); + lsasum_calculate(&lsa,body,po); + WALK_LIST(ifa, po->iface_list) + { + en=lsa_install_new(&lsa, body, ifa->oa, &po->proto); + } + if(en==NULL) die("Some bug in Ext lsa generating\n"); + flood_lsa(NULL,NULL,&en->lsa,po,NULL,ifa->oa); +} + + static void ospf_top_ht_alloc(struct top_graph *f) { |