From 758291693c2891830b2f0cce6416927e2de6470e Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Wed, 28 Jul 2021 14:27:42 +1000 Subject: [PATCH] Support building without IPv6 enabled. --- components/base_nodemcu/include/ip_fmt.h | 5 ++- components/base_nodemcu/ip_fmt.c | 45 ++++++++++++++++-------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/components/base_nodemcu/include/ip_fmt.h b/components/base_nodemcu/include/ip_fmt.h index 35b899ce..2053fcb4 100644 --- a/components/base_nodemcu/include/ip_fmt.h +++ b/components/base_nodemcu/include/ip_fmt.h @@ -46,10 +46,13 @@ void macstr (char *out, const uint8_t *mac); #define IP_STR_SZ (8*4+7+1) void ipstr (char *out, const ip_addr_t *ip); void ip4str (char *out, const ip4_addr_t *ip); -void ip6str (char *out, const ip6_addr_t *ip); void ipstr_esp (char *out, const esp_ip_addr_t *ip); void ip4str_esp (char *out, const esp_ip4_addr_t *ip); + +#ifdef CONFIG_LWIP_IPV6 +void ip6str (char *out, const ip6_addr_t *ip); void ip6str_esp (char *out, const esp_ip6_addr_t *ip); +#endif #endif diff --git a/components/base_nodemcu/ip_fmt.c b/components/base_nodemcu/ip_fmt.c index 0bd83878..40e10b33 100644 --- a/components/base_nodemcu/ip_fmt.c +++ b/components/base_nodemcu/ip_fmt.c @@ -41,6 +41,22 @@ void macstr (char *str, const uint8_t *mac) } + +void ip4str (char *out, const ip4_addr_t *ip) +{ + ip4addr_ntoa_r(ip, out, IP_STR_SZ); +} + + + +void ip4str_esp (char *out, const esp_ip4_addr_t *ip) +{ + esp_ip4addr_ntoa(ip, out, IP_STR_SZ); +} + + +#ifdef CONFIG_LWIP_IPV6 + void ipstr (char *out, const ip_addr_t *ip) { if (ip->type == IPADDR_TYPE_V4) @@ -49,19 +65,11 @@ void ipstr (char *out, const ip_addr_t *ip) ip6str (out, &ip->u_addr.ip6); } - -void ip4str (char *out, const ip4_addr_t *ip) -{ - ip4addr_ntoa_r(ip, out, IP_STR_SZ); -} - - void ip6str (char *out, const ip6_addr_t *ip) { ip6addr_ntoa_r(ip, out, IP_STR_SZ); } - void ipstr_esp (char *out, const esp_ip_addr_t *ip) { if (ip->type == ESP_IPADDR_TYPE_V4) @@ -70,14 +78,21 @@ void ipstr_esp (char *out, const esp_ip_addr_t *ip) ip6str (out, &ip->u_addr.ip6); } - -void ip4str_esp (char *out, const esp_ip4_addr_t *ip) -{ - esp_ip4addr_ntoa(ip, out, IP_STR_SZ); -} - - void ip6str_esp (char *out, const esp_ip6_addr_t *ip) { ip6addr_ntoa_r((ip6_addr_t *)ip, out, IP_STR_SZ); } + +#else + +void ipstr (char *out, const ip_addr_t *ip) +{ + ip4str(out, ip); +} + +void ipstr_esp(char *out, const esp_ip_addr_t *ip) +{ + ip4str_esp(out, ip); +} + +#endif