mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-21 21:43:26 +02:00
Wrap ipv6 code a bit more (#4574)
* Wrap ipv6 code a bit more for when ipv6 support should not be compiled in * More checks * More uses * Fix
This commit is contained in:
@@ -20,7 +20,9 @@ std::string format_sockaddr(const struct sockaddr_storage &storage) {
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
if (inet_ntop(AF_INET, &addr->sin_addr, buf, sizeof(buf)) != nullptr)
|
||||
return std::string{buf};
|
||||
} else if (storage.ss_family == AF_INET6) {
|
||||
}
|
||||
#if LWIP_IPV6
|
||||
else if (storage.ss_family == AF_INET6) {
|
||||
const struct sockaddr_in6 *addr = reinterpret_cast<const struct sockaddr_in6 *>(&storage);
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
// Format IPv4-mapped IPv6 addresses as regular IPv4 addresses
|
||||
@@ -32,6 +34,7 @@ std::string format_sockaddr(const struct sockaddr_storage &storage) {
|
||||
if (inet_ntop(AF_INET6, &addr->sin6_addr, buf, sizeof(buf)) != nullptr)
|
||||
return std::string{buf};
|
||||
}
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user