diff options
author | Ondrej Filip <feela@network.cz> | 2000-03-29 14:32:25 +0200 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2000-03-29 14:32:25 +0200 |
commit | 04c6319a630e9e18bc45da5e5b1c1f11d726c261 (patch) | |
tree | 43ef043f4f9c984517f1a6c0aefb36f59e2c9132 /proto/ospf | |
parent | 0a06a9b8b3dbd59c850303c49eea97c12e1ac0ff (diff) | |
download | bird-04c6319a630e9e18bc45da5e5b1c1f11d726c261.tar bird-04c6319a630e9e18bc45da5e5b1c1f11d726c261.zip |
IMMS reverted to bits. Outgoing packets dumping added.
Cisco does not set inteface MTU. Hmm....
Diffstat (limited to 'proto/ospf')
-rw-r--r-- | proto/ospf/dbdes.c | 42 | ||||
-rw-r--r-- | proto/ospf/neighbor.c | 5 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 21 |
3 files changed, 46 insertions, 22 deletions
diff --git a/proto/ospf/dbdes.c b/proto/ospf/dbdes.c index cf7a747..7ee40da 100644 --- a/proto/ospf/dbdes.c +++ b/proto/ospf/dbdes.c @@ -67,8 +67,8 @@ ospf_dbdes_tx(struct ospf_neighbor *n) break; case NEIGHBOR_EXCHANGE: - if(! ((IAMMASTER(n->myimms) && (n->dds==n->ddr+1)) || - ((!IAMMASTER(n->myimms)) && (n->dds==n->ddr)))) + 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; @@ -111,7 +111,7 @@ ospf_dbdes_tx(struct ospf_neighbor *n) { DBG("Number of LSA NOT sent: %d\n", i); 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); @@ -133,6 +133,17 @@ ospf_dbdes_tx(struct ospf_neighbor *n) { *(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); 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); if(n->state!=NEIGHBOR_EXSTART) return; 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))) { /* I'm slave! */ n->dds=ps->ddseq; n->options=ps->options; - n->myimms=(n->myimms && DBDES_M); + n->myimms.bit.ms=0; 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); ospf_neigh_sm(n, INM_NEGDONE); } else { - if(((ps->imms & (DBDES_I|DBDES_MS))== 0) && (n->rid < myrid) && - (n->dds == ps->ddseq)) + if(((ps->imms.bit.i==0) && (ps->imms.bit.ms==0)) && + (n->rid < myrid) && (n->dds == ps->ddseq)) { /* I'm master! */ n->options=ps->options; 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); 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 */ 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)) { /* Duplicate packet */ 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); } 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"); ospf_neigh_sm(n, INM_SEQMIS); break; } - if(INISET(ps->imms)) /* I bit is set */ + if(ps->imms.bit.i) /* I bit is set */ { DBG("SEQMIS-BIT-I\n"); ospf_neigh_sm(n, INM_SEQMIS); @@ -262,7 +274,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p, break; } - if(IAMMASTER(n->myimms)) + if(n->myimms.bit.ms) { if(ps->ddseq!=n->dds) { @@ -286,7 +298,7 @@ ospf_dbdes_rx(struct ospf_dbdes_packet *ps, struct proto *p, break; case NEIGHBOR_LOADING: 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 */ { debug("%s: Received duplicate dbdes from (%u)!\n", p->name, nrid); diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index 20c2f3c..3f9b0eb 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -159,7 +159,10 @@ tryadj(struct ospf_neighbor *n, struct proto *p) n->dds=random_u32(); } 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 ? */ } diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 6ea8833..6557355 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -11,9 +11,6 @@ #define LOCAL_DEBUG -#define IAMMASTER(x) ((x) & DBDES_MS) -#define INISET(x) ((x) & DBDES_I) - #include <string.h> #include "nest/bird.h" @@ -137,11 +134,23 @@ struct ospf_hello_packet { 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_packet ospf_packet; u16 iface_mtu; u8 options; - u8 imms; /* I, M, MS bits */ + union imms imms; /* I, M, MS bits */ #define DBDES_MS 1 #define DBDES_M 2 #define DBDES_I 4 @@ -238,10 +247,10 @@ struct ospf_neighbor #define NEIGHBOR_LOADING 6 #define NEIGHBOR_FULL 7 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 ddr; /* last Dat Des packet received */ - u8 myimms; /* I, M Master/slave */ + union imms myimms; /* I, M Master/slave */ u32 rid; /* Router ID */ ip_addr ip; /* IP of it's interface */ u8 priority; /* Priority */ |