diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2009-12-11 01:20:53 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2009-12-11 11:06:51 +0100 |
commit | 8a70a13e7e79afa6818b10cf64d4f1ae4cf89e4b (patch) | |
tree | c674a054dd38aebc945a7a53c6f61539d70a01fc /proto/ospf/hello.c | |
parent | be2d38b7e977c1f72ed9cd52f8e3e85130c0aaa1 (diff) |
Implements protocol-specific Router ID for OSPF.
And fixes one minor bug.
Diffstat (limited to 'proto/ospf/hello.c')
-rw-r--r-- | proto/ospf/hello.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/proto/ospf/hello.c b/proto/ospf/hello.c index 855b0700..738748d8 100644 --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@ -45,7 +45,8 @@ void ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa, struct ospf_neighbor *n, ip_addr faddr) { - struct proto *p = &ifa->oa->po->proto; + struct proto_ospf *po = ifa->oa->po; + struct proto *p = &po->proto; char *beg = "Bad OSPF HELLO packet from ", *rec = " received: "; unsigned int size, i, twoway, oldpriority, eligible, peers; u32 olddr, oldbdr, oldiface_id, tmp; @@ -175,7 +176,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa, twoway = 0; for (i = 0; i < peers; i++) { - if (ntohl(*(pnrid + i)) == p->cf->global->router_id) + if (ntohl(pnrid[i]) == po->router_id) { DBG("%s: Twoway received from %I\n", p->name, faddr); ospf_neigh_sm(n, INM_2WAYREC); @@ -206,9 +207,9 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa, if (n->state >= NEIGHBOR_2WAY) { #ifdef OSPFv2 - u32 rid = ipa_to_u32(n->ip); + u32 neigh = ipa_to_u32(n->ip); #else /* OSPFv3 */ - u32 rid = p->cf->global->router_id; + u32 neigh = n->rid; #endif if (n->priority != oldpriority) @@ -219,23 +220,23 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa, ospf_iface_sm(ifa, ISM_NEICH); #endif - /* Router is declaring itself ad DR and there is no BDR */ - if ((rid == n->dr) && (n->bdr == 0) + /* Neighbor is declaring itself ad DR and there is no BDR */ + if ((n->dr == neigh) && (n->bdr == 0) && (n->state != NEIGHBOR_FULL)) ospf_iface_sm(ifa, ISM_BACKS); /* Neighbor is declaring itself as BDR */ - if ((rid == n->bdr) && (n->state != NEIGHBOR_FULL)) + if ((n->bdr == neigh) && (n->state != NEIGHBOR_FULL)) ospf_iface_sm(ifa, ISM_BACKS); /* Neighbor is newly declaring itself as DR or BDR */ - if (((rid == n->dr) && (n->dr != olddr)) - || ((rid == n->bdr) && (n->bdr != oldbdr))) + if (((n->dr == neigh) && (n->dr != olddr)) + || ((n->bdr == neigh) && (n->bdr != oldbdr))) ospf_iface_sm(ifa, ISM_NEICH); /* Neighbor is no more declaring itself as DR or BDR */ - if (((rid == olddr) && (n->dr != olddr)) - || ((rid == oldbdr) && (n->bdr != oldbdr))) + if (((olddr == neigh) && (n->dr != olddr)) + || ((oldbdr == neigh) && (n->bdr != oldbdr))) ospf_iface_sm(ifa, ISM_NEICH); } |