diff mbox

[ovs-dev,v2,07/14] lib: add format_in6_addr and scan_in6_addr

Message ID 1448458277-28154-8-git-send-email-cascardo@redhat.com
State Accepted
Headers show

Commit Message

Thadeu Lima de Souza Cascardo Nov. 25, 2015, 1:31 p.m. UTC
From: Jiri Benc <jbenc@redhat.com>

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>
Acked-by: Ben Pfaff <blp@ovn.org>
---
 lib/odp-util.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

Comments

Ben Pfaff Nov. 30, 2015, 6:17 p.m. UTC | #1
On Wed, Nov 25, 2015 at 11:31:10AM -0200, Thadeu Lima de Souza Cascardo wrote:
> From: Jiri Benc <jbenc@redhat.com>
> 
> 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>
> Acked-by: Ben Pfaff <blp@ovn.org>

Applied, thanks!
diff mbox

Patch

diff --git a/lib/odp-util.c b/lib/odp-util.c
index b7c58d3..d37173c 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -1759,13 +1759,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) {
@@ -1782,6 +1781,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)
 {
@@ -2754,7 +2763,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];
@@ -2777,6 +2786,13 @@  scan_ipv6(const char *s, ovs_be32 (*key)[4], ovs_be32 (*mask)[4])
 }
 
 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)
 {
     int key_, mask_;