0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Some bug fixes. LSA checksum is still bad. I'll fix it later.

This commit is contained in:
Ondrej Filip 2000-03-31 01:14:41 +00:00
parent f45fd3164b
commit 9f940976d1
4 changed files with 29 additions and 12 deletions

View File

@ -103,12 +103,12 @@ ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
for(i=0;i<(length-sizeof(struct ospf_lsreq_packet))/ for(i=0;i<(length-sizeof(struct ospf_lsreq_packet))/
sizeof(struct ospf_lsreq_header);i++); sizeof(struct ospf_lsreq_header);i++);
{ {
DBG("Processing LSA: ID=%u, Type=%u, Router=%u\n", lsh->id, DBG("Processing LSA: ID=%u, Type=%u, Router=%u\n", ntohl(lsh->id),
ntohl(lsh->type), ntohl(lsh->rt)); lsh->type, ntohl(lsh->rt));
llsh=sl_alloc(upslab); llsh=sl_alloc(upslab);
llsh->lsh.id=ntohl(lsh->id); llsh->lsh.id=ntohl(lsh->id);
llsh->lsh.rt=ntohl(lsh->rt); llsh->lsh.rt=ntohl(lsh->rt);
llsh->lsh.type=ntohl(lsh->type); llsh->lsh.type=lsh->type;
add_tail(&uplist, NODE llsh); add_tail(&uplist, NODE llsh);
if(ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt, if(ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
llsh->lsh.type)==NULL) llsh->lsh.type)==NULL)

View File

@ -24,11 +24,15 @@ ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
struct ospf_lsupd_packet *pk; struct ospf_lsupd_packet *pk;
struct ospf_packet *op; struct ospf_packet *op;
void *pktpos; void *pktpos;
u8 ii;
u8 *jj=n->ifa->ip_sk->tbuf;
if(HEAD(*l)==NULL) return; if(HEAD(*l)==NULL) return;
pk=(struct ospf_lsupd_packet *)n->ifa->ip_sk->tbuf; pk=(struct ospf_lsupd_packet *)n->ifa->ip_sk->tbuf;
op=(struct ospf_packet *)n->ifa->ip_sk->tbuf; op=(struct ospf_packet *)n->ifa->ip_sk->tbuf;
DBG("LSupd: 1st packet\n");
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD); fill_ospf_pkt_hdr(n->ifa, pk, LSUPD);
len=SIPH+sizeof(struct ospf_lsupd_packet); len=SIPH+sizeof(struct ospf_lsupd_packet);
@ -38,13 +42,20 @@ ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
WALK_LIST(llsh, *l) WALK_LIST(llsh, *l)
{ {
en=ospf_hash_find(n->ifa->oa->gr,llsh->lsh.id,llsh->lsh.rt,llsh->lsh.type); en=ospf_hash_find(n->ifa->oa->gr,llsh->lsh.id,llsh->lsh.rt,llsh->lsh.type);
if((len+sizeof(struct ospf_lsa_header)+en->body_len)>n->ifa->iface->mtu) 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)
{ {
pk->lsano=htonl(lsano); pk->lsano=htonl(lsano);
op->length=htons(len); op->length=htons(len);
ospf_pkt_finalize(n->ifa, op); ospf_pkt_finalize(n->ifa, op);
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));
sk_send_to(n->ifa->ip_sk,len, n->ip, OSPF_PROTO); sk_send_to(n->ifa->ip_sk,len, n->ip, OSPF_PROTO);
DBG("LSupd: next packet\n");
fill_ospf_pkt_hdr(n->ifa, pk, LSUPD); fill_ospf_pkt_hdr(n->ifa, pk, LSUPD);
len=SIPH+sizeof(struct ospf_lsupd_packet); len=SIPH+sizeof(struct ospf_lsupd_packet);
lsano=0; lsano=0;
@ -53,13 +64,19 @@ ospf_lsupd_tx_list(struct ospf_neighbor *n, list *l)
htonlsah(&(en->lsa), pktpos); htonlsah(&(en->lsa), pktpos);
pktpos=pktpos+sizeof(struct ospf_lsa_header); pktpos=pktpos+sizeof(struct ospf_lsa_header);
htonlsab(en->lsa_body, pktpos, en->lsa.type, en->lsa.length); htonlsab(en->lsa_body, pktpos, en->lsa.type, en->lsa.length);
pktpos=pktpos+en->body_len; pktpos=pktpos+en->lsa.length-sizeof(struct ospf_lsa_header);
len=len+en->body_len+sizeof(struct ospf_lsa_header); len=len+en->lsa.length;
lsano++;
} }
pk->lsano=htonl(lsano); pk->lsano=htonl(lsano);
op->length=htons(len); op->length=htons(len-SIPH);
ospf_pkt_finalize(n->ifa, op); ospf_pkt_finalize(n->ifa, op);
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));
sk_send_to(n->ifa->ip_sk,len, n->ip, OSPF_PROTO); sk_send_to(n->ifa->ip_sk,len, n->ip, OSPF_PROTO);
DBG("LSupd: sent\n");
} }
void void

View File

@ -27,7 +27,8 @@ unsigned int
make_rt_lsa(struct ospf_area *oa, struct proto_ospf *p) make_rt_lsa(struct ospf_area *oa, struct proto_ospf *p)
{ {
struct ospf_iface *ifa; struct ospf_iface *ifa;
int i=0,j=0,k=0,v=0,e=0,b=0; int j=0,k=0,v=0,e=0,b=0;
u16 i=0;
struct ospf_lsa_rt *rt; struct ospf_lsa_rt *rt;
struct ospf_lsa_rt_link *ln; struct ospf_lsa_rt_link *ln;
struct ospf_neighbor *neigh; struct ospf_neighbor *neigh;
@ -147,7 +148,7 @@ make_rt_lsa(struct ospf_area *oa, struct proto_ospf *p)
rt->links=i; rt->links=i;
if(old->lsa_body!=NULL) mb_free(old->lsa_body); if(old->lsa_body!=NULL) mb_free(old->lsa_body);
old->lsa_body=rt; old->lsa_body=rt;
return rt->links*sizeof(struct ospf_lsa_rt_link)+sizeof(struct ospf_lsa_rt); return i*sizeof(struct ospf_lsa_rt_link)+sizeof(struct ospf_lsa_rt);
} }
@ -188,14 +189,14 @@ addifa_rtlsa(struct ospf_iface *ifa)
lsa=&(oa->rt->lsa); lsa=&(oa->rt->lsa);
oa->rt->lsa_body=NULL; oa->rt->lsa_body=NULL;
lsa->age=0; lsa->age=0;
lsa->sn=LSA_INITSEQNO-1; /* FIXME Check it latter */ lsa->sn=LSA_INITSEQNO; /* FIXME Check it latter */
lsa->checksum=0; lsa->checksum=0;
lsa->checksum=ipsum_calculate(lsa,sizeof(struct ospf_lsa_header),NULL); lsa->checksum=ipsum_calculate(lsa,sizeof(struct ospf_lsa_header),NULL);
ifa->oa=oa; ifa->oa=oa;
DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an); DBG("%s: New OSPF area \"%d\" added.\n", po->proto.name, ifa->an);
} }
oa->rt->body_len=make_rt_lsa(oa, po); oa->rt->lsa.length=make_rt_lsa(oa, po)+sizeof(struct ospf_lsa_header);
/*FIXME seq no++ */ /*FIXME seq no++ */
/*FIXME lsa_flood(oa->rt) */ /*FIXME lsa_flood(oa->rt) */
} }

View File

@ -14,7 +14,6 @@ struct top_hash_entry { /* Index for fast mapping (type,rtrid,LSid)->vertex */
struct top_hash_entry *next; /* Next in hash chain */ struct top_hash_entry *next; /* Next in hash chain */
struct ospf_lsa_header lsa; struct ospf_lsa_header lsa;
void *lsa_body; void *lsa_body;
unsigned int body_len;
}; };
struct top_graph { struct top_graph {