net/ip: print ip addresses using ip4_addrN macro

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko
2023-08-18 22:57:42 +03:00
committed by Xiang Xiao
parent 2b58cc6578
commit 189d0c803f
7 changed files with 111 additions and 126 deletions

View File

@@ -57,6 +57,7 @@
#include <arpa/inet.h>
#include <netinet/udp.h>
#include <nuttx/net/ip.h>
#include "netutils/dhcpc.h"
#include "netutils/netlib.h"
@@ -907,26 +908,26 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
return ERROR;
}
ninfo("Got IP address %d.%d.%d.%d\n",
(int)((presult->ipaddr.s_addr) & 0xff),
(int)((presult->ipaddr.s_addr >> 8) & 0xff),
(int)((presult->ipaddr.s_addr >> 16) & 0xff),
(int)((presult->ipaddr.s_addr >> 24) & 0xff));
ninfo("Got netmask %d.%d.%d.%d\n",
(int)((presult->netmask.s_addr) & 0xff),
(int)((presult->netmask.s_addr >> 8) & 0xff),
(int)((presult->netmask.s_addr >> 16) & 0xff),
(int)((presult->netmask.s_addr >> 24) & 0xff));
ninfo("Got DNS server %d.%d.%d.%d\n",
(int)((presult->dnsaddr.s_addr) & 0xff),
(int)((presult->dnsaddr.s_addr >> 8) & 0xff),
(int)((presult->dnsaddr.s_addr >> 16) & 0xff),
(int)((presult->dnsaddr.s_addr >> 24) & 0xff));
ninfo("Got default router %d.%d.%d.%d\n",
(int)((presult->default_router.s_addr) & 0xff),
(int)((presult->default_router.s_addr >> 8) & 0xff),
(int)((presult->default_router.s_addr >> 16) & 0xff),
(int)((presult->default_router.s_addr >> 24) & 0xff));
ninfo("Got IP address %u.%u.%u.%u\n",
ip4_addr1(presult->ipaddr.s_addr),
ip4_addr2(presult->ipaddr.s_addr),
ip4_addr3(presult->ipaddr.s_addr),
ip4_addr4(presult->ipaddr.s_addr));
ninfo("Got netmask %u.%u.%u.%u\n",
ip4_addr1(presult->netmask.s_addr),
ip4_addr2(presult->netmask.s_addr),
ip4_addr3(presult->netmask.s_addr),
ip4_addr4(presult->netmask.s_addr));
ninfo("Got DNS server %u.%u.%u.%u\n",
ip4_addr1(presult->dnsaddr.s_addr),
ip4_addr2(presult->dnsaddr.s_addr),
ip4_addr3(presult->dnsaddr.s_addr),
ip4_addr4(presult->dnsaddr.s_addr));
ninfo("Got default router %u.%u.%u.%u\n",
ip4_addr1(presult->default_router.s_addr),
ip4_addr2(presult->default_router.s_addr),
ip4_addr3(presult->default_router.s_addr),
ip4_addr4(presult->default_router.s_addr));
ninfo("Lease expires in %" PRId32 " seconds\n", presult->lease_time);
return OK;
}