dbdes indent an minor changes.
This commit is contained in:
parent
85305e5d8f
commit
12bed559ff
4 changed files with 288 additions and 285 deletions
|
@ -9,7 +9,7 @@
|
||||||
#include "ospf.h"
|
#include "ospf.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ospf_dbdes_tx - transmit database description packet
|
* ospf_dbdes_send - transmit database description packet
|
||||||
* @n: neighbor
|
* @n: neighbor
|
||||||
*
|
*
|
||||||
* Sending of a database description packet is described in 10.6 of RFC 2328.
|
* Sending of a database description packet is described in 10.6 of RFC 2328.
|
||||||
|
@ -19,334 +19,338 @@
|
||||||
* of the buffer.
|
* of the buffer.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ospf_dbdes_tx(struct ospf_neighbor *n)
|
ospf_dbdes_send(struct ospf_neighbor *n)
|
||||||
{
|
{
|
||||||
struct ospf_dbdes_packet *pkt;
|
struct ospf_dbdes_packet *pkt;
|
||||||
struct ospf_packet *op;
|
struct ospf_packet *op;
|
||||||
struct ospf_iface *ifa=n->ifa;
|
struct ospf_iface *ifa = n->ifa;
|
||||||
struct ospf_area *oa=ifa->oa;
|
struct ospf_area *oa = ifa->oa;
|
||||||
u16 length;
|
u16 length;
|
||||||
struct proto *p;
|
struct proto *p = (struct proto *) (ifa->proto);
|
||||||
u16 i,j;
|
u16 i, j;
|
||||||
u8 *aa,*bb;
|
u8 *aa, *bb;
|
||||||
|
|
||||||
if((oa->rt==NULL)||(EMPTY_LIST(oa->lsal))) originate_rt_lsa(oa);
|
if ((oa->rt == NULL) || (EMPTY_LIST(oa->lsal)))
|
||||||
|
originate_rt_lsa(oa);
|
||||||
|
|
||||||
p=(struct proto *)(ifa->proto);
|
switch (n->state)
|
||||||
|
|
||||||
switch(n->state)
|
|
||||||
{
|
{
|
||||||
case NEIGHBOR_EXSTART: /* Send empty packets */
|
case NEIGHBOR_EXSTART: /* Send empty packets */
|
||||||
n->myimms.bit.i=1;
|
n->myimms.bit.i = 1;
|
||||||
pkt=(struct ospf_dbdes_packet *)(ifa->ip_sk->tbuf);
|
pkt = (struct ospf_dbdes_packet *) (ifa->ip_sk->tbuf);
|
||||||
op=(struct ospf_packet *)pkt;
|
op = (struct ospf_packet *) pkt;
|
||||||
|
fill_ospf_pkt_hdr(ifa, pkt, DBDES_P);
|
||||||
|
pkt->iface_mtu = htons(ifa->iface->mtu); /* FIXME NOT for VLINK! */
|
||||||
|
pkt->options = ifa->options;
|
||||||
|
pkt->imms = n->myimms;
|
||||||
|
pkt->ddseq = htonl(n->dds);
|
||||||
|
length = sizeof(struct ospf_dbdes_packet);
|
||||||
|
op->length = htons(length);
|
||||||
|
ospf_pkt_finalize(ifa, op);
|
||||||
|
sk_send_to(ifa->ip_sk, length, n->ip, OSPF_PROTO);
|
||||||
|
OSPF_TRACE(D_PACKETS, "DB_DES (I) sent to %I via %s.", n->ip,
|
||||||
|
ifa->iface->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NEIGHBOR_EXCHANGE:
|
||||||
|
n->myimms.bit.i = 0;
|
||||||
|
|
||||||
|
if (((n->myimms.bit.ms) && (n->dds == n->ddr + 1)) ||
|
||||||
|
((!(n->myimms.bit.ms)) && (n->dds == n->ddr)))
|
||||||
|
{
|
||||||
|
snode *sn; /* Send next */
|
||||||
|
struct ospf_lsa_header *lsa;
|
||||||
|
|
||||||
|
pkt = n->ldbdes;
|
||||||
|
op = (struct ospf_packet *) pkt;
|
||||||
|
|
||||||
fill_ospf_pkt_hdr(ifa, pkt, DBDES_P);
|
fill_ospf_pkt_hdr(ifa, pkt, DBDES_P);
|
||||||
pkt->iface_mtu=htons(ifa->iface->mtu); /* FIXME NOT for VLINK! */
|
pkt->iface_mtu = htons(ifa->iface->mtu);
|
||||||
pkt->options= ifa->options;
|
pkt->options = ifa->options;
|
||||||
pkt->imms=n->myimms;
|
pkt->ddseq = htonl(n->dds);
|
||||||
pkt->ddseq=htonl(n->dds);
|
|
||||||
length=sizeof(struct ospf_dbdes_packet);
|
j = i = (ifa->iface->mtu - sizeof(struct ospf_dbdes_packet) - SIPH) / sizeof(struct ospf_lsa_header); /* Number of possible lsaheaders to send */
|
||||||
op->length=htons(length);
|
lsa = (n->ldbdes + sizeof(struct ospf_dbdes_packet));
|
||||||
|
|
||||||
|
if (n->myimms.bit.m)
|
||||||
|
{
|
||||||
|
sn = s_get(&(n->dbsi));
|
||||||
|
|
||||||
|
DBG("Number of LSA: %d\n", j);
|
||||||
|
for (; i > 0; i--)
|
||||||
|
{
|
||||||
|
struct top_hash_entry *en;
|
||||||
|
|
||||||
|
en = (struct top_hash_entry *) sn;
|
||||||
|
htonlsah(&(en->lsa), lsa);
|
||||||
|
DBG("Working on: %d\n", i);
|
||||||
|
DBG("\tX%01x %-1I %-1I %p\n", en->lsa.type, en->lsa.id,
|
||||||
|
en->lsa.rt, en->lsa_body);
|
||||||
|
|
||||||
|
if (sn == STAIL(n->ifa->oa->lsal))
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
break; /* Should set some flag? */
|
||||||
|
}
|
||||||
|
sn = sn->next;
|
||||||
|
lsa++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sn == STAIL(n->ifa->oa->lsal))
|
||||||
|
{
|
||||||
|
DBG("Number of LSA NOT sent: %d\n", i);
|
||||||
|
DBG("M bit unset.\n");
|
||||||
|
n->myimms.bit.m = 0; /* Unset more bit */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
s_put(&(n->dbsi), sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
pkt->imms.byte = n->myimms.byte;
|
||||||
|
|
||||||
|
length = (j - i) * sizeof(struct ospf_lsa_header) +
|
||||||
|
sizeof(struct ospf_dbdes_packet);
|
||||||
|
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);
|
DBG("%s: DB_DES (M) prepared for %I.\n", p->name, n->ip);
|
||||||
OSPF_TRACE(D_PACKETS, "DB_DES (I) sent to %I via %s.", n->ip,
|
}
|
||||||
ifa->iface->name);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NEIGHBOR_EXCHANGE:
|
case NEIGHBOR_LOADING:
|
||||||
n->myimms.bit.i=0;
|
case NEIGHBOR_FULL:
|
||||||
|
aa = ifa->ip_sk->tbuf;
|
||||||
|
bb = n->ldbdes;
|
||||||
|
op = n->ldbdes;
|
||||||
|
length = ntohs(op->length);
|
||||||
|
|
||||||
if(((n->myimms.bit.ms) && (n->dds==n->ddr+1)) ||
|
for (i = 0; i < length; i++)
|
||||||
((!(n->myimms.bit.ms)) && (n->dds==n->ddr)))
|
{
|
||||||
|
*(aa + i) = *(bb + i); /* Copy last sent packet again */
|
||||||
|
}
|
||||||
|
|
||||||
|
sk_send_to(ifa->ip_sk, length, n->ip, OSPF_PROTO);
|
||||||
|
OSPF_TRACE(D_PACKETS, "DB_DES (M) sent to %I via %s.", n->ip,
|
||||||
|
ifa->iface->name);
|
||||||
|
if (!n->myimms.bit.ms)
|
||||||
|
{
|
||||||
|
if ((n->myimms.bit.m == 0) && (n->imms.bit.m == 0) &&
|
||||||
|
(n->state == NEIGHBOR_EXCHANGE))
|
||||||
{
|
{
|
||||||
snode *sn; /* Send next */
|
ospf_neigh_sm(n, INM_EXDONE);
|
||||||
struct ospf_lsa_header *lsa;
|
|
||||||
|
|
||||||
pkt=n->ldbdes;
|
|
||||||
op=(struct ospf_packet *)pkt;
|
|
||||||
|
|
||||||
fill_ospf_pkt_hdr(ifa, pkt, DBDES_P);
|
|
||||||
pkt->iface_mtu=htons(ifa->iface->mtu);
|
|
||||||
pkt->options= ifa->options;
|
|
||||||
pkt->ddseq=htonl(n->dds);
|
|
||||||
|
|
||||||
j=i=(ifa->iface->mtu-sizeof(struct ospf_dbdes_packet)-SIPH)/
|
|
||||||
sizeof(struct ospf_lsa_header); /* Number of possible lsaheaders to send */
|
|
||||||
lsa=(n->ldbdes+sizeof(struct ospf_dbdes_packet));
|
|
||||||
|
|
||||||
if(n->myimms.bit.m)
|
|
||||||
{
|
|
||||||
sn=s_get(&(n->dbsi));
|
|
||||||
|
|
||||||
DBG("Number of LSA: %d\n", j);
|
|
||||||
for(;i>0;i--)
|
|
||||||
{
|
|
||||||
struct top_hash_entry *en;
|
|
||||||
|
|
||||||
en=(struct top_hash_entry *)sn;
|
|
||||||
htonlsah(&(en->lsa), lsa);
|
|
||||||
DBG("Working on: %d\n", i);
|
|
||||||
DBG("\tX%01x %-1I %-1I %p\n", en->lsa.type, en->lsa.id,
|
|
||||||
en->lsa.rt, en->lsa_body);
|
|
||||||
|
|
||||||
if(sn==STAIL(n->ifa->oa->lsal))
|
|
||||||
{
|
|
||||||
i--;
|
|
||||||
break; /* Should set some flag? */
|
|
||||||
}
|
|
||||||
sn=sn->next;
|
|
||||||
lsa++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sn==STAIL(n->ifa->oa->lsal))
|
|
||||||
{
|
|
||||||
DBG("Number of LSA NOT sent: %d\n", i);
|
|
||||||
DBG("M bit unset.\n");
|
|
||||||
n->myimms.bit.m=0; /* Unset more bit */
|
|
||||||
}
|
|
||||||
else s_put(&(n->dbsi),sn);
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt->imms.byte=n->myimms.byte;
|
|
||||||
|
|
||||||
length=(j-i)*sizeof(struct ospf_lsa_header)+
|
|
||||||
sizeof(struct ospf_dbdes_packet);
|
|
||||||
op->length=htons(length);
|
|
||||||
|
|
||||||
ospf_pkt_finalize(ifa, op);
|
|
||||||
DBG("%s: DB_DES (M) prepared for %I.\n", p->name, n->ip);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case NEIGHBOR_LOADING:
|
default: /* Ignore it */
|
||||||
case NEIGHBOR_FULL:
|
break;
|
||||||
aa=ifa->ip_sk->tbuf;
|
|
||||||
bb=n->ldbdes;
|
|
||||||
op=n->ldbdes;
|
|
||||||
length=ntohs(op->length);
|
|
||||||
|
|
||||||
for(i=0; i<length; i++)
|
|
||||||
{
|
|
||||||
*(aa+i)=*(bb+i); /* Copy last sent packet again */
|
|
||||||
}
|
|
||||||
|
|
||||||
sk_send_to(ifa->ip_sk,length, n->ip, OSPF_PROTO);
|
|
||||||
OSPF_TRACE(D_PACKETS, "DB_DES (M) sent to %I via %s.", n->ip,
|
|
||||||
ifa->iface->name);
|
|
||||||
if(! n->myimms.bit.ms)
|
|
||||||
{
|
|
||||||
if((n->myimms.bit.m==0) && (n->imms.bit.m==0) &&
|
|
||||||
(n->state==NEIGHBOR_EXCHANGE))
|
|
||||||
{
|
|
||||||
ospf_neigh_sm(n, INM_EXDONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: /* Ignore it */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_dbdes_reqladd(struct ospf_dbdes_packet *ps, struct proto *p,
|
ospf_dbdes_reqladd(struct ospf_dbdes_packet *ps, struct ospf_neighbor *n)
|
||||||
struct ospf_neighbor *n)
|
|
||||||
{
|
{
|
||||||
struct ospf_lsa_header *plsa,lsa;
|
struct ospf_lsa_header *plsa, lsa;
|
||||||
struct top_hash_entry *he,*sn;
|
struct top_hash_entry *he, *sn;
|
||||||
struct top_graph *gr;
|
struct top_graph *gr = n->ifa->oa->gr;
|
||||||
struct ospf_packet *op;
|
struct ospf_packet *op;
|
||||||
int i,j;
|
struct proto *p = (struct proto *) n->ifa->proto;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
gr=n->ifa->oa->gr;
|
op = (struct ospf_packet *) ps;
|
||||||
op=(struct ospf_packet *)ps;
|
|
||||||
|
|
||||||
plsa=(void *)(ps+1);
|
plsa = (void *) (ps + 1);
|
||||||
|
|
||||||
j=(ntohs(op->length)-sizeof(struct ospf_dbdes_packet))/
|
j = (ntohs(op->length) - sizeof(struct ospf_dbdes_packet)) /
|
||||||
sizeof( struct ospf_lsa_header);
|
sizeof(struct ospf_lsa_header);
|
||||||
|
|
||||||
for(i=0;i<j;i++)
|
for (i = 0; i < j; i++)
|
||||||
{
|
{
|
||||||
ntohlsah(plsa+i, &lsa);
|
ntohlsah(plsa + i, &lsa);
|
||||||
if(((he=ospf_hash_find(gr,lsa.id,lsa.rt,lsa.type))==NULL)||
|
if (((he = ospf_hash_find(gr, lsa.id, lsa.rt, lsa.type)) == NULL) ||
|
||||||
(lsa_comp(&lsa, &(he->lsa))==1))
|
(lsa_comp(&lsa, &(he->lsa)) == 1))
|
||||||
{
|
{
|
||||||
/* Is this condition necessary? */
|
/* Is this condition necessary? */
|
||||||
if(ospf_hash_find(n->lsrqh,lsa.id,lsa.rt,lsa.type)==NULL)
|
if (ospf_hash_find(n->lsrqh, lsa.id, lsa.rt, lsa.type) == NULL)
|
||||||
{
|
{
|
||||||
sn=ospf_hash_get(n->lsrqh,lsa.id,lsa.rt,lsa.type);
|
sn = ospf_hash_get(n->lsrqh, lsa.id, lsa.rt, lsa.type);
|
||||||
ntohlsah(plsa+i, &(sn->lsa));
|
ntohlsah(plsa + i, &(sn->lsa));
|
||||||
s_add_tail(&(n->lsrql), SNODE sn);
|
s_add_tail(&(n->lsrql), SNODE sn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
|
ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
|
||||||
struct ospf_iface *ifa, u16 size)
|
struct ospf_iface *ifa, u16 size)
|
||||||
{
|
{
|
||||||
u32 nrid, myrid;
|
struct proto *p = (struct proto *) ifa->proto;
|
||||||
|
u32 nrid, myrid = p->cf->global->router_id;
|
||||||
struct ospf_neighbor *n;
|
struct ospf_neighbor *n;
|
||||||
|
|
||||||
nrid=ntohl(((struct ospf_packet *)ps)->routerid);
|
nrid = ntohl(((struct ospf_packet *) ps)->routerid);
|
||||||
|
|
||||||
myrid=p->cf->global->router_id;
|
|
||||||
|
|
||||||
if((n=find_neigh(ifa, nrid))==NULL)
|
if ((n = find_neigh(ifa, nrid)) == NULL)
|
||||||
{
|
{
|
||||||
OSPF_TRACE(D_PACKETS, "Received dbdes from unknown neigbor! %I.",
|
OSPF_TRACE(D_PACKETS, "Received dbdes from unknown neigbor! %I.", nrid);
|
||||||
nrid);
|
return;
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ifa->iface->mtu<size)
|
if (ifa->iface->mtu < size)
|
||||||
{
|
{
|
||||||
OSPF_TRACE(D_PACKETS, "Received dbdes larger than MTU from %I!", n->ip);
|
OSPF_TRACE(D_PACKETS, "Received dbdes larger than MTU from %I!", n->ip);
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSPF_TRACE(D_PACKETS, "Received dbdes from %I via %s.", n->ip,
|
OSPF_TRACE(D_PACKETS, "Received dbdes from %I via %s.", n->ip,
|
||||||
ifa->iface->name);
|
ifa->iface->name);
|
||||||
ospf_neigh_sm(n, INM_HELLOREC);
|
ospf_neigh_sm(n, INM_HELLOREC);
|
||||||
|
|
||||||
switch(n->state)
|
switch (n->state)
|
||||||
{
|
{
|
||||||
case NEIGHBOR_DOWN:
|
case NEIGHBOR_DOWN:
|
||||||
case NEIGHBOR_ATTEMPT:
|
case NEIGHBOR_ATTEMPT:
|
||||||
case NEIGHBOR_2WAY:
|
case NEIGHBOR_2WAY:
|
||||||
return;
|
return;
|
||||||
|
break;
|
||||||
|
case NEIGHBOR_INIT:
|
||||||
|
ospf_neigh_sm(n, INM_2WAYREC);
|
||||||
|
if (n->state != NEIGHBOR_EXSTART)
|
||||||
|
return;
|
||||||
|
case NEIGHBOR_EXSTART:
|
||||||
|
if ((ps->imms.bit.m && ps->imms.bit.ms && ps->imms.bit.i)
|
||||||
|
&& (n->rid > myrid) && (size == sizeof(struct ospf_dbdes_packet)))
|
||||||
|
{
|
||||||
|
/* I'm slave! */
|
||||||
|
n->dds = ntohl(ps->ddseq);
|
||||||
|
n->ddr = ntohl(ps->ddseq);
|
||||||
|
n->options = ps->options;
|
||||||
|
n->myimms.bit.ms = 0;
|
||||||
|
n->imms.byte = ps->imms.byte;
|
||||||
|
OSPF_TRACE(D_PACKETS, "I'm slave to %I.", n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_NEGDONE);
|
||||||
|
ospf_dbdes_send(n);
|
||||||
break;
|
break;
|
||||||
case NEIGHBOR_INIT:
|
}
|
||||||
ospf_neigh_sm(n, INM_2WAYREC);
|
else
|
||||||
if(n->state!=NEIGHBOR_EXSTART) return;
|
{
|
||||||
case NEIGHBOR_EXSTART:
|
if (((ps->imms.bit.i == 0) && (ps->imms.bit.ms == 0)) &&
|
||||||
if((ps->imms.bit.m && ps->imms.bit.ms && ps->imms.bit.i)
|
(n->rid < myrid) && (n->dds == ntohl(ps->ddseq)))
|
||||||
&& (n->rid > myrid) &&
|
{
|
||||||
(size == sizeof(struct ospf_dbdes_packet)))
|
/* I'm master! */
|
||||||
{
|
n->options = ps->options;
|
||||||
/* I'm slave! */
|
n->ddr = ntohl(ps->ddseq) - 1;
|
||||||
n->dds=ntohl(ps->ddseq);
|
n->imms.byte = ps->imms.byte;
|
||||||
n->ddr=ntohl(ps->ddseq);
|
OSPF_TRACE(D_PACKETS, "I'm master to %I.", n->ip);
|
||||||
n->options=ps->options;
|
ospf_neigh_sm(n, INM_NEGDONE);
|
||||||
n->myimms.bit.ms=0;
|
}
|
||||||
n->imms.byte=ps->imms.byte;
|
else
|
||||||
OSPF_TRACE(D_PACKETS, "I'm slave to %I.", n->ip);
|
{
|
||||||
ospf_neigh_sm(n, INM_NEGDONE);
|
DBG("%s: Nothing happend to %I (imms=%u)\n", p->name, n->ip,
|
||||||
ospf_dbdes_tx(n);
|
ps->imms.byte);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
if (ps->imms.bit.i)
|
||||||
if(((ps->imms.bit.i==0) && (ps->imms.bit.ms==0)) &&
|
|
||||||
(n->rid < myrid) && (n->dds == ntohl(ps->ddseq)))
|
|
||||||
{
|
|
||||||
/* I'm master! */
|
|
||||||
n->options=ps->options;
|
|
||||||
n->ddr=ntohl(ps->ddseq)-1;
|
|
||||||
n->imms.byte=ps->imms.byte;
|
|
||||||
OSPF_TRACE(D_PACKETS, "I'm master to %I.", n->ip);
|
|
||||||
ospf_neigh_sm(n, INM_NEGDONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DBG("%s: Nothing happend to %I (imms=%u)\n", p->name, n->ip,
|
|
||||||
ps->imms.byte);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ps->imms.bit.i) break;
|
|
||||||
case NEIGHBOR_EXCHANGE:
|
|
||||||
if((ps->imms.byte==n->imms.byte) && (ps->options==n->options) &&
|
|
||||||
(ntohl(ps->ddseq)==n->ddr))
|
|
||||||
{
|
|
||||||
/* Duplicate packet */
|
|
||||||
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip);
|
|
||||||
if(n->imms.bit.ms==0)
|
|
||||||
{
|
|
||||||
ospf_dbdes_tx(n);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
n->ddr=ntohl(ps->ddseq);
|
|
||||||
|
|
||||||
if(ps->imms.bit.ms!=n->imms.bit.ms) /* M/S bit differs */
|
|
||||||
{
|
|
||||||
log("SEQMIS-BIT-MS\n");
|
|
||||||
ospf_neigh_sm(n, INM_SEQMIS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ps->imms.bit.i) /* I bit is set */
|
|
||||||
{
|
|
||||||
log("SEQMIS-BIT-I\n");
|
|
||||||
ospf_neigh_sm(n, INM_SEQMIS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
n->imms.byte=ps->imms.byte;
|
|
||||||
|
|
||||||
if(ps->options!=n->options) /* Options differs */
|
|
||||||
{
|
|
||||||
log("SEQMIS-OPT\n");
|
|
||||||
ospf_neigh_sm(n, INM_SEQMIS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(n->myimms.bit.ms)
|
|
||||||
{
|
|
||||||
if(ntohl(ps->ddseq)!=n->dds) /* MASTER */
|
|
||||||
{
|
|
||||||
log("SEQMIS-MASTER\n");
|
|
||||||
ospf_neigh_sm(n, INM_SEQMIS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
n->dds++;
|
|
||||||
DBG("Incrementing dds\n");
|
|
||||||
ospf_dbdes_reqladd(ps,p,n);
|
|
||||||
if((n->myimms.bit.m==0) && (ps->imms.bit.m==0))
|
|
||||||
{
|
|
||||||
ospf_neigh_sm(n, INM_EXDONE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ospf_dbdes_tx(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(ntohl(ps->ddseq)!=(n->dds+1)) /* SLAVE */
|
|
||||||
{
|
|
||||||
log("SEQMIS-SLAVE\n");
|
|
||||||
ospf_neigh_sm(n, INM_SEQMIS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
n->ddr=ntohl(ps->ddseq);
|
|
||||||
n->dds=ntohl(ps->ddseq);
|
|
||||||
ospf_dbdes_reqladd(ps,p,n);
|
|
||||||
ospf_dbdes_tx(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NEIGHBOR_LOADING:
|
case NEIGHBOR_EXCHANGE:
|
||||||
case NEIGHBOR_FULL:
|
if ((ps->imms.byte == n->imms.byte) && (ps->options == n->options) &&
|
||||||
if((ps->imms.byte==n->imms.byte) && (ps->options==n->options) &&
|
(ntohl(ps->ddseq) == n->ddr))
|
||||||
(ntohl(ps->ddseq)==n->ddr)) /* Only duplicate are accepted */
|
{
|
||||||
{
|
/* Duplicate packet */
|
||||||
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.",n->ip);
|
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip);
|
||||||
return;
|
if (n->imms.bit.ms == 0)
|
||||||
}
|
{
|
||||||
else
|
ospf_dbdes_send(n);
|
||||||
{
|
}
|
||||||
log("SEQMIS-FULL\n");
|
return;
|
||||||
ospf_neigh_sm(n, INM_SEQMIS);
|
}
|
||||||
}
|
|
||||||
|
n->ddr = ntohl(ps->ddseq);
|
||||||
|
|
||||||
|
if (ps->imms.bit.ms != n->imms.bit.ms) /* M/S bit differs */
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (bit MS)",
|
||||||
|
n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_SEQMIS);
|
||||||
break;
|
break;
|
||||||
defaut:
|
}
|
||||||
bug("%s: Received dbdes from %I in undefined state.", p->name, n->ip);
|
|
||||||
|
if (ps->imms.bit.i) /* I bit is set */
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (bit I)",
|
||||||
|
n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_SEQMIS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n->imms.byte = ps->imms.byte;
|
||||||
|
|
||||||
|
if (ps->options != n->options) /* Options differs */
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (options)",
|
||||||
|
n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_SEQMIS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n->myimms.bit.ms)
|
||||||
|
{
|
||||||
|
if (ntohl(ps->ddseq) != n->dds) /* MASTER */
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS,
|
||||||
|
"dbdes - sequence mismatch neighbor %I (master)", n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_SEQMIS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
n->dds++;
|
||||||
|
DBG("Incrementing dds\n");
|
||||||
|
ospf_dbdes_reqladd(ps, n);
|
||||||
|
if ((n->myimms.bit.m == 0) && (ps->imms.bit.m == 0))
|
||||||
|
{
|
||||||
|
ospf_neigh_sm(n, INM_EXDONE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ospf_dbdes_send(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ntohl(ps->ddseq) != (n->dds + 1)) /* SLAVE */
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (slave)",
|
||||||
|
n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_SEQMIS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
n->ddr = ntohl(ps->ddseq);
|
||||||
|
n->dds = ntohl(ps->ddseq);
|
||||||
|
ospf_dbdes_reqladd(ps, n);
|
||||||
|
ospf_dbdes_send(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NEIGHBOR_LOADING:
|
||||||
|
case NEIGHBOR_FULL:
|
||||||
|
if ((ps->imms.byte == n->imms.byte) && (ps->options == n->options)
|
||||||
|
&& (ntohl(ps->ddseq) == n->ddr))
|
||||||
|
/* Only duplicate are accepted */
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (full)",
|
||||||
|
n->ip);
|
||||||
|
ospf_neigh_sm(n, INM_SEQMIS);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
defaut:
|
||||||
|
bug("Received dbdes from %I in undefined state.", n->ip);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
* (c) 1999 - 2004 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*
|
*
|
||||||
|
@ -10,9 +10,8 @@
|
||||||
#ifndef _BIRD_OSPF_DBDES_H_
|
#ifndef _BIRD_OSPF_DBDES_H_
|
||||||
#define _BIRD_OSPF_DBDES_H_
|
#define _BIRD_OSPF_DBDES_H_
|
||||||
|
|
||||||
void ospf_dbdes_tx(struct ospf_neighbor *n);
|
void ospf_dbdes_send(struct ospf_neighbor *n);
|
||||||
void ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
|
void ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
|
||||||
struct ospf_iface *ifa, u16 size);
|
struct ospf_iface *ifa, u16 size);
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_DBDES_H_ */
|
#endif /* _BIRD_OSPF_DBDES_H_ */
|
||||||
|
|
||||||
|
|
|
@ -577,7 +577,7 @@ rxmt_timer_hook(timer *timer)
|
||||||
|
|
||||||
DBG("%s: RXMT timer fired on interface %s for neigh: %I.\n",
|
DBG("%s: RXMT timer fired on interface %s for neigh: %I.\n",
|
||||||
p->name, ifa->iface->name, n->ip);
|
p->name, ifa->iface->name, n->ip);
|
||||||
if (n->state < NEIGHBOR_LOADING) ospf_dbdes_tx(n);
|
if (n->state < NEIGHBOR_LOADING) ospf_dbdes_send(n);
|
||||||
|
|
||||||
if(n->state < NEIGHBOR_FULL) ospf_lsreq_send(n);
|
if(n->state < NEIGHBOR_FULL) ospf_lsreq_send(n);
|
||||||
else
|
else
|
||||||
|
|
|
@ -80,7 +80,7 @@ ospf_pkt_finalize (struct ospf_iface *ifa, struct ospf_packet *pkt)
|
||||||
* non generic functions.
|
* non generic functions.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ospf_rx_hook (sock * sk, int size)
|
ospf_rx_hook (sock *sk, int size)
|
||||||
{
|
{
|
||||||
#ifndef IPV6
|
#ifndef IPV6
|
||||||
struct ospf_packet *ps;
|
struct ospf_packet *ps;
|
||||||
|
@ -180,7 +180,7 @@ ospf_rx_hook (sock * sk, int size)
|
||||||
break;
|
break;
|
||||||
case DBDES_P:
|
case DBDES_P:
|
||||||
DBG ("%s: Database description received.\n", p->name);
|
DBG ("%s: Database description received.\n", p->name);
|
||||||
ospf_dbdes_rx ((struct ospf_dbdes_packet *) ps, p, ifa, size);
|
ospf_dbdes_receive ((struct ospf_dbdes_packet *) ps, ifa, size);
|
||||||
break;
|
break;
|
||||||
case LSREQ_P:
|
case LSREQ_P:
|
||||||
DBG ("%s: Link state request received.\n", p->name);
|
DBG ("%s: Link state request received.\n", p->name);
|
||||||
|
|
Loading…
Reference in a new issue