diff options
author | Stephen Hemminger <stephen@networkplumber.org> | 2019-04-10 10:41:32 -0700 |
---|---|---|
committer | Thomas Monjalon <thomas@monjalon.net> | 2019-04-22 13:20:33 +0200 |
commit | d5ceea4ab1603a182e93eb3be1c49b3b4158a499 (patch) | |
tree | 231701ed72e55346a4a710e811d6b372a989a61b /examples/l3fwd | |
parent | 37afe381bde4277f0078116b8d4d7a315c8e39b3 (diff) | |
download | dpdk-d5ceea4ab1603a182e93eb3be1c49b3b4158a499.zip dpdk-d5ceea4ab1603a182e93eb3be1c49b3b4158a499.tar.gz dpdk-d5ceea4ab1603a182e93eb3be1c49b3b4158a499.tar.xz |
examples/l3fwd: format IP addresses for printing
The IP addresses should be formatted using standard routines
rather than outputing in raw hex.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
Diffstat (limited to 'examples/l3fwd')
-rw-r--r-- | examples/l3fwd/l3fwd_lpm.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 3191fc4..172a036 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -13,6 +13,7 @@ #include <errno.h> #include <getopt.h> #include <stdbool.h> +#include <arpa/inet.h> #include <rte_debug.h> #include <rte_ether.h> @@ -260,6 +261,7 @@ setup_lpm(const int socketid) unsigned i; int ret; char s[64]; + char abuf[INET6_ADDRSTRLEN]; /* create the LPM table */ config_ipv4.max_rules = IPV4_L3FWD_LPM_MAX_RULES; @@ -275,6 +277,7 @@ setup_lpm(const int socketid) /* populate the LPM table */ for (i = 0; i < IPV4_L3FWD_LPM_NUM_ROUTES; i++) { + struct in_addr in; /* skip unused ports */ if ((1 << ipv4_l3fwd_lpm_route_array[i].if_out & @@ -292,8 +295,9 @@ setup_lpm(const int socketid) i, socketid); } - printf("LPM: Adding route 0x%08x / %d (%d)\n", - (unsigned)ipv4_l3fwd_lpm_route_array[i].ip, + in.s_addr = htonl(ipv4_l3fwd_lpm_route_array[i].ip); + printf("LPM: Adding route %s / %d (%d)\n", + inet_ntop(AF_INET, &in, abuf, sizeof(abuf)), ipv4_l3fwd_lpm_route_array[i].depth, ipv4_l3fwd_lpm_route_array[i].if_out); } @@ -331,9 +335,10 @@ setup_lpm(const int socketid) } printf("LPM: Adding route %s / %d (%d)\n", - "IPV6", - ipv6_l3fwd_lpm_route_array[i].depth, - ipv6_l3fwd_lpm_route_array[i].if_out); + inet_ntop(AF_INET6, ipv6_l3fwd_lpm_route_array[i].ip, + abuf, sizeof(abuf)), + ipv6_l3fwd_lpm_route_array[i].depth, + ipv6_l3fwd_lpm_route_array[i].if_out); } } |