dbdes indent an minor changes.

This commit is contained in:
Ondrej Filip 2004-06-04 17:49:25 +00:00
parent 85305e5d8f
commit 12bed559ff
4 changed files with 288 additions and 285 deletions

View file

@ -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,20 +19,19 @@
* 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)
{ {
@ -70,8 +69,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
pkt->options = ifa->options; pkt->options = ifa->options;
pkt->ddseq = htonl(n->dds); pkt->ddseq = htonl(n->dds);
j=i=(ifa->iface->mtu-sizeof(struct ospf_dbdes_packet)-SIPH)/ j = i = (ifa->iface->mtu - sizeof(struct ospf_dbdes_packet) - SIPH) / sizeof(struct ospf_lsa_header); /* Number of possible lsaheaders to send */
sizeof(struct ospf_lsa_header); /* Number of possible lsaheaders to send */
lsa = (n->ldbdes + sizeof(struct ospf_dbdes_packet)); lsa = (n->ldbdes + sizeof(struct ospf_dbdes_packet));
if (n->myimms.bit.m) if (n->myimms.bit.m)
@ -104,7 +102,8 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
DBG("M bit unset.\n"); DBG("M bit unset.\n");
n->myimms.bit.m = 0; /* Unset more bit */ n->myimms.bit.m = 0; /* Unset more bit */
} }
else s_put(&(n->dbsi),sn); else
s_put(&(n->dbsi), sn);
} }
pkt->imms.byte = n->myimms.byte; pkt->imms.byte = n->myimms.byte;
@ -148,16 +147,15 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
} }
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;
struct proto *p = (struct proto *) n->ifa->proto;
int i, j; 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);
@ -183,20 +181,19 @@ ospf_dbdes_reqladd(struct ospf_dbdes_packet *ps, struct proto *p,
} }
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;
} }
@ -219,11 +216,11 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
break; break;
case NEIGHBOR_INIT: case NEIGHBOR_INIT:
ospf_neigh_sm(n, INM_2WAYREC); ospf_neigh_sm(n, INM_2WAYREC);
if(n->state!=NEIGHBOR_EXSTART) return; if (n->state != NEIGHBOR_EXSTART)
return;
case NEIGHBOR_EXSTART: case NEIGHBOR_EXSTART:
if ((ps->imms.bit.m && ps->imms.bit.ms && ps->imms.bit.i) if ((ps->imms.bit.m && ps->imms.bit.ms && ps->imms.bit.i)
&& (n->rid > myrid) && && (n->rid > myrid) && (size == sizeof(struct ospf_dbdes_packet)))
(size == sizeof(struct ospf_dbdes_packet)))
{ {
/* I'm slave! */ /* I'm slave! */
n->dds = ntohl(ps->ddseq); n->dds = ntohl(ps->ddseq);
@ -233,7 +230,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
n->imms.byte = ps->imms.byte; n->imms.byte = ps->imms.byte;
OSPF_TRACE(D_PACKETS, "I'm slave to %I.", n->ip); OSPF_TRACE(D_PACKETS, "I'm slave to %I.", n->ip);
ospf_neigh_sm(n, INM_NEGDONE); ospf_neigh_sm(n, INM_NEGDONE);
ospf_dbdes_tx(n); ospf_dbdes_send(n);
break; break;
} }
else else
@ -255,7 +252,8 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
break; break;
} }
} }
if(ps->imms.bit.i) break; if (ps->imms.bit.i)
break;
case NEIGHBOR_EXCHANGE: case NEIGHBOR_EXCHANGE:
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))
@ -264,7 +262,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip); OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip);
if (n->imms.bit.ms == 0) if (n->imms.bit.ms == 0)
{ {
ospf_dbdes_tx(n); ospf_dbdes_send(n);
} }
return; return;
} }
@ -273,14 +271,16 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
if (ps->imms.bit.ms != n->imms.bit.ms) /* M/S bit differs */ if (ps->imms.bit.ms != n->imms.bit.ms) /* M/S bit differs */
{ {
log("SEQMIS-BIT-MS\n"); OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (bit MS)",
n->ip);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
if (ps->imms.bit.i) /* I bit is set */ if (ps->imms.bit.i) /* I bit is set */
{ {
log("SEQMIS-BIT-I\n"); OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (bit I)",
n->ip);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
@ -289,7 +289,8 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
if (ps->options != n->options) /* Options differs */ if (ps->options != n->options) /* Options differs */
{ {
log("SEQMIS-OPT\n"); OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (options)",
n->ip);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
@ -298,20 +299,21 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
{ {
if (ntohl(ps->ddseq) != n->dds) /* MASTER */ if (ntohl(ps->ddseq) != n->dds) /* MASTER */
{ {
log("SEQMIS-MASTER\n"); OSPF_TRACE(D_PACKETS,
"dbdes - sequence mismatch neighbor %I (master)", n->ip);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
n->dds++; n->dds++;
DBG("Incrementing dds\n"); DBG("Incrementing dds\n");
ospf_dbdes_reqladd(ps,p,n); ospf_dbdes_reqladd(ps, n);
if ((n->myimms.bit.m == 0) && (ps->imms.bit.m == 0)) if ((n->myimms.bit.m == 0) && (ps->imms.bit.m == 0))
{ {
ospf_neigh_sm(n, INM_EXDONE); ospf_neigh_sm(n, INM_EXDONE);
} }
else else
{ {
ospf_dbdes_tx(n); ospf_dbdes_send(n);
} }
} }
@ -319,34 +321,36 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
{ {
if (ntohl(ps->ddseq) != (n->dds + 1)) /* SLAVE */ if (ntohl(ps->ddseq) != (n->dds + 1)) /* SLAVE */
{ {
log("SEQMIS-SLAVE\n"); OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (slave)",
n->ip);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
break; break;
} }
n->ddr = ntohl(ps->ddseq); n->ddr = ntohl(ps->ddseq);
n->dds = ntohl(ps->ddseq); n->dds = ntohl(ps->ddseq);
ospf_dbdes_reqladd(ps,p,n); ospf_dbdes_reqladd(ps, n);
ospf_dbdes_tx(n); ospf_dbdes_send(n);
} }
break; break;
case NEIGHBOR_LOADING: case NEIGHBOR_LOADING:
case NEIGHBOR_FULL: 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)) /* Only duplicate are accepted */ && (ntohl(ps->ddseq) == n->ddr))
/* Only duplicate are accepted */
{ {
OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip); OSPF_TRACE(D_PACKETS, "Received duplicate dbdes from %I.", n->ip);
return; return;
} }
else else
{ {
log("SEQMIS-FULL\n"); OSPF_TRACE(D_PACKETS, "dbdes - sequence mismatch neighbor %I (full)",
n->ip);
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
} }
break; break;
defaut: defaut:
bug("%s: Received dbdes from %I in undefined state.", p->name, n->ip); bug("Received dbdes from %I in undefined state.", n->ip);
break; break;
} }
} }

View file

@ -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_ */

View file

@ -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

View file

@ -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);