From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by dpdk.org (Postfix) with ESMTP id E80E7160 for ; Tue, 19 Dec 2017 16:37:10 +0100 (CET) Received: by mail-pg0-f65.google.com with SMTP id o2so10668999pgc.8 for ; Tue, 19 Dec 2017 07:37:10 -0800 (PST) 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=wymTtd8WQ6/fEIJLbDIUwmf+ei4+64YycgSH/qWoFT8=; b=uT+cQQQFVARZmgDJyb/Zf0JaSfDPoJI5+1uRAB3laIaaDoCkmmhNqFYMzLVzeediCb WMjqUTmAUzNSJG47DYhlkf1e8sNb7LTRYiz5owgqyp8DA1s8rLSLF9pSF9qxe+wLZH// P5S+aJbk1UmFUzn0/4jhXkgqoalcEDlbjV4XFLcVygzn+UGgKJqu3gpNNsJV8CANCFI/ rJYqDrKizApxDZ05hQ5Btm8GKYi3/PhpufYiattJsrmTxzENAq0omiT9y88wjxo9JeN1 hZsXd2Yglp6yc15Ifqf7fuKPEUatNcu5k3gSB3VmS9WFw3ktQ2pMINRtWP50ZQpPxBDJ lJjg== 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=wymTtd8WQ6/fEIJLbDIUwmf+ei4+64YycgSH/qWoFT8=; b=Ez93u+HVkXvoLDV8Qav/xSFuUlvxLene4v3Mh2ciiMm/aSSwxY97lWKJOEEXQl91Vg LnLzMu2435EZxS5x8opZW3lergxPcEYVkOte1GgM0uOtkRRO3cmPzjcFWAFCykMNmGC2 j9suQIPTrlpZ+Gbo2COfUAS+mfsWQv6FuaHSyFdfI7wddZ/VbjmRtX36iIAc95InHHq/ F6dha0fFvr2tQtfiiKXOIAGO8icIGlNqBmh+lQdv+9II38iCiK2HQAlxYRsLkDZueh4T N1gaslrfff20ZdxJ+Ml9jkADPf/D+8gEGSGI0hVQ4g9GcwDEABs3lyeWZVgADqsF6XNE UJww== X-Gm-Message-State: AKGB3mLf+qsbZzW7gANL2FJ97UNT7M3i7pp+D1DvArrhU8d7jCYqRJjZ MJibVBkcs5Gd9PkHHMgLy6iL6w== X-Google-Smtp-Source: ACJfBouvOVS6NUzd6PLt1ODPNlOW84OC+1IxlHOPT4kS8EzrbWvm0QD587AKDmcGyOfytDNq3EnvvA== X-Received: by 10.99.130.74 with SMTP id w71mr3265091pgd.31.1513697829831; Tue, 19 Dec 2017 07:37:09 -0800 (PST) Received: from xeon-e3 (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id z74sm33098606pfi.123.2017.12.19.07.37.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2017 07:37:09 -0800 (PST) Date: Tue, 19 Dec 2017 07:37:07 -0800 From: Stephen Hemminger To: Adrien Mazarguil Cc: Ferruh Yigit , dev@dpdk.org Message-ID: <20171219073707.292ea50d@xeon-e3> In-Reply-To: <20171219100155.GB5377@6wind.com> References: <20171124172132.GW4062@6wind.com> <20171218162443.12971-1-adrien.mazarguil@6wind.com> <20171218162443.12971-3-adrien.mazarguil@6wind.com> <20171218155946.5806589a@xeon-e3> <20171219100155.GB5377@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v1 2/3] net/hyperv: implement core functionality 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: , X-List-Received-Date: Tue, 19 Dec 2017 15:37:11 -0000 On Tue, 19 Dec 2017 11:01:55 +0100 Adrien Mazarguil wrote: > > Why not use sscanf which would be safer in this case. > > Right, this is indeed the obvious implementation, however not only the fixed > MAC-48 format is not the most convenient to use for user input (somewhat > like forcing them to enter fully expanded IPv6 addresses every time), > sscanf() also ignores leading white spaces and successfully parses weird > expressions like " -42: 0x66: 0af: 0: 44:-6", which I think is a > problem. There is a standard for ethernet representation, that is all you need to accept. The only simplifications are optional leading zeros 02 vs 2 and upper and lower case a-f. Don't overthink this. The FreeBSD version of ether_aton_r is: struct ether_addr * ether_aton_r(const char *a, struct ether_addr *e) { int i; unsigned int o0, o1, o2, o3, o4, o5; i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o0, &o1, &o2, &o3, &o4, &o5); if (i != 6) return (NULL); e->octet[0]=o0; e->octet[1]=o1; e->octet[2]=o2; e->octet[3]=o3; e->octet[4]=o4; e->octet[5]=o5; return (e); }