]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Originating of external LSA.
authorOndrej Filip <feela@network.cz>
Sat, 27 May 2000 14:17:35 +0000 (14:17 +0000)
committerOndrej Filip <feela@network.cz>
Sat, 27 May 2000 14:17:35 +0000 (14:17 +0000)
proto/ospf/ospf.c
proto/ospf/ospf.h
proto/ospf/topology.c

index 17149927ff2d1b5bb3019a60ca4ab5471ffa5260..7e04a518cc1d2fe630e8588d33dcc82354677843 100644 (file)
@@ -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",
index c7b48d029979cae3121e257c47ac3aa5756839d3..4aea135bce6c5e7a6cb097418039b72e898c85c6 100644 (file)
@@ -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"
index d80d3c8d2044f2d367c2cb00afb19ebbfbe0adf4..c02b0b7901c79628e6cd1643b207c03105e6bef6 100644 (file)
@@ -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)
 {