summaryrefslogtreecommitdiff
path: root/proto/ospf/topology.c
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2000-05-02 23:09:44 +0000
committerOndrej Filip <feela@network.cz>2000-05-02 23:09:44 +0000
commit0bf2f2039e1fc95fe0fa3ee231711212f1f2b128 (patch)
treecd34f6c0ff55622a9f0cebe318476d076deaa08c /proto/ospf/topology.c
parent92bbd812e332c9948d737e95526c571ff371d394 (diff)
Originating of network LSA.
Diffstat (limited to 'proto/ospf/topology.c')
-rw-r--r--proto/ospf/topology.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c
index a69c01a2..0020b572 100644
--- a/proto/ospf/topology.c
+++ b/proto/ospf/topology.c
@@ -244,6 +244,62 @@ originate_rt_lsa(struct ospf_area *oa, struct proto_ospf *po)
return en;
}
+void *
+originate_net_lsa_body(struct ospf_iface *ifa, u16 *length,
+ struct proto_ospf *po)
+{
+ u16 i=1;
+ 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);
+ i=1;
+ *body=po->proto.cf->global->router_id;
+ WALK_LIST(n,ifa->neigh_list)
+ {
+ if(n->state==NEIGHBOR_FULL)
+ {
+ *(body+i)=n->rid;
+ i++;
+ }
+ }
+ *length=i*sizeof(u32)+sizeof(struct ospf_lsa_header);
+ return body;
+}
+
+struct top_hash_entry *
+originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
+{
+ struct ospf_lsa_header lsa;
+ u32 rtid=po->proto.cf->global->router_id;
+ struct top_hash_entry *en;
+ void *body;
+
+ DBG("%s: Originating Net lsa for iface \"%s\".\n", po->proto.name, ifa->iface->name);
+
+ lsa.age=0;
+ lsa.id=rtid;
+ lsa.type=LSA_T_NET;
+ lsa.rt=rtid;
+ if(ifa->nlsa==NULL)
+ {
+ lsa.sn=LSA_INITSEQNO;
+ }
+ else
+ {
+ lsa.sn=ifa->nlsa->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;
+}
+
+
static void