1999-11-17 23:50:41 +08:00
|
|
|
/*
|
|
|
|
* BIRD -- OSPF
|
|
|
|
*
|
2004-06-05 02:24:15 +08:00
|
|
|
* (c) 1999--2004 Ondrej Filip <feela@network.cz>
|
1999-11-17 23:50:41 +08:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ospf.h"
|
|
|
|
|
2009-04-06 22:17:47 +08:00
|
|
|
|
|
|
|
static void ospf_dump_dbdes(struct proto *p, struct ospf_dbdes_packet *pkt)
|
|
|
|
{
|
|
|
|
struct ospf_packet *op = &pkt->ospf_packet;
|
|
|
|
|
|
|
|
ASSERT(op->type == DBDES_P);
|
|
|
|
ospf_dump_common(p, op);
|
|
|
|
log(L_TRACE "%s: imms %s%s%s",
|
|
|
|
p->name, pkt->imms.bit.ms ? "MS " : "",
|
|
|
|
pkt->imms.bit.m ? "M " : "",
|
|
|
|
pkt->imms.bit.i ? "I " : "" );
|
|
|
|
log(L_TRACE "%s: ddseq %u", p->name, ntohl(pkt->ddseq));
|
|
|
|
|
|
|
|
struct ospf_lsa_header *plsa = (void *) (pkt + 1);
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
j = (ntohs(op->length) - sizeof(struct ospf_dbdes_packet)) /
|
|
|
|
sizeof(struct ospf_lsa_header);
|
|
|
|
|
|
|
|
for (i = 0; i < j; i++)
|
|
|
|
ospf_dump_lsahdr(p, plsa + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-08 06:53:51 +08:00
|
|
|
/**
|
2004-06-05 01:49:25 +08:00
|
|
|
* ospf_dbdes_send - transmit database description packet
|
2000-06-08 06:53:51 +08:00
|
|
|
* @n: neighbor
|
2009-04-06 22:53:06 +08:00
|
|
|
* @next: whether to send a next packet in a sequence (1) or to retransmit the old one (0)
|
2000-06-08 06:53:51 +08:00
|
|
|
*
|
2003-08-23 18:42:41 +08:00
|
|
|
* Sending of a database description packet is described in 10.6 of RFC 2328.
|
|
|
|
* Reception of each packet is acknowledged in the sequence number of another.
|
|
|
|
* When I send a packet to a neighbor I keep a copy in a buffer. If the neighbor
|
|
|
|
* does not reply, I don't create a new packet but just send the content
|
|
|
|
* of the buffer.
|
2000-06-08 06:53:51 +08:00
|
|
|
*/
|
1999-11-17 23:50:41 +08:00
|
|
|
void
|
2009-04-06 22:53:06 +08:00
|
|
|
ospf_dbdes_send(struct ospf_neighbor *n, int next)
|
1999-11-17 23:50:41 +08:00
|
|
|
{
|
|
|
|
struct ospf_dbdes_packet *pkt;
|
|
|
|
struct ospf_packet *op;
|
2004-06-05 01:49:25 +08:00
|
|
|
struct ospf_iface *ifa = n->ifa;
|
|
|
|
struct ospf_area *oa = ifa->oa;
|
2004-07-16 00:37:52 +08:00
|
|
|
struct proto_ospf *po = oa->po;
|
|
|
|
struct proto *p = &po->proto;
|
|
|
|
u16 length, i, j;
|
1999-11-17 23:50:41 +08:00
|
|
|
|
2004-07-16 00:37:52 +08:00
|
|
|
if ((oa->rt == NULL) || (EMPTY_LIST(po->lsal)))
|
2004-06-05 01:49:25 +08:00
|
|
|
originate_rt_lsa(oa);
|
2000-06-09 03:02:31 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
switch (n->state)
|
1999-11-17 23:50:41 +08:00
|
|
|
{
|
2004-06-05 01:49:25 +08:00
|
|
|
case NEIGHBOR_EXSTART: /* Send empty packets */
|
|
|
|
n->myimms.bit.i = 1;
|
|
|
|
pkt = (struct ospf_dbdes_packet *) (ifa->ip_sk->tbuf);
|
|
|
|
op = (struct ospf_packet *) pkt;
|
2004-06-27 04:15:34 +08:00
|
|
|
ospf_pkt_fill_hdr(ifa, pkt, DBDES_P);
|
2004-06-26 00:39:53 +08:00
|
|
|
pkt->iface_mtu = htons(ifa->iface->mtu);
|
2004-07-16 00:37:52 +08:00
|
|
|
pkt->options = oa->opt.byte;
|
2004-06-05 01:49:25 +08:00
|
|
|
pkt->imms = n->myimms;
|
|
|
|
pkt->ddseq = htonl(n->dds);
|
|
|
|
length = sizeof(struct ospf_dbdes_packet);
|
|
|
|
op->length = htons(length);
|
2009-04-06 22:17:47 +08:00
|
|
|
|
|
|
|
OSPF_PACKET(ospf_dump_dbdes, pkt, "DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
|
2004-06-27 04:15:34 +08:00
|
|
|
ospf_send_to(ifa->ip_sk, n->ip, ifa);
|
2004-06-05 01:49:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEIGHBOR_EXCHANGE:
|
|
|
|
n->myimms.bit.i = 0;
|
|
|
|
|
2009-04-06 22:53:06 +08:00
|
|
|
if (next)
|
2004-06-05 01:49:25 +08:00
|
|
|
{
|
2009-04-06 22:53:06 +08:00
|
|
|
snode *sn;
|
2004-06-05 01:49:25 +08:00
|
|
|
struct ospf_lsa_header *lsa;
|
|
|
|
|
|
|
|
pkt = n->ldbdes;
|
|
|
|
op = (struct ospf_packet *) pkt;
|
|
|
|
|
2004-06-27 04:15:34 +08:00
|
|
|
ospf_pkt_fill_hdr(ifa, pkt, DBDES_P);
|
2004-06-05 01:49:25 +08:00
|
|
|
pkt->iface_mtu = htons(ifa->iface->mtu);
|
2004-07-16 00:37:52 +08:00
|
|
|
pkt->options = oa->opt.byte;
|
2004-06-05 01:49:25 +08:00
|
|
|
pkt->ddseq = htonl(n->dds);
|
2000-03-08 20:50:28 +08:00
|
|
|
|
2004-06-27 04:15:34 +08:00
|
|
|
j = i = (ospf_pkt_maxsize(ifa) - sizeof(struct ospf_dbdes_packet)) / sizeof(struct ospf_lsa_header); /* Number of possible lsaheaders to send */
|
2004-06-05 01:49:25 +08:00
|
|
|
lsa = (n->ldbdes + sizeof(struct ospf_dbdes_packet));
|
2004-05-31 21:22:49 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
if (n->myimms.bit.m)
|
2000-03-08 20:50:28 +08:00
|
|
|
{
|
2004-06-05 01:49:25 +08:00
|
|
|
sn = s_get(&(n->dbsi));
|
|
|
|
|
|
|
|
DBG("Number of LSA: %d\n", j);
|
|
|
|
for (; i > 0; i--)
|
2000-03-30 01:18:06 +08:00
|
|
|
{
|
2004-07-16 00:37:52 +08:00
|
|
|
struct top_hash_entry *en= (struct top_hash_entry *) sn;
|
|
|
|
int send = 1;
|
2004-06-26 00:39:53 +08:00
|
|
|
|
2004-07-16 00:37:52 +08:00
|
|
|
/* Don't send ext LSA into stub areas */
|
|
|
|
if (oa->stub && (en->lsa.type == LSA_T_EXT)) send = 0;
|
|
|
|
/* Don't send ext LSAs through VLINK */
|
|
|
|
if ((ifa->type == OSPF_IT_VLINK) && (en->lsa.type == LSA_T_EXT)) send = 0;;
|
|
|
|
/* Don't send LSA of other areas */
|
|
|
|
if ((en->lsa.type != LSA_T_EXT) && (en->oa != oa)) send = 0;
|
|
|
|
|
|
|
|
if (send)
|
2004-06-26 00:39:53 +08:00
|
|
|
{
|
|
|
|
htonlsah(&(en->lsa), lsa);
|
|
|
|
DBG("Working on: %d\n", i);
|
2009-07-06 03:18:55 +08:00
|
|
|
DBG("\tX%01x %-1I %-1I %p\n", en->lsa.type, ipa_from_u32(en->lsa.id),
|
|
|
|
ipa_from_u32(en->lsa.rt), en->lsa_body);
|
2004-06-26 00:39:53 +08:00
|
|
|
|
|
|
|
lsa++;
|
|
|
|
}
|
|
|
|
else i++; /* No lsa added */
|
2000-03-29 08:34:28 +08:00
|
|
|
|
2004-07-16 00:37:52 +08:00
|
|
|
if (sn == STAIL(po->lsal))
|
2004-06-26 00:39:53 +08:00
|
|
|
{
|
|
|
|
i--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
sn = sn->next;
|
2000-03-30 01:18:06 +08:00
|
|
|
}
|
2000-03-29 08:34:28 +08:00
|
|
|
|
2004-07-16 00:37:52 +08:00
|
|
|
if (sn == STAIL(po->lsal))
|
2004-06-05 01:49:25 +08:00
|
|
|
{
|
|
|
|
DBG("Number of LSA NOT sent: %d\n", i);
|
|
|
|
DBG("M bit unset.\n");
|
|
|
|
n->myimms.bit.m = 0; /* Unset more bit */
|
|
|
|
}
|
2009-01-14 02:15:49 +08:00
|
|
|
|
|
|
|
s_put(&(n->dbsi), sn);
|
2000-03-08 20:50:28 +08:00
|
|
|
}
|
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
pkt->imms.byte = n->myimms.byte;
|
2000-03-08 20:50:28 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
length = (j - i) * sizeof(struct ospf_lsa_header) +
|
|
|
|
sizeof(struct ospf_dbdes_packet);
|
|
|
|
op->length = htons(length);
|
|
|
|
|
|
|
|
DBG("%s: DB_DES (M) prepared for %I.\n", p->name, n->ip);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NEIGHBOR_LOADING:
|
|
|
|
case NEIGHBOR_FULL:
|
2004-06-06 17:37:54 +08:00
|
|
|
length = ntohs(((struct ospf_packet *) n->ldbdes)->length);
|
2004-06-05 01:49:25 +08:00
|
|
|
|
2004-06-06 17:37:54 +08:00
|
|
|
if (!length)
|
2004-06-05 02:51:29 +08:00
|
|
|
{
|
|
|
|
OSPF_TRACE(D_PACKETS, "No packet in my buffer for repeating");
|
|
|
|
ospf_neigh_sm(n, INM_KILLNBR);
|
2004-06-05 03:21:19 +08:00
|
|
|
return;
|
2004-06-05 02:51:29 +08:00
|
|
|
}
|
|
|
|
|
2004-06-06 17:37:54 +08:00
|
|
|
/* Copy last sent packet again */
|
2009-04-06 22:17:47 +08:00
|
|
|
memcpy(ifa->ip_sk->tbuf, n->ldbdes, length);
|
2000-03-29 20:32:25 +08:00
|
|
|
|
2009-04-06 22:17:47 +08:00
|
|
|
OSPF_PACKET(ospf_dump_dbdes, (struct ospf_dbdes_packet *) ifa->ip_sk->tbuf,
|
|
|
|
"DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
|
2004-06-27 04:15:34 +08:00
|
|
|
ospf_send_to(ifa->ip_sk, n->ip, n->ifa);
|
2004-06-11 17:34:48 +08:00
|
|
|
|
|
|
|
if(n->myimms.bit.ms) tm_start(n->rxmt_timer, n->ifa->rxmtint); /* Restart timer */
|
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
if (!n->myimms.bit.ms)
|
|
|
|
{
|
|
|
|
if ((n->myimms.bit.m == 0) && (n->imms.bit.m == 0) &&
|
|
|
|
(n->state == NEIGHBOR_EXCHANGE))
|
2000-03-30 01:18:06 +08:00
|
|
|
{
|
2004-06-05 01:49:25 +08:00
|
|
|
ospf_neigh_sm(n, INM_EXDONE);
|
2000-03-30 01:18:06 +08:00
|
|
|
}
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
|
|
|
break;
|
1999-11-17 23:50:41 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
default: /* Ignore it */
|
|
|
|
break;
|
1999-11-17 23:50:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-05 17:58:23 +08:00
|
|
|
static void
|
2004-06-05 01:49:25 +08:00
|
|
|
ospf_dbdes_reqladd(struct ospf_dbdes_packet *ps, struct ospf_neighbor *n)
|
2000-03-30 01:18:06 +08:00
|
|
|
{
|
2004-06-05 01:49:25 +08:00
|
|
|
struct ospf_lsa_header *plsa, lsa;
|
|
|
|
struct top_hash_entry *he, *sn;
|
2004-07-16 00:37:52 +08:00
|
|
|
struct ospf_area *oa = n->ifa->oa;
|
|
|
|
struct top_graph *gr = oa->po->gr;
|
2000-03-30 08:18:59 +08:00
|
|
|
struct ospf_packet *op;
|
2004-06-05 01:49:25 +08:00
|
|
|
int i, j;
|
2000-03-30 01:18:06 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
op = (struct ospf_packet *) ps;
|
2000-03-30 01:18:06 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
plsa = (void *) (ps + 1);
|
2000-03-30 08:18:59 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
j = (ntohs(op->length) - sizeof(struct ospf_dbdes_packet)) /
|
|
|
|
sizeof(struct ospf_lsa_header);
|
2000-03-30 08:18:59 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
for (i = 0; i < j; i++)
|
2000-03-30 08:18:59 +08:00
|
|
|
{
|
2004-06-05 01:49:25 +08:00
|
|
|
ntohlsah(plsa + i, &lsa);
|
2004-07-16 00:37:52 +08:00
|
|
|
if (((he = ospf_hash_find(gr, oa->areaid, lsa.id, lsa.rt, lsa.type)) == NULL) ||
|
2004-06-05 01:49:25 +08:00
|
|
|
(lsa_comp(&lsa, &(he->lsa)) == 1))
|
2000-03-31 03:37:26 +08:00
|
|
|
{
|
2000-04-03 04:41:33 +08:00
|
|
|
/* Is this condition necessary? */
|
2004-07-16 00:37:52 +08:00
|
|
|
if (ospf_hash_find(n->lsrqh, oa->areaid, lsa.id, lsa.rt, lsa.type) == NULL)
|
2000-03-31 03:37:26 +08:00
|
|
|
{
|
2004-07-16 00:37:52 +08:00
|
|
|
sn = ospf_hash_get(n->lsrqh, oa, lsa.id, lsa.rt, lsa.type);
|
2004-06-05 01:49:25 +08:00
|
|
|
ntohlsah(plsa + i, &(sn->lsa));
|
|
|
|
s_add_tail(&(n->lsrql), SNODE sn);
|
2000-03-31 03:37:26 +08:00
|
|
|
}
|
|
|
|
}
|
2000-03-30 08:18:59 +08:00
|
|
|
}
|
1999-11-17 23:50:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-06-05 01:49:25 +08:00
|
|
|
ospf_dbdes_receive(struct ospf_dbdes_packet *ps,
|
2004-06-07 03:53:52 +08:00
|
|
|
struct ospf_iface *ifa, struct ospf_neighbor *n)
|
1999-11-17 23:50:41 +08:00
|
|
|
{
|
2004-07-16 00:37:52 +08:00
|
|
|
struct proto *p = &ifa->oa->po->proto;
|
2004-06-07 03:53:52 +08:00
|
|
|
u32 myrid = p->cf->global->router_id;
|
|
|
|
unsigned int size = ntohs(ps->ospf_packet.length);
|
1999-11-17 23:50:41 +08:00
|
|
|
|
2009-04-06 22:17:47 +08:00
|
|
|
OSPF_PACKET(ospf_dump_dbdes, ps, "DBDES packet received from %I via %s", n->ip, ifa->iface->name);
|
2004-06-11 17:34:48 +08:00
|
|
|
|
2000-06-06 03:45:06 +08:00
|
|
|
ospf_neigh_sm(n, INM_HELLOREC);
|
2000-05-10 20:22:00 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
switch (n->state)
|
1999-11-17 23:50:41 +08:00
|
|
|
{
|
2004-06-05 01:49:25 +08:00
|
|
|
case NEIGHBOR_DOWN:
|
|
|
|
case NEIGHBOR_ATTEMPT:
|
|
|
|
case NEIGHBOR_2WAY:
|
|
|
|
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);
|
2009-04-06 22:53:06 +08:00
|
|
|
ospf_dbdes_send(n, 1);
|
1999-11-17 23:50:41 +08:00
|
|
|
break;
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
2004-06-11 17:34:48 +08:00
|
|
|
|
|
|
|
if (((ps->imms.bit.i == 0) && (ps->imms.bit.ms == 0)) &&
|
|
|
|
(n->rid < myrid) && (n->dds == ntohl(ps->ddseq)))
|
2004-06-05 01:49:25 +08:00
|
|
|
{
|
2004-06-11 17:34:48 +08:00
|
|
|
/* I'm master! */
|
|
|
|
n->options = ps->options;
|
|
|
|
n->ddr = ntohl(ps->ddseq) - 1; /* It will be set corectly a few lines down */
|
|
|
|
n->imms.byte = ps->imms.byte;
|
|
|
|
OSPF_TRACE(D_PACKETS, "I'm master to %I.", n->ip);
|
|
|
|
ospf_neigh_sm(n, INM_NEGDONE);
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
2004-06-11 17:34:48 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG("%s: Nothing happend to %I (imms=%u)\n", p->name, n->ip,
|
|
|
|
ps->imms.byte);
|
2004-06-05 01:49:25 +08:00
|
|
|
break;
|
2004-06-11 17:34:48 +08:00
|
|
|
}
|
2004-06-05 01:49:25 +08:00
|
|
|
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);
|
2009-02-13 02:46:51 +08:00
|
|
|
if (n->myimms.bit.ms == 0)
|
2004-06-05 01:49:25 +08:00
|
|
|
{
|
2009-02-13 02:46:51 +08:00
|
|
|
/* Slave should retransmit dbdes packet */
|
2009-04-06 22:53:06 +08:00
|
|
|
ospf_dbdes_send(n, 0);
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2000-03-30 01:18:06 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
n->ddr = ntohl(ps->ddseq);
|
1999-11-17 23:50:41 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
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);
|
1999-11-17 23:50:41 +08:00
|
|
|
break;
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
1999-11-17 23:50:41 +08:00
|
|
|
break;
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
1999-11-17 23:50:41 +08:00
|
|
|
break;
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
1999-11-17 23:50:41 +08:00
|
|
|
|
2004-06-05 01:49:25 +08:00
|
|
|
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
|
|
|
|
{
|
2009-04-06 22:53:06 +08:00
|
|
|
ospf_dbdes_send(n, 1);
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
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);
|
2009-04-06 22:53:06 +08:00
|
|
|
ospf_dbdes_send(n, 1);
|
2004-06-05 01:49:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2009-02-25 23:28:21 +08:00
|
|
|
if (n->myimms.bit.ms == 0)
|
|
|
|
{
|
|
|
|
/* Slave should retransmit dbdes packet */
|
2009-04-06 22:53:06 +08:00
|
|
|
ospf_dbdes_send(n, 0);
|
2009-02-25 23:28:21 +08:00
|
|
|
}
|
2004-06-05 01:49:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (full)",
|
|
|
|
n->ip);
|
2009-01-11 19:14:27 +08:00
|
|
|
DBG("PS=%u, DDR=%u, DDS=%u\n", ntohl(ps->ddseq), n->ddr, n->dds);
|
2004-06-05 01:49:25 +08:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
|
|
|
}
|
|
|
|
break;
|
2004-06-05 17:29:38 +08:00
|
|
|
default:
|
2004-06-05 01:49:25 +08:00
|
|
|
bug("Received dbdes from %I in undefined state.", n->ip);
|
|
|
|
}
|
|
|
|
}
|