{
char buf[INET6_ADDRSTRLEN];
p = ifc->address;
- vty_out (vty, " ip%s address %s/%d",
+ vty_out (vty, " ip%s address %s",
p->family == AF_INET ? "" : "v6",
- inet_ntop (p->family, &p->u.prefix, buf, sizeof(buf)),
- p->prefixlen);
+ prefix2str (p, buf, sizeof(buf)));
if (ifc->label)
vty_out (vty, " label %s", ifc->label);
int
if_prefix_add_ipv6 (struct interface *ifp, struct connected *ifc)
{
- char addrbuf[INET_ADDRSTRLEN];
+ char addrbuf[PREFIX_STRLEN];
- inet_ntop (AF_INET6, &(((struct prefix_ipv6 *) (ifc->address))->prefix),
- addrbuf, sizeof (addrbuf));
- zlog_warn ("Can't set %s on interface %s", addrbuf, ifp->name);
+ zlog_warn ("Can't set %s on interface %s",
+ prefix2str(ifc->address->prefix, addrbuf, sizeof(addrbuf)),
+ ifp->name);
return 0;
int
if_prefix_delete_ipv6 (struct interface *ifp, struct connected *ifc)
{
- char addrbuf[INET_ADDRSTRLEN];
+ char addrbuf[PREFIX_STRLEN];
- inet_ntop (AF_INET6, &(((struct prefix_ipv6 *) (ifc->address))->prefix),
- addrbuf, sizeof (addrbuf));
- zlog_warn ("Can't delete %s on interface %s", addrbuf, ifp->name);
+ zlog_warn ("Can't delete %s on interface %s",
+ prefix2str(ifc->address->prefix, addrbuf, sizeof(addrbuf)),
+ ifp->name);
return 0;
{
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
+ char buf[PREFIX_STRLEN];
u_int32_t dst;
u_int32_t ttl=1;
dst = htonl(INADDR_ALLHOSTS_GROUP);
if(irdp->flags & IF_DEBUG_MESSAGES)
- zlog_debug("IRDP: TX Advert on %s %s/%d Holdtime=%d Preference=%d",
+ zlog_debug("IRDP: TX Advert on %s %s Holdtime=%d Preference=%d",
ifp->name,
- inet_ntoa(p->u.prefix4),
- p->prefixlen,
+ prefix2str(p, buf, sizeof buf),
irdp->flags & IF_SHUTDOWN? 0 : irdp->Lifetime,
get_pref(irdp, p));
if (IS_ZEBRA_DEBUG_KERNEL)
{
- switch (sockunion_family(addr))
+ int family = sockunion_family(addr);
+ switch (family)
{
case AF_INET:
- {
- char buf[4][INET_ADDRSTRLEN];
- zlog_debug ("%s: ifindex %d, ifname %s, ifam_addrs 0x%x, "
- "ifam_flags 0x%x, addr %s/%d broad %s dst %s "
- "gateway %s",
- __func__, ifm->ifam_index,
- (ifnlen ? ifname : "(nil)"), ifm->ifam_addrs,
- ifm->ifam_flags,
- inet_ntop(AF_INET,&addr->sin.sin_addr,
- buf[0],sizeof(buf[0])),
- ip_masklen(mask->sin.sin_addr),
- inet_ntop(AF_INET,&brd->sin.sin_addr,
- buf[1],sizeof(buf[1])),
- inet_ntop(AF_INET,&dst.sin.sin_addr,
- buf[2],sizeof(buf[2])),
- inet_ntop(AF_INET,&gateway.sin.sin_addr,
- buf[3],sizeof(buf[3])));
- }
- break;
#ifdef HAVE_IPV6
case AF_INET6:
+#endif
{
char buf[4][INET6_ADDRSTRLEN];
zlog_debug ("%s: ifindex %d, ifname %s, ifam_addrs 0x%x, "
"ifam_flags 0x%x, addr %s/%d broad %s dst %s "
"gateway %s",
- __func__, ifm->ifam_index,
+ __func__, ifm->ifam_index,
(ifnlen ? ifname : "(nil)"), ifm->ifam_addrs,
ifm->ifam_flags,
- inet_ntop(AF_INET6,&addr->sin6.sin6_addr,
+ inet_ntop(family,&addr->sin.sin_addr,
buf[0],sizeof(buf[0])),
- ip6_masklen(mask->sin6.sin6_addr),
- inet_ntop(AF_INET6,&brd->sin6.sin6_addr,
+ ip_masklen(mask->sin.sin_addr),
+ inet_ntop(family,&brd->sin.sin_addr,
buf[1],sizeof(buf[1])),
- inet_ntop(AF_INET6,&dst.sin6.sin6_addr,
+ inet_ntop(family,&dst.sin.sin_addr,
buf[2],sizeof(buf[2])),
- inet_ntop(AF_INET6,&gateway.sin6.sin6_addr,
+ inet_ntop(family,&gateway.sin.sin_addr,
buf[3],sizeof(buf[3])));
}
break;
-#endif /* HAVE_IPV6 */
default:
zlog_debug ("%s: ifindex %d, ifname %s, ifam_addrs 0x%x",
__func__, ifm->ifam_index,
*/
if (rtm->rtm_type != RTM_GET && rtm->rtm_pid == pid)
{
- char buf[PREFIX2STR_BUFFER], gate_buf[INET_ADDRSTRLEN];
+ char buf[PREFIX_STRLEN], gate_buf[INET_ADDRSTRLEN];
int ret;
if (! IS_ZEBRA_DEBUG_RIB)
return;
switch (ret)
{
case ZEBRA_RIB_NOTFOUND:
- zlog_debug ("%s: %s %s/%d: desync: RR isn't yet in RIB, while already in FIB",
- __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+ zlog_debug ("%s: %s %s: desync: RR isn't yet in RIB, while already in FIB",
+ __func__, lookup (rtm_type_str, rtm->rtm_type), buf);
break;
case ZEBRA_RIB_FOUND_CONNECTED:
case ZEBRA_RIB_FOUND_NOGATE:
inet_ntop (AF_INET, &gate.sin.sin_addr, gate_buf, INET_ADDRSTRLEN);
- zlog_debug ("%s: %s %s/%d: desync: RR is in RIB, but gate differs (ours is %s)",
- __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen, gate_buf);
+ zlog_debug ("%s: %s %s: desync: RR is in RIB, but gate differs (ours is %s)",
+ __func__, lookup (rtm_type_str, rtm->rtm_type), buf, gate_buf);
break;
case ZEBRA_RIB_FOUND_EXACT: /* RIB RR == FIB RR */
- zlog_debug ("%s: %s %s/%d: done Ok",
- __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+ zlog_debug ("%s: %s %s: done Ok",
+ __func__, lookup (rtm_type_str, rtm->rtm_type), buf);
rib_lookup_and_dump (&p);
return;
break;
switch (ret)
{
case ZEBRA_RIB_FOUND_EXACT:
- zlog_debug ("%s: %s %s/%d: desync: RR is still in RIB, while already not in FIB",
- __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+ zlog_debug ("%s: %s %s: desync: RR is still in RIB, while already not in FIB",
+ __func__, lookup (rtm_type_str, rtm->rtm_type), buf);
rib_lookup_and_dump (&p);
break;
case ZEBRA_RIB_FOUND_CONNECTED:
case ZEBRA_RIB_FOUND_NOGATE:
- zlog_debug ("%s: %s %s/%d: desync: RR is still in RIB, plus gate differs",
- __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+ zlog_debug ("%s: %s %s: desync: RR is still in RIB, plus gate differs",
+ __func__, lookup (rtm_type_str, rtm->rtm_type), buf);
rib_lookup_and_dump (&p);
break;
case ZEBRA_RIB_NOTFOUND: /* RIB RR == FIB RR */
- zlog_debug ("%s: %s %s/%d: done Ok",
- __func__, lookup (rtm_type_str, rtm->rtm_type), buf, p.prefixlen);
+ zlog_debug ("%s: %s %s: done Ok",
+ __func__, lookup (rtm_type_str, rtm->rtm_type), buf);
rib_lookup_and_dump (&p);
return;
break;
}
break;
default:
- zlog_debug ("%s: %s/%d: warning: loopback RTM of type %s received",
- __func__, buf, p.prefixlen, lookup (rtm_type_str, rtm->rtm_type));
+ zlog_debug ("%s: %s: warning: loopback RTM of type %s received",
+ __func__, buf, lookup (rtm_type_str, rtm->rtm_type));
}
return;
}
if (IS_ZEBRA_DEBUG_EVENT)
{
- char buf[INET6_ADDRSTRLEN];
+ char buf[PREFIX_STRLEN];
p = ifc->address;
- zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s/%d on %s",
- inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN),
- p->prefixlen, ifc->ifp->name);
+ zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD %s on %s",
+ prefix2str (p, buf, sizeof(buf)),
+ ifc->ifp->name);
}
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_REAL))
if (IS_ZEBRA_DEBUG_EVENT)
{
- char buf[INET6_ADDRSTRLEN];
+ char buf[PREFIX_STRLEN];
p = ifc->address;
- zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s/%d on %s",
- inet_ntop (p->family, &p->u.prefix, buf, INET6_ADDRSTRLEN),
- p->prefixlen, ifc->ifp->name);
+ zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADDRESS_DELETE %s on %s",
+ prefix2str (p, buf, sizeof(buf)),
+ ifc->ifp->name);
}
router_id_del_address(ifc);
if (IS_ZEBRA_DEBUG_KERNEL)
{
- char buf[PREFIX2STR_BUFFER];
+ char buf[PREFIX_STRLEN];
zlog_debug ("%s %s vrf %u",
h->nlmsg_type == RTM_NEWROUTE ? "RTM_NEWROUTE" : "RTM_DELROUTE",
prefix2str (&p, buf, sizeof(buf)), vrf_id);
if (rtm->rtm_family == AF_INET6)
{
struct prefix_ipv6 p;
- char buf[PREFIX2STR_BUFFER];
p.family = AF_INET6;
memcpy (&p.prefix, dest, 16);
if (IS_ZEBRA_DEBUG_KERNEL)
{
+ char buf[PREFIX_STRLEN];
zlog_debug ("%s %s vrf %u",
h->nlmsg_type == RTM_NEWROUTE ? "RTM_NEWROUTE" : "RTM_DELROUTE",
prefix2str (&p, buf, sizeof(buf)), vrf_id);
{
if (IS_ZEBRA_DEBUG_KERNEL)
{
- zlog_debug ("netlink_route_multipath() (%s): %s %s/%d vrf %u type %s",
- routedesc,
- lookup (nlmsg_str, cmd),
-#ifdef HAVE_IPV6
- (family == AF_INET) ? inet_ntoa (p->u.prefix4) :
- inet6_ntoa (p->u.prefix6),
-#else
- inet_ntoa (p->u.prefix4),
-#endif /* HAVE_IPV6 */
- p->prefixlen, zvrf->vrf_id, nexthop_type_to_str (nexthop->type));
+ char buf[PREFIX_STRLEN];
+ zlog_debug ("netlink_route_multipath() (%s): %s %s vrf %u type %s",
+ routedesc,
+ lookup (nlmsg_str, cmd),
+ prefix2str (p, buf, sizeof(buf)),
+ zvrf->vrf_id, nexthop_type_to_str (nexthop->type));
}
}
unsigned int ifindex = 0;
int gate = 0;
int error;
- char prefix_buf[INET_ADDRSTRLEN];
+ char prefix_buf[PREFIX_STRLEN];
if (IS_ZEBRA_DEBUG_RIB)
- inet_ntop (AF_INET, &p->u.prefix, prefix_buf, INET_ADDRSTRLEN);
+ prefix2str (p, prefix_buf, sizeof(prefix_buf));
memset (&sin_dest, 0, sizeof (struct sockaddr_in));
sin_dest.sin_family = AF_INET;
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
{
if (!gate)
{
- zlog_debug ("%s: %s/%d: attention! gate not found for rib %p",
- __func__, prefix_buf, p->prefixlen, rib);
+ zlog_debug ("%s: %s: attention! gate not found for rib %p",
+ __func__, prefix_buf, rib);
rib_dump (p, rib);
}
else
case ZEBRA_ERR_NOERROR:
nexthop_num++;
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug ("%s: %s/%d: successfully did NH %s",
- __func__, prefix_buf, p->prefixlen, gate_buf);
+ zlog_debug ("%s: %s: successfully did NH %s",
+ __func__, prefix_buf, gate_buf);
if (cmd == RTM_ADD)
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
break;
case ZEBRA_ERR_RTNOEXIST:
case ZEBRA_ERR_RTUNREACH:
default:
- /* This point is reachable regardless of debugging mode. */
- if (!IS_ZEBRA_DEBUG_RIB)
- inet_ntop (AF_INET, &p->u.prefix, prefix_buf, INET_ADDRSTRLEN);
- zlog_err ("%s: %s/%d: rtm_write() unexpectedly returned %d for command %s",
- __func__, prefix_buf, p->prefixlen, error, lookup (rtm_type_str, cmd));
+ zlog_err ("%s: %s: rtm_write() unexpectedly returned %d for command %s",
+ __func__, prefix2str(p, prefix_buf, sizeof(prefix_buf)),
+ error, lookup (rtm_type_str, cmd));
break;
}
} /* if (cmd and flags make sense) */
struct zebra_if *zif;
struct listnode *node;
struct rtadv_prefix *rprefix;
- u_char buf[INET6_ADDRSTRLEN];
+ char buf[PREFIX_STRLEN];
int interval;
zif = ifp->info;
for (ALL_LIST_ELEMENTS_RO (zif->rtadv.AdvPrefixList, node, rprefix))
{
- vty_out (vty, " ipv6 nd prefix %s/%d",
- inet_ntop (AF_INET6, &rprefix->prefix.prefix,
- (char *) buf, INET6_ADDRSTRLEN),
- rprefix->prefix.prefixlen);
+ vty_out (vty, " ipv6 nd prefix %s",
+ prefix2str (&rprefix->prefix, buf, sizeof(buf)));
if ((rprefix->AdvValidLifetime != RTADV_VALID_LIFETIME) ||
(rprefix->AdvPreferredLifetime != RTADV_PREFERRED_LIFETIME))
{
zfpm_trigger_update (struct route_node *rn, const char *reason)
{
rib_dest_t *dest;
- char buf[INET6_ADDRSTRLEN];
+ char buf[PREFIX_STRLEN];
/*
* Ignore if the connection is down. We will update the FPM about
if (reason)
{
- zfpm_debug ("%s/%d triggering update to FPM - Reason: %s",
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, sizeof (buf)),
- rn->p.prefixlen, reason);
+ zfpm_debug ("%s triggering update to FPM - Reason: %s",
+ prefix2str (&rn->p, buf, sizeof(buf)), reason);
}
SET_FLAG (dest->flags, RIB_DEST_UPDATE_FPM);
_rnode_zlog(const char *_func, vrf_id_t vrf_id, struct route_node *rn, int priority,
const char *msgfmt, ...)
{
- char buf[INET6_ADDRSTRLEN + 4], *bptr;
+ char buf[PREFIX_STRLEN + 8];
char msgbuf[512];
va_list ap;
{
rib_table_info_t *info = rn->table->info;
- inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN);
- bptr = buf + strlen(buf);
- snprintf(bptr, buf + sizeof(buf) - bptr, "/%d%s", rn->p.prefixlen,
- info->safi == SAFI_MULTICAST ? " (MRIB)" : "");
+ prefix2str(&rn->p, buf, sizeof(buf));
+ if (info->safi == SAFI_MULTICAST)
+ strcat(buf, " (MRIB)");
}
else
{
union prefix46constptr pp, const struct rib * rib)
{
const struct prefix *p = pp.p;
- char straddr[PREFIX2STR_BUFFER];
+ char straddr[PREFIX_STRLEN];
struct nexthop *nexthop, *tnexthop;
int recursing;
return;
}
- inet_ntop (AF_INET, &p->prefix.s_addr, prefix_buf, INET_ADDRSTRLEN);
/* Scan the RIB table for exactly matching RIB entry. */
rn = route_node_lookup (table, (struct prefix *) p);
/* No route for this prefix. */
if (! rn)
{
- zlog_debug ("%s: lookup failed for %s/%d", __func__, prefix_buf, p->prefixlen);
+ zlog_debug ("%s: lookup failed for %s", __func__,
+ prefix2str((struct prefix*) p, prefix_buf, sizeof(prefix_buf)));
return;
}
changed = 1;
if (IS_ZEBRA_DEBUG_RIB)
{
- char buf[INET_ADDRSTRLEN];
- inet_ntop (rn->p.family, &p->prefix, buf, INET_ADDRSTRLEN);
- zlog_debug ("%u:%s/%d: freeing way for connected prefix",
- rib->vrf_id, buf, p->prefixlen);
+ char buf[PREFIX_STRLEN];
+ zlog_debug ("%u:%s: freeing way for connected prefix",
+ rib->vrf_id, prefix2str(&rn->p, buf, sizeof(buf)));
rib_dump (&rn->p, rib);
}
rib_uninstall (rn, rib);
struct rib *same = NULL;
struct nexthop *nexthop, *tnexthop;
int recursing;
- char buf1[PREFIX2STR_BUFFER];
+ char buf1[PREFIX_STRLEN];
char buf2[INET6_ADDRSTRLEN];
/* Lookup table. */
if (! rn)
{
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug ("%u:%s/%d: doesn't exist in rib",
- vrf_id, inet_ntop (p->family, &p->prefix, buf1, INET6_ADDRSTRLEN),
- p->prefixlen);
+ zlog_debug ("%u:%s: doesn't exist in rib",
+ vrf_id, prefix2str (p, buf1, sizeof(buf1)));
return ZEBRA_ERR_RTNOEXIST;
}
if (gate)
zlog_debug ("%u:%s: via %s ifindex %d type %d "
"doesn't exist in rib",
- vrf_id, prefix2str (p, buf1, sizeof(buf1)),
- inet_ntop (AF_INET, gate, buf2, INET_ADDRSTRLEN),
- ifindex,
- type);
+ vrf_id, prefix2str (p, buf1, sizeof(buf1)),
+ inet_ntop (AF_INET, gate, buf2, INET_ADDRSTRLEN),
+ ifindex,
+ type);
else
zlog_debug ("%u:%s: ifindex %d type %d doesn't exist in rib",
- vrf_id, prefix2str (p, buf1, sizeof(buf1)),
- ifindex,
- type);
+ vrf_id, prefix2str (p, buf1, sizeof(buf1)),
+ ifindex,
+ type);
}
route_unlock_node (rn);
return ZEBRA_ERR_RTNOEXIST;
struct rib *same = NULL;
struct nexthop *nexthop, *tnexthop;
int recursing;
- char buf1[PREFIX2STR_BUFFER];
+ char buf1[PREFIX_STRLEN];
char buf2[INET6_ADDRSTRLEN];
/* Apply mask. */
if (! rn)
{
if (IS_ZEBRA_DEBUG_RIB)
- zlog_debug ("%u:%s/%d: doesn't exist in rib",
- vrf_id, inet_ntop (p->family, &p->prefix, buf1, INET6_ADDRSTRLEN),
- p->prefixlen);
+ zlog_debug ("%u:%s: doesn't exist in rib",
+ vrf_id, prefix2str (p, buf1, sizeof(buf1)));
return ZEBRA_ERR_RTNOEXIST;
}
{
if (gate)
zlog_debug ("%s: vrf %u via %s ifindex %d type %d "
- "doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)), vrf_id,
- inet_ntop (AF_INET6, gate, buf2, INET6_ADDRSTRLEN),
- ifindex,
- type);
+ "doesn't exist in rib",
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
+ inet_ntop (AF_INET6, gate, buf2, INET6_ADDRSTRLEN),
+ ifindex,
+ type);
else
zlog_debug ("%s: vrf %u ifindex %d type %d doesn't exist in rib",
- prefix2str (p, buf1, sizeof(buf1)), vrf_id,
- ifindex,
- type);
+ prefix2str (p, buf1, sizeof(buf1)), vrf_id,
+ ifindex,
+ type);
}
route_unlock_node (rn);
return ZEBRA_ERR_RTNOEXIST;