From 075738cf1468d9f44ba2cd523dba3c8b27fd8f45 Mon Sep 17 00:00:00 2001 From: Petro Karashchenko Date: Fri, 18 Aug 2023 23:23:01 +0300 Subject: [PATCH] net/ip: print ip addresses using ip4_addrN macro Signed-off-by: Petro Karashchenko --- arch/arm/src/c5471/c5471_ethernet.c | 9 ++--- arch/arm/src/gd32f4/gd32f4xx_enet.c | 9 ++--- arch/arm/src/imx6/imx_enet.c | 17 ++++----- arch/arm/src/imxrt/imxrt_enet.c | 17 ++++----- arch/arm/src/kinetis/kinetis_enet.c | 9 ++--- arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c | 9 ++--- arch/arm/src/lpc43xx/lpc43_ethernet.c | 10 ++--- arch/arm/src/lpc54xx/lpc54_ethernet.c | 9 ++--- arch/arm/src/s32k1xx/s32k1xx_enet.c | 13 ++++--- arch/arm/src/s32k3xx/s32k3xx_emac.c | 13 ++++--- arch/arm/src/sam34/sam_emac.c | 9 ++--- arch/arm/src/sama5/sam_emaca.c | 9 ++--- arch/arm/src/sama5/sam_emacb.c | 9 ++--- arch/arm/src/sama5/sam_gmac.c | 9 ++--- arch/arm/src/samd5e5/sam_gmac.c | 7 ++-- arch/arm/src/samv7/sam_emac.c | 9 ++--- arch/arm/src/stm32/stm32_eth.c | 9 ++--- arch/arm/src/stm32f7/stm32_ethernet.c | 9 ++--- arch/arm/src/stm32h7/stm32_ethernet.c | 7 ++-- arch/arm/src/tiva/lm/lm3s_ethernet.c | 21 +++++----- arch/arm/src/tiva/tm4c/tm4c_ethernet.c | 9 ++--- arch/hc/src/m9s12/m9s12_ethernet.c | 7 ++-- arch/mips/src/pic32mx/pic32mx_ethernet.c | 9 ++--- arch/mips/src/pic32mz/pic32mz_ethernet.c | 9 ++--- arch/misoc/src/common/misoc_net.c | 7 ++-- arch/renesas/src/rx65n/rx65n_eth.c | 9 ++--- arch/risc-v/src/esp32c3/esp32c3_wlan.c | 8 ++-- arch/risc-v/src/litex/litex_emac.c | 13 +++---- arch/risc-v/src/mpfs/mpfs_ethernet.c | 7 ++-- arch/xtensa/src/esp32/esp32_wlan.c | 8 ++-- arch/xtensa/src/esp32s3/esp32s3_wlan.c | 8 ++-- arch/z80/src/ez80/ez80_emac.c | 7 ++-- drivers/net/dm90x0.c | 9 ++--- drivers/net/enc28j60.c | 17 ++++----- drivers/net/encx24j600.c | 13 ++++--- drivers/net/ftmac100.c | 7 ++-- drivers/net/lan91c111.c | 14 ++++--- drivers/net/loopback.c | 8 ++-- drivers/net/rpmsgdrv.c | 7 ++-- drivers/net/skeleton.c | 9 ++--- drivers/net/slip.c | 9 ++--- drivers/net/tun.c | 9 ++--- drivers/net/w5500.c | 11 +++--- drivers/usbdev/cdcecm.c | 9 ++--- drivers/usbhost/usbhost_cdcmbim.c | 7 ++-- drivers/virtio/virtio-net.c | 9 ++--- include/nuttx/net/ip.h | 38 ++++++++++--------- libs/libc/net/lib_inetaddr.c | 8 ++-- libs/libc/netdb/lib_dnsquery.c | 11 +++--- net/arp/arp_dump.c | 4 +- 50 files changed, 252 insertions(+), 261 deletions(-) diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index fa00b31d98..83f364e69e 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1721,11 +1722,9 @@ static int c5471_ifup(struct net_driver_s *dev) struct c5471_driver_s *priv = (struct c5471_driver_s *)dev->d_private; volatile uint32_t clearbits; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize Ethernet interface */ diff --git a/arch/arm/src/gd32f4/gd32f4xx_enet.c b/arch/arm/src/gd32f4/gd32f4xx_enet.c index 58dd72e4c1..30b43d19b2 100644 --- a/arch/arm/src/gd32f4/gd32f4xx_enet.c +++ b/arch/arm/src/gd32f4/gd32f4xx_enet.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #if defined(CONFIG_NET_PKT) @@ -2242,11 +2243,9 @@ static int gd32_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif /* Configure the Ethernet interface for DMA operation. */ diff --git a/arch/arm/src/imx6/imx_enet.c b/arch/arm/src/imx6/imx_enet.c index f61aa7b7aa..10a49b3971 100644 --- a/arch/arm/src/imx6/imx_enet.c +++ b/arch/arm/src/imx6/imx_enet.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1276,11 +1277,9 @@ static int imx_ifup_action(struct net_driver_s *dev, bool resetphy) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize ENET buffers */ @@ -1422,11 +1421,9 @@ static int imx_ifdown(struct net_driver_s *dev) (struct imx_driver_s *)dev->d_private; irqstate_t flags; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Flush and disable the Ethernet interrupts at the NVIC */ diff --git a/arch/arm/src/imxrt/imxrt_enet.c b/arch/arm/src/imxrt/imxrt_enet.c index d823fb6dc9..75c54702f3 100644 --- a/arch/arm/src/imxrt/imxrt_enet.c +++ b/arch/arm/src/imxrt/imxrt_enet.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1313,11 +1314,9 @@ static int imxrt_ifup_action(struct net_driver_s *dev, bool resetphy) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize ENET buffers */ @@ -1454,11 +1453,9 @@ static int imxrt_ifdown(struct net_driver_s *dev) (struct imxrt_driver_s *)dev->d_private; irqstate_t flags; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Flush and disable the Ethernet interrupts at the NVIC */ diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 587a3c9d74..ff48618d9d 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -995,11 +996,9 @@ static int kinetis_ifup(struct net_driver_s *dev) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #if defined(PIN_ENET_PHY_EN) kinetis_gpiowrite(PIN_ENET_PHY_EN, true); diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c index 4a8a1e7fa8..5ed46db164 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_ethernet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1454,11 +1455,9 @@ static int lpc17_40_ifup(struct net_driver_s *dev) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Reset the Ethernet controller (again) */ diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c index 053e9ccfcc..6cc77709ac 100644 --- a/arch/arm/src/lpc43xx/lpc43_ethernet.c +++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c @@ -42,7 +42,9 @@ #include #include #include +#include #include + #if defined(CONFIG_NET_PKT) # include #endif @@ -2071,11 +2073,9 @@ static int lpc43_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/lpc54xx/lpc54_ethernet.c b/arch/arm/src/lpc54xx/lpc54_ethernet.c index d4ec7ba5a6..bad52f8f52 100644 --- a/arch/arm/src/lpc54xx/lpc54_ethernet.c +++ b/arch/arm/src/lpc54xx/lpc54_ethernet.c @@ -80,6 +80,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1722,11 +1723,9 @@ static int lpc54_eth_ifup(struct net_driver_s *dev) int i; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/s32k1xx/s32k1xx_enet.c b/arch/arm/src/s32k1xx/s32k1xx_enet.c index ff18da16f3..439bea32eb 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_enet.c +++ b/arch/arm/src/s32k1xx/s32k1xx_enet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1150,9 +1151,9 @@ static int s32k1xx_ifup_action(struct net_driver_s *dev, bool resetphy) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize ENET buffers */ @@ -1290,9 +1291,9 @@ static int s32k1xx_ifdown(struct net_driver_s *dev) (struct s32k1xx_driver_s *)dev->d_private; irqstate_t flags; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Flush and disable the Ethernet interrupts at the NVIC */ diff --git a/arch/arm/src/s32k3xx/s32k3xx_emac.c b/arch/arm/src/s32k3xx/s32k3xx_emac.c index a89234f263..c0bb1bcf09 100644 --- a/arch/arm/src/s32k3xx/s32k3xx_emac.c +++ b/arch/arm/src/s32k3xx/s32k3xx_emac.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1947,9 +1948,9 @@ static int s32k3xx_ifup_action(struct net_driver_s *dev, bool resetphy) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize the free buffer list */ @@ -2059,9 +2060,9 @@ static int s32k3xx_ifdown(struct net_driver_s *dev) struct s32k3xx_driver_s *priv = (struct s32k3xx_driver_s *)dev->d_private; irqstate_t flags; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Flush and disable the Ethernet interrupts at the NVIC */ diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index e215297a34..31168e6963 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -1676,11 +1677,9 @@ static int sam_ifup(struct net_driver_s *dev) struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Configure the EMAC interface for normal operation. */ diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 9e19eaf478..a103773f3a 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include @@ -1737,11 +1738,9 @@ static int sam_ifup(struct net_driver_s *dev) struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Configure the EMAC interface for normal operation. */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index ab509587f9..9068b0f2fc 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -2075,11 +2076,9 @@ static int sam_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index 07cce97b9e..a2ac30b2d0 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -1721,11 +1722,9 @@ static int sam_ifup(struct net_driver_s *dev) struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Configure the GMAC interface for normal operation. */ diff --git a/arch/arm/src/samd5e5/sam_gmac.c b/arch/arm/src/samd5e5/sam_gmac.c index 52e28a26c0..d0eb50f9f9 100644 --- a/arch/arm/src/samd5e5/sam_gmac.c +++ b/arch/arm/src/samd5e5/sam_gmac.c @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -1686,9 +1687,9 @@ static int sam_ifup(struct net_driver_s *dev) struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Configure the GMAC interface for normal operation. */ diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 708cacc35b..d402880801 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -2523,11 +2524,9 @@ static int sam_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 4acfa0af59..ae75009d79 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #if defined(CONFIG_NET_PKT) @@ -2221,11 +2222,9 @@ static int stm32_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index 5f4902e0ae..92daf09f5d 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -2311,11 +2312,9 @@ static int stm32_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/stm32h7/stm32_ethernet.c b/arch/arm/src/stm32h7/stm32_ethernet.c index b0d76c38db..3a0314578e 100644 --- a/arch/arm/src/stm32h7/stm32_ethernet.c +++ b/arch/arm/src/stm32h7/stm32_ethernet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -2424,9 +2425,9 @@ static int stm32_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/arm/src/tiva/lm/lm3s_ethernet.c b/arch/arm/src/tiva/lm/lm3s_ethernet.c index 95c34e6d75..0935f4289f 100644 --- a/arch/arm/src/tiva/lm/lm3s_ethernet.c +++ b/arch/arm/src/tiva/lm/lm3s_ethernet.c @@ -40,14 +40,15 @@ #include #include #include - -#include +#include #include #ifdef CONFIG_NET_PKT # include #endif +#include + #include "chip.h" #include "arm_internal.h" #include "tiva_gpio.h" @@ -1131,11 +1132,9 @@ static int tiva_ifup(struct net_driver_s *dev) uint16_t phyreg; #endif - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Enable and reset the Ethernet controller */ @@ -1285,11 +1284,9 @@ static int tiva_ifdown(struct net_driver_s *dev) irqstate_t flags; uint32_t regval; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Cancel the TX timeout timers */ diff --git a/arch/arm/src/tiva/tm4c/tm4c_ethernet.c b/arch/arm/src/tiva/tm4c/tm4c_ethernet.c index ee1d7efdbc..6eb38dbba1 100644 --- a/arch/arm/src/tiva/tm4c/tm4c_ethernet.c +++ b/arch/arm/src/tiva/tm4c/tm4c_ethernet.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #ifdef CONFIG_TIVA_PHY_INTERRUPTS @@ -2196,11 +2197,9 @@ static int tiva_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/hc/src/m9s12/m9s12_ethernet.c b/arch/hc/src/m9s12/m9s12_ethernet.c index 1bd2126376..270c91bdc2 100644 --- a/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/arch/hc/src/m9s12/m9s12_ethernet.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -435,9 +436,9 @@ static int emac_ifup(struct net_driver_s *dev) FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)dev->d_private; - ninfo("Bringing up: %d.%d.%d.%d\n", - dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, - (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize PHYs, Ethernet interface, and setup up Ethernet interrupts */ diff --git a/arch/mips/src/pic32mx/pic32mx_ethernet.c b/arch/mips/src/pic32mx/pic32mx_ethernet.c index c8bf69ae12..398caea876 100644 --- a/arch/mips/src/pic32mx/pic32mx_ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx_ethernet.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1904,11 +1905,9 @@ static int pic32mx_ifup(struct net_driver_s *dev) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Reset the Ethernet controller (again) */ diff --git a/arch/mips/src/pic32mz/pic32mz_ethernet.c b/arch/mips/src/pic32mz/pic32mz_ethernet.c index f48ac49a3a..210c1cc0eb 100644 --- a/arch/mips/src/pic32mz/pic32mz_ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz_ethernet.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -2041,11 +2042,9 @@ static int pic32mz_ifup(struct net_driver_s *dev) uint32_t regval; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (uint8_t)((dev->d_ipaddr >> 0) & 0xff), - (uint8_t)((dev->d_ipaddr >> 8) & 0xff), - (uint8_t)((dev->d_ipaddr >> 16) & 0xff), - (uint8_t)((dev->d_ipaddr >> 24) & 0xff)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Reset the Ethernet controller (again) */ diff --git a/arch/misoc/src/common/misoc_net.c b/arch/misoc/src/common/misoc_net.c index f0a92b4534..7c00f3cba4 100644 --- a/arch/misoc/src/common/misoc_net.c +++ b/arch/misoc/src/common/misoc_net.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -671,9 +672,9 @@ static int misoc_net_ifup(struct net_driver_s *dev) (struct misoc_net_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, - (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/renesas/src/rx65n/rx65n_eth.c b/arch/renesas/src/rx65n/rx65n_eth.c index ea5ed27ed1..88fb8ead4b 100644 --- a/arch/renesas/src/rx65n/rx65n_eth.c +++ b/arch/renesas/src/rx65n/rx65n_eth.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #if defined(CONFIG_ARCH_PHY_INTERRUPT) @@ -2041,11 +2042,9 @@ static int rx65n_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/risc-v/src/esp32c3/esp32c3_wlan.c b/arch/risc-v/src/esp32c3/esp32c3_wlan.c index 548d0a4e7e..d268136692 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wlan.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wlan.c @@ -38,7 +38,9 @@ #include #include #include +#include #include + #if defined(CONFIG_NET_PKT) # include #endif @@ -797,9 +799,9 @@ static int wlan_ifup(struct net_driver_s *dev) struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (uint8_t)(dev->d_ipaddr), (uint8_t)(dev->d_ipaddr >> 8), - (uint8_t)(dev->d_ipaddr >> 16), (uint8_t)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/risc-v/src/litex/litex_emac.c b/arch/risc-v/src/litex/litex_emac.c index d6cf1f3604..1a1fcd15cf 100644 --- a/arch/risc-v/src/litex/litex_emac.c +++ b/arch/risc-v/src/litex/litex_emac.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -794,13 +795,11 @@ static int litex_ifup(struct net_driver_s *dev) struct litex_emac_s *priv = (struct litex_emac_s *)dev->d_private; int ret; - #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); - #endif +#ifdef CONFIG_NET_IPv4 + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); +#endif /* Configure the EMAC interface for normal operation. */ diff --git a/arch/risc-v/src/mpfs/mpfs_ethernet.c b/arch/risc-v/src/mpfs/mpfs_ethernet.c index 1ce267f07f..7b058d9424 100644 --- a/arch/risc-v/src/mpfs/mpfs_ethernet.c +++ b/arch/risc-v/src/mpfs/mpfs_ethernet.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1463,9 +1464,9 @@ static int mpfs_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/xtensa/src/esp32/esp32_wlan.c b/arch/xtensa/src/esp32/esp32_wlan.c index cff4984c5d..f1c088f086 100644 --- a/arch/xtensa/src/esp32/esp32_wlan.c +++ b/arch/xtensa/src/esp32/esp32_wlan.c @@ -40,7 +40,9 @@ #include #include #include +#include #include + #if defined(CONFIG_NET_PKT) # include #endif @@ -1139,9 +1141,9 @@ static int wlan_ifup(struct net_driver_s *dev) struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff, - (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/xtensa/src/esp32s3/esp32s3_wlan.c b/arch/xtensa/src/esp32s3/esp32s3_wlan.c index 70f0b7f9dc..a7c43423ee 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_wlan.c +++ b/arch/xtensa/src/esp32s3/esp32s3_wlan.c @@ -40,7 +40,9 @@ #include #include #include +#include #include + #if defined(CONFIG_NET_PKT) # include #endif @@ -795,9 +797,9 @@ static int wlan_ifup(struct net_driver_s *dev) struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (uint8_t)(dev->d_ipaddr), (uint8_t)(dev->d_ipaddr >> 8), - (uint8_t)(dev->d_ipaddr >> 16), (uint8_t)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index 3a908c8028..1aae9325a2 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1928,9 +1929,9 @@ static int ez80emac_ifup(FAR struct net_driver_s *dev) dev->d_mac.ether.ether_addr_octet[3], dev->d_mac.ether.ether_addr_octet[4], dev->d_mac.ether.ether_addr_octet[5]); - ninfo(" IP %d.%d.%d.%d\n", - dev->d_ipaddr >> 24, (dev->d_ipaddr >> 16) & 0xff, - (dev->d_ipaddr >> 8) & 0xff, dev->d_ipaddr & 0xff); + ninfo(" IP %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Bring up the interface -- Must be down right now */ diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index 7009e6f7ae..02722b7854 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1355,11 +1356,9 @@ static int dm9x_ifup(FAR struct net_driver_s *dev) uint8_t netstatus; int i; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Initialize DM90x0 chip */ diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index bfeb5b0e32..157f5e2a8f 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -1897,11 +1898,9 @@ static int enc_ifup(struct net_driver_s *dev) FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Lock the SPI bus so that we have exclusive access */ @@ -1966,11 +1965,9 @@ static int enc_ifdown(struct net_driver_s *dev) irqstate_t flags; int ret; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Lock the SPI bus so that we have exclusive access */ diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index fc164f27fb..347541274c 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -2042,9 +2043,9 @@ static int enc_ifup(struct net_driver_s *dev) FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private; int ret; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Lock the SPI bus so that we have exclusive access */ @@ -2110,9 +2111,9 @@ static int enc_ifdown(struct net_driver_s *dev) irqstate_t flags; int ret; - ninfo("Taking down: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Taking down: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Lock the SPI bus so that we have exclusive access */ diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index bd2a1a1078..7ed1bbb19a 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1037,9 +1038,9 @@ static int ftmac100_ifup(struct net_driver_s *dev) (FAR struct ftmac100_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/net/lan91c111.c b/drivers/net/lan91c111.c index b21a674cc8..84672bc081 100644 --- a/drivers/net/lan91c111.c +++ b/drivers/net/lan91c111.c @@ -33,9 +33,13 @@ #include #include -#include +#include #include -#include +#include + +#ifdef CONFIG_NET_PKT +# include +#endif #include "lan91c111.h" @@ -934,9 +938,9 @@ static int lan91c111_ifup(FAR struct net_driver_s *dev) FAR struct lan91c111_driver_s *priv = dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 55e14aa7c6..a6c8b08a95 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -39,8 +39,8 @@ #include #include #include -#include #include +#include #include #ifdef CONFIG_NET_PKT @@ -124,9 +124,9 @@ static int lo_ifup(FAR struct net_driver_s *dev) FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/net/rpmsgdrv.c b/drivers/net/rpmsgdrv.c index c519ee8463..33309d1c7b 100644 --- a/drivers/net/rpmsgdrv.c +++ b/drivers/net/rpmsgdrv.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -659,9 +660,9 @@ static int net_rpmsg_drv_ifup(FAR struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/net/skeleton.c b/drivers/net/skeleton.c index 81d7a22690..6a2e96650e 100644 --- a/drivers/net/skeleton.c +++ b/drivers/net/skeleton.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_PKT @@ -636,11 +637,9 @@ static int skel_ifup(FAR struct net_driver_s *dev) (FAR struct skel_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)dev->d_ipaddr & 0xff, - (int)(dev->d_ipaddr >> 8) & 0xff, - (int)(dev->d_ipaddr >> 16) & 0xff, - (int)dev->d_ipaddr >> 24); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/net/slip.c b/drivers/net/slip.c index cebb56d98f..7e10fbc6d1 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #ifdef CONFIG_NET_SLIP @@ -821,11 +822,9 @@ static int slip_ifup(FAR struct net_driver_s *dev) FAR struct slip_driver_s *self = (FAR struct slip_driver_s *)dev->d_private; - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)dev->d_ipaddr & 0xff, - (int)(dev->d_ipaddr >> 8) & 0xff, - (int)(dev->d_ipaddr >> 16) & 0xff, - (int)dev->d_ipaddr >> 24); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); /* Enable POLLIN and POLLOUT events on the TTY */ diff --git a/drivers/net/tun.c b/drivers/net/tun.c index f77ef7583d..3f00b0b365 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -651,11 +652,9 @@ static int tun_ifup(FAR struct net_driver_s *dev) FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/net/w5500.c b/drivers/net/w5500.c index c05bbe8420..356675d240 100644 --- a/drivers/net/w5500.c +++ b/drivers/net/w5500.c @@ -43,9 +43,10 @@ #include #include #include +#include +#include #include #include -#include #ifdef CONFIG_NET_PKT # include @@ -1747,11 +1748,9 @@ static int w5500_ifup(FAR struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)dev->d_ipaddr & 0xff, - (int)(dev->d_ipaddr >> 8) & 0xff, - (int)(dev->d_ipaddr >> 16) & 0xff, - (int)dev->d_ipaddr >> 24); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/usbdev/cdcecm.c b/drivers/usbdev/cdcecm.c index 0ff155ed0e..53d0527b87 100644 --- a/drivers/usbdev/cdcecm.c +++ b/drivers/usbdev/cdcecm.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -585,11 +586,9 @@ static int cdcecm_ifup(FAR struct net_driver_s *dev) (FAR struct cdcecm_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), - (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), - (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/usbhost/usbhost_cdcmbim.c b/drivers/usbhost/usbhost_cdcmbim.c index 29e0ffb196..655f6f7d48 100644 --- a/drivers/usbhost/usbhost_cdcmbim.c +++ b/drivers/usbhost/usbhost_cdcmbim.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -2310,9 +2311,9 @@ static int cdcmbim_ifup(struct net_driver_s *dev) int ret; #ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %d.%d.%d.%d\n", - (int)(dev->d_ipaddr & 0xff), (int)((dev->d_ipaddr >> 8) & 0xff), - (int)((dev->d_ipaddr >> 16) & 0xff), (int)(dev->d_ipaddr >> 24)); + ninfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), + ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/drivers/virtio/virtio-net.c b/drivers/virtio/virtio-net.c index 56d88959de..1c463d4fe9 100644 --- a/drivers/virtio/virtio-net.c +++ b/drivers/virtio/virtio-net.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -232,11 +233,9 @@ static int virtio_net_ifup(FAR struct netdev_lowerhalf_s *dev) FAR struct virtio_net_priv_s *priv = (FAR struct virtio_net_priv_s *)dev; #ifdef CONFIG_NET_IPv4 - vrtinfo("Bringing up: %d.%d.%d.%d\n", - (int)dev->netdev.d_ipaddr & 0xff, - (int)(dev->netdev.d_ipaddr >> 8) & 0xff, - (int)(dev->netdev.d_ipaddr >> 16) & 0xff, - (int)dev->netdev.d_ipaddr >> 24); + vrtinfo("Bringing up: %u.%u.%u.%u\n", + ip4_addr1(dev->netdev.d_ipaddr), ip4_addr2(dev->netdev.d_ipaddr), + ip4_addr3(dev->netdev.d_ipaddr), ip4_addr4(dev->netdev.d_ipaddr)); #endif #ifdef CONFIG_NET_IPv6 vrtinfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", diff --git a/include/nuttx/net/ip.h b/include/nuttx/net/ip.h index b6b554e594..31c97dac10 100644 --- a/include/nuttx/net/ip.h +++ b/include/nuttx/net/ip.h @@ -314,17 +314,17 @@ extern "C" #ifdef CONFIG_ENDIAN_BIG /* Big-endian byte order: 11223344 */ -# define ip4_addr1(ipaddr) (((ipaddr) >> 24) & 0xff) -# define ip4_addr2(ipaddr) (((ipaddr) >> 16) & 0xff) -# define ip4_addr3(ipaddr) (((ipaddr) >> 8) & 0xff) -# define ip4_addr4(ipaddr) ((ipaddr) & 0xff) +# define ip4_addr1(ipaddr) ((uint8_t)(((ipaddr) >> 24) & 0xff)) +# define ip4_addr2(ipaddr) ((uint8_t)(((ipaddr) >> 16) & 0xff)) +# define ip4_addr3(ipaddr) ((uint8_t)(((ipaddr) >> 8) & 0xff)) +# define ip4_addr4(ipaddr) ((uint8_t)((ipaddr) & 0xff)) #else /* Little endian byte order: 44223311 */ -# define ip4_addr1(ipaddr) ((ipaddr) & 0xff) -# define ip4_addr2(ipaddr) (((ipaddr) >> 8) & 0xff) -# define ip4_addr3(ipaddr) (((ipaddr) >> 16) & 0xff) -# define ip4_addr4(ipaddr) (((ipaddr) >> 24) & 0xff) +# define ip4_addr1(ipaddr) ((uint8_t)((ipaddr) & 0xff)) +# define ip4_addr2(ipaddr) ((uint8_t)(((ipaddr) >> 8) & 0xff)) +# define ip4_addr3(ipaddr) ((uint8_t)(((ipaddr) >> 16) & 0xff)) +# define ip4_addr4(ipaddr) ((uint8_t)(((ipaddr) >> 24) & 0xff)) #endif /**************************************************************************** @@ -470,14 +470,18 @@ extern "C" #ifdef CONFIG_NET_IPv4 # define net_ipv4addr_copy(dest, src) \ - do { \ - (dest) = (in_addr_t)(src); \ - } while (0) + do \ + { \ + (dest) = (in_addr_t)(src); \ + } \ + while (0) # define net_ipv4addr_hdrcopy(dest, src) \ - do { \ - ((FAR uint16_t *)(dest))[0] = ((FAR uint16_t *)(src))[0]; \ - ((FAR uint16_t *)(dest))[1] = ((FAR uint16_t *)(src))[1]; \ - } while (0) + do \ + { \ + ((FAR uint16_t *)(dest))[0] = ((FAR uint16_t *)(src))[0]; \ + ((FAR uint16_t *)(dest))[1] = ((FAR uint16_t *)(src))[1]; \ + } \ + while (0) #endif #ifdef CONFIG_NET_IPv6 @@ -605,8 +609,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1, ****************************************************************************/ #define net_ipv4addr_broadcast(addr, mask) \ - (((in_addr_t)(addr) & ~(in_addr_t)(mask)) == \ - ((in_addr_t)(0xffffffff) & ~(in_addr_t)(mask))) + (((in_addr_t)(addr) & ~(in_addr_t)(mask)) == \ + ((in_addr_t)(0xffffffff) & ~(in_addr_t)(mask))) /**************************************************************************** * Name: net_ipv6addr_prefixcmp diff --git a/libs/libc/net/lib_inetaddr.c b/libs/libc/net/lib_inetaddr.c index 146ee68916..13f8b786b9 100644 --- a/libs/libc/net/lib_inetaddr.c +++ b/libs/libc/net/lib_inetaddr.c @@ -102,7 +102,7 @@ in_addr_t inet_addr(FAR const char *cp) { if ((a < 0x100) && (b < 0x1000000)) { - result = (((uint32_t) a) << 24) | b; + result = (((uint32_t)a) << 24) | b; } break; } @@ -111,7 +111,7 @@ in_addr_t inet_addr(FAR const char *cp) { if ((a < 0x100) && (b < 0x100) && (c < 0x10000)) { - result = (((uint32_t) a) << 24) | (((uint32_t) b) << 16) | c; + result = (((uint32_t)a) << 24) | (((uint32_t)b) << 16) | c; } break; } @@ -120,8 +120,8 @@ in_addr_t inet_addr(FAR const char *cp) { if ((a < 0x100) && (b < 0x100) && (c < 0x100) && (d < 0x100)) { - result = (((uint32_t) a) << 24) | (((uint32_t) b) << 16) | - (((uint32_t) c) << 8) | d; + result = (((uint32_t)a) << 24) | (((uint32_t)b) << 16) | + (((uint32_t)c) << 8) | d; } break; } diff --git a/libs/libc/netdb/lib_dnsquery.c b/libs/libc/netdb/lib_dnsquery.c index ba7789d9a7..117a2f1b1e 100644 --- a/libs/libc/netdb/lib_dnsquery.c +++ b/libs/libc/netdb/lib_dnsquery.c @@ -59,6 +59,7 @@ #include #include +#include #include #include "netdb/lib_dns.h" @@ -502,11 +503,11 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr, nameptr += 10 + 4; - ninfo("IPv4 address: %d.%d.%d.%d\n", - (int)((ans->u.ipv4.s_addr) & 0xff), - (int)((ans->u.ipv4.s_addr >> 8) & 0xff), - (int)((ans->u.ipv4.s_addr >> 16) & 0xff), - (int)((ans->u.ipv4.s_addr >> 24) & 0xff)); + ninfo("IPv4 address: %u.%u.%u.%u\n", + ip4_addr1(ans->u.ipv4.s_addr), + ip4_addr2(ans->u.ipv4.s_addr), + ip4_addr3(ans->u.ipv4.s_addr), + ip4_addr4(ans->u.ipv4.s_addr)); inaddr = &addr[naddr_read].ipv4; inaddr->sin_family = AF_INET; diff --git a/net/arp/arp_dump.c b/net/arp/arp_dump.c index 8466763d85..c22573b5ef 100644 --- a/net/arp/arp_dump.c +++ b/net/arp/arp_dump.c @@ -73,12 +73,12 @@ void arp_dump(FAR struct arp_hdr_s *arp) arp->ah_hwtype, arp->ah_protocol); ninfo(" HW len: %02x Proto len: %02x Operation: %04x\n", arp->ah_hwlen, arp->ah_protolen, arp->ah_opcode); - ninfo(" Sender MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %d.%d.%d.%d\n", + ninfo(" Sender MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %u.%u.%u.%u\n", arp->ah_shwaddr[0], arp->ah_shwaddr[1], arp->ah_shwaddr[2], arp->ah_shwaddr[3], arp->ah_shwaddr[4], arp->ah_shwaddr[5], arp->ah_sipaddr[0] & 0xff, arp->ah_sipaddr[0] >> 8, arp->ah_sipaddr[1] & 0xff, arp->ah_sipaddr[1] >> 8); - ninfo(" Dest MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %d.%d.%d.%d\n", + ninfo(" Dest MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %u.%u.%u.%u\n", arp->ah_dhwaddr[0], arp->ah_dhwaddr[1], arp->ah_dhwaddr[2], arp->ah_dhwaddr[3], arp->ah_dhwaddr[4], arp->ah_dhwaddr[5], arp->ah_dipaddr[0] & 0xff, arp->ah_dipaddr[0] >> 8,