Support building without IPv6 enabled.

This commit is contained in:
Johny Mattsson 2021-07-28 14:27:42 +10:00
parent c8e1c44c0e
commit 758291693c
2 changed files with 34 additions and 16 deletions

View File

@ -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

View File

@ -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