mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 06:34:51 +00:00
lib: Convert inet_ntoa to %pI4
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
84de5a245a
commit
af3b34f690
33
lib/filter.c
33
lib/filter.c
@ -576,14 +576,12 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
|
||||
if (filter->addr_mask.s_addr == 0xffffffff)
|
||||
vty_out(vty, " any\n");
|
||||
else {
|
||||
vty_out(vty, " %s",
|
||||
inet_ntoa(filter->addr));
|
||||
vty_out(vty, " %pI4", &filter->addr);
|
||||
if (filter->addr_mask.s_addr
|
||||
!= INADDR_ANY)
|
||||
vty_out(vty,
|
||||
", wildcard bits %s",
|
||||
inet_ntoa(
|
||||
filter->addr_mask));
|
||||
", wildcard bits %pI4",
|
||||
&filter->addr_mask);
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
}
|
||||
@ -625,14 +623,12 @@ static int filter_show(struct vty *vty, const char *name, afi_t afi)
|
||||
if (filter->addr_mask.s_addr == 0xffffffff)
|
||||
vty_out(vty, " any\n");
|
||||
else {
|
||||
vty_out(vty, " %s",
|
||||
inet_ntoa(filter->addr));
|
||||
vty_out(vty, " %pI4", &filter->addr);
|
||||
if (filter->addr_mask.s_addr
|
||||
!= INADDR_ANY)
|
||||
vty_out(vty,
|
||||
", wildcard bits %s",
|
||||
inet_ntoa(
|
||||
filter->addr_mask));
|
||||
", wildcard bits %pI4",
|
||||
&filter->addr_mask);
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
}
|
||||
@ -722,29 +718,28 @@ static void config_write_access_cisco(struct vty *vty, struct filter *mfilter)
|
||||
if (filter->addr_mask.s_addr == 0xffffffff)
|
||||
vty_out(vty, " any");
|
||||
else if (filter->addr_mask.s_addr == INADDR_ANY)
|
||||
vty_out(vty, " host %s", inet_ntoa(filter->addr));
|
||||
vty_out(vty, " host %pI4", &filter->addr);
|
||||
else {
|
||||
vty_out(vty, " %s", inet_ntoa(filter->addr));
|
||||
vty_out(vty, " %s", inet_ntoa(filter->addr_mask));
|
||||
vty_out(vty, " %pI4", &filter->addr);
|
||||
vty_out(vty, " %pI4", &filter->addr_mask);
|
||||
}
|
||||
|
||||
if (filter->mask_mask.s_addr == 0xffffffff)
|
||||
vty_out(vty, " any");
|
||||
else if (filter->mask_mask.s_addr == INADDR_ANY)
|
||||
vty_out(vty, " host %s", inet_ntoa(filter->mask));
|
||||
vty_out(vty, " host %pI4", &filter->mask);
|
||||
else {
|
||||
vty_out(vty, " %s", inet_ntoa(filter->mask));
|
||||
vty_out(vty, " %s", inet_ntoa(filter->mask_mask));
|
||||
vty_out(vty, " %pI4", &filter->mask);
|
||||
vty_out(vty, " %pI4", &filter->mask_mask);
|
||||
}
|
||||
vty_out(vty, "\n");
|
||||
} else {
|
||||
if (filter->addr_mask.s_addr == 0xffffffff)
|
||||
vty_out(vty, " any\n");
|
||||
else {
|
||||
vty_out(vty, " %s", inet_ntoa(filter->addr));
|
||||
vty_out(vty, " %pI4", &filter->addr);
|
||||
if (filter->addr_mask.s_addr != INADDR_ANY)
|
||||
vty_out(vty, " %s",
|
||||
inet_ntoa(filter->addr_mask));
|
||||
vty_out(vty, " %pI4", &filter->addr_mask);
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
}
|
||||
|
7
lib/if.c
7
lib/if.c
@ -1106,8 +1106,8 @@ ifaddr_ipv4_add (struct in_addr *ifaddr, struct interface *ifp)
|
||||
if (rn)
|
||||
{
|
||||
route_unlock_node (rn);
|
||||
zlog_info ("ifaddr_ipv4_add(): address %s is already added",
|
||||
inet_ntoa (*ifaddr));
|
||||
zlog_info("ifaddr_ipv4_add(): address %pI4 is already added",
|
||||
ifaddr);
|
||||
return;
|
||||
}
|
||||
rn->info = ifp;
|
||||
@ -1126,8 +1126,7 @@ ifaddr_ipv4_delete (struct in_addr *ifaddr, struct interface *ifp)
|
||||
rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
|
||||
if (! rn)
|
||||
{
|
||||
zlog_info ("ifaddr_ipv4_delete(): can't find address %s",
|
||||
inet_ntoa (*ifaddr));
|
||||
zlog_info("%s: can't find address %pI4", __func__, ifaddr);
|
||||
return;
|
||||
}
|
||||
rn->info = NULL;
|
||||
|
@ -431,13 +431,13 @@ const char *nexthop2str(const struct nexthop *nexthop, char *str, int size)
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
snprintf(str, size, "%s if %u", inet_ntoa(nexthop->gate.ipv4),
|
||||
nexthop->ifindex);
|
||||
snprintfrr(str, size, "%pI4 if %u", &nexthop->gate.ipv4,
|
||||
nexthop->ifindex);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
snprintf(str, size, "%s if %u", inet6_ntoa(nexthop->gate.ipv6),
|
||||
nexthop->ifindex);
|
||||
snprintfrr(str, size, "%pI6 if %u", &nexthop->gate.ipv6,
|
||||
nexthop->ifindex);
|
||||
break;
|
||||
case NEXTHOP_TYPE_BLACKHOLE:
|
||||
snprintf(str, size, "blackhole");
|
||||
|
@ -975,7 +975,6 @@ void nexthop_group_write_nexthop_simple(struct vty *vty,
|
||||
const struct nexthop *nh,
|
||||
char *altifname)
|
||||
{
|
||||
char buf[100];
|
||||
char *ifname;
|
||||
|
||||
vty_out(vty, "nexthop ");
|
||||
@ -990,19 +989,16 @@ void nexthop_group_write_nexthop_simple(struct vty *vty,
|
||||
vty_out(vty, "%s", ifname);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
vty_out(vty, "%s", inet_ntoa(nh->gate.ipv4));
|
||||
vty_out(vty, "%pI4", &nh->gate.ipv4);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
vty_out(vty, "%s %s", inet_ntoa(nh->gate.ipv4), ifname);
|
||||
vty_out(vty, "%pI4 %s", &nh->gate.ipv4, ifname);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
vty_out(vty, "%s",
|
||||
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)));
|
||||
vty_out(vty, "%pI6", &nh->gate.ipv6);
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
||||
vty_out(vty, "%s %s",
|
||||
inet_ntop(AF_INET6, &nh->gate.ipv6, buf, sizeof(buf)),
|
||||
ifname);
|
||||
vty_out(vty, "%pI6 %s", &nh->gate.ipv6, ifname);
|
||||
break;
|
||||
case NEXTHOP_TYPE_BLACKHOLE:
|
||||
break;
|
||||
@ -1056,10 +1052,14 @@ void nexthop_group_json_nexthop(json_object *j, const struct nexthop *nh)
|
||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
json_object_string_add(j, "nexthop", inet_ntoa(nh->gate.ipv4));
|
||||
json_object_string_add(
|
||||
j, "nexthop",
|
||||
inet_ntop(AF_INET, &nh->gate.ipv4, buf, sizeof(buf)));
|
||||
break;
|
||||
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
||||
json_object_string_add(j, "nexthop", inet_ntoa(nh->gate.ipv4));
|
||||
json_object_string_add(
|
||||
j, "nexthop",
|
||||
inet_ntop(AF_INET, &nh->gate.ipv4, buf, sizeof(buf)));
|
||||
json_object_string_add(j, "vrfId",
|
||||
ifindex2ifname(nh->ifindex, nh->vrf_id));
|
||||
break;
|
||||
|
@ -587,15 +587,11 @@ static void __attribute__((unused)) sockunion_print(const union sockunion *su)
|
||||
|
||||
switch (su->sa.sa_family) {
|
||||
case AF_INET:
|
||||
printf("%s\n", inet_ntoa(su->sin.sin_addr));
|
||||
printf("%pI4\n", &su->sin.sin_addr);
|
||||
break;
|
||||
case AF_INET6:
|
||||
printf("%pI6\n", &su->sin6.sin6_addr);
|
||||
break;
|
||||
case AF_INET6: {
|
||||
char buf[SU_ADDRSTRLEN];
|
||||
|
||||
printf("%s\n", inet_ntop(AF_INET6, &(su->sin6.sin6_addr), buf,
|
||||
sizeof(buf)));
|
||||
} break;
|
||||
|
||||
#ifdef AF_LINK
|
||||
case AF_LINK: {
|
||||
struct sockaddr_dl *sdl;
|
||||
|
Loading…
Reference in New Issue
Block a user