From patchwork Thu Oct 22 17:29:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 534508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 7058E141302 for ; Fri, 23 Oct 2015 04:29:56 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 33F3F10928; Thu, 22 Oct 2015 10:29:30 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id E47E010912 for ; Thu, 22 Oct 2015 10:29:26 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 1AFCA618459 for ; Thu, 22 Oct 2015 11:29:26 -0600 (MDT) X-ASG-Debug-ID: 1445534965-03dc210f7a1d5ed0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar4.cudamail.com with ESMTP id fWrvFuOY6hKXRVjH (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 22 Oct 2015 11:29:25 -0600 (MDT) X-Barracuda-Envelope-From: cascardo@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 22 Oct 2015 17:29:23 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4CCD885544 for ; Thu, 22 Oct 2015 17:29:24 +0000 (UTC) Received: from indiana.gru.redhat.com (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9MHTEAa023789 for ; Thu, 22 Oct 2015 13:29:23 -0400 X-CudaMail-Envelope-Sender: cascardo@redhat.com From: Thadeu Lima de Souza Cascardo To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1021039475 X-CudaMail-DTE: 102215 X-CudaMail-Originating-IP: 209.132.183.28 Date: Thu, 22 Oct 2015 15:29:00 -0200 X-ASG-Orig-Subj: [##CM-V3-1021039475##][PATCH 07/15] lib: add format_in6_addr and scan_in6_addr Message-Id: <1445534948-10538-8-git-send-email-cascardo@redhat.com> In-Reply-To: <1445534948-10538-1-git-send-email-cascardo@redhat.com> References: <1445534948-10538-1-git-send-email-cascardo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0.279065 p=-0.2 Source Normal X-MessageSniffer-Rules: 0-0-0-5997-c X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1445534965 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=3.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.23722 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH 07/15] lib: add format_in6_addr and scan_in6_addr X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" From: Jiri Benc 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 Acked-by: Ben Pfaff --- lib/odp-util.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/odp-util.c b/lib/odp-util.c index e131e36..752e2ea 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1758,13 +1758,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) { @@ -1781,6 +1780,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) { @@ -2753,7 +2762,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]; @@ -2776,6 +2785,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_;