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 BAF9D7F6D for ; Wed, 12 Nov 2014 07:15:13 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 11 Nov 2014 22:22:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,367,1413270000"; d="scan'208";a="635505409" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 11 Nov 2014 22:25:05 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sAC6P3Oo020474; Wed, 12 Nov 2014 14:25:03 +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 sAC6P0fR031210; Wed, 12 Nov 2014 14:25:03 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAC6P0Rh031206; Wed, 12 Nov 2014 14:25:00 +0800 From: Cunming Liang To: dev@dpdk.org Date: Wed, 12 Nov 2014 14:24:33 +0800 Message-Id: <1415773476-31004-5-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 4/7] app/testpmd: cleanup eth_addr print 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:16 -0000 Signed-off-by: Cunming Liang --- app/test-pmd/config.c | 10 +++------- app/test-pmd/icmpecho.c | 16 ++-------------- app/test-pmd/rxonly.c | 11 +++-------- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 9bc08f4..b102b72 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -99,13 +99,9 @@ static void print_ethaddr(const char *name, struct ether_addr *eth_addr) { - printf("%s%02X:%02X:%02X:%02X:%02X:%02X", name, - (unsigned int)eth_addr->addr_bytes[0], - (unsigned int)eth_addr->addr_bytes[1], - (unsigned int)eth_addr->addr_bytes[2], - (unsigned int)eth_addr->addr_bytes[3], - (unsigned int)eth_addr->addr_bytes[4], - (unsigned int)eth_addr->addr_bytes[5]); + char buf[ETHER_ADDR_FMT_SIZE]; + ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr); + printf("%s%s", name, buf); } void diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 7fd4b6d..774924e 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -236,18 +236,6 @@ ip_proto_name(uint8_t ip_proto) } static void -ether_addr_to_hexa(const struct ether_addr *ea, char *buf) -{ - sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", - ea->addr_bytes[0], - ea->addr_bytes[1], - ea->addr_bytes[2], - ea->addr_bytes[3], - ea->addr_bytes[4], - ea->addr_bytes[5]); -} - -static void ipv4_addr_to_dot(uint32_t be_ipv4_addr, char *buf) { uint32_t ipv4_addr; @@ -261,9 +249,9 @@ ipv4_addr_to_dot(uint32_t be_ipv4_addr, char *buf) static void ether_addr_dump(const char *what, const struct ether_addr *ea) { - char buf[18]; + char buf[ETHER_ADDR_FMT_SIZE]; - ether_addr_to_hexa(ea, buf); + ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, ea); if (what) printf("%s", what); printf("%s", buf); diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 4410c3d..9ad1df6 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -94,14 +94,9 @@ static const char *pkt_rx_flag_names[MAX_PKT_RX_FLAGS] = { static inline void print_ether_addr(const char *what, struct ether_addr *eth_addr) { - printf("%s%02X:%02X:%02X:%02X:%02X:%02X", - what, - 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]); + char buf[ETHER_ADDR_FMT_SIZE]; + ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr); + printf("%s%s", what, buf); } /* -- 1.7.4.1