From patchwork Thu Jul 28 09:31:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Forrest Shi X-Patchwork-Id: 72943 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp749613qga; Thu, 28 Jul 2016 02:31:25 -0700 (PDT) X-Received: by 10.237.49.130 with SMTP id 2mr55661648qth.38.1469698285172; Thu, 28 Jul 2016 02:31:25 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j9si3811847qka.337.2016.07.28.02.31.24; Thu, 28 Jul 2016 02:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BAB056850E; Thu, 28 Jul 2016 09:31:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, NORMAL_HTTP_TO_IP, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9228D684E9; Thu, 28 Jul 2016 09:31:18 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DA7E9684ED; Thu, 28 Jul 2016 09:31:14 +0000 (UTC) Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by lists.linaro.org (Postfix) with ESMTPS id 64505684E7 for ; Thu, 28 Jul 2016 09:31:08 +0000 (UTC) Received: by mail-pf0-f173.google.com with SMTP id y134so20408864pfg.0 for ; Thu, 28 Jul 2016 02:31:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:thread-index:content-language; bh=lfA7O4QZaEczPVvXhSdLcbOhKli+iHTg4cU3BJZbbFw=; b=PsGYcPA8GZF9rqc/fq3LGMWp9IH8fTPJY1NJzgkNiCdcKCudfbWqg9H6HKCS+xk1V0 UgJuWYmglM7z99175vAzQrx0hFSq5JQwLRpXeRzTXCVluOhaSXl+wRTIu+sEZQvK0hRW HmLKFOAH4hqSCEvRZWRpNkz2FsncEGydxqOPK37G9wDGDbrEDrB5y3xXdRr3mgXzI4lt f5Fl66bCyq0YdpkteQzIACSIsPpic8TFQW6jwdOLmhJp4tYK+qwFapwkK1TgXTgy6tLS 1PIWcOr314nbCf4m/ck45xKALgFPPZ/iFF4KKPfVxIWfInkR1RFMN7cq6osfa/6xIZbJ 1HXQ== X-Gm-Message-State: AEkooutmMBJGbh7dy2brC0Yn4WPoVvTdJX90T++B+ydjOdFAo2W9gM9ybm5gkw8WG8q9bo+8d28= X-Received: by 10.98.19.214 with SMTP id 83mr58206491pft.117.1469698267614; Thu, 28 Jul 2016 02:31:07 -0700 (PDT) Received: from b2923702 (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 15sm15372663pfz.36.2016.07.28.02.31.03 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jul 2016 02:31:06 -0700 (PDT) From: "forrest.shi" To: "'Mike Holmes'" References: <1467965654-34734-1-git-send-email-forrest.shi@linaro.org> <1467965654-34734-3-git-send-email-forrest.shi@linaro.org> <000001d1e257$c9454fd0$5bcfef70$@linaro.org> In-Reply-To: Date: Thu, 28 Jul 2016 17:31:00 +0800 Message-ID: <004001d1e8b2$c341ff00$49c5fd00$@linaro.org> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQIvZz2XdvQ9r+JpIVz2bA7zibAHpAFtJjW1AHCR9hwCfPuTmwHVa6k/n0EVn3A= Content-Language: en-us X-Content-Filtered-By: Mailman/MimeDel 2.1.16 X-Topics: patch Cc: 'lng-odp' Subject: Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet parsing X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Hi Mike, Here is the gcov of helper function. Please see the attachments. Thanks, Forrest From: Mike Holmes [mailto:mike.holmes@linaro.org] Sent: Wednesday, July 20, 2016 20:01 To: forrest.shi Cc: Bill Fischofer ; lng-odp Subject: Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet parsing Did you look in the publishing directory? It should all be in there, by default everything in the build dir is cleaned up unless you do CLEANUP=0 and output like docs is copied to that publishing dir. On 20 July 2016 at 03:24, forrest.shi > wrote: Hi Mike I got the following with: GIT_URL=~/git/odp GIT_BRANCH=forrest LCOV=1 ./build.sh No html is generated in the publishing. -- 2.1.0.27.g96db324 -- Mike Holmes Technical Manager - Linaro Networking Group Linaro.org │ Open source software for ARM SoCs "Work should be fun and collaborative, the rest follows" -- Mike Holmes Technical Manager - Linaro Networking Group Linaro.org │ Open source software for ARM SoCs "Work should be fun and collaborative, the rest follows" ======================================================================= OpenDataPlane 1.10.1.0.git71.ga942cb4: helper/test/test-suite.log ======================================================================= # TOTAL: 9 # PASS: 8 # SKIP: 0 # XFAIL: 0 # FAIL: 1 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 FAIL: cuckootable ================= cuckootable.c:213:odph_cuckoo_table_create():cuckoo hash table put_remove already exists cuckoo hash table creation failed cuckoo hash table test fail!! Thanks, Forrest From: Mike Holmes [mailto:mike.holmes@linaro.org ] Sent: Friday, July 15, 2016 20:26 To: Forrest Shi > Cc: Bill Fischofer >; lng-odp > Subject: Re: [lng-odp] [PATCH/API-NEXT 3/3] helper/ip: add ipv4/subnet parsing On 8 July 2016 at 04:14, > wrote: From: Xuelin Shi > parse an ipv4/subnet string like "192.168.1.0/24 " into 3 values: ipv4-addr, subnet bit width and subnet mask Signed-off-by: Xuelin Shi > --- helper/include/odp/helper/ip.h | 19 +++++++++++++++++++ helper/ip.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index 4cfc00f..dd538c9 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -233,6 +233,25 @@ typedef struct ODP_PACKED { int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str); /** + * Parse text string representing an IPv4 address or subnet + * + * String is of the format "XXX.XXX.XXX.XXX(/W)" where + * "XXX" is decimal value and "/W" is optional subnet length + * + * @param ip_net_str Pointer to IP address/subnet string to convert + * @param ip_addr Pointer to return IPv4 address, host endianness + * @param depth Pointer to subnet bit width + * @param subnet_mask Pointer to subnet mask + * + * @retval 0 on success of parsing both ip and subnet + * @retval 1 on success of parsing only ip + * @retval 2 on success of parsing only subnet + * @retval <0 on failure + */ +int odph_ipv4_subnet_parse(const char *ip_net_str, uint32_t *ip_addr, + uint32_t *depth, uint32_t *subnet_mask); This new api is not tested by the validation suite To see this in LCOV use check-odp and point at your repo and branch setting LCOV GIT_URL=~/git/odp GIT_BRANCH=forrest LCOV=1 ./build.sh firefox publishing/forrest/linux-generic-helper-lcov-html/helper/ip.c.gcov.html + +/** * @} */ #ifdef __cplusplus diff --git a/helper/ip.c b/helper/ip.c index e211001..d2ca21e 100644 --- a/helper/ip.c +++ b/helper/ip.c @@ -30,3 +30,36 @@ int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str) return 0; } + +int odph_ipv4_subnet_parse(const char *ip_net_str, uint32_t *ip_addr, + uint32_t *depth, uint32_t *subnet_mask) +{ + char *s; + int converted; + uint32_t qualifier = 32; + char ip_valid = 0; + char subnet_valid = 0; + + s = strchr(ip_net_str, '/'); + if (s) { + converted = sscanf(s, "/%u", &qualifier); + if (converted == 1 && qualifier && qualifier <= 32) { + *depth = qualifier; + *subnet_mask = ((1 << qualifier) - 1) << + (32 - qualifier); + subnet_valid = 1; + } + } + + if (!odph_ipv4_addr_parse(ip_addr, ip_net_str)) + ip_valid = 1; + + if (ip_valid && subnet_valid) + return 0; + else if (ip_valid) + return 1; + else if (subnet_valid) + return 2; + else + return -1; +}