lib: add format_in6_addr and scan_in6_addr
authorJiri Benc <jbenc@redhat.com>
Wed, 25 Nov 2015 13:31:10 +0000 (11:31 -0200)
committerBen Pfaff <blp@ovn.org>
Mon, 30 Nov 2015 18:16:53 +0000 (10:16 -0800)
Add in6_addr counterparts to the existing format and scan functions.
Otherwise we'd need to recast all the time.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/odp-util.c

index 8733bc3..74da5ad 100644 (file)
@@ -2095,13 +2095,12 @@ format_ipv4(struct ds *ds, const char *name, ovs_be32 key,
 }
 
 static void
-format_ipv6(struct ds *ds, const char *name, const ovs_be32 key_[4],
-            const ovs_be32 (*mask_)[4], bool verbose)
+format_in6_addr(struct ds *ds, const char *name,
+                const struct in6_addr *key,
+                const struct in6_addr *mask,
+                bool verbose)
 {
     char buf[INET6_ADDRSTRLEN];
-    const struct in6_addr *key = (const struct in6_addr *)key_;
-    const struct in6_addr *mask = mask_ ? (const struct in6_addr *)*mask_
-        : NULL;
     bool mask_empty = mask && ipv6_mask_is_any(mask);
 
     if (verbose || !mask_empty) {
@@ -2117,6 +2116,16 @@ format_ipv6(struct ds *ds, const char *name, const ovs_be32 key_[4],
     }
 }
 
+static void
+format_ipv6(struct ds *ds, const char *name, const ovs_be32 key_[4],
+            const ovs_be32 (*mask_)[4], bool verbose)
+{
+    format_in6_addr(ds, name,
+                    (const struct in6_addr *)key_,
+                    mask_ ? (const struct in6_addr *)*mask_ : NULL,
+                    verbose);
+}
+
 static void
 format_ipv6_label(struct ds *ds, const char *name, ovs_be32 key,
                   const ovs_be32 *mask, bool verbose)
@@ -3090,7 +3099,7 @@ scan_ipv4(const char *s, ovs_be32 *key, ovs_be32 *mask)
 }
 
 static int
-scan_ipv6(const char *s, ovs_be32 (*key)[4], ovs_be32 (*mask)[4])
+scan_in6_addr(const char *s, struct in6_addr *key, struct in6_addr *mask)
 {
     int n;
     char ipv6_s[IPV6_SCAN_LEN + 1];
@@ -3112,6 +3121,13 @@ scan_ipv6(const char *s, ovs_be32 (*key)[4], ovs_be32 (*mask)[4])
     return 0;
 }
 
+static int
+scan_ipv6(const char *s, ovs_be32 (*key)[4], ovs_be32 (*mask)[4])
+{
+    return scan_in6_addr(s, key ? (struct in6_addr *) *key : NULL,
+                         mask ? (struct in6_addr *) *mask : NULL);
+}
+
 static int
 scan_ipv6_label(const char *s, ovs_be32 *key, ovs_be32 *mask)
 {