[dpdk-dev] [PATCH v7 4/7] app/testpmd: cleanup eth_addr print
Cunming Liang
cunming.liang at intel.com
Wed Nov 12 07:24:33 CET 2014
Signed-off-by: Cunming Liang <cunming.liang at intel.com>
---
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
More information about the dev
mailing list