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;
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);
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)
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);
}
struct ospf_lsa_header lsa;
struct proto_ospf *po = oa->po;
struct proto *p = &po->proto;
- u32 rid = po->proto.cf->global->router_id;
void *body;
OSPF_TRACE(D_EVENTS, "Originating router-LSA for area %R", oa->areaid);
lsa.options = oa->options;
#endif
- lsa.id = rid;
- lsa.rt = rid;
+ lsa.id = po->router_id;
+ lsa.rt = po->router_id;
lsa.sn = oa->rt ? (oa->rt->lsa.sn + 1) : LSA_INITSEQNO;
u32 dom = oa->areaid;
originate_net_lsa_body(struct ospf_iface *ifa, u16 *length,
struct proto_ospf *po)
{
+ u32 rid = proto_get_router_id(po->proto.cf);
u16 i = 1;
struct ospf_neighbor *n;
struct ospf_lsa_net *net;
u32 options = 0;
#endif
- net->routers[0] = po->proto.cf->global->router_id;
+ net->routers[0] = po->router_id;
WALK_LIST(n, ifa->neigh_list)
{
originate_net_lsa(struct ospf_iface *ifa)
{
struct proto_ospf *po = ifa->oa->po;
+ struct proto *p = &po->proto;
struct ospf_lsa_header lsa;
- u32 rid = po->proto.cf->global->router_id;
u32 dom = ifa->oa->areaid;
- struct proto *p = &po->proto;
+
void *body;
OSPF_TRACE(D_EVENTS, "Originating network-LSA for iface %s",
lsa.id = ifa->iface->index;
#endif
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = ifa->net_lsa ? (ifa->net_lsa->lsa.sn + 1) : LSA_INITSEQNO;
body = originate_net_lsa_body(ifa, &lsa.length, po);
struct proto_ospf *po = oa->po;
struct proto *p = &po->proto;
struct top_hash_entry *en;
- u32 rid = po->proto.cf->global->router_id;
u32 dom = oa->areaid;
struct ospf_lsa_header lsa;
void *body;
#endif
lsa.type = LSA_T_SUM_NET;
lsa.id = fibnode_to_lsaid(po, fn);
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = LSA_INITSEQNO;
if ((en = ospf_hash_find_header(po->gr, dom, &lsa)) != NULL)
struct proto_ospf *po = oa->po;
struct proto *p = &po->proto;
struct top_hash_entry *en;
- u32 rid = po->proto.cf->global->router_id;
u32 dom = oa->areaid;
struct ospf_lsa_header lsa;
void *body;
lsa.type = LSA_T_SUM_RT;
/* In OSPFv3, LSA ID is meaningless, but we still use Router ID of ASBR */
lsa.id = ipa_to_rid(fn->prefix);
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = LSA_INITSEQNO;
if ((en = ospf_hash_find_header(po->gr, dom, &lsa)) != NULL)
struct proto_ospf *po = oa->po;
struct proto *p = &po->proto;
struct top_hash_entry *en;
- u32 rid = po->proto.cf->global->router_id;
struct ospf_lsa_header lsa;
- lsa.rt = rid;
+ lsa.rt = po->router_id;
if (type == ORT_NET)
{
lsa.id = fibnode_to_lsaid(po, fn);
struct proto *p = &po->proto;
struct fib_node *fn = &n->n;
struct ospf_lsa_header lsa;
- u32 rid = po->proto.cf->global->router_id;
struct top_hash_entry *en = NULL;
void *body;
struct ospf_area *oa;
#endif
lsa.type = LSA_T_EXT;
lsa.id = fibnode_to_lsaid(po, fn);
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = LSA_INITSEQNO;
if ((en = ospf_hash_find_header(po->gr, 0, &lsa)) != NULL)
{
struct proto *p = &po->proto;
struct fib_node *fn = &n->n;
- u32 rid = po->proto.cf->global->router_id;
struct ospf_area *oa;
struct top_hash_entry *en;
u32 lsaid = fibnode_to_lsaid(po, fn);
- if (en = ospf_hash_find(po->gr, 0, lsaid, rid, LSA_T_EXT))
+ if (en = ospf_hash_find(po->gr, 0, lsaid, po->router_id, LSA_T_EXT))
{
if (check_ext_lsaid_collision(fn, en))
{
struct ospf_lsa_header lsa;
struct proto_ospf *po = ifa->oa->po;
struct proto *p = &po->proto;
- u32 rid = po->proto.cf->global->router_id;
void *body;
/* FIXME check for vlink and skip that? */
lsa.age = 0;
lsa.type = LSA_T_LINK;
lsa.id = ifa->iface->index;
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = ifa->link_lsa ? (ifa->link_lsa->lsa.sn + 1) : LSA_INITSEQNO;
u32 dom = ifa->iface->index;
struct proto_ospf *po = oa->po;
struct ospf_iface *ifa;
struct ospf_lsa_prefix *lp;
- u32 rid = po->proto.cf->global->router_id;
int net_lsa;
int i = 0;
u8 flags;
lp = lsab_allocz(po, sizeof(struct ospf_lsa_prefix));
lp->ref_type = LSA_T_RT;
lp->ref_id = 0;
- lp->ref_rt = rid;
+ lp->ref_rt = po->router_id;
lp = NULL; /* buffer might be reallocated later */
WALK_LIST(ifa, po->iface_list)
{
struct proto_ospf *po = oa->po;
struct proto *p = &po->proto;
- u32 rid = po->proto.cf->global->router_id;
struct ospf_lsa_header lsa;
void *body;
lsa.age = 0;
lsa.type = LSA_T_PREFIX;
lsa.id = 0;
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = oa->pxr_lsa ? (oa->pxr_lsa->lsa.sn + 1) : LSA_INITSEQNO;
u32 dom = oa->areaid;
struct ospf_lsa_prefix *lp;
struct ospf_neighbor *n;
struct top_hash_entry *en;
- u32 rid = po->proto.cf->global->router_id;
int pxc, offset;
ASSERT(po->lsab_used == 0);
lp = lsab_allocz(po, sizeof(struct ospf_lsa_prefix));
lp->ref_type = LSA_T_NET;
lp->ref_id = ifa->net_lsa->lsa.id;
- lp->ref_rt = rid;
+ lp->ref_rt = po->router_id;
lp = NULL; /* buffer might be reallocated later */
pxc = 0;
{
struct proto_ospf *po = ifa->oa->po;
struct proto *p = &po->proto;
- u32 rid = po->proto.cf->global->router_id;
struct ospf_lsa_header lsa;
void *body;
lsa.age = 0;
lsa.type = LSA_T_PREFIX;
lsa.id = ifa->iface->index;
- lsa.rt = rid;
+ lsa.rt = po->router_id;
lsa.sn = ifa->pxn_lsa ? (ifa->pxn_lsa->lsa.sn + 1) : LSA_INITSEQNO;
u32 dom = ifa->oa->areaid;