From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E5720A0096 for ; Wed, 5 Jun 2019 10:55:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CBF0F1B9BD; Wed, 5 Jun 2019 10:55:31 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id B6A4C1B9B8 for ; Wed, 5 Jun 2019 10:55:30 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 9B1F228006A; Wed, 5 Jun 2019 08:55:29 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 5 Jun 2019 09:55:25 +0100 To: Stephen Hemminger , References: <20190516180427.17270-1-stephen@networkplumber.org> <20190605010852.28395-1-stephen@networkplumber.org> <20190605010852.28395-3-stephen@networkplumber.org> From: Andrew Rybchenko Message-ID: <052eb763-4908-9f4c-e448-0756e1a6ab55@solarflare.com> Date: Wed, 5 Jun 2019 11:55:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190605010852.28395-3-stephen@networkplumber.org> Content-Language: en-GB X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24658.003 X-TM-AS-Result: No-14.547200-8.000000-10 X-TMASE-MatchedRID: VfovoVrt/obmLzc6AOD8DfHkpkyUphL93V4UShoTXad8vx8dQICa6y5I pZ2L7Iq9YWTNNhkmbNCUCv8HOvXVat1RkEnBFAu+nFVnNmvv47tLXPA26IG0hN9RlPzeVuQQSFS A6daXeoAYVhUfHa5+ifkilH8bkgs3WtIN7LMiDChoOA9kFf9sy66IBbSnfz+3x4gtHcG+Se9R18 QpzXStTv2Fq3oxveV/7qL4IUbQ95ZhyMOhUPZ7nrzK9RGVgYIhH3yyYiehccvZhqPLU/1bVd8mf xiZsPBGWrDkp7pQgx//voIzhn8wZuVHGbcDbAq6gxsfzkNRlfKx5amWK2anSLVV9mtf2bFYDzza EUj+J5Wfi4GooW/76CnHcejBtvUej4kuzFXlCr3aAgGKLvkBokSjYhaDwLImOGwiwun2vzDwp3V Ny+4FZ5XBAswLKT3d X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--14.547200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24658.003 X-MDID: 1559724930-opRjv3QruDWL Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v3 2/6] net/ether: add rte_eth_unformat_addr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 6/5/19 4:08 AM, Stephen Hemminger wrote: > Make a function that coresponds with eth_aton_r which can I guess ether_aton_r > be used to convert string to rte_ether_addr. > > This also allows rte_ethdev to no longer depend on the > cmdline library. > > Signed-off-by: Stephen Hemminger > --- > lib/librte_net/rte_ether.c | 47 ++++++++++++++++++++++++++++++ > lib/librte_net/rte_ether.h | 14 +++++++++ > lib/librte_net/rte_net_version.map | 1 + > 3 files changed, 62 insertions(+) > > diff --git a/lib/librte_net/rte_ether.c b/lib/librte_net/rte_ether.c > index 974fe815b335..acc8a0e938c5 100644 > --- a/lib/librte_net/rte_ether.c > +++ b/lib/librte_net/rte_ether.c > @@ -27,3 +27,50 @@ rte_ether_format_addr(char *buf, uint16_t size, > eth_addr->addr_bytes[4], > eth_addr->addr_bytes[5]); > } > + > +/* > + * Like ether_aton_r but can handle either > + * XX:XX:XX:XX:XX:XX or XXXX:XXXX:XXXX > + */ > +int > +rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea) > +{ > + unsigned int o0, o1, o2, o3, o4, o5; > + int n; > + > + n = sscanf(s, "%x:%x:%x:%x:%x:%x", > + &o0, &o1, &o2, &o3, &o4, &o5); Is it intended that the following input will pass?  "af:bb:03:65:dc:ddobar" or  "af:bb:03:65:dc:dd foobar" I guess yes since ether_aton() accepts it. If so, Reviewed-by: Andrew Rybchenko