From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v2] net/tap: allow user MAC to be passed as args Date: Mon, 12 Mar 2018 10:33:17 -0700 Message-ID: <20180312103317.01739678@xeon-e3> References: <1518446689-26839-1-git-send-email-vipin.varghese@intel.com> <1520886094-28319-1-git-send-email-vipin.varghese@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, ferruh.yigit@intel.com, pascal.mazon@6wind.com To: Vipin Varghese Return-path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id 6A6DD29CB for ; Mon, 12 Mar 2018 18:33:26 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id u5so4645442pfh.6 for ; Mon, 12 Mar 2018 10:33:26 -0700 (PDT) In-Reply-To: <1520886094-28319-1-git-send-email-vipin.varghese@intel.com> 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 Tue, 13 Mar 2018 01:51:34 +0530 Vipin Varghese wrote: > +static int parse_user_mac(struct ether_addr *user_mac, > + const char *value) > +{ > + unsigned int index = 0; > + char mac_temp[strlen(ETH_TAP_USR_MAC_FMT) + 1], *mac_byte = NULL; > + > + if (user_mac == NULL || value == NULL) > + return 0; > + > + snprintf(mac_temp, sizeof(mac_temp), "%s", value); > + mac_byte = strtok(mac_temp, ":"); > + > + while ((mac_byte != NULL) && > + (strlen(mac_byte) <= 2) && > + (strlen(mac_byte) == strspn(mac_byte, > + ETH_TAP_CMP_MAC_FMT))) { > + user_mac->addr_bytes[index++] = strtoul(mac_byte, NULL, 16); > + mac_byte = strtok(NULL, ":"); > + } > + > + return index; > +} We need rte_ether_aton or better yet replace the DPDK custom definition of "struct ether_addr" with the with the one from Linux/BSD There is no value in having a private version of all these routines...