mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 02:17:37 +08:00
net/ip: print ip addresses using ip4_addrN macro
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:

committed by
Xiang Xiao

parent
2b58cc6578
commit
189d0c803f
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user