1999-11-17 15:50:41 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- OSPF
|
|
|
|
*
|
2004-06-04 18:24:15 +00:00
|
|
|
* (c) 1999--2004 Ondrej Filip <feela@network.cz>
|
1999-11-17 15:50:41 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ospf.h"
|
|
|
|
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_dbdes2_packet
|
2009-08-21 07:27:52 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_packet hdr;
|
|
|
|
union ospf_auth auth;
|
|
|
|
|
2009-08-21 07:27:52 +00:00
|
|
|
u16 iface_mtu;
|
|
|
|
u8 options;
|
2012-08-05 20:32:06 +00:00
|
|
|
u8 imms; /* I, M, MS bits */
|
2009-08-21 07:27:52 +00:00
|
|
|
u32 ddseq;
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_lsa_header lsas[];
|
|
|
|
};
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_dbdes3_packet
|
2009-08-21 07:27:52 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_packet hdr;
|
|
|
|
|
2009-08-21 07:27:52 +00:00
|
|
|
u32 options;
|
|
|
|
u16 iface_mtu;
|
|
|
|
u8 padding;
|
2012-08-05 20:32:06 +00:00
|
|
|
u8 imms; /* I, M, MS bits */
|
2009-08-21 07:27:52 +00:00
|
|
|
u32 ddseq;
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
struct ospf_lsa_header lsas[];
|
2009-08-21 07:27:52 +00:00
|
|
|
};
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
static inline unsigned
|
|
|
|
ospf_dbdes_hdrlen(struct proto_ospf *po)
|
|
|
|
{
|
|
|
|
return ospf_is_v2(po) ?
|
|
|
|
sizeof(struct ospf_dbdes2_packet) :
|
|
|
|
sizeof(struct ospf_dbdes3_packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf_dbdes_body(struct proto_ospf *po, struct ospf_packet *pkt, unsigned plen,
|
|
|
|
struct ospf_lsa_header **body, unsigned *count)
|
|
|
|
{
|
|
|
|
unsigned hdrlen = ospf_dbdes_hdrlen(po);
|
|
|
|
*body = ((void *) pkt) + hdrlen;
|
|
|
|
*count = (plen - hdrlen) / sizeof(struct ospf_lsa_header);
|
|
|
|
}
|
2009-04-06 14:17:47 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
static void ospf_dbdes_dump(struct proto_ospf *po, struct ospf_packet *pkt)
|
2009-04-06 14:17:47 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_lsa_header *lsas;
|
|
|
|
unsigned i, lsa_count;
|
2012-10-02 09:44:05 +00:00
|
|
|
u32 pkt_ddseq;
|
|
|
|
u16 pkt_iface_mtu;
|
|
|
|
u8 pkt_imms;
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
ASSERT(pkt->type == DBDES_P);
|
|
|
|
ospf_dump_common(po, pkt);
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
if (ospf_is_v2(po))
|
|
|
|
{
|
|
|
|
struct ospf_dbdes2_packet *ps = (void *) pkt;
|
|
|
|
pkt_iface_mtu = ntohs(ps->iface_mtu);
|
|
|
|
pkt_imms = ps->imms;
|
|
|
|
pkt_ddseq = ntohl(ps->ddseq);
|
|
|
|
}
|
|
|
|
else /* OSPFv3 */
|
|
|
|
{
|
|
|
|
struct ospf_dbdes3_packet *ps = (void *) pkt;
|
|
|
|
pkt_iface_mtu = ntohs(ps->iface_mtu);
|
|
|
|
pkt_imms = ps->imms;
|
|
|
|
pkt_ddseq = ntohl(ps->ddseq);
|
|
|
|
}
|
2009-04-06 14:17:47 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
log(L_TRACE "%s: mtu %u", po->proto.name, pkt_iface_mtu);
|
|
|
|
log(L_TRACE "%s: imms %s%s%s", po->proto.name,
|
|
|
|
(pkt_imms & DBDES_I) ? "I " : "",
|
|
|
|
(pkt_imms & DBDES_M) ? "M " : "",
|
|
|
|
(pkt_imms & DBDES_MS) ? "MS" : "");
|
|
|
|
log(L_TRACE "%s: ddseq %u", po->proto.name, pkt_ddseq);
|
2009-04-06 14:17:47 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
ospf_dbdes_body(po, pkt, ntohs(pkt->length), &lsas, &lsa_count);
|
|
|
|
for (i = 0; i < lsa_count; i++)
|
|
|
|
ospf_dump_lsahdr(po, lsas + i);
|
2009-04-06 14:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
static void
|
|
|
|
ospf_dbdes_prepare(struct ospf_neighbor *n, struct ospf_packet *pkt, int lsdb)
|
|
|
|
{
|
|
|
|
struct ospf_iface *ifa = n->ifa;
|
|
|
|
struct proto_ospf *po = ifa->oa->po;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
ospf_pkt_fill_hdr(ifa, pkt, DBDES_P);
|
|
|
|
|
|
|
|
if (lsdb && (n->myimms & DBDES_M))
|
|
|
|
{
|
|
|
|
struct ospf_lsa_header *lsas;
|
|
|
|
unsigned lsa_max;
|
|
|
|
snode *sn;
|
|
|
|
|
|
|
|
ospf_dbdes_body(po, pkt, ospf_pkt_maxsize(ifa), &lsas, &lsa_max);
|
|
|
|
sn = s_get(&(n->dbsi));
|
|
|
|
|
|
|
|
while (i < lsa_max)
|
|
|
|
{
|
|
|
|
struct top_hash_entry *en = (struct top_hash_entry *) sn;
|
|
|
|
|
|
|
|
if (lsa_flooding_allowed(en->lsa_type, en->domain, ifa))
|
|
|
|
{
|
|
|
|
lsa_hton_hdr(&(en->lsa), lsas + i);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sn == STAIL(po->lsal))
|
|
|
|
{
|
|
|
|
n->myimms &= ~DBDES_M; /* Unset more bit */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sn = sn->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
s_put(&(n->dbsi), sn);
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 iface_mtu = (ifa->type == OSPF_IT_VLINK) ? 0 : ifa->iface->mtu;
|
|
|
|
unsigned length;
|
|
|
|
|
|
|
|
if (ospf_is_v2(po))
|
|
|
|
{
|
|
|
|
struct ospf_dbdes2_packet *ps = (void *) pkt;
|
|
|
|
|
|
|
|
ps->iface_mtu = htons(iface_mtu);
|
|
|
|
ps->options = ifa->oa->options;
|
|
|
|
ps->imms = n->myimms;
|
|
|
|
ps->ddseq = htonl(n->dds);
|
|
|
|
|
|
|
|
length = sizeof(struct ospf_dbdes2_packet);
|
|
|
|
}
|
|
|
|
else /* OSPFv3 */
|
|
|
|
{
|
|
|
|
struct ospf_dbdes3_packet *ps = (void *) pkt;
|
|
|
|
|
|
|
|
ps->options = htonl(ifa->oa->options);
|
|
|
|
ps->iface_mtu = htons(iface_mtu);
|
|
|
|
ps->imms = n->myimms;
|
|
|
|
ps->ddseq = htonl(n->dds);
|
|
|
|
|
|
|
|
length = sizeof(struct ospf_dbdes3_packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
length += i * sizeof(struct ospf_lsa_header);
|
|
|
|
pkt->length = htons(length);
|
|
|
|
}
|
|
|
|
|
2000-06-07 22:53:51 +00:00
|
|
|
/**
|
2004-06-04 17:49:25 +00:00
|
|
|
* ospf_dbdes_send - transmit database description packet
|
2000-06-07 22:53:51 +00:00
|
|
|
* @n: neighbor
|
2009-04-06 14:53:06 +00:00
|
|
|
* @next: whether to send a next packet in a sequence (1) or to retransmit the old one (0)
|
2000-06-07 22:53:51 +00:00
|
|
|
*
|
2009-08-21 07:27:52 +00:00
|
|
|
* Sending of a database description packet is described in 10.8 of RFC 2328.
|
2003-08-23 10:42:41 +00:00
|
|
|
* 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-07 22:53:51 +00:00
|
|
|
*/
|
1999-11-17 15:50:41 +00:00
|
|
|
void
|
2009-04-06 14:53:06 +00:00
|
|
|
ospf_dbdes_send(struct ospf_neighbor *n, int next)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2004-06-04 17:49:25 +00:00
|
|
|
struct ospf_iface *ifa = n->ifa;
|
|
|
|
struct ospf_area *oa = ifa->oa;
|
2004-07-15 16:37:52 +00:00
|
|
|
struct proto_ospf *po = oa->po;
|
2012-10-02 09:44:05 +00:00
|
|
|
struct ospf_packet *pkt;
|
|
|
|
unsigned length;
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2009-08-25 14:42:14 +00:00
|
|
|
/* FIXME ??? */
|
2004-07-15 16:37:52 +00:00
|
|
|
if ((oa->rt == NULL) || (EMPTY_LIST(po->lsal)))
|
2009-08-25 14:42:14 +00:00
|
|
|
update_rt_lsa(oa);
|
2000-06-08 19:02:31 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
switch (n->state)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
case NEIGHBOR_EXSTART:
|
2012-08-05 20:32:06 +00:00
|
|
|
n->myimms |= DBDES_I;
|
2012-10-02 09:44:05 +00:00
|
|
|
|
|
|
|
/* Send empty packets */
|
2010-03-11 17:07:24 +00:00
|
|
|
pkt = ospf_tx_buffer(ifa);
|
2012-10-02 09:44:05 +00:00
|
|
|
ospf_dbdes_prepare(n, pkt, 0);
|
|
|
|
OSPF_PACKET(ospf_dbdes_dump, pkt, "DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
|
2009-09-04 09:06:51 +00:00
|
|
|
ospf_send_to(ifa, n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEIGHBOR_EXCHANGE:
|
2012-08-05 20:32:06 +00:00
|
|
|
n->myimms &= ~DBDES_I;
|
2004-06-04 17:49:25 +00:00
|
|
|
|
2009-04-06 14:53:06 +00:00
|
|
|
if (next)
|
2012-10-02 09:44:05 +00:00
|
|
|
ospf_dbdes_prepare(n, n->ldbdes, 1);
|
2004-06-04 17:49:25 +00:00
|
|
|
|
|
|
|
case NEIGHBOR_LOADING:
|
|
|
|
case NEIGHBOR_FULL:
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
length = ntohs(((struct ospf_packet *) n->ldbdes)->length);
|
2004-06-06 09:37:54 +00:00
|
|
|
if (!length)
|
2004-06-04 18:51:29 +00:00
|
|
|
{
|
|
|
|
OSPF_TRACE(D_PACKETS, "No packet in my buffer for repeating");
|
|
|
|
ospf_neigh_sm(n, INM_KILLNBR);
|
2004-06-04 19:21:19 +00:00
|
|
|
return;
|
2004-06-04 18:51:29 +00:00
|
|
|
}
|
|
|
|
|
2004-06-06 09:37:54 +00:00
|
|
|
/* Copy last sent packet again */
|
2010-03-11 17:07:24 +00:00
|
|
|
pkt = ospf_tx_buffer(ifa);
|
2010-02-11 09:23:35 +00:00
|
|
|
memcpy(pkt, n->ldbdes, length);
|
2000-03-29 12:32:25 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
OSPF_PACKET(ospf_dbdes_dump, pkt, "DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
|
2009-09-04 09:06:51 +00:00
|
|
|
ospf_send_to(ifa, n->ip);
|
2004-06-11 09:34:48 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
/* XXXX remove this? */
|
2012-08-05 20:32:06 +00:00
|
|
|
if (n->myimms & DBDES_MS)
|
|
|
|
tm_start(n->rxmt_timer, n->ifa->rxmtint); /* Restart timer */
|
2004-06-11 09:34:48 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!(n->myimms & DBDES_MS))
|
|
|
|
if (!(n->myimms & DBDES_M) &&
|
|
|
|
!(n->imms & DBDES_M) &&
|
2004-06-04 17:49:25 +00:00
|
|
|
(n->state == NEIGHBOR_EXCHANGE))
|
|
|
|
ospf_neigh_sm(n, INM_EXDONE);
|
2012-10-02 09:44:05 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
break;
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
default: /* Ignore it */
|
|
|
|
break;
|
1999-11-17 15:50:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-05 09:58:23 +00:00
|
|
|
static void
|
2012-10-02 09:44:05 +00:00
|
|
|
ospf_dbdes_process(struct ospf_neighbor *n, struct ospf_packet *pkt, unsigned plen)
|
2000-03-29 17:18:06 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
struct ospf_iface *ifa = n->ifa;
|
|
|
|
struct proto_ospf *po = ifa->oa->po;
|
|
|
|
struct ospf_lsa_header *lsas;
|
|
|
|
unsigned i, lsa_count;
|
|
|
|
|
|
|
|
ospf_dbdes_body(po, pkt, plen, &lsas, &lsa_count);
|
2000-03-29 17:18:06 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
for (i = 0; i < lsa_count; i++)
|
|
|
|
{
|
|
|
|
struct top_hash_entry *en, *req;
|
|
|
|
struct ospf_lsa_header lsa;
|
|
|
|
u32 lsa_type, lsa_domain;
|
2000-03-29 17:18:06 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
lsa_ntoh_hdr(lsas + i, &lsa);
|
|
|
|
lsa_xxxxtype(lsa.type_raw, ifa, &lsa_type, &lsa_domain);
|
2000-03-30 00:18:59 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
/* XXXX: Add check for 0-type or flooding_allowed */
|
2000-03-30 00:18:59 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
en = ospf_hash_find(po->gr, lsa_domain, lsa.id, lsa.rt, lsa_type);
|
|
|
|
if (!en || (lsa_comp(&lsa, &(en->lsa)) == CMP_NEWER))
|
2000-03-30 19:37:26 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
req = ospf_hash_get(n->lsrqh, lsa_domain, lsa.id, lsa.rt, lsa_type);
|
|
|
|
|
|
|
|
if (ospf_hash_is_new(req))
|
|
|
|
s_add_tail(&(n->lsrql), SNODE req);
|
|
|
|
|
2013-04-15 23:14:57 +00:00
|
|
|
en->lsa = lsa; // XXXX ??? should be req->lsa ?
|
2000-03-30 19:37:26 +00:00
|
|
|
}
|
2000-03-30 00:18:59 +00:00
|
|
|
}
|
1999-11-17 15:50:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-05 20:32:06 +00:00
|
|
|
ospf_dbdes_receive(struct ospf_packet *pkt, struct ospf_iface *ifa,
|
2009-08-21 07:27:52 +00:00
|
|
|
struct ospf_neighbor *n)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2009-12-11 00:20:53 +00:00
|
|
|
struct proto_ospf *po = ifa->oa->po;
|
2012-08-05 20:32:06 +00:00
|
|
|
u32 rcv_ddseq, rcv_options;
|
|
|
|
u16 rcv_iface_mtu;
|
|
|
|
u8 rcv_imms;
|
2012-10-02 09:44:05 +00:00
|
|
|
unsigned plen;
|
2012-08-05 20:32:06 +00:00
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
plen = ntohs(pkt->length);
|
|
|
|
if (plen < ospf_dbdes_hdrlen(po))
|
2009-10-29 22:57:42 +00:00
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
log(L_ERR "OSPF: Bad DBDES packet from %I - too short (%u B)", n->ip, plen);
|
2009-10-29 22:57:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-02 09:44:05 +00:00
|
|
|
OSPF_PACKET(ospf_dbdes_dump, pkt, "DBDES packet received from %I via %s", n->ip, ifa->iface->name);
|
|
|
|
|
|
|
|
ospf_neigh_sm(n, INM_HELLOREC);
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (ospf_is_v2(po))
|
|
|
|
{
|
|
|
|
struct ospf_dbdes2_packet *ps = (void *) pkt;
|
|
|
|
rcv_iface_mtu = ntohs(ps->iface_mtu);
|
|
|
|
rcv_options = ps->options;
|
|
|
|
rcv_imms = ps->imms;
|
|
|
|
rcv_ddseq = ntohl(ps->ddseq);
|
|
|
|
}
|
|
|
|
else /* OSPFv3 */
|
|
|
|
{
|
|
|
|
struct ospf_dbdes3_packet *ps = (void *) pkt;
|
|
|
|
rcv_options = ntohl(ps->options);
|
|
|
|
rcv_iface_mtu = ntohs(ps->iface_mtu);
|
|
|
|
rcv_imms = ps->imms;
|
|
|
|
rcv_ddseq = ntohl(ps->ddseq);
|
|
|
|
}
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
switch (n->state)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2004-06-04 17:49:25 +00:00
|
|
|
case NEIGHBOR_DOWN:
|
|
|
|
case NEIGHBOR_ATTEMPT:
|
|
|
|
case NEIGHBOR_2WAY:
|
|
|
|
return;
|
2012-08-05 20:32:06 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
case NEIGHBOR_INIT:
|
|
|
|
ospf_neigh_sm(n, INM_2WAYREC);
|
|
|
|
if (n->state != NEIGHBOR_EXSTART)
|
|
|
|
return;
|
2012-03-15 12:45:55 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
case NEIGHBOR_EXSTART:
|
|
|
|
if ((rcv_iface_mtu != ifa->iface->mtu) &&
|
|
|
|
(rcv_iface_mtu != 0) &&
|
|
|
|
(ifa->iface->mtu != 0) &&
|
|
|
|
(ifa->type != OSPF_IT_VLINK))
|
2012-10-02 09:44:05 +00:00
|
|
|
log(L_WARN "OSPF: MTU mismatch with neighbor %I on interface %s (remote %d, local %d)",
|
2012-08-05 20:32:06 +00:00
|
|
|
n->ip, ifa->iface->name, rcv_iface_mtu, ifa->iface->mtu);
|
2012-03-15 12:45:55 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((rcv_imms == DBDES_IMMS) &&
|
|
|
|
(n->rid > po->router_id) &&
|
2012-10-02 09:44:05 +00:00
|
|
|
(plen == ospf_dbdes_hdrlen(po)))
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
|
|
|
/* I'm slave! */
|
2012-08-05 20:32:06 +00:00
|
|
|
n->dds = rcv_ddseq;
|
|
|
|
n->ddr = rcv_ddseq;
|
|
|
|
n->options = rcv_options;
|
|
|
|
n->myimms &= ~DBDES_MS;
|
|
|
|
n->imms = rcv_imms;
|
|
|
|
OSPF_TRACE(D_PACKETS, "I'm slave to %I", n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_NEGDONE);
|
2009-04-06 14:53:06 +00:00
|
|
|
ospf_dbdes_send(n, 1);
|
1999-11-17 15:50:41 +00:00
|
|
|
break;
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
2004-06-11 09:34:48 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!(rcv_imms & DBDES_I) &&
|
|
|
|
!(rcv_imms & DBDES_MS) &&
|
|
|
|
(n->rid < po->router_id) &&
|
|
|
|
(n->dds == rcv_ddseq))
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2004-06-11 09:34:48 +00:00
|
|
|
/* I'm master! */
|
2012-08-05 20:32:06 +00:00
|
|
|
n->options = rcv_options;
|
|
|
|
n->ddr = rcv_ddseq - 1; /* It will be set corectly a few lines down */
|
|
|
|
n->imms = rcv_imms;
|
|
|
|
OSPF_TRACE(D_PACKETS, "I'm master to %I", n->ip);
|
2004-06-11 09:34:48 +00:00
|
|
|
ospf_neigh_sm(n, INM_NEGDONE);
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
2004-06-11 09:34:48 +00:00
|
|
|
else
|
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
DBG("%s: Nothing happend to %I (imms=%d)\n", p->name, n->ip, rcv_imms);
|
2004-06-04 17:49:25 +00:00
|
|
|
break;
|
2004-06-11 09:34:48 +00:00
|
|
|
}
|
2012-08-05 20:32:06 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
case NEIGHBOR_EXCHANGE:
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((rcv_imms == n->imms) &&
|
|
|
|
(rcv_options == n->options) &&
|
|
|
|
(rcv_ddseq == n->ddr))
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
|
|
|
/* Duplicate packet */
|
2012-10-02 09:44:05 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I", n->ip);
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!(n->myimms & DBDES_MS))
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2009-02-12 18:46:51 +00:00
|
|
|
/* Slave should retransmit dbdes packet */
|
2009-04-06 14:53:06 +00:00
|
|
|
ospf_dbdes_send(n, 0);
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2000-03-29 17:18:06 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((rcv_imms & DBDES_MS) != (n->imms & DBDES_MS)) /* M/S bit differs */
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (bit MS)", n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
1999-11-17 15:50:41 +00:00
|
|
|
break;
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (rcv_imms & DBDES_I) /* I bit is set */
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (bit I)", n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
1999-11-17 15:50:41 +00:00
|
|
|
break;
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (rcv_options != n->options) /* Options differs */
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (options)", n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
1999-11-17 15:50:41 +00:00
|
|
|
break;
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
n->ddr = rcv_ddseq;
|
|
|
|
n->imms = rcv_imms;
|
|
|
|
|
|
|
|
if (n->myimms & DBDES_MS)
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (rcv_ddseq != n->dds) /* MASTER */
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (master)", n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
n->dds++;
|
|
|
|
DBG("Incrementing dds\n");
|
2012-10-02 09:44:05 +00:00
|
|
|
ospf_dbdes_process(n, pkt, plen);
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!(n->myimms & DBDES_M) &&
|
|
|
|
!(rcv_imms & DBDES_M))
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
|
|
|
ospf_neigh_sm(n, INM_EXDONE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-06 14:53:06 +00:00
|
|
|
ospf_dbdes_send(n, 1);
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (rcv_ddseq != (n->dds + 1)) /* SLAVE */
|
2004-06-04 17:49:25 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (slave)", n->ip);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
|
|
|
break;
|
|
|
|
}
|
2012-08-05 20:32:06 +00:00
|
|
|
n->ddr = rcv_ddseq;
|
|
|
|
n->dds = rcv_ddseq;
|
2012-10-02 09:44:05 +00:00
|
|
|
ospf_dbdes_process(n, pkt, plen);
|
2009-04-06 14:53:06 +00:00
|
|
|
ospf_dbdes_send(n, 1);
|
2004-06-04 17:49:25 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-08-05 20:32:06 +00:00
|
|
|
|
2004-06-04 17:49:25 +00:00
|
|
|
case NEIGHBOR_LOADING:
|
|
|
|
case NEIGHBOR_FULL:
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((rcv_imms == n->imms) &&
|
|
|
|
(rcv_options == n->options) &&
|
|
|
|
(rcv_ddseq == n->ddr))
|
2004-06-04 17:49:25 +00:00
|
|
|
/* Only duplicate are accepted */
|
|
|
|
{
|
2012-10-02 09:44:05 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I", n->ip);
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!(n->myimms & DBDES_MS))
|
2009-02-25 15:28:21 +00:00
|
|
|
{
|
|
|
|
/* Slave should retransmit dbdes packet */
|
2009-04-06 14:53:06 +00:00
|
|
|
ospf_dbdes_send(n, 0);
|
2009-02-25 15:28:21 +00:00
|
|
|
}
|
2004-06-04 17:49:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (full)", n->ip);
|
|
|
|
DBG("PS=%u, DDR=%u, DDS=%u\n", rcv_ddseq, n->ddr, n->dds);
|
2004-06-04 17:49:25 +00:00
|
|
|
ospf_neigh_sm(n, INM_SEQMIS);
|
|
|
|
}
|
|
|
|
break;
|
2004-06-05 09:29:38 +00:00
|
|
|
default:
|
2004-06-04 17:49:25 +00:00
|
|
|
bug("Received dbdes from %I in undefined state.", n->ip);
|
|
|
|
}
|
|
|
|
}
|