From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 967757F50 for ; Wed, 12 Nov 2014 07:15:09 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 11 Nov 2014 22:22:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,367,1413270000"; d="scan'208";a="635505353" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 11 Nov 2014 22:25:00 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sAC6OwTd020457; Wed, 12 Nov 2014 14:24:58 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sAC6OuTu031203; Wed, 12 Nov 2014 14:24:58 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAC6Ou3M031199; Wed, 12 Nov 2014 14:24:56 +0800 From: Cunming Liang To: dev@dpdk.org Date: Wed, 12 Nov 2014 14:24:32 +0800 Message-Id: <1415773476-31004-4-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1415773476-31004-1-git-send-email-cunming.liang@intel.com> References: <1414372809-14044-1-git-send-email-cunming.liang@intel.com> <1415773476-31004-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH v7 3/7] ether: new API to format eth_addr in string X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Nov 2014 06:15:10 -0000 Signed-off-by: Cunming Liang --- lib/librte_ether/rte_ether.h | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lib/librte_ether/rte_ether.h b/lib/librte_ether/rte_ether.h index f173509..187608d 100644 --- a/lib/librte_ether/rte_ether.h +++ b/lib/librte_ether/rte_ether.h @@ -45,6 +45,7 @@ extern "C" { #endif #include +#include #include #include @@ -266,6 +267,30 @@ static inline void ether_addr_copy(const struct ether_addr *ea_from, #endif } +#define ETHER_ADDR_FMT_SIZE 18 +/** + * Format 48bits Ethernet address in pattern xx:xx:xx:xx:xx:xx. + * + * @param buf + * A pointer to buffer contains the formatted MAC address. + * @param size + * The format buffer size. + * @param ea_to + * A pointer to a ether_addr structure. + */ +static inline void +ether_format_addr(char *buf, uint16_t size, + const struct ether_addr *eth_addr) +{ + snprintf(buf, size, "%02X:%02X:%02X:%02X:%02X:%02X", + eth_addr->addr_bytes[0], + eth_addr->addr_bytes[1], + eth_addr->addr_bytes[2], + eth_addr->addr_bytes[3], + eth_addr->addr_bytes[4], + eth_addr->addr_bytes[5]); +} + /** * Ethernet header: Contains the destination address, source address * and frame type. -- 1.7.4.1