本文整理汇总了C++中IF_NAME函数的典型用法代码示例。如果您正苦于以下问题:C++ IF_NAME函数的具体用法?C++ IF_NAME怎么用?C++ IF_NAME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IF_NAME函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: if_setsockopt_bindtodevice
int
if_setsockopt_bindtodevice(int *sd, interface_t *ifp)
{
int ret;
if (*sd < 0)
return -1;
/* -> inbound processing option
* Specify the bound_dev_if.
* why IP_ADD_MEMBERSHIP & IP_MULTICAST_IF doesnt set
* sk->bound_dev_if themself ??? !!!
* Needed for filter multicasted advert per interface.
*
* -- If you read this !!! and know the answer to the question
* please feel free to answer me ! :)
*/
ret = setsockopt(*sd, SOL_SOCKET, SO_BINDTODEVICE, IF_NAME(ifp), strlen(IF_NAME(ifp)) + 1);
if (ret < 0) {
log_message(LOG_INFO, "cant bind to device %s. errno=%d. (try to run it as root)",
IF_NAME(ifp), errno);
close(*sd);
*sd = -1;
}
return *sd;
}
开发者ID:DStape,项目名称:keepalived,代码行数:27,代码来源:vrrp_if.c
示例2: ospf_nsm_event
/* Execute NSM event process. */
int
ospf_nsm_event (struct thread *thread)
{
int event;
int next_state;
struct ospf_neighbor *nbr;
struct in_addr router_id;
int old_state;
struct ospf_interface *oi;
nbr = THREAD_ARG (thread);
event = THREAD_VAL (thread);
router_id = nbr->router_id;
old_state = nbr->state;
oi = nbr->oi ;
/* Call function. */
next_state = (*(NSM [nbr->state][event].func))(nbr);
/* When event is NSM_KillNbr or InactivityTimer, the neighbor is
deleted. */
if (event == NSM_KillNbr || event == NSM_InactivityTimer)
{
if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
zlog_debug ("NSM[%s:%s]: neighbor deleted",
IF_NAME (oi), inet_ntoa (router_id));
/* Timers are canceled in ospf_nbr_free, moreover we cannot call
nsm_timer_set here because nbr is freed already!!!*/
/*nsm_timer_set (nbr);*/
return 0;
}
if (! next_state)
next_state = NSM [nbr->state][event].next_state;
if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (oi),
inet_ntoa (nbr->router_id),
LOOKUP (ospf_nsm_state_msg, nbr->state),
ospf_nsm_event_str [event]);
/* If state is changed. */
if (next_state != nbr->state)
nsm_change_state (nbr, next_state);
/* Make sure timer is set. */
nsm_timer_set (nbr);
return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:54,代码来源:ospf_nsm.c
示例3: nsm_notice_state_change
static void
nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
{
/* Logging change of status. */
if (IS_DEBUG_OSPF (nsm, NSM_STATUS))
zlog_debug ("NSM[%s:%s]: State change %s -> %s (%s)",
IF_NAME (nbr->oi), inet_ntoa (nbr->router_id),
LOOKUP (ospf_nsm_state_msg, nbr->state),
LOOKUP (ospf_nsm_state_msg, next_state),
ospf_nsm_event_str [event]);
/* Optionally notify about adjacency changes */
if (CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) &&
(CHECK_FLAG(nbr->oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) ||
(next_state == NSM_Full) || (next_state < nbr->state)))
zlog_notice("AdjChg: Nbr %s on %s: %s -> %s (%s)",
inet_ntoa (nbr->router_id), IF_NAME (nbr->oi),
LOOKUP (ospf_nsm_state_msg, nbr->state),
LOOKUP (ospf_nsm_state_msg, next_state),
ospf_nsm_event_str [event]);
/* Advance in NSM */
if (next_state > nbr->state)
nbr->ts_last_progress = recent_relative_time ();
else /* regression in NSM */
{
nbr->ts_last_regress = recent_relative_time ();
nbr->last_regress_str = ospf_nsm_event_str [event];
}
#ifdef HAVE_SNMP
/* Terminal state or regression */
if ((next_state == NSM_Full)
|| (next_state == NSM_TwoWay)
|| (next_state < nbr->state))
{
/* ospfVirtNbrStateChange */
if (nbr->oi->type == OSPF_IFTYPE_VIRTUALLINK)
ospfTrapVirtNbrStateChange(nbr);
/* ospfNbrStateChange trap */
else
/* To/From FULL, only managed by DR */
if (((next_state != NSM_Full) && (nbr->state != NSM_Full))
|| (nbr->oi->state == ISM_DR))
ospfTrapNbrStateChange(nbr);
}
#endif
}
开发者ID:AsherBond,项目名称:quagga,代码行数:48,代码来源:ospf_nsm.c
示例4: address_print
void
address_print(FILE *file, void *data)
{
ip_address_t *ipaddr = data;
char *broadcast = (char *) MALLOC(21);
char *addr_str = (char *) MALLOC(41);
if (IP_IS6(ipaddr)) {
inet_ntop(AF_INET6, &ipaddr->u.sin6_addr, addr_str, 41);
} else {
inet_ntop(AF_INET, &ipaddr->u.sin.sin_addr, addr_str, 41);
if (ipaddr->u.sin.sin_brd.s_addr)
snprintf(broadcast, 20, " brd %s",
inet_ntop2(ipaddr->u.sin.sin_brd.s_addr));
}
fprintf(file, " %s/%d%s dev %s scope %s%s%s\n"
, addr_str
, ipaddr->ifa.ifa_prefixlen
, broadcast
, IF_NAME(ipaddr->ifp)
, netlink_scope_n2a(ipaddr->ifa.ifa_scope)
, ipaddr->label ? " label " : ""
, ipaddr->label ? ipaddr->label : "");
FREE(broadcast);
FREE(addr_str);
}
开发者ID:jwalzer,项目名称:keepalived,代码行数:27,代码来源:vrrp_print.c
示例5: ospf_nbr_delete
/* Delete specified OSPF neighbor from interface. */
void ospf_nbr_delete(struct ospf_neighbor *nbr)
{
struct ospf_interface *oi;
struct route_node *rn;
struct prefix p;
oi = nbr->oi;
/* get appropriate prefix 'key' */
ospf_nbr_key(oi, nbr, &p);
rn = route_node_lookup(oi->nbrs, &p);
if (rn) {
/* If lookup for a NBR succeeds, the leaf route_node could
* only exist because there is (or was) a nbr there.
* If the nbr was deleted, the leaf route_node should have
* lost its last refcount too, and be deleted.
* Therefore a looked-up leaf route_node in nbrs table
* should never have NULL info.
*/
assert(rn->info);
if (rn->info) {
rn->info = NULL;
route_unlock_node(rn);
} else
zlog_info("Can't find neighbor %s in the interface %s",
inet_ntoa(nbr->src), IF_NAME(oi));
route_unlock_node(rn);
}
/* Free ospf_neighbor structure. */
ospf_nbr_free(nbr);
}
开发者ID:yubo,项目名称:quagga,代码行数:36,代码来源:ospf_neighbor.c
示例6: dump_iproute
void
dump_iproute(void *rt_data)
{
ip_route_t *route = rt_data;
char *log_msg = MALLOC(1024);
char *op = log_msg;
if (route->blackhole) {
strncat(log_msg, "blackhole ", 30);
}
if (route->dst)
op += snprintf(op, log_msg + 1024 - op, "%s/%d", ipaddresstos(NULL, route->dst), route->dmask);
if (route->gw)
op += snprintf(op, log_msg + 1024 - op, " gw %s", ipaddresstos(NULL, route->gw));
if (route->gw2)
op += snprintf(op, log_msg + 1024 - op, " or gw %s", ipaddresstos(NULL, route->gw2));
if (route->src)
op += snprintf(op, log_msg + 1024 - op, " src %s", ipaddresstos(NULL, route->src));
if (route->index)
op += snprintf(op, log_msg + 1024 - op, " dev %s",
IF_NAME(if_get_by_ifindex(route->index)));
if (route->table)
op += snprintf(op, log_msg + 1024 - op, " table %d", route->table);
if (route->scope)
op += snprintf(op, log_msg + 1024 - op, " scope %s",
netlink_scope_n2a(route->scope));
if (route->metric)
op += snprintf(op, log_msg + 1024 - op, " metric %d", route->metric);
log_message(LOG_INFO, " %s", log_msg);
FREE(log_msg);
}
开发者ID:Zex,项目名称:keepalived,代码行数:33,代码来源:vrrp_iproute.c
示例7: route_print
static void
route_print(FILE *file, void *data)
{
ip_route_t *route = data;
fprintf(file, " ");
if (route->blackhole)
fprintf(file, "blackhole ");
if (route->dst)
fprintf(file, "%s/%d", ipaddresstos(NULL, route->dst), route->dmask);
if (route->gw)
fprintf(file, " gw %s", ipaddresstos(NULL, route->gw));
if (route->gw2)
fprintf(file, " or gw %s", ipaddresstos(NULL, route->gw2));
if (route->src)
fprintf(file, " src %s", ipaddresstos(NULL, route->src));
if (route->index)
fprintf(file, " dev %s", IF_NAME(if_get_by_ifindex(route->index)));
if (route->table)
fprintf(file, " table %d", route->table);
if (route->scope)
fprintf(file, " scope %s", netlink_scope_n2a(route->scope));
if (route->metric)
fprintf(file, " metric %d", route->metric);
fprintf(file, "\n");
}
开发者ID:DStape,项目名称:keepalived,代码行数:28,代码来源:vrrp_print.c
示例8: address_print
static void
address_print(FILE *file, void *data)
{
ip_address_t *ipaddr = data;
char broadcast[INET_ADDRSTRLEN + 5] = ""; /* allow for " brd " */
char addr_str[INET6_ADDRSTRLEN] = "";
if (IP_IS6(ipaddr)) {
inet_ntop(AF_INET6, &ipaddr->u.sin6_addr, addr_str, sizeof(addr_str));
} else {
inet_ntop(AF_INET, &ipaddr->u.sin.sin_addr, addr_str, sizeof(addr_str));
if (ipaddr->u.sin.sin_brd.s_addr)
snprintf(broadcast, sizeof(broadcast) - 1, " brd %s",
inet_ntop2(ipaddr->u.sin.sin_brd.s_addr));
}
fprintf(file, " %s/%d%s dev %s%s%s%s%s\n"
, addr_str
, ipaddr->ifa.ifa_prefixlen
, broadcast
, IF_NAME(ipaddr->ifp)
, IP_IS4(ipaddr) ? " scope " : ""
, IP_IS4(ipaddr) ? netlink_scope_n2a(ipaddr->ifa.ifa_scope) : ""
, ipaddr->label ? " label " : ""
, ipaddr->label ? ipaddr->label : "");
}
开发者ID:DStape,项目名称:keepalived,代码行数:26,代码来源:vrrp_print.c
示例9: ospf_ism_event
/* Execute ISM event process. */
int
ospf_ism_event (struct thread *thread)
{
int event;
int next_state;
struct ospf_interface *oi;
oi = THREAD_ARG (thread);
event = THREAD_VAL (thread);
/* Call function. */
next_state = (*(ISM [oi->state][event].func))(oi);
if (! next_state)
next_state = ISM [oi->state][event].next_state;
if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
zlog (NULL, LOG_DEBUG, "ISM[%s]: %s (%s)", IF_NAME (oi),
LOOKUP (ospf_ism_state_msg, oi->state),
ospf_ism_event_str[event]);
/* If state is changed. */
if (next_state != oi->state)
ism_change_state (oi, next_state);
/* Make sure timer is set. */
ism_timer_set (oi);
return 0;
}
开发者ID:ColinBS,项目名称:quagga-rtrlib,代码行数:31,代码来源:ospf_ism.c
示例10: nsm_kill_nbr
static int
nsm_kill_nbr (struct ospf_neighbor *nbr)
{
/* killing nbr_self is invalid */
if (nbr == nbr->oi->nbr_self)
{
assert (nbr != nbr->oi->nbr_self);
return 0;
}
if (nbr->oi->type == OSPF_IFTYPE_NBMA && nbr->nbr_nbma != NULL)
{
struct ospf_nbr_nbma *nbr_nbma = nbr->nbr_nbma;
nbr_nbma->nbr = NULL;
nbr_nbma->state_change = nbr->state_change;
nbr->nbr_nbma = NULL;
OSPF_POLL_TIMER_ON (nbr_nbma->t_poll, ospf_poll_timer,
nbr_nbma->v_poll);
if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
zlog_debug ("NSM[%s:%s]: Down (PollIntervalTimer scheduled)",
IF_NAME (nbr->oi), inet_ntoa (nbr->address.u.prefix4));
}
return 0;
}
开发者ID:AsherBond,项目名称:quagga,代码行数:29,代码来源:ospf_nsm.c
示例11: dump_iproute
void
dump_iproute(void *rt_data)
{
ip_route_t *route = rt_data;
char *log_msg = MALLOC(1024);
char *tmp = MALLOC(INET6_ADDRSTRLEN + 30);
char *tmp_str;
if (route->blackhole) {
strncat(log_msg, "blackhole ", 30);
}
if (route->dst) {
tmp_str = ipaddresstos(route->dst);
snprintf(tmp, INET6_ADDRSTRLEN + 30, "%s/%d", tmp_str, route->dmask);
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
FREE(tmp_str);
}
if (route->gw) {
tmp_str = ipaddresstos(route->gw);
snprintf(tmp, INET6_ADDRSTRLEN + 30, " gw %s", tmp_str);
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
FREE(tmp_str);
}
if (route->gw2) {
tmp_str = ipaddresstos(route->gw2);
snprintf(tmp, INET6_ADDRSTRLEN + 30, " or gw %s", tmp_str);
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
FREE(tmp_str);
}
if (route->src) {
tmp_str = ipaddresstos(route->src);
snprintf(tmp, INET6_ADDRSTRLEN + 30, " src %s", tmp_str);
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
FREE(tmp_str);
}
if (route->index) {
snprintf(tmp, INET6_ADDRSTRLEN + 30, " dev %s",
IF_NAME(if_get_by_ifindex(route->index)));
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
}
if (route->table) {
snprintf(tmp, INET6_ADDRSTRLEN + 30, " table %d", route->table);
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
}
if (route->scope) {
snprintf(tmp, INET6_ADDRSTRLEN + 30, " scope %s",
netlink_scope_n2a(route->scope));
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
}
if (route->metric) {
snprintf(tmp, INET6_ADDRSTRLEN + 30, " metric %d", route->metric);
strncat(log_msg, tmp, INET6_ADDRSTRLEN + 30);
}
log_message(LOG_INFO, " %s", log_msg);
FREE(tmp);
FREE(log_msg);
}
开发者ID:jadderbao,项目名称:keepalived,代码行数:59,代码来源:vrrp_iproute.c
示例12: vrrp_log_int_up
static void vrrp_log_int_up(vrrp_t *vrrp)
{
if (IF_ISUP(vrrp->ifp))
log_message(LOG_INFO, "Kernel is reporting: interface %s UP",
IF_NAME(vrrp->ifp));
if (!LIST_ISEMPTY(vrrp->track_ifp))
log_message(LOG_INFO, "Kernel is reporting: tracked interface are UP");
}
开发者ID:Olipro,项目名称:keepalived,代码行数:8,代码来源:vrrp_scheduler.c
示例13: ism_ignore
static int
ism_ignore (struct ospf_interface *oi)
{
if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
zlog (NULL, LOG_DEBUG, "ISM[%s]: ism_ignore called", IF_NAME (oi));
return 0;
}
开发者ID:ColinBS,项目名称:quagga-rtrlib,代码行数:8,代码来源:ospf_ism.c
示例14: vrrp_log_int_down
/* Log interface message */
static void vrrp_log_int_down(vrrp_t *vrrp)
{
if (!IF_ISUP(vrrp->ifp))
log_message(LOG_INFO, "Kernel is reporting: interface %s DOWN",
IF_NAME(vrrp->ifp));
if (!LIST_ISEMPTY(vrrp->track_ifp))
vrrp_log_tracked_down(vrrp->track_ifp);
}
开发者ID:Olipro,项目名称:keepalived,代码行数:9,代码来源:vrrp_scheduler.c
示例15: ism_change_state
void
ism_change_state (struct ospf_interface *oi, int state)
{
int old_state;
struct ospf_lsa *lsa;
/* Logging change of state. */
if (IS_DEBUG_OSPF (ism, ISM_STATUS))
zlog (NULL, LOG_DEBUG, "ISM[%s]: State change %s -> %s", IF_NAME (oi),
LOOKUP (ospf_ism_state_msg, oi->state),
LOOKUP (ospf_ism_state_msg, state));
old_state = oi->state;
oi->state = state;
oi->state_change++;
if (old_state == ISM_Down || state == ISM_Down)
ospf_check_abr_status (oi->ospf);
/* Originate router-LSA. */
if (oi->area)
{
if (state == ISM_Down)
{
if (oi->area->act_ints > 0)
oi->area->act_ints--;
}
else if (old_state == ISM_Down)
oi->area->act_ints++;
/* schedule router-LSA originate. */
ospf_router_lsa_timer_add (oi->area);
}
/* Originate network-LSA. */
if (old_state != ISM_DR && state == ISM_DR)
ospf_network_lsa_timer_add (oi);
else if (old_state == ISM_DR && state != ISM_DR)
{
/* Free self originated network LSA. */
lsa = oi->network_lsa_self;
if (lsa)
{
ospf_lsa_flush_area (lsa, oi->area);
OSPF_TIMER_OFF (oi->t_network_lsa_self);
}
ospf_lsa_unlock (oi->network_lsa_self);
oi->network_lsa_self = NULL;
}
#ifdef HAVE_OPAQUE_LSA
ospf_opaque_ism_change (oi, old_state);
#endif /* HAVE_OPAQUE_LSA */
/* Check area border status. */
ospf_check_abr_status (oi->ospf);
}
开发者ID:inet-framework,项目名称:inet-quagga,代码行数:58,代码来源:ospf_ism.c
示例16: nsm_ignore
/* OSPF NSM functions. */
int
nsm_ignore (struct ospf_neighbor *nbr)
{
if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
zlog (NULL, LOG_DEBUG, "NSM[%s:%s]: nsm_ignore called",
IF_NAME (nbr->oi), inet_ntoa (nbr->router_id));
return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:10,代码来源:ospf_nsm.c
示例17: route_print
void
route_print(FILE *file, void *data)
{
ip_route_t *route = data;
char *msg = MALLOC(150);
char *tmp = MALLOC(30);
if (route->blackhole) {
strncat(msg, "blackhole ", 30);
}
if (route->dst) {
snprintf(tmp, 30, "%s/%d", ipaddresstos(route->dst),
route->dmask);
strncat(msg, tmp, 30);
}
if (route->gw) {
snprintf(tmp, 30, " gw %s", ipaddresstos(route->gw));
strncat(msg, tmp, 30);
}
if (route->gw2) {
snprintf(tmp, 30, " or gw %s", ipaddresstos(route->gw2));
strncat(msg, tmp, 30);
}
if (route->src) {
snprintf(tmp, 30, " src %s", ipaddresstos(route->src));
strncat(msg, tmp, 30);
}
if (route->index) {
snprintf(tmp, 30, " dev %s",
IF_NAME(if_get_by_ifindex(route->index)));
strncat(msg, tmp, 30);
}
if (route->table) {
snprintf(tmp, 30, " table %d", route->table);
strncat(msg, tmp, 30);
}
if (route->scope) {
snprintf(tmp, 30, " scope %s",
netlink_scope_n2a(route->scope));
strncat(msg, tmp, 30);
}
if (route->metric) {
snprintf(tmp, 30, " metric %d", route->metric);
strncat(msg, tmp, 30);
}
fprintf(file, " %s\n", msg);
FREE(tmp);
FREE(msg);
}
开发者ID:jwalzer,项目名称:keepalived,代码行数:52,代码来源:vrrp_print.c
示例18: vrrp_log_tracked_down
/* Log tracked interface down */
void
vrrp_log_tracked_down(list l)
{
element e;
tracked_if *tip;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
tip = ELEMENT_DATA(e);
if (!IF_ISUP(tip->ifp))
log_message(LOG_INFO, "Kernel is reporting: interface %s DOWN",
IF_NAME(tip->ifp));
}
}
开发者ID:jsouthworth,项目名称:keepalived,代码行数:14,代码来源:vrrp_track.c
示例19: ospf_wait_timer
static int ospf_wait_timer(struct thread *thread)
{
struct ospf_interface *oi;
oi = THREAD_ARG(thread);
oi->t_wait = NULL;
if (IS_DEBUG_OSPF(ism, ISM_TIMERS))
zlog(NULL, LOG_DEBUG, "ISM[%s]: Timer (Wait timer expire)",
IF_NAME(oi));
OSPF_ISM_EVENT_SCHEDULE(oi, ISM_WaitTimer);
return 0;
}
开发者ID:yubo,项目名称:quagga,代码行数:15,代码来源:ospf_ism.c
示例20: ospf_inactivity_timer
/* OSPF NSM Timer functions. */
int
ospf_inactivity_timer (struct thread *thread)
{
struct ospf_neighbor *nbr;
nbr = THREAD_ARG (thread);
nbr->t_inactivity = NULL;
if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
zlog (NULL, LOG_DEBUG, "NSM[%s:%s]: Timer (Inactivity timer expire)",
IF_NAME (nbr->oi), inet_ntoa (nbr->router_id));
OSPF_NSM_EVENT_SCHEDULE (nbr, NSM_InactivityTimer);
return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:17,代码来源:ospf_nsm.c
注:本文中的IF_NAME函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论