本文整理汇总了C++中IPV4_ADDR_SAME函数的典型用法代码示例。如果您正苦于以下问题:C++ IPV4_ADDR_SAME函数的具体用法?C++ IPV4_ADDR_SAME怎么用?C++ IPV4_ADDR_SAME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IPV4_ADDR_SAME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ospf_vl_up_check
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!");
}
}
}
}
示例2: ospf_vl_lookup
/* 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;
}
示例3: nsm_twoway_received
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;
}
示例4: nsm_adj_ok
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;
}
示例5: ospf_dr_election
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;
}
示例6: ospf_vl_up_check
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!");
}
}
}
}
示例7: ospf_ism_state
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;
}
示例8: ospf_vl_up_check
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);
}
}
}
示例9: ospf_dr_election
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;
}
示例10: ospf_if_is_configured
/*
* 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;
}
示例11: ospf_if_is_configured
/*
* 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;
}
示例12: if_lookup_exact_address
/* 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;
}
示例13: ospf_nbr_state_message
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));
}
示例14: nsm_should_adj
/* 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;
}
示例15: ospf_abr_announce_rtr
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");
}