本文整理汇总了C++中pim_inet4_dump函数的典型用法代码示例。如果您正苦于以下问题:C++ pim_inet4_dump函数的具体用法?C++ pim_inet4_dump怎么用?C++ pim_inet4_dump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pim_inet4_dump函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pim_assert_build_msg
int pim_assert_build_msg(uint8_t *pim_msg, int buf_size,
struct interface *ifp,
struct in_addr group_addr,
struct in_addr source_addr,
uint32_t metric_preference,
uint32_t route_metric,
uint32_t rpt_bit_flag)
{
uint8_t *buf_pastend = pim_msg + buf_size;
uint8_t *pim_msg_curr;
int pim_msg_size;
int remain;
pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN; /* skip room for pim header */
/* Encode group */
remain = buf_pastend - pim_msg_curr;
pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
remain,
group_addr);
if (!pim_msg_curr) {
char group_str[100];
pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
zlog_warn("%s: failure encoding group address %s: space left=%d",
__PRETTY_FUNCTION__, group_str, remain);
return -1;
}
/* Encode source */
remain = buf_pastend - pim_msg_curr;
pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
remain,
source_addr);
if (!pim_msg_curr) {
char source_str[100];
pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
zlog_warn("%s: failure encoding source address %s: space left=%d",
__PRETTY_FUNCTION__, source_str, remain);
return -2;
}
/* Metric preference */
pim_write_uint32(pim_msg_curr, rpt_bit_flag ?
metric_preference | 0x80000000 :
metric_preference);
pim_msg_curr += 4;
/* Route metric */
pim_write_uint32(pim_msg_curr, route_metric);
pim_msg_curr += 4;
/*
Add PIM header
*/
pim_msg_size = pim_msg_curr - pim_msg;
pim_msg_build_header(pim_msg, pim_msg_size,
PIM_MSG_TYPE_ASSERT);
return pim_msg_size;
}
示例2: pim_msdp_config_write
/*********************** MSDP feature APIs *********************************/
int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty,
const char *spaces)
{
struct listnode *mbrnode;
struct pim_msdp_mg_mbr *mbr;
struct pim_msdp_mg *mg = pim->msdp.mg;
char mbr_str[INET_ADDRSTRLEN];
char src_str[INET_ADDRSTRLEN];
int count = 0;
if (!mg) {
return count;
}
if (mg->src_ip.s_addr != INADDR_ANY) {
pim_inet4_dump("<src?>", mg->src_ip, src_str, sizeof(src_str));
vty_out(vty, "%sip msdp mesh-group %s source %s\n", spaces,
mg->mesh_group_name, src_str);
++count;
}
for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) {
pim_inet4_dump("<mbr?>", mbr->mbr_ip, mbr_str, sizeof(mbr_str));
vty_out(vty, "%sip msdp mesh-group %s member %s\n", spaces,
mg->mesh_group_name, mbr_str);
++count;
}
return count;
}
示例3: pim_forward_stop
void pim_forward_stop(struct pim_ifchannel *ch)
{
struct pim_upstream *up = ch->upstream;
if (PIM_DEBUG_PIM_TRACE) {
char source_str[100];
char group_str[100];
pim_inet4_dump("<source?>", ch->source_addr, source_str, sizeof(source_str));
pim_inet4_dump("<group?>", ch->group_addr, group_str, sizeof(group_str));
zlog_debug("%s: (S,G)=(%s,%s) oif=%s",
__PRETTY_FUNCTION__,
source_str, group_str, ch->interface->name);
}
if (!up->channel_oil) {
char source_str[100];
char group_str[100];
pim_inet4_dump("<source?>", ch->source_addr, source_str, sizeof(source_str));
pim_inet4_dump("<group?>", ch->group_addr, group_str, sizeof(group_str));
zlog_warn("%s: (S,G)=(%s,%s) oif=%s missing channel OIL",
__PRETTY_FUNCTION__,
source_str, group_str, ch->interface->name);
return;
}
del_oif(up->channel_oil,
ch->interface,
PIM_OIF_FLAG_PROTO_PIM);
}
示例4: send_join
static void send_join(struct pim_upstream *up)
{
zassert(up->join_state == PIM_UPSTREAM_JOINED);
if (PIM_DEBUG_PIM_TRACE) {
if (PIM_INADDR_IS_ANY(up->rpf.rpf_addr)) {
char src_str[100];
char grp_str[100];
char rpf_str[100];
pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
pim_inet4_dump("<rpf?>", up->rpf.rpf_addr, rpf_str, sizeof(rpf_str));
zlog_warn("%s: can't send join upstream: RPF'(%s,%s)=%s",
__PRETTY_FUNCTION__,
src_str, grp_str, rpf_str);
/* warning only */
}
}
/* send Join(S,G) to the current upstream neighbor */
pim_joinprune_send(up->rpf.source_nexthop.interface,
up->rpf.rpf_addr,
up->source_addr,
up->group_addr,
1 /* join */);
}
示例5: on_primary_address_change
static void on_primary_address_change(struct interface *ifp,
const char *caller,
struct in_addr old_addr,
struct in_addr new_addr)
{
struct pim_interface *pim_ifp;
{
char old_str[100];
char new_str[100];
pim_inet4_dump("<old?>", old_addr, old_str, sizeof(old_str));
pim_inet4_dump("<new?>", new_addr, new_str, sizeof(new_str));
zlog_info("%s: %s: primary address changed from %s to %s on interface %s",
__PRETTY_FUNCTION__, caller,
old_str, new_str, ifp->name);
}
pim_ifp = ifp->info;
if (!pim_ifp) {
return;
}
if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
return;
}
pim_addr_change(ifp);
}
示例6: pim_assert_timer_set
static void pim_assert_timer_set(struct pim_ifchannel *ch,
int interval)
{
struct interface *ifp;
zassert(ch);
ifp = ch->interface;
zassert(ifp);
assert_timer_off(ch);
if (PIM_DEBUG_PIM_TRACE) {
char src_str[100];
char grp_str[100];
pim_inet4_dump("<src?>", ch->source_addr, src_str, sizeof(src_str));
pim_inet4_dump("<grp?>", ch->group_addr, grp_str, sizeof(grp_str));
zlog_debug("%s: (S,G)=(%s,%s) starting %u sec timer on interface %s",
__PRETTY_FUNCTION__,
src_str, grp_str, interval, ifp->name);
}
THREAD_TIMER_ON(master, ch->t_ifassert_timer,
on_assert_timer,
ch, interval);
}
示例7: pim_if_find_by_vif_index
static struct channel_oil *channel_oil_new(struct in_addr group_addr,
struct in_addr source_addr,
int input_vif_index)
{
struct channel_oil *c_oil;
struct interface *ifp_in;
ifp_in = pim_if_find_by_vif_index(input_vif_index);
if (!ifp_in) {
/* warning only */
char group_str[100];
char source_str[100];
pim_inet4_dump("<group?>", group_addr, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", source_addr, source_str, sizeof(source_str));
zlog_warn("%s: (S,G)=(%s,%s) could not find input interface for input_vif_index=%d",
__PRETTY_FUNCTION__,
source_str, group_str, input_vif_index);
}
c_oil = XCALLOC(MTYPE_PIM_CHANNEL_OIL, sizeof(*c_oil));
if (!c_oil) {
zlog_err("PIM XCALLOC(%zu) failure", sizeof(*c_oil));
return 0;
}
c_oil->oil.mfcc_mcastgrp = group_addr;
c_oil->oil.mfcc_origin = source_addr;
c_oil->oil.mfcc_parent = input_vif_index;
c_oil->oil_ref_count = 1;
zassert(c_oil->oil_size == 0);
return c_oil;
}
示例8: pim_igmp_general_query
/* Issue IGMP general query */
static int pim_igmp_general_query(struct thread *t)
{
char query_buf[PIM_IGMP_BUFSIZE_WRITE];
struct igmp_sock *igmp;
struct in_addr dst_addr;
struct in_addr group_addr;
struct pim_interface *pim_ifp;
zassert(t);
igmp = THREAD_ARG(t);
zassert(igmp);
zassert(igmp->interface);
zassert(igmp->interface->info);
pim_ifp = igmp->interface->info;
/*
RFC3376: 4.1.12. IP Destination Addresses for Queries
In IGMPv3, General Queries are sent with an IP destination address
of 224.0.0.1, the all-systems multicast address. Group-Specific
and Group-and-Source-Specific Queries are sent with an IP
destination address equal to the multicast address of interest.
*/
dst_addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP);
group_addr.s_addr = PIM_NET_INADDR_ANY;
if (PIM_DEBUG_IGMP_TRACE) {
char querier_str[100];
char dst_str[100];
pim_inet4_dump("<querier?>", igmp->ifaddr, querier_str,
sizeof(querier_str));
pim_inet4_dump("<dst?>", dst_addr, dst_str, sizeof(dst_str));
zlog_debug("Querier %s issuing IGMP general query to %s on %s",
querier_str, dst_str, igmp->interface->name);
}
pim_igmp_send_membership_query(0 /* igmp_group */,
igmp->fd,
igmp->interface->name,
query_buf,
sizeof(query_buf),
0 /* num_sources */,
dst_addr,
group_addr,
pim_ifp->igmp_query_max_response_time_dsec,
1 /* s_flag: always set for general queries */,
igmp->querier_robustness_variable,
igmp->querier_query_interval);
pim_igmp_general_query_on(igmp);
return 0;
}
示例9: pim_msg_send
int pim_msg_send(int fd,
struct in_addr dst,
uint8_t *pim_msg,
int pim_msg_size,
const char *ifname)
{
ssize_t sent;
struct sockaddr_in to;
socklen_t tolen;
if (PIM_DEBUG_PIM_PACKETS) {
char dst_str[100];
pim_inet4_dump("<dst?>", dst, dst_str, sizeof(dst_str));
zlog_debug("%s: to %s on %s: msg_size=%d checksum=%x",
__PRETTY_FUNCTION__,
dst_str, ifname, pim_msg_size,
*(uint16_t *) PIM_MSG_HDR_OFFSET_CHECKSUM(pim_msg));
}
#if 0
memset(&to, 0, sizeof(to));
#endif
to.sin_family = AF_INET;
to.sin_addr = dst;
#if 0
to.sin_port = htons(0);
#endif
tolen = sizeof(to);
if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
pim_pkt_dump(__PRETTY_FUNCTION__, pim_msg, pim_msg_size);
}
sent = sendto(fd, pim_msg, pim_msg_size, MSG_DONTWAIT,
(struct sockaddr *)&to, tolen);
if (sent != (ssize_t) pim_msg_size) {
int e = errno;
char dst_str[100];
pim_inet4_dump("<dst?>", dst, dst_str, sizeof(dst_str));
if (sent < 0) {
zlog_warn("%s: sendto() failure to %s on %s: fd=%d msg_size=%d: errno=%d: %s",
__PRETTY_FUNCTION__,
dst_str, ifname, fd, pim_msg_size,
e, safe_strerror(e));
}
else {
zlog_warn("%s: sendto() partial to %s on %s: fd=%d msg_size=%d: sent=%zd",
__PRETTY_FUNCTION__,
dst_str, ifname, fd,
pim_msg_size, sent);
}
return -1;
}
return 0;
}
示例10: igmp_source_forward_stop
/*
igmp_source_forward_stop: stop fowarding, but keep the source
igmp_source_delete: stop fowarding, and delete the source
*/
void igmp_source_forward_stop(struct igmp_source *source)
{
struct igmp_group *group;
int result;
if (PIM_DEBUG_IGMP_TRACE) {
char source_str[100];
char group_str[100];
pim_inet4_dump("<source?>", source->source_addr, source_str, sizeof(source_str));
pim_inet4_dump("<group?>", source->source_group->group_addr, group_str, sizeof(group_str));
zlog_debug("%s: (S,G)=(%s,%s) igmp_sock=%d oif=%s fwd=%d",
__PRETTY_FUNCTION__,
source_str, group_str,
source->source_group->group_igmp_sock->fd,
source->source_group->group_igmp_sock->interface->name,
IGMP_SOURCE_TEST_FORWARDING(source->source_flags));
}
/* Prevent IGMP interface from removing multicast route multiple
times */
if (!IGMP_SOURCE_TEST_FORWARDING(source->source_flags)) {
return;
}
group = source->source_group;
/*
It appears that in certain circumstances that
igmp_source_forward_stop is called when IGMP forwarding
was not enabled in oif_flags for this outgoing interface.
Possibly because of multiple calls. When that happens, we
enter the below if statement and this function returns early
which in turn triggers the calling function to assert.
Making the call to del_oif and ignoring the return code
fixes the issue without ill effect, similar to
pim_forward_stop below.
*/
result = del_oif(source->source_channel_oil,
group->group_igmp_sock->interface,
PIM_OIF_FLAG_PROTO_IGMP);
if (result) {
zlog_warn("%s: del_oif() failed with return=%d",
__func__, result);
return;
}
/*
Feed IGMPv3-gathered local membership information into PIM
per-interface (S,G) state.
*/
pim_ifchannel_local_membership_del(group->group_igmp_sock->interface,
source->source_addr, group->group_addr);
IGMP_SOURCE_DONT_FORWARDING(source->source_flags);
}
示例11: pim_if_igmp_join_del
int pim_if_igmp_join_del(struct interface *ifp,
struct in_addr group_addr,
struct in_addr source_addr)
{
struct pim_interface *pim_ifp;
struct igmp_join *ij;
pim_ifp = ifp->info;
if (!pim_ifp) {
zlog_warn("%s: multicast not enabled on interface %s",
__PRETTY_FUNCTION__,
ifp->name);
return -1;
}
if (!pim_ifp->igmp_join_list) {
zlog_warn("%s: no IGMP join on interface %s",
__PRETTY_FUNCTION__,
ifp->name);
return -2;
}
ij = igmp_join_find(pim_ifp->igmp_join_list, group_addr, source_addr);
if (!ij) {
char group_str[100];
char source_str[100];
pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
zlog_warn("%s: could not find IGMP group %s source %s on interface %s",
__PRETTY_FUNCTION__,
group_str, source_str, ifp->name);
return -3;
}
if (close(ij->sock_fd)) {
int e = errno;
char group_str[100];
char source_str[100];
pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
zlog_warn("%s: failure closing sock_fd=%d for IGMP group %s source %s on interface %s: errno=%d: %s",
__PRETTY_FUNCTION__,
ij->sock_fd, group_str, source_str, ifp->name, e, safe_strerror(e));
/* warning only */
}
listnode_delete(pim_ifp->igmp_join_list, ij);
igmp_join_free(ij);
if (listcount(pim_ifp->igmp_join_list) < 1) {
list_delete(pim_ifp->igmp_join_list);
pim_ifp->igmp_join_list = 0;
}
return 0;
}
示例12: delete_from_neigh_addr
/*
RFC 4601: 4.3.4. Maintaining Secondary Address Lists
All the advertised secondary addresses in received Hello messages
must be checked against those previously advertised by all other
PIM neighbors on that interface. If there is a conflict and the
same secondary address was previously advertised by another
neighbor, then only the most recently received mapping MUST be
maintained, and an error message SHOULD be logged to the
administrator in a rate-limited manner.
*/
static void delete_from_neigh_addr(struct interface *ifp,
struct list *addr_list,
struct in_addr neigh_addr)
{
struct listnode *addr_node;
struct prefix *addr;
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
zassert(pim_ifp);
zassert(addr_list);
/*
Scan secondary address list
*/
for (ALL_LIST_ELEMENTS_RO(addr_list, addr_node,
addr)) {
struct listnode *neigh_node;
struct pim_neighbor *neigh;
if (addr->family != AF_INET)
continue;
/*
Scan neighbors
*/
for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neigh_node,
neigh)) {
{
struct prefix *p = pim_neighbor_find_secondary(neigh, addr->u.prefix4);
if (p) {
char addr_str[100];
char this_neigh_str[100];
char other_neigh_str[100];
pim_inet4_dump("<addr?>", addr->u.prefix4, addr_str, sizeof(addr_str));
pim_inet4_dump("<neigh1?>", neigh_addr, this_neigh_str, sizeof(this_neigh_str));
pim_inet4_dump("<neigh2?>", neigh->source_addr, other_neigh_str, sizeof(other_neigh_str));
zlog_info("secondary addr %s recvd from neigh %s deleted from neigh %s on %s",
addr_str, this_neigh_str, other_neigh_str, ifp->name);
listnode_delete(neigh->prefix_list, p);
prefix_free(p);
}
}
} /* scan neighbors */
} /* scan addr list */
}
示例13: pim_msdp_peer_add
/* add peer configuration if it doesn't already exist */
enum pim_msdp_err pim_msdp_peer_add(struct pim_instance *pim,
struct in_addr peer_addr,
struct in_addr local_addr,
const char *mesh_group_name,
struct pim_msdp_peer **mp_p)
{
struct pim_msdp_peer *mp;
if (mp_p) {
*mp_p = NULL;
}
if (peer_addr.s_addr == local_addr.s_addr) {
/* skip session setup if config is invalid */
if (PIM_DEBUG_MSDP_EVENTS) {
char peer_str[INET_ADDRSTRLEN];
pim_inet4_dump("<peer?>", peer_addr, peer_str,
sizeof(peer_str));
zlog_debug("%s add skipped as DIP=SIP", peer_str);
}
return PIM_MSDP_ERR_SIP_EQ_DIP;
}
mp = pim_msdp_peer_find(pim, peer_addr);
if (mp) {
if (mp_p) {
*mp_p = mp;
}
return PIM_MSDP_ERR_PEER_EXISTS;
}
return pim_msdp_peer_new(pim, peer_addr, local_addr, mesh_group_name,
mp_p);
}
示例14: on_neighbor_timer
static int on_neighbor_timer(struct thread *t)
{
struct pim_neighbor *neigh;
struct interface *ifp;
char msg[100];
zassert(t);
neigh = THREAD_ARG(t);
zassert(neigh);
ifp = neigh->interface;
if (PIM_DEBUG_PIM_TRACE) {
char src_str[100];
pim_inet4_dump("<src?>", neigh->source_addr, src_str, sizeof(src_str));
zlog_debug("Expired %d sec holdtime for neighbor %s on interface %s",
neigh->holdtime, src_str, ifp->name);
}
neigh->t_expire_timer = 0;
snprintf(msg, sizeof(msg), "%d-sec holdtime expired", neigh->holdtime);
pim_neighbor_delete(ifp, neigh, msg);
/*
RFC 4601: 4.3.2. DR Election
A router's idea of the current DR on an interface can change when a
PIM Hello message is received, when a neighbor times out, or when a
router's own DR Priority changes.
*/
pim_if_dr_election(ifp); // neighbor times out
return 0;
}
示例15: pim_neighbor_timer_reset
void pim_neighbor_timer_reset(struct pim_neighbor *neigh, uint16_t holdtime)
{
neigh->holdtime = holdtime;
neighbor_timer_off(neigh);
/*
0xFFFF is request for no holdtime
*/
if (neigh->holdtime == 0xFFFF) {
return;
}
if (PIM_DEBUG_PIM_TRACE) {
char src_str[100];
pim_inet4_dump("<src?>", neigh->source_addr, src_str, sizeof(src_str));
zlog_debug("%s: starting %u sec timer for neighbor %s on %s",
__PRETTY_FUNCTION__,
neigh->holdtime, src_str, neigh->interface->name);
}
THREAD_TIMER_ON(master, neigh->t_expire_timer,
on_neighbor_timer,
neigh, neigh->holdtime);
}