2000-03-30 20:00:42 +00:00
|
|
|
/*
|
|
|
|
* 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_lsupd_tx(struct ospf_neighbor *n)
|
|
|
|
{
|
|
|
|
/* FIXME Go on! */
|
|
|
|
}
|
|
|
|
|
2000-03-31 00:21:41 +00:00
|
|
|
void /* I send all I received in LSREQ */
|
|
|
|
ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
|
|
|
|
{
|
|
|
|
struct l_lsr_head *llsh;
|
|
|
|
u16 len;
|
|
|
|
u32 lsano;
|
|
|
|
struct top_hash_entry *en;
|
|
|
|
struct ospf_lsupd_packet *pk;
|
|
|
|
struct ospf_packet *op;
|
|
|
|
void *pktpos;
|
2000-03-31 01:14:41 +00:00
|
|
|
u8 ii;
|
|
|
|
u8 *jj=n->ifa->ip_sk->tbuf;
|
2000-03-31 00:21:41 +00:00
|
|
|
|
|
|
|
if(HEAD(*l)==NULL) return;
|
|
|
|
|
|
|
|
pk=(struct ospf_lsupd_packet *)n->ifa->ip_sk->tbuf;
|
|
|
|
op=(struct ospf_packet *)n->ifa->ip_sk->tbuf;
|
2000-03-31 01:14:41 +00:00
|
|
|
|
|
|
|
DBG("LSupd: 1st packet\n");
|
2000-03-31 00:21:41 +00:00
|
|
|
|
|
|
|
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD);
|
|
|
|
len=SIPH+sizeof(struct ospf_lsupd_packet);
|
|
|
|
lsano=0;
|
|
|
|
pktpos=(pk+1);
|
|
|
|
|
|
|
|
WALK_LIST(llsh, *l)
|
|
|
|
{
|
|
|
|
en=ospf_hash_find(n->ifa->oa->gr,llsh->lsh.id,llsh->lsh.rt,llsh->lsh.type);
|
2000-03-31 01:14:41 +00:00
|
|
|
DBG("Sending ID=%u, Type=%u, RT=%u\n", llsh->lsh.id, llsh->lsh.type,
|
|
|
|
llsh->lsh.rt);
|
|
|
|
if((len+sizeof(struct ospf_lsa_header)+en->lsa.length)>n->ifa->iface->mtu)
|
2000-03-31 00:21:41 +00:00
|
|
|
{
|
|
|
|
pk->lsano=htonl(lsano);
|
|
|
|
op->length=htons(len);
|
|
|
|
ospf_pkt_finalize(n->ifa, op);
|
2000-03-31 01:14:41 +00:00
|
|
|
|
|
|
|
for(ii=0;ii<(len-SIPH);ii+=4)
|
|
|
|
DBG("Out dump: %d,%d,%d,%d\n", *(jj+ii), *(jj+ii+1), *(jj+ii+2), *(jj+ii+3));
|
|
|
|
|
2000-03-31 00:21:41 +00:00
|
|
|
sk_send_to(n->ifa->ip_sk,len, n->ip, OSPF_PROTO);
|
|
|
|
|
2000-03-31 01:14:41 +00:00
|
|
|
DBG("LSupd: next packet\n");
|
2000-03-31 00:21:41 +00:00
|
|
|
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD);
|
|
|
|
len=SIPH+sizeof(struct ospf_lsupd_packet);
|
|
|
|
lsano=0;
|
|
|
|
pktpos=(pk+1);
|
|
|
|
}
|
|
|
|
htonlsah(&(en->lsa), pktpos);
|
|
|
|
pktpos=pktpos+sizeof(struct ospf_lsa_header);
|
|
|
|
htonlsab(en->lsa_body, pktpos, en->lsa.type, en->lsa.length);
|
2000-03-31 01:14:41 +00:00
|
|
|
pktpos=pktpos+en->lsa.length-sizeof(struct ospf_lsa_header);
|
|
|
|
len=len+en->lsa.length;
|
|
|
|
lsano++;
|
2000-03-31 00:21:41 +00:00
|
|
|
}
|
|
|
|
pk->lsano=htonl(lsano);
|
2000-03-31 01:14:41 +00:00
|
|
|
op->length=htons(len-SIPH);
|
2000-03-31 00:21:41 +00:00
|
|
|
ospf_pkt_finalize(n->ifa, op);
|
2000-03-31 01:14:41 +00:00
|
|
|
|
|
|
|
for(ii=0;ii<(len-SIPH);ii+=4)
|
|
|
|
DBG("Out dump: %d,%d,%d,%d\n", *(jj+ii), *(jj+ii+1), *(jj+ii+2), *(jj+ii+3));
|
|
|
|
|
2000-03-31 00:21:41 +00:00
|
|
|
sk_send_to(n->ifa->ip_sk,len, n->ip, OSPF_PROTO);
|
2000-03-31 01:14:41 +00:00
|
|
|
DBG("LSupd: sent\n");
|
2000-03-31 00:21:41 +00:00
|
|
|
}
|
|
|
|
|
2000-03-30 20:00:42 +00:00
|
|
|
void
|
|
|
|
ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
|
|
|
|
struct ospf_iface *ifa, u16 size)
|
|
|
|
{
|
2000-04-02 20:41:33 +00:00
|
|
|
u32 area,nrid,myrid;
|
2000-03-30 20:00:42 +00:00
|
|
|
struct ospf_neighbor *n;
|
2000-04-02 20:41:33 +00:00
|
|
|
struct ospf_lsa_header *lsa;
|
|
|
|
u16 length;
|
2000-03-30 20:00:42 +00:00
|
|
|
u8 i;
|
|
|
|
|
|
|
|
nrid=ntohl(ps->ospf_packet.routerid);
|
|
|
|
|
|
|
|
myrid=p->cf->global->router_id;
|
|
|
|
|
|
|
|
if((n=find_neigh(ifa, nrid))==NULL)
|
|
|
|
{
|
|
|
|
debug("%s: Received lsupd from unknown neigbor! (%u)\n", p->name,
|
|
|
|
nrid);
|
|
|
|
return ;
|
|
|
|
}
|
2000-04-02 20:41:33 +00:00
|
|
|
if(n->state<NEIGHBOR_EXCHANGE)
|
|
|
|
{
|
|
|
|
debug("%s: Received lsupd in lesser state than EXCHANGE from (%u)\n",
|
|
|
|
p->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
lsa=(struct ospf_lsa_header *)(ps+1);
|
|
|
|
area=htonl(ps->ospf_packet.areaid);
|
|
|
|
for(i=0;i<ntohl(ps->lsano);i++)
|
|
|
|
{
|
|
|
|
if(lsa->checksum==lsasum_check(lsa,NULL,(struct proto_ospf *)p))
|
|
|
|
{
|
|
|
|
DBG("Processing update Type: %u ID: %u RT: %u\n",lsa->type,
|
|
|
|
ntohl(lsa->id), ntohl(lsa->rt));
|
|
|
|
/* FIXME Go on */
|
|
|
|
}
|
|
|
|
lsa=(struct ospf_lsa_header *)(((u8 *)lsa)+ntohs(lsa->length));
|
|
|
|
}
|
2000-03-30 20:00:42 +00:00
|
|
|
}
|
|
|
|
|