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 14BB6A0096 for ; Wed, 5 Jun 2019 18:31:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D25451B9CB; Wed, 5 Jun 2019 18:31:35 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id AE60F1B9B4 for ; Wed, 5 Jun 2019 18:31:33 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id d30so12669123pgm.7 for ; Wed, 05 Jun 2019 09:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UXXZgFYFqQqmOy2iYuHqkmvhXmYifK7unhAYEzKCwMw=; b=u21GCiwDIHkbgmZPfLJtKCNb7nCJsyYeeA4Fh/mwZl9jIlI3AfbRNywVBoLLeScDDD QUaN6AuV2R2uquHrrXvYp5wHSrrP3KaTAipRAXNYOjhhxIoXx1UajPWPdsjPKxFB2Af/ YNP0mTk0ekkDfmfeuvN/DgONq+9PWNsyBdXzHyOtpw+vJBEUxBfPv21rYDaeSZJGB9I/ qHY9J/aqCXhlDWV/5xLzphi97+FzKAk7Sxkue2m9+bBsz0EuiqwLmf0Z2OtmvlyjcbUR ngTPOyB2G2HcjNckzWQTXcm2vfzpoN0YCAq4OgSTQZLbSIWB+mKnFaqU936OxyB04ITU as9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UXXZgFYFqQqmOy2iYuHqkmvhXmYifK7unhAYEzKCwMw=; b=mnL26QTzcIwDHhZ9DGTGLItcUKup5dZbt+Mw6Qrh4hPVyxGjppBFQshKLpPYeQyTBn eruYT5BAKPa7wU8Hde0U2/Biw5yrBmEOwJ5bAyXb4KHno4uqcKA1M72uxhB+/hK9L9tb uZk7dVEiN1YS6O7cNtgRvoPEKaXVoPmSCsRb1fffjP59umjSEF6Ey51qnvsiuEnL2mLE ooh+aA8P6Um4wZ/RUZfM+4mx4ylSBxA32gIohsRzyEOag84NTHu+PStu7kJKaUd7txQC bawOM4YePZb24jo0bABcpsfpEePvk6ZLcYyeOUZfaL9Dh8+RnmeX1WNc+CGNlvBCrrKo y5OQ== X-Gm-Message-State: APjAAAWyeXkjtGVFmOWY65tuZCU9mpkBWznRihc7v/XAx7eXwyBNm24A yykuF67sX1SnQz2eLJDuFjxLow== X-Google-Smtp-Source: APXvYqz5AUjMyEnQYlpJ5agatieS2st0pJ1Dk10b2mFp9iFm+SFbAyYWZT7HWJJzZjFzf+rLjGNWvw== X-Received: by 2002:a62:4e48:: with SMTP id c69mr25117542pfb.176.1559752292873; Wed, 05 Jun 2019 09:31:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id u4sm20798437pfu.26.2019.06.05.09.31.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 09:31:32 -0700 (PDT) Date: Wed, 5 Jun 2019 09:31:31 -0700 From: Stephen Hemminger To: Andrew Rybchenko Cc: Message-ID: <20190605093131.539c3853@hermes.lan> In-Reply-To: <052eb763-4908-9f4c-e448-0756e1a6ab55@solarflare.com> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190605010852.28395-1-stephen@networkplumber.org> <20190605010852.28395-3-stephen@networkplumber.org> <052eb763-4908-9f4c-e448-0756e1a6ab55@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Wed, 5 Jun 2019 11:55:21 +0300 Andrew Rybchenko wrote: > On 6/5/19 4:08 AM, Stephen Hemminger wrote: > > Make a function that coresponds with eth_aton_r which can =20 >=20 > I guess ether_aton_r >=20 > > 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 =3D sscanf(s, "%x:%x:%x:%x:%x:%x", > > + &o0, &o1, &o2, &o3, &o4, &o5); =20 >=20 > Is it intended that the following input will pass? > =C2=A0"af:bb:03:65:dc:ddobar" or=C2=A0 "af:bb:03:65:dc:dd foobar" >=20 > I guess yes since ether_aton() accepts it. If so, > Reviewed-by: Andrew Rybchenko you are right ether_aton has same logic. doing something more complex is possible but not really needed.