DBdes sending/receiving changes.

This commit is contained in:
Ondrej Filip 2000-03-29 00:34:28 +00:00
parent d0031c5ee9
commit 963ea03d87
3 changed files with 43 additions and 17 deletions

View file

@ -48,14 +48,14 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
ifa=n->ifa; ifa=n->ifa;
p=(struct proto *)(ifa->proto); p=(struct proto *)(ifa->proto);
pkt=(struct ospf_dbdes_packet *)(ifa->ip_sk->tbuf);
op=(struct ospf_packet *)pkt;
switch(n->state) switch(n->state)
{ {
case NEIGHBOR_EXSTART: /* Send empty packets */ case NEIGHBOR_EXSTART: /* Send empty packets */
pkt=(struct ospf_dbdes_packet *)(ifa->ip_sk->tbuf);
op=(struct ospf_packet *)pkt;
fill_ospf_pkt_hdr(ifa, pkt, DBDES); fill_ospf_pkt_hdr(ifa, pkt, DBDES);
pkt->iface_mtu=ifa->iface->mtu; pkt->iface_mtu=htons(ifa->iface->mtu);
pkt->options= ifa->options; pkt->options= ifa->options;
pkt->imms=n->myimms; pkt->imms=n->myimms;
pkt->ddseq=n->dds; pkt->ddseq=n->dds;
@ -63,62 +63,78 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
op->length=htons(length); op->length=htons(length);
ospf_pkt_finalize(ifa, op); ospf_pkt_finalize(ifa, op);
sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO); sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO);
debug("%s: DB_DES sent for %u.\n", p->name, n->rid); debug("%s: DB_DES (I) sent for %u.\n", p->name, n->rid);
break; break;
case NEIGHBOR_EXCHANGE: case NEIGHBOR_EXCHANGE:
if(! ((IAMMASTER(n->myimms) && (n->dds==n->ddr+1)) || ((!IAMMASTER(n->myimms)) && (n->dds==n->ddr)))) if(! ((IAMMASTER(n->myimms) && (n->dds==n->ddr+1)) ||
((!IAMMASTER(n->myimms)) && (n->dds==n->ddr))))
{ {
snode *sn; /* Send next */ snode *sn; /* Send next */
struct ospf_lsa_header *lsa; struct ospf_lsa_header *lsa;
pkt=n->ldbdes;
op=(struct ospf_packet *)pkt;
fill_ospf_pkt_hdr(ifa, pkt, DBDES); fill_ospf_pkt_hdr(ifa, pkt, DBDES);
pkt->iface_mtu= ifa->iface->mtu; pkt->iface_mtu=htons(ifa->iface->mtu);
pkt->options= ifa->options; pkt->options= ifa->options;
pkt->ddseq=n->dds; pkt->ddseq=n->dds;
sn=s_get(&(n->dbsi)); j=i=(ifa->iface->mtu-sizeof(struct ospf_dbdes_packet))/
j=i=(pkt->iface_mtu-sizeof(struct ospf_dbdes_packet))/
sizeof(struct ospf_lsa_header); /* Number of lsaheaders */ sizeof(struct ospf_lsa_header); /* Number of lsaheaders */
lsa=(n->ldbdes+sizeof(struct ospf_dbdes_packet)); lsa=(n->ldbdes+sizeof(struct ospf_dbdes_packet));
sn=s_get(&(n->dbsi));
DBG("Number of LSA: %d\n", j);
for(;i>0;i--) for(;i>0;i--)
{ {
struct top_hash_entry *en; struct top_hash_entry *en;
en=(struct top_hash_entry *)sn; en=(struct top_hash_entry *)sn;
htonlsah(&(en->lsa), lsa); htonlsah(&(en->lsa), lsa);
DBG("Working on: %d\n", i);
debug("\t%04x %08x %08x %p\n", en->lsa.type, en->lsa.id,
en->lsa.rt, en->lsa_body);
if(sn->next==NULL) if(sn->next==NULL)
{ {
break; /* Should set some flag? */ break; /* Should set some flag? */
} }
sn=sn->next; sn=sn->next;
lsa++;
} }
s_put(&(n->dbsi),sn); i--;
if(sn->next==NULL) if(sn->next==NULL)
{ {
DBG("Number of LSA NOT sent: %d\n", i);
DBG("M bit unset.\n");
n->myimms=(n->myimms-DBDES_M); /* Unset more bit */ n->myimms=(n->myimms-DBDES_M); /* Unset more bit */
} }
s_put(&(n->dbsi),sn);
pkt->imms=n->myimms; pkt->imms=n->myimms;
length=j*sizeof(struct ospf_lsa_header)+ length=(j-i)*sizeof(struct ospf_lsa_header)+
sizeof(struct ospf_dbdes_packet); sizeof(struct ospf_dbdes_packet);
op->length=htons(length); op->length=htons(length);
ospf_pkt_finalize(ifa, op); ospf_pkt_finalize(ifa, op);
sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO);
} }
aa=ifa->ip_sk->tbuf; aa=ifa->ip_sk->tbuf;
bb=n->ldbdes; bb=n->ldbdes;
op=n->ldbdes;
length=ntohs(op->length); length=ntohs(op->length);
for(i=0; i<ifa->iface->mtu; i++) for(i=0; i<ifa->iface->mtu; i++)
{ {
*(aa+i)=*(bb+i); /* Copy last sent packet again */ *(bb+i)=*(aa+i); /* Copy last sent packet again */
} }
sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO); sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO);
debug("%s: DB_DES sent for %u.\n", p->name, n->rid);
default: /* Ignore it */ default: /* Ignore it */
break; break;
@ -227,18 +243,21 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
if(IAMMASTER(ps->imms)!=IAMMASTER(n->myimms)) /* M/S bit differs */ if(IAMMASTER(ps->imms)!=IAMMASTER(n->myimms)) /* M/S bit differs */
{ {
DBG("SEQMIS-IMMS\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
if(INISET(ps->imms)) /* I bit is set */ if(INISET(ps->imms)) /* I bit is set */
{ {
DBG("SEQMIS-BIT-I\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
if(ps->options!=n->options) /* Options differs */ if(ps->options!=n->options) /* Options differs */
{ {
DBG("SEQMIS-OPT\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
@ -247,6 +266,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
{ {
if(ps->ddseq!=n->dds) if(ps->ddseq!=n->dds)
{ {
DBG("SEQMIS-MASTER\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
@ -255,6 +275,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
{ {
if(ps->ddseq!=(n->dds+1)) if(ps->ddseq!=(n->dds+1))
{ {
DBG("SEQMIS-SLAVE\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }

View file

@ -206,9 +206,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
neigh_chstate(n,NEIGHBOR_EXCHANGE); neigh_chstate(n,NEIGHBOR_EXCHANGE);
s_init_list(&(n->lsrql)); s_init_list(&(n->lsrql));
s_init_list(&(n->lsrtl)); s_init_list(&(n->lsrtl));
DBG("OK1\n");
s_init(&(n->dbsi), &(n->ifa->oa->lsal)); s_init(&(n->dbsi), &(n->ifa->oa->lsal));
DBG("OK2\n");
ospf_dbdes_tx(n); ospf_dbdes_tx(n);
} }
break; break;
@ -243,7 +241,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
if(n->state>=NEIGHBOR_EXCHANGE) if(n->state>=NEIGHBOR_EXCHANGE)
{ {
neigh_chstate(n,NEIGHBOR_EXSTART); neigh_chstate(n,NEIGHBOR_EXSTART);
/* Go on....*/ /* FIXME: Go on....*/
} }
break; break;
case INM_KILLNBR: case INM_KILLNBR:

View file

@ -174,6 +174,8 @@ addifa_rtlsa(struct ospf_iface *ifa)
if(oa==NULL) /* New area */ if(oa==NULL) /* New area */
{ {
struct ospf_lsa_header *lsa;
oa=po->firstarea; oa=po->firstarea;
po->firstarea=mb_alloc(po->proto.pool, sizeof(struct ospf_area)); po->firstarea=mb_alloc(po->proto.pool, sizeof(struct ospf_area));
po->firstarea->next=oa; po->firstarea->next=oa;
@ -183,9 +185,14 @@ addifa_rtlsa(struct ospf_iface *ifa)
s_init_list(&(oa->lsal)); s_init_list(&(oa->lsal));
oa->rt=ospf_hash_get(oa->gr, rtid, rtid, LSA_T_RT); oa->rt=ospf_hash_get(oa->gr, rtid, rtid, LSA_T_RT);
s_add_head(&(oa->lsal), (snode *)oa->rt); s_add_head(&(oa->lsal), (snode *)oa->rt);
((snode *)oa->rt)->next=NULL;
lsa=&(oa->rt->lsa);
oa->rt->lsa_body=NULL; oa->rt->lsa_body=NULL;
oa->rt->lsa.age=0; lsa->age=0;
oa->rt->lsa.sn=LSA_INITSEQNO-1; /* FIXME Check it latter */ lsa->sn=LSA_INITSEQNO-1; /* FIXME Check it latter */
lsa->checksum=0;
lsa->checksum=ipsum_calculate(lsa,sizeof(struct ospf_lsa_header),NULL);
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);
} }