IMMS reverted to bits. Outgoing packets dumping added.

Cisco does not set inteface MTU. Hmm....
This commit is contained in:
Ondrej Filip 2000-03-29 12:32:25 +00:00
parent 0a06a9b8b3
commit 04c6319a63
3 changed files with 46 additions and 22 deletions

View file

@ -67,8 +67,8 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
break; break;
case NEIGHBOR_EXCHANGE: case NEIGHBOR_EXCHANGE:
if(! ((IAMMASTER(n->myimms) && (n->dds==n->ddr+1)) || if(! (((n->myimms.bit.ms) && (n->dds==n->ddr+1)) ||
((!IAMMASTER(n->myimms)) && (n->dds==n->ddr)))) ((!(n->myimms.bit.ms)) && (n->dds==n->ddr))))
{ {
snode *sn; /* Send next */ snode *sn; /* Send next */
struct ospf_lsa_header *lsa; struct ospf_lsa_header *lsa;
@ -111,7 +111,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
{ {
DBG("Number of LSA NOT sent: %d\n", i); DBG("Number of LSA NOT sent: %d\n", i);
DBG("M bit unset.\n"); DBG("M bit unset.\n");
n->myimms=(n->myimms-DBDES_M); /* Unset more bit */ n->myimms.bit.m=0; /* Unset more bit */
} }
s_put(&(n->dbsi),sn); s_put(&(n->dbsi),sn);
@ -133,6 +133,17 @@ ospf_dbdes_tx(struct ospf_neighbor *n)
{ {
*(bb+i)=*(aa+i); /* Copy last sent packet again */ *(bb+i)=*(aa+i); /* Copy last sent packet again */
} }
{
u8 ii;
u8 *jj=ifa->ip_sk->tbuf;
for(ii=0;ii<length;ii+=4)
{
DBG("Out dump: %d,%d,%d,%d\n", *(jj+ii), *(jj+ii+1), *(jj+ii+2), *(jj+ii+3));
}
}
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 sent for %u.\n", p->name, n->rid);
@ -195,27 +206,28 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
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==(DBDES_I|DBDES_M|DBDES_MS) && (n->rid > myrid) && if((ps->imms.bit.m && ps->imms.bit.ms && ps->imms.bit.i)
&& (n->rid > myrid) &&
(size == sizeof(struct ospf_dbdes_packet))) (size == sizeof(struct ospf_dbdes_packet)))
{ {
/* I'm slave! */ /* I'm slave! */
n->dds=ps->ddseq; n->dds=ps->ddseq;
n->options=ps->options; n->options=ps->options;
n->myimms=(n->myimms && DBDES_M); n->myimms.bit.ms=0;
n->ddr=ps->ddseq; n->ddr=ps->ddseq;
n->imms=ps->imms; n->imms.byte=ps->imms.byte;
debug("%s: I'm slave to %u. \n", p->name, nrid); debug("%s: I'm slave to %u. \n", p->name, nrid);
ospf_neigh_sm(n, INM_NEGDONE); ospf_neigh_sm(n, INM_NEGDONE);
} }
else else
{ {
if(((ps->imms & (DBDES_I|DBDES_MS))== 0) && (n->rid < myrid) && if(((ps->imms.bit.i==0) && (ps->imms.bit.ms==0)) &&
(n->dds == ps->ddseq)) (n->rid < myrid) && (n->dds == ps->ddseq))
{ {
/* I'm master! */ /* I'm master! */
n->options=ps->options; n->options=ps->options;
n->ddr=ps->ddseq; n->ddr=ps->ddseq;
n->imms=ps->imms; n->imms.byte=ps->imms.byte;
debug("%s: I'm master to %u. \n", p->name, nrid); debug("%s: I'm master to %u. \n", p->name, nrid);
ospf_neigh_sm(n, INM_NEGDONE); ospf_neigh_sm(n, INM_NEGDONE);
} }
@ -229,26 +241,26 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
break; /* I should probably continue processing packet */ break; /* I should probably continue processing packet */
case NEIGHBOR_EXCHANGE: case NEIGHBOR_EXCHANGE:
if((ps->imms==n->imms) && (ps->options=n->options) && if((ps->imms.byte==n->imms.byte) && (ps->options=n->options) &&
(ps->ddseq==n->dds)) (ps->ddseq==n->dds))
{ {
/* Duplicate packet */ /* Duplicate packet */
debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid); debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid);
if(!IAMMASTER(n->imms)) if(n->imms.bit.ms==0)
{ {
ospf_dbdes_tx(n); ospf_dbdes_tx(n);
} }
return; return;
} }
if(IAMMASTER(ps->imms)!=IAMMASTER(n->myimms)) /* M/S bit differs */ if(ps->imms.bit.ms!=n->myimms.bit.m) /* M/S bit differs */
{ {
DBG("SEQMIS-IMMS\n"); 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(ps->imms.bit.i) /* I bit is set */
{ {
DBG("SEQMIS-BIT-I\n"); DBG("SEQMIS-BIT-I\n");
ospf_neigh_sm(n, INM_SEQMIS); ospf_neigh_sm(n, INM_SEQMIS);
@ -262,7 +274,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
break; break;
} }
if(IAMMASTER(n->myimms)) if(n->myimms.bit.ms)
{ {
if(ps->ddseq!=n->dds) if(ps->ddseq!=n->dds)
{ {
@ -286,7 +298,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p,
break; break;
case NEIGHBOR_LOADING: case NEIGHBOR_LOADING:
case NEIGHBOR_FULL: case NEIGHBOR_FULL:
if((ps->imms==n->imms) && (ps->options=n->options) && if((ps->imms.byte==n->imms.byte) && (ps->options=n->options) &&
(ps->ddseq==n->dds)) /* Only duplicate are accepted */ (ps->ddseq==n->dds)) /* Only duplicate are accepted */
{ {
debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid); debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid);

View file

@ -159,7 +159,10 @@ tryadj(struct ospf_neighbor *n, struct proto *p)
n->dds=random_u32(); n->dds=random_u32();
} }
n->dds++; n->dds++;
n->myimms=(DBDES_MS | DBDES_M | DBDES_I ); n->myimms.byte=0;
n->myimms.bit.ms=1;
n->myimms.bit.m=1;
n->myimms.bit.i=1;
tm_start(n->ifa->rxmt_timer,1); /* Or some other number ? */ tm_start(n->ifa->rxmt_timer,1); /* Or some other number ? */
} }

View file

@ -11,9 +11,6 @@
#define LOCAL_DEBUG #define LOCAL_DEBUG
#define IAMMASTER(x) ((x) & DBDES_MS)
#define INISET(x) ((x) & DBDES_I)
#include <string.h> #include <string.h>
#include "nest/bird.h" #include "nest/bird.h"
@ -137,11 +134,23 @@ struct ospf_hello_packet {
u32 bdr; u32 bdr;
}; };
struct immsb {
u8 ms:1;
u8 m:1;
u8 i:1;
u8 padding:5;
};
union imms {
u8 byte;
struct immsb bit;
};
struct ospf_dbdes_packet { struct ospf_dbdes_packet {
struct ospf_packet ospf_packet; struct ospf_packet ospf_packet;
u16 iface_mtu; u16 iface_mtu;
u8 options; u8 options;
u8 imms; /* I, M, MS bits */ union imms imms; /* I, M, MS bits */
#define DBDES_MS 1 #define DBDES_MS 1
#define DBDES_M 2 #define DBDES_M 2
#define DBDES_I 4 #define DBDES_I 4
@ -238,10 +247,10 @@ struct ospf_neighbor
#define NEIGHBOR_LOADING 6 #define NEIGHBOR_LOADING 6
#define NEIGHBOR_FULL 7 #define NEIGHBOR_FULL 7
timer *inactim; /* Inactivity timer */ timer *inactim; /* Inactivity timer */
u8 imms; /* I, M, Master/slave received */ union imms imms; /* I, M, Master/slave received */
u32 dds; /* DD Sequence number being sent */ u32 dds; /* DD Sequence number being sent */
u32 ddr; /* last Dat Des packet received */ u32 ddr; /* last Dat Des packet received */
u8 myimms; /* I, M Master/slave */ union imms myimms; /* I, M Master/slave */
u32 rid; /* Router ID */ u32 rid; /* Router ID */
ip_addr ip; /* IP of it's interface */ ip_addr ip; /* IP of it's interface */
u8 priority; /* Priority */ u8 priority; /* Priority */