Commit 6d2b3211 authored by Ondřej Filip's avatar Ondřej Filip

LSreq initial work.

parent 3ee2310c
source=ospf.c topology.c packet.c hello.c neighbor.c iface.c dbdes.c
source=ospf.c topology.c packet.c hello.c neighbor.c iface.c dbdes.c lsreq.c
root-rel=../../
dir-name=proto/ospf
......
......@@ -184,7 +184,7 @@ rxmt_timer_hook(timer *timer)
n=(struct ospf_neighbor *)timer->data;
ifa=n->ifa;
p=(struct proto *)(ifa->proto);
debug("%s: RXMT timer fired on interface %s for nigh: %d.\n",
debug("%s: RXMT timer fired on interface %s for neigh: %u.\n",
p->name, ifa->iface->name, n->rid);
if(n->state<NEIGHBOR_LOADING) ospf_dbdes_tx(n);
else
......@@ -221,19 +221,29 @@ ospf_dbdes_reqladd(struct ospf_dbdes_packet *ps, struct proto *p,
struct ospf_lsa_header *plsa,lsa;
struct top_hash_entry *he,*sn;
struct top_graph *gr;
struct ospf_packet *op;
int i,j;
gr=n->ifa->oa->gr;
op=(struct ospf_packet *)ps;
plsa=(void *)(ps+1);
ntohlsah(plsa, &lsa);
j=(ntohs(op->length)-sizeof(struct ospf_dbdes_packet))/
sizeof( struct ospf_lsa_header);
for(i=0;i<j;i++)
{
ntohlsah(plsa+i, &lsa);
/* FIXME Test Checksum */
if(((he=ospf_hash_find(gr,lsa.id,lsa.rt,lsa.type))==NULL)||
(lsa_comp(&lsa, &(he->lsa))==1))
{
sn=sl_alloc(gr->hash_slab);
ntohlsah(plsa, &(sn->lsa));
ntohlsah(plsa+i, &(sn->lsa));
s_add_tail(&(n->lsrql), SNODE sn);
}
}
}
void
......
......@@ -112,6 +112,12 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
n->rxmt_timer->hook=rxmt_timer_hook;
n->rxmt_timer->recurrent=ifa->rxmtint;
DBG("%s: Installing rxmt timer.\n", p->name);
n->lsrr_timer=tm_new(p->pool);
n->lsrr_timer->data=n;
n->lsrr_timer->randomize=0;
n->lsrr_timer->hook=lsrr_timer_hook;
n->lsrr_timer->recurrent=ifa->rxmtint;
DBG("%s: Installing lsrr timer.\n", p->name);
}
ospf_neigh_sm(n, INM_HELLOREC);
......
/*
* BIRD -- OSPF
*
* (c) 2000 Ondrej Filip <feela@network.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "ospf.h"
void
ospf_lsreq_tx(struct ospf_neighbor *n)
{
snode *sn;
struct top_hash_entry *en;
struct ospf_lsreq_packet *pk;
struct ospf_packet *op;
struct ospf_lsreq_header *lsh;
u16 length;
int i,j;
pk=(struct ospf_lsreq_packet *)n->ifa->ip_sk->tbuf;
op=(struct ospf_packet *)n->ifa->ip_sk->tbuf;
fill_ospf_pkt_hdr(n->ifa, pk, LSREQ);
s_init(&(n->lsrqi), &(n->lsrql));
sn=s_get(&(n->lsrqi));
if(sn==NULL) return;
/* FIXME above I don't need iterator and slist */
i=j=(n->ifa->iface->mtu-SIPH-sizeof(struct ospf_lsreq_packet))/
sizeof(struct ospf_lsreq_header); /* FIXME IP header! */
lsh=(struct ospf_lsreq_header *)(pk+1);
for(;i>0;i--)
{
en=(struct top_hash_entry *)sn;
lsh->padd1=0; lsh->padd2=0;
lsh->type=en->lsa.type;
lsh->rt=htonl(en->lsa.rt);
lsh->id=htonl(en->lsa.id);
lsh++;
DBG("Requesting %uth LSA: Type: %u, Id: %u, RT: %u\n",i, en->lsa.type,
en->lsa.id, en->lsa.rt);
if((sn=sn->next)==NULL) break;
}
length=sizeof(struct ospf_lsreq_packet)+(j-i)*sizeof(struct ospf_lsreq_header);
op->length=htons(length);
ospf_pkt_finalize(n->ifa, op);
sk_send_to(n->ifa->ip_sk,length, n->ip, OSPF_PROTO);
DBG("Lsreq send to: %u\n", n->rid);
}
void
lsrr_timer_hook(timer *timer)
{
struct ospf_iface *ifa;
struct proto *p;
struct ospf_neighbor *n;
n=(struct ospf_neighbor *)timer->data;
ifa=n->ifa;
p=(struct proto *)(ifa->proto);
debug("%s: LSRR timer fired on interface %s for neigh: %u.\n",
p->name, ifa->iface->name, n->rid);
ospf_lsreq_tx(n);
}
void
ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
struct ospf_iface *ifa, u16 size)
{
u32 nrid, myrid;
struct ospf_neighbor *n;
struct ospf_lsreq_header *lsh;
int length;
u8 i;
nrid=ntohl(ps->ospf_packet.routerid);
myrid=p->cf->global->router_id;
if((n=find_neigh(ifa, nrid))==NULL)
{
debug("%s: Received dbdes from unknown neigbor! (%u)\n", p->name,
nrid);
return ;
}
if(n->state<NEIGHBOR_EXCHANGE) debug("%s: Ignoring it.\n", p->name);
length=htons(ps->ospf_packet.length);
lsh=(void *)(ps+1);
for(i=0;i<(length-sizeof(struct ospf_lsreq_packet))/
sizeof(struct ospf_lsreq_header);i++);
{
DBG("Processing LSA: ID=%u, Type=%u, Router=%u\n", lsh->id, lsh->type,
lsh->rt);
/* FIXME Go on */
}
}
/*
* BIRD -- OSPF
*
* (c) 2000 Ondrej Filip <feela@network.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*
*/
#ifndef _BIRD_OSPF_LSREQ_H_
#define _BIRD_OSPF_LSREQ_H_
void ospf_lsreq_tx(struct ospf_neighbor *n);
void lsrr_timer_hook(timer *timer);
void ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
struct ospf_iface *ifa, u16 size);
#endif /* _BIRD_OSPF_LSREQ_H_ */
......@@ -210,8 +210,11 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
s_init_list(&(n->lsrql));
s_init_list(&(n->lsrtl));
s_init(&(n->dbsi), &(n->ifa->oa->lsal));
s_init(&(n->lsrqi), &(n->lsrql));
tm_start(n->lsrr_timer,n->ifa->rxmtint);
/*ospf_dbdes_tx(n);*/
}
else die("NEGDONE and I'm not in EXSTART?\n");
break;
case INM_EXDONE:
neigh_chstate(n,NEIGHBOR_LOADING);
......
......@@ -11,6 +11,8 @@
#define LOCAL_DEBUG
#define SIPH 64 /* FIXME Size Of IP header */
#include <string.h>
#include "nest/bird.h"
......@@ -232,6 +234,18 @@ struct ospf_lsa_ext_tos {
u32 tag;
};
struct ospf_lsreq_packet {
struct ospf_packet ospf_packet;
};
struct ospf_lsreq_header {
u16 padd1;
u8 padd2;
u8 type;
u32 id;
u32 rt; /* Advertising router */
};
struct ospf_neighbor
{
node n;
......@@ -258,12 +272,13 @@ struct ospf_neighbor
u32 bdr; /* Neigbour's idea of BDR */
u8 adj; /* built adjacency? */
siterator dbsi; /* Database summary list iterator */
slist lsrql; /* Link state request */ /* FIXME add top_gr hashing? */
slist lsrql; /* Link state request */ /* FIXME add hashing? */
siterator lsrqi;
slist lsrtl; /* Link state retransmission list */
siterator lsrti;
void *ldbdes; /* Last database description packet */
timer *rxmt_timer; /* RXMT timer */
timer *rxmt_timer; /* RXMT timer */
timer *lsrr_timer; /* Link state requiest retransmition timer */
};
/* Definitions for interface state machine */
......@@ -318,5 +333,6 @@ static void ospf_postconfig(struct proto_config *c);
#include "proto/ospf/neighbor.h"
#include "proto/ospf/topology.h"
#include "proto/ospf/dbdes.h"
#include "proto/ospf/lsreq.h"
#endif /* _BIRD_OSPF_H_ */
......@@ -141,6 +141,7 @@ ospf_rx_hook(sock *sk, int size)
break;
case LSREQ:
DBG("%s: Link state request received.\n", p->name);
ospf_lsreq_rx((struct ospf_lsreq_packet *)ps, p, ifa, size);
break;
case LSUPD:
DBG("%s: Link state update received.\n", p->name);
......
......@@ -197,6 +197,7 @@ addifa_rtlsa(struct ospf_iface *ifa)
}
make_rt_lsa(oa, po);
/* FIXME length? */
/*FIXME seq no++ */
/*FIXME lsa_flood(oa->rt) */
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment