@@ -862,7 +862,7 @@ format_ipv6_netmask(struct ds *s, const char *name,
{
if (!ipv6_mask_is_any(netmask)) {
ds_put_format(s, "%s=", name);
- print_ipv6_masked(s, addr, netmask);
+ ipv6_format_masked(addr, netmask, s);
ds_put_char(s, ',');
}
}
@@ -2422,7 +2422,7 @@ mf_format(const struct mf_field *mf,
break;
case MFS_IPV6:
- print_ipv6_masked(s, &value->ipv6, mask ? &mask->ipv6 : NULL);
+ ipv6_format_masked(&value->ipv6, mask ? &mask->ipv6 : NULL, s);
break;
case MFS_FRAG:
@@ -318,7 +318,7 @@ ovs_router_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
} else {
ds_put_format(&ds, "User: ");
}
- print_ipv6_mapped(&ds, &rt->nw_addr);
+ ipv6_format_mapped(&rt->nw_addr, &ds);
plen = rt->plen;
if (IN6_IS_ADDR_V4MAPPED(&rt->nw_addr)) {
plen -= 96;
@@ -326,7 +326,7 @@ ovs_router_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
ds_put_format(&ds, "/%"PRIu16" dev %s", plen, rt->output_bridge);
if (ipv6_addr_is_set(&rt->gw)) {
ds_put_format(&ds, " GW ");
- print_ipv6_mapped(&ds, &rt->gw);
+ ipv6_format_mapped(&rt->gw, &ds);
}
ds_put_format(&ds, "\n");
}
@@ -353,7 +353,7 @@ ovs_router_lookup_cmd(struct unixctl_conn *conn, int argc OVS_UNUSED,
if (ovs_router_lookup(&ip6, iface, &gw)) {
struct ds ds = DS_EMPTY_INITIALIZER;
ds_put_format(&ds, "gateway ");
- print_ipv6_mapped(&ds, &ip6);
+ ipv6_format_mapped(&ip6, &ds);
ds_put_format(&ds, "\ndev %s\n", iface);
unixctl_command_reply(conn, ds_cstr(&ds));
ds_destroy(&ds);
@@ -435,50 +435,41 @@ ip_parse_masked(const char *s, ovs_be32 *ip, ovs_be32 *mask)
return NULL;
}
-/* Stores the string representation of the IPv6 address 'addr' into the
- * character array 'addr_str', which must be at least INET6_ADDRSTRLEN
- * bytes long. */
void
-format_ipv6_addr(char *addr_str, const struct in6_addr *addr)
-{
- inet_ntop(AF_INET6, addr, addr_str, INET6_ADDRSTRLEN);
-}
-
-void
-print_ipv6_addr(struct ds *string, const struct in6_addr *addr)
+ipv6_format_addr(const struct in6_addr *addr, struct ds *s)
{
char *dst;
- ds_reserve(string, string->length + INET6_ADDRSTRLEN);
+ ds_reserve(s, s->length + INET6_ADDRSTRLEN);
- dst = string->string + string->length;
- format_ipv6_addr(dst, addr);
- string->length += strlen(dst);
+ dst = s->string + s->length;
+ inet_ntop(AF_INET6, addr, dst, INET6_ADDRSTRLEN);
+ s->length += strlen(dst);
}
void
-print_ipv6_mapped(struct ds *s, const struct in6_addr *addr)
+ipv6_format_mapped(const struct in6_addr *addr, struct ds *s)
{
if (IN6_IS_ADDR_V4MAPPED(addr)) {
ds_put_format(s, IP_FMT, addr->s6_addr[12], addr->s6_addr[13],
addr->s6_addr[14], addr->s6_addr[15]);
} else {
- print_ipv6_addr(s, addr);
+ ipv6_format_addr(addr, s);
}
}
void
-print_ipv6_masked(struct ds *s, const struct in6_addr *addr,
- const struct in6_addr *mask)
+ipv6_format_masked(const struct in6_addr *addr, const struct in6_addr *mask,
+ struct ds *s)
{
- print_ipv6_addr(s, addr);
+ ipv6_format_addr(addr, s);
if (mask && !ipv6_mask_is_exact(mask)) {
if (ipv6_is_cidr(mask)) {
int cidr_bits = ipv6_count_cidr_bits(mask);
ds_put_format(s, "/%d", cidr_bits);
} else {
ds_put_char(s, '/');
- print_ipv6_addr(s, mask);
+ ipv6_format_addr(mask, s);
}
}
}
@@ -950,11 +950,10 @@ struct vxlanhdr {
#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
-void format_ipv6_addr(char *addr_str, const struct in6_addr *addr);
-void print_ipv6_addr(struct ds *string, const struct in6_addr *addr);
-void print_ipv6_mapped(struct ds *string, const struct in6_addr *addr);
-void print_ipv6_masked(struct ds *string, const struct in6_addr *addr,
- const struct in6_addr *mask);
+void ipv6_format_addr(const struct in6_addr *addr, struct ds *);
+void ipv6_format_mapped(const struct in6_addr *addr, struct ds *);
+void ipv6_format_masked(const struct in6_addr *addr,
+ const struct in6_addr *mask, struct ds *);
struct in6_addr ipv6_addr_bitand(const struct in6_addr *src,
const struct in6_addr *mask);
struct in6_addr ipv6_create_mask(int mask);
@@ -291,7 +291,7 @@ tnl_arp_cache_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
int start_len, need_ws;
start_len = ds.length;
- print_ipv6_mapped(&ds, &arp->ip);
+ ipv6_format_mapped(&arp->ip, &ds);
need_ws = INET6_ADDRSTRLEN - (ds.length - start_len);
ds_put_char_multiple(&ds, ' ', need_ws);
@@ -4540,7 +4540,7 @@ ofproto_unixctl_mcast_snooping_show(struct unixctl_conn *conn,
ofputil_port_to_string(ofbundle_get_a_port(bundle)->up.ofp_port,
name, sizeof name);
ds_put_format(&ds, "%5s %4d ", name, grp->vlan);
- print_ipv6_mapped(&ds, &grp->addr);
+ ipv6_format_mapped(&grp->addr, &ds);
ds_put_format(&ds, " %3d\n",
mcast_bundle_age(ofproto->ms, b));
}
@@ -584,11 +584,11 @@ tnl_match_fmt(const struct tnl_match *match, struct ds *ds)
OVS_REQ_RDLOCK(rwlock)
{
if (!match->ip_dst_flow) {
- print_ipv6_mapped(ds, &match->ipv6_src);
+ ipv6_format_mapped(&match->ipv6_src, ds);
ds_put_cstr(ds, "->");
- print_ipv6_mapped(ds, &match->ipv6_dst);
+ ipv6_format_mapped(&match->ipv6_dst, ds);
} else if (!match->ip_src_flow) {
- print_ipv6_mapped(ds, &match->ipv6_src);
+ ipv6_format_mapped(&match->ipv6_src, ds);
ds_put_cstr(ds, "->flow");
} else {
ds_put_cstr(ds, "flow->flow");
@@ -117,7 +117,7 @@ lex_token_format_value(const union mf_subvalue *value,
break;
case LEX_F_IPV6:
- print_ipv6_addr(s, &value->ipv6);
+ ipv6_format_addr(&value->ipv6, s);
break;
case LEX_F_ETHERNET: