int nsm_adj_ok (struct ospf_neighbor *nbr) { struct ospf_interface *oi; int next_state; int flag = 0; oi = nbr->oi; next_state = nbr->state; /* These netowork types must be adjacency. */ if (oi->type == OSPF_IFTYPE_POINTOPOINT || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT || oi->type == OSPF_IFTYPE_VIRTUALLINK) flag = 1; /* Router itself is the DRouter or the BDRouter. */ if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)) || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi))) flag = 1; if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi)) || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi))) flag = 1; if (nbr->state == NSM_TwoWay && flag == 1) next_state = NSM_ExStart; else if (nbr->state >= NSM_ExStart && flag == 0) next_state = NSM_TwoWay; return next_state; }
void ospf_vl_up_check (struct ospf_area *area, struct in_addr rid, struct vertex *v) { struct ospf *ospf = area->ospf; struct listnode *node; struct ospf_vl_data *vl_data; struct ospf_interface *oi; if (IS_DEBUG_OSPF_EVENT) { zlog_debug ("ospf_vl_up_check(): Start"); zlog_debug ("ospf_vl_up_check(): Router ID is %s", inet_ntoa (rid)); zlog_debug ("ospf_vl_up_check(): Area is %s", inet_ntoa (area->area_id)); } for (node = listhead (ospf->vlinks); node; nextnode (node)) { if ((vl_data = getdata (node)) == NULL) continue; if (IS_DEBUG_OSPF_EVENT) { zlog_debug ("ospf_vl_up_check(): considering VL, name: %s", vl_data->vl_oi->ifp->name); zlog_debug ("ospf_vl_up_check(): VL area: %s, peer ID: %s", inet_ntoa (vl_data->vl_area_id), inet_ntoa (vl_data->vl_peer)); } if (IPV4_ADDR_SAME (&vl_data->vl_peer, &rid) && IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id)) { oi = vl_data->vl_oi; SET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED); if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_vl_up_check(): this VL matched"); if (oi->state == ISM_Down) { if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_vl_up_check(): VL is down, waking it up"); SET_FLAG (oi->ifp->flags, IFF_UP); OSPF_ISM_EVENT_EXECUTE(oi,ISM_InterfaceUp); } if (ospf_vl_set_params (vl_data, v)) { if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) zlog_debug ("ospf_vl_up_check: VL cost change," " scheduling router lsa refresh"); if(ospf->backbone) ospf_router_lsa_timer_add (ospf->backbone); else if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) zlog_debug ("ospf_vl_up_check: VL cost change, no backbone!"); } } } }
/* Look up vl_data for given peer, optionally qualified to be in the * specified area. NULL area returns first found.. */ struct ospf_vl_data * ospf_vl_lookup (struct ospf *ospf, struct ospf_area *area, struct in_addr vl_peer) { struct ospf_vl_data *vl_data; struct listnode *node; if (IS_DEBUG_OSPF_EVENT) { zlog_debug ("%s: Looking for %s", __func__, inet_ntoa (vl_peer)); if (area) zlog_debug ("%s: in area %s", __func__, inet_ntoa (area->area_id)); } for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug ("%s: VL %s, peer %s", __func__, vl_data->vl_oi->ifp->name, inet_ntoa (vl_data->vl_peer)); if (area && !IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id)) continue; if (IPV4_ADDR_SAME (&vl_data->vl_peer, &vl_peer)) return vl_data; } return NULL; }
int nsm_twoway_received (struct ospf_neighbor *nbr) { struct ospf_interface *oi; int next_state = NSM_TwoWay; oi = nbr->oi; /* These netowork types must be adjacency. */ if (oi->type == OSPF_IFTYPE_POINTOPOINT || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT || oi->type == OSPF_IFTYPE_VIRTUALLINK) next_state = NSM_ExStart; /* Router itself is the DRouter or the BDRouter. */ if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)) || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi))) next_state = NSM_ExStart; /* Neighboring Router is the DRouter or the BDRouter. */ if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &nbr->d_router) || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &nbr->bd_router)) next_state = NSM_ExStart; return next_state; }
int ospf_dr_election (struct ospf_interface *oi) { struct in_addr old_dr, old_bdr; int old_state, new_state; struct list *el_list; struct ospf_neighbor *dr, *bdr; /* backup current values. */ old_dr = DR (oi); old_bdr = BDR (oi); old_state = oi->state; el_list = list_new (); /* List eligible routers. */ ospf_dr_eligible_routers (oi->nbrs, el_list); /* First election of DR and BDR. */ bdr = ospf_elect_bdr (oi, el_list); dr = ospf_elect_dr (oi, el_list); new_state = ospf_ism_state (oi); zlog_info ("DR-Election[1st]: Backup %s", inet_ntoa (BDR (oi))); zlog_info ("DR-Election[1st]: DR %s", inet_ntoa (DR (oi))); if (new_state != old_state && !(new_state == ISM_DROther && old_state < ISM_DROther)) { ospf_elect_bdr (oi, el_list); ospf_elect_dr (oi, el_list); new_state = ospf_ism_state (oi); zlog_info ("DR-Election[2nd]: Backup %s", inet_ntoa (BDR (oi))); zlog_info ("DR-Election[2nd]: DR %s", inet_ntoa (DR (oi))); } list_delete (el_list); /* if DR or BDR changes, cause AdjOK? neighbor event. */ if (!IPV4_ADDR_SAME (&old_dr, &DR (oi)) || !IPV4_ADDR_SAME (&old_bdr, &BDR (oi))) ospf_dr_change (oi->ospf, oi->nbrs); if (oi->type == OSPF_IFTYPE_BROADCAST || oi->type == OSPF_IFTYPE_POINTOPOINT) { /* Multicast group change. */ if ((old_state != ISM_DR && old_state != ISM_Backup) && (new_state == ISM_DR || new_state == ISM_Backup)) ospf_if_add_alldrouters (oi->ospf, oi->address, oi->ifp->ifindex); else if ((old_state == ISM_DR || old_state == ISM_Backup) && (new_state != ISM_DR && new_state != ISM_Backup)) ospf_if_drop_alldrouters (oi->ospf, oi->address, oi->ifp->ifindex); } return new_state; }
void ospf_vl_up_check (struct ospf_area *area, struct in_addr rid, struct vertex *v) { struct ospf *ospf = area->ospf; struct listnode *node; struct ospf_vl_data *vl_data; struct ospf_interface *oi; if (IS_DEBUG_OSPF_EVENT) { zlog_debug ("ospf_vl_up_check(): Start"); zlog_debug ("ospf_vl_up_check(): Router ID is %s", inet_ntoa (rid)); zlog_debug ("ospf_vl_up_check(): Area is %s", inet_ntoa (area->area_id)); } for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data)) { if (IS_DEBUG_OSPF_EVENT) { zlog_debug ("%s: considering VL, %s in area %s", __func__, vl_data->vl_oi->ifp->name, inet_ntoa (vl_data->vl_area_id)); zlog_debug ("%s: peer ID: %s", __func__, inet_ntoa (vl_data->vl_peer)); } if (IPV4_ADDR_SAME (&vl_data->vl_peer, &rid) && IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id)) { oi = vl_data->vl_oi; SET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED); if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_vl_up_check(): this VL matched"); if (oi->state == ISM_Down) { if (IS_DEBUG_OSPF_EVENT) zlog_debug ("ospf_vl_up_check(): VL is down, waking it up"); SET_FLAG (oi->ifp->flags, IFF_UP); OSPF_ISM_EVENT_EXECUTE(oi,ISM_InterfaceUp); } if (ospf_vl_set_params (vl_data, v)) { if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) zlog_debug ("ospf_vl_up_check: VL cost change," " scheduling router lsa refresh"); if (ospf->backbone) ospf_router_lsa_update_area (ospf->backbone); else if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) zlog_debug ("ospf_vl_up_check: VL cost change, no backbone!"); } } } }
static int ospf_ism_state(struct ospf_interface *oi) { if (IPV4_ADDR_SAME(&DR(oi), &oi->address->u.prefix4)) return ISM_DR; else if (IPV4_ADDR_SAME(&BDR(oi), &oi->address->u.prefix4)) return ISM_Backup; else return ISM_DROther; }
void ospf_vl_up_check (struct ospf_area *area, struct in_addr rid, struct vertex *v) { struct ospf *ospf = area->ospf; listnode node; struct ospf_vl_data *vl_data; struct ospf_interface *oi; if (IS_DEBUG_OSPF_EVENT) { zlog_info ("ospf_vl_up_check(): Start"); zlog_info ("ospf_vl_up_check(): Router ID is %s", inet_ntoa (rid)); zlog_info ("ospf_vl_up_check(): Area is %s", inet_ntoa (area->area_id)); } for (node = listhead (ospf->vlinks); node; nextnode (node)) { if ((vl_data = getdata (node)) == NULL) continue; if (IS_DEBUG_OSPF_EVENT) { zlog_info ("ospf_vl_up_check(): considering VL, name: %s", vl_data->vl_oi->ifp->name); zlog_info ("ospf_vl_up_check(): VL area: %s, peer ID: %s", inet_ntoa (vl_data->vl_area_id), inet_ntoa (vl_data->vl_peer)); } if (IPV4_ADDR_SAME (&vl_data->vl_peer, &rid) && IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id)) { oi = vl_data->vl_oi; SET_FLAG (vl_data->flags, OSPF_VL_FLAG_APPROVED); if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_vl_up_check(): this VL matched"); if (oi->state == ISM_Down) { if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_vl_up_check(): VL is down, waking it up"); SET_FLAG (oi->ifp->flags, IFF_UP); OSPF_ISM_EVENT_SCHEDULE (oi, ISM_InterfaceUp); } ospf_vl_set_params (vl_data, v); } } }
static int ospf_dr_election (struct ospf_interface *oi) { struct in_addr old_dr, old_bdr; int old_state, new_state; struct list *el_list; struct ospf_neighbor *dr, *bdr; /* backup current values. */ old_dr = DR (oi); old_bdr = BDR (oi); old_state = oi->state; el_list = list_new (); /* List eligible routers. */ ospf_dr_eligible_routers (oi->nbrs, el_list); /* First election of DR and BDR. */ bdr = ospf_elect_bdr (oi, el_list); dr = ospf_elect_dr (oi, el_list); new_state = ospf_ism_state (oi); zlog_info ("DR-Election[1st]: Backup %s", inet_ntoa (BDR (oi))); zlog_info ("DR-Election[1st]: DR %s", inet_ntoa (DR (oi))); if (new_state != old_state && !(new_state == ISM_DROther && old_state < ISM_DROther)) { ospf_elect_bdr (oi, el_list); ospf_elect_dr (oi, el_list); new_state = ospf_ism_state (oi); zlog_info ("DR-Election[2nd]: Backup %s", inet_ntoa (BDR (oi))); zlog_info ("DR-Election[2nd]: DR %s", inet_ntoa (DR (oi))); } list_delete (el_list); /* if DR or BDR changes, cause AdjOK? neighbor event. */ if (!IPV4_ADDR_SAME (&old_dr, &DR (oi)) || !IPV4_ADDR_SAME (&old_bdr, &BDR (oi))) ospf_dr_change (oi->ospf, oi->nbrs); return new_state; }
/* * check if interface with given address is configured and * return it if yes. special treatment for PtP networks. */ struct ospf_interface * ospf_if_is_configured (struct ospf *ospf, struct in_addr *address) { struct listnode *node, *nnode; struct ospf_interface *oi; struct prefix_ipv4 addr; addr.family = AF_INET; addr.prefix = *address; addr.prefixlen = IPV4_MAX_PREFIXLEN; for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi)) if (oi->type != OSPF_IFTYPE_VIRTUALLINK) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) { /* special leniency: match if addr is anywhere on peer subnet */ if (prefix_match(CONNECTED_PREFIX(oi->connected), (struct prefix *)&addr)) return oi; } else { if (IPV4_ADDR_SAME (address, &oi->address->u.prefix4)) return oi; } } return NULL; }
/* * check if interface with given address is configured and * return it if yes. */ struct ospf_interface * ospf_if_is_configured (struct ospf *ospf, struct in_addr *address) { listnode node; struct ospf_interface *oi; struct prefix *addr; struct prefix query_addr; for (node = listhead (ospf->oiflist); node; nextnode (node)) if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK) { /* if (oi->type == OSPF_IFTYPE_POINTOPOINT) addr = oi->connected->destination; else */ addr = oi->address; query_addr.family = AF_INET; query_addr.u.prefix4 = *address; query_addr.prefixlen = IPV4_ALLOWABLE_BITLEN_P2P; if (oi->type == OSPF_IFTYPE_POINTOPOINT && prefix_match (addr, &query_addr)) return oi; else if (IPV4_ADDR_SAME (address, &addr->u.prefix4)) return oi; } return NULL; }
/* Lookup interface by IPv4 address. */ struct interface * if_lookup_exact_address (struct in_addr src) { listnode node; listnode cnode; struct interface *ifp; struct prefix *p; struct connected *c; for (node = listhead (iflist); node; nextnode (node)) { ifp = getdata (node); for (cnode = listhead (ifp->connected); cnode; nextnode (cnode)) { c = getdata (cnode); p = c->address; if (p && p->family == AF_INET) { if (IPV4_ADDR_SAME (&p->u.prefix4, &src)) return ifp; } } } return NULL; }
void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) { int state; struct ospf_interface *oi = nbr->oi; if (IPV4_ADDR_SAME(&DR(oi), &nbr->address.u.prefix4)) state = ISM_DR; else if (IPV4_ADDR_SAME(&BDR(oi), &nbr->address.u.prefix4)) state = ISM_Backup; else state = ISM_DROther; snprintf(buf, size, "%s/%s", lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), lookup_msg(ospf_ism_state_msg, state, NULL)); }
/* 10.4 of RFC2328, indicate whether an adjacency is appropriate with * the given neighbour */ static int nsm_should_adj (struct ospf_neighbor *nbr) { struct ospf_interface *oi = nbr->oi; /* These network types must always form adjacencies. */ if (oi->type == OSPF_IFTYPE_POINTOPOINT || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT || oi->type == OSPF_IFTYPE_VIRTUALLINK /* Router itself is the DRouter or the BDRouter. */ || IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi)) || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi)) /* Neighboring Router is the DRouter or the BDRouter. */ || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi)) || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi))) return 1; return 0; }
void ospf_abr_announce_rtr (struct ospf *ospf, struct prefix_ipv4 *p, struct ospf_route *or) { listnode node; struct ospf_area *area; if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_abr_announce_rtr(): Start"); for (node = listhead (ospf->areas); node; nextnode (node)) { area = getdata (node); if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_abr_announce_rtr(): looking at area %s", inet_ntoa (area->area_id)); if (IPV4_ADDR_SAME (&or->u.std.area_id, &area->area_id)) continue; if (ospf_abr_nexthops_belong_to_area (or, area)) continue; if (area->external_routing != OSPF_AREA_DEFAULT) { if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_abr_announce_network(): " "area %s doesn't support external routing", inet_ntoa(area->area_id)); continue; } if (or->path_type == OSPF_PATH_INTER_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_abr_announce_rtr(): " "this is inter-area route to %s", inet_ntoa (p->prefix)); if (!OSPF_IS_AREA_BACKBONE (area)) ospf_abr_announce_rtr_to_area (p, or->cost, area); } if (or->path_type == OSPF_PATH_INTRA_AREA) { if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_abr_announce_rtr(): " "this is intra-area route to %s", inet_ntoa (p->prefix)); ospf_abr_announce_rtr_to_area (p, or->cost, area); } } if (IS_DEBUG_OSPF_EVENT) zlog_info ("ospf_abr_announce_rtr(): Stop"); }
struct rip_peer *rip_peer_lookup(struct in_addr *addr) { struct rip_peer *peer; struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) { if (IPV4_ADDR_SAME(&peer->addr, addr)) return peer; } return NULL; }
static int bgp_nexthop_same (struct nexthop *next1, struct nexthop *next2) { if (next1->type != next2->type) return 0; switch (next1->type) { case ZEBRA_NEXTHOP_IPV4: if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4)) return 0; break; case ZEBRA_NEXTHOP_IPV4_IFINDEX: if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4) || next1->ifindex != next2->ifindex) return 0; break; case ZEBRA_NEXTHOP_IFINDEX: case ZEBRA_NEXTHOP_IFNAME: if (next1->ifindex != next2->ifindex) return 0; break; #ifdef HAVE_IPV6 case ZEBRA_NEXTHOP_IPV6: if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6)) return 0; break; case ZEBRA_NEXTHOP_IPV6_IFINDEX: case ZEBRA_NEXTHOP_IPV6_IFNAME: if (! IPV6_ADDR_SAME (&next1->gate.ipv6, &next2->gate.ipv6)) return 0; if (next1->ifindex != next2->ifindex) return 0; break; #endif /* HAVE_IPV6 */ default: /* do nothing */ break; } return 1; }
int ospf_vls_in_area(struct ospf_area *area) { struct listnode *node; struct ospf_vl_data *vl_data; int c = 0; for (ALL_LIST_ELEMENTS_RO(area->ospf->vlinks, node, vl_data)) if (IPV4_ADDR_SAME(&vl_data->vl_area_id, &area->area_id)) c++; return c; }
/* * check if interface with given address is configured and * return it if yes. special treatment for PtP networks. */ struct ospf_interface * ospf_if_is_configured (struct ospf *ospf, struct in_addr *address) { struct listnode *node; struct ospf_interface *oi; struct prefix_ipv4 addr; addr.family = AF_INET; addr.prefix = *address; addr.prefixlen = IPV4_MAX_PREFIXLEN; for (node = listhead (ospf->oiflist); node; nextnode (node)) if ((oi = getdata (node)) != NULL && oi->type != OSPF_IFTYPE_VIRTUALLINK) { if (oi->type == OSPF_IFTYPE_POINTOPOINT) { if (CONNECTED_DEST_HOST(oi->connected)) { /* match only destination addr, since local addr is most likely * not unique (borrowed from another interface) */ if (IPV4_ADDR_SAME (address, &oi->connected->destination->u.prefix4)) return oi; } else { /* special leniency: match if addr is anywhere on PtP subnet */ if (prefix_match(oi->address,(struct prefix *)&addr)) return oi; } } else { if (IPV4_ADDR_SAME (address, &oi->address->u.prefix4)) return oi; } } return NULL; }
/* Check myself is in the neighbor list. */ int ospf_nbr_bidirectional(struct in_addr *router_id, struct in_addr *neighbors, int size) { int i; int max; max = size / sizeof(struct in_addr); for (i = 0; i < max; i++) if (IPV4_ADDR_SAME(router_id, &neighbors[i])) return 1; return 0; }
struct ospf_vl_data * ospf_vl_lookup (struct ospf_area *area, struct in_addr vl_peer) { struct ospf_vl_data *vl_data; struct listnode *node; for (node = listhead (area->ospf->vlinks); node; nextnode (node)) if ((vl_data = getdata (node)) != NULL) if (vl_data->vl_peer.s_addr == vl_peer.s_addr && IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id)) return vl_data; return NULL; }
int ospf_vls_in_area (struct ospf_area *area) { struct listnode *node; struct ospf_vl_data *vl_data; int c = 0; for (node = listhead (area->ospf->vlinks); node; nextnode (node)) if ((vl_data = getdata (node)) != NULL) if (IPV4_ADDR_SAME (&vl_data->vl_area_id, &area->area_id)) c++; return c; }
void ospf_if_update_params(struct interface *ifp, struct in_addr addr) { struct route_node *rn; struct ospf_interface *oi; for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) { if ((oi = rn->info) == NULL) continue; if (IPV4_ADDR_SAME(&oi->address->u.prefix4, &addr)) oi->params = ospf_lookup_if_params(ifp, oi->address->u.prefix4); } }
/* Get neighbor count by status. Specify status = 0, get all neighbor other than myself. */ int ospf_nbr_count(struct ospf_interface *oi, int state) { struct ospf_neighbor *nbr; struct route_node *rn; int count = 0; for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) if ((nbr = rn->info)) if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id)) if (state == 0 || nbr->state == state) count++; return count; }
struct ospf_neighbor *ospf_nbr_lookup_by_routerid(struct route_table *nbrs, struct in_addr *id) { struct route_node *rn; struct ospf_neighbor *nbr; for (rn = route_top(nbrs); rn; rn = route_next(rn)) if ((nbr = rn->info) != NULL) if (IPV4_ADDR_SAME(&nbr->router_id, id)) { route_unlock_node(rn); return nbr; } return NULL; }
/* Generate AdjOK? NSM event. */ static void ospf_dr_change (struct ospf *ospf, struct route_table *nbrs) { struct route_node *rn; struct ospf_neighbor *nbr; for (rn = route_top (nbrs); rn; rn = route_next (rn)) if ((nbr = rn->info) != NULL) /* Ignore 0.0.0.0 node*/ if (nbr->router_id.s_addr != 0) /* Is neighbor upper 2-Way? */ if (nbr->state >= NSM_TwoWay) /* Ignore myself. */ if (!IPV4_ADDR_SAME (&nbr->router_id, &ospf->router_id)) OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_AdjOK); }
/* If two connected address has same prefix return 1. */ static int connected_same_prefix (struct prefix *p1, struct prefix *p2) { if (p1->family == p2->family) { if (p1->family == AF_INET && IPV4_ADDR_SAME (&p1->u.prefix4, &p2->u.prefix4)) return 1; #ifdef HAVE_IPV6 if (p1->family == AF_INET6 && IPV6_ADDR_SAME (&p1->u.prefix6, &p2->u.prefix6)) return 1; #endif /* HAVE_IPV6 */ } return 0; }
/* * Return 1 if the address/netmask contained in the prefix structure * is the same, and else return 0. For this routine, 'same' requires * that not only the prefix length and the network part be the same, * but also the host part. Thus, 10.0.0.1/8 and 10.0.0.2/8 are not * the same. Note that this routine has the same return value sense * as '==' (which is different from isis_prefix_cmp). */ int isis_prefix_same (const struct isis_prefix *p1, const struct isis_prefix *p2) { if (p1->family == p2->family && p1->prefixlen == p2->prefixlen) { if (p1->family == AF_INET) if (IPV4_ADDR_SAME (&p1->u.prefix, &p2->u.prefix)) return 1; #ifdef ENABLE_IPV6 if (p1->family == AF_INET6 ) if (IPV6_ADDR_SAME (&p1->u.prefix, &p2->u.prefix)) return 1; #endif /* ENABLE_IPV6 */ } return 0; }
/* * Return 1 if the address/netmask contained in the prefix structure * is the same, and else return 0. For this routine, 'same' requires * that not only the prefix length and the network part be the same, * but also the host part. Thus, 10.0.0.1/8 and 10.0.0.2/8 are not * the same. Note that this routine has the same return value sense * as '==' (which is different from prefix_cmp). */ int prefix_same (const struct prefix *p1, const struct prefix *p2) { if (p1->family == p2->family && p1->prefixlen == p2->prefixlen) { if (p1->family == AF_INET) if (IPV4_ADDR_SAME (&p1->u.prefix4.s_addr, &p2->u.prefix4.s_addr)) return 1; #ifdef HAVE_IPV6 if (p1->family == AF_INET6 ) if (IPV6_ADDR_SAME (&p1->u.prefix6.s6_addr, &p2->u.prefix6.s6_addr)) return 1; #endif /* HAVE_IPV6 */ } return 0; }
int ospf_nbr_count_opaque_capable (struct ospf_interface *oi) { struct ospf_neighbor *nbr; struct route_node *rn; int count = 0; for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) if ((nbr = rn->info)) if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id)) if (nbr->state == NSM_Full) if (CHECK_FLAG (nbr->options, OSPF_OPTION_O)) count++; return count; }