11#if defined(USE_ESP32) || defined(USE_LIBRETINY) || USE_ARDUINO_VERSION_CODE > VERSION_CODE(3, 0, 0)
12#include <lwip/ip_addr.h>
24#define ipaddr_aton(x, y) inet_aton((x), (y))
27#if USE_ESP32_FRAMEWORK_ARDUINO
28#define arduino_ns Arduino_h
30#define arduino_ns arduino
44static constexpr size_t IP_ADDRESS_BUFFER_SIZE = 40;
48 for (
char *p = buf; *p; ++p) {
49 if (*p >=
'A' && *p <=
'F')
59 this->
ip_addr_.s_addr = htonl((first << 24) | (
second << 16) | (third << 8) | fourth);
65 "str() is deprecated: use 'char buf[IP_ADDRESS_BUFFER_SIZE]; ip.str_to(buf);' instead. Removed in 2026.8.0",
67 std::
string str()
const {
68 char buf[IP_ADDRESS_BUFFER_SIZE];
73 char *str_to(
char *buf)
const {
74 inet_ntop(AF_INET, &
ip_addr_, buf, IP_ADDRESS_BUFFER_SIZE);
87#if USE_ESP32 && LWIP_IPV6
92 IPAddress(
const arduino_ns::IPAddress &other_ip) { ip_addr_set_ip4_u32(&
ip_addr_, other_ip); }
96 memcpy((
void *) &
ip_addr_, (
void *) other_ip,
sizeof(ip6_addr_t));
104 memcpy((
void *) &
ip_addr_.u_addr.ip6, (
void *) other_ip,
sizeof(esp_ip6_addr_t));
109 memcpy((
void *) &
ip_addr_, (
void *) other_ip,
sizeof(esp_ip4_addr_t));
118 memcpy((
void *) &
ip_addr_, (
void *) &other_ip->u_addr.ip4,
sizeof(
ip_addr_));
121 operator esp_ip_addr_t()
const {
130 operator esp_ip4_addr_t()
const {
133 memcpy((
void *) &tmp, (
void *) &
ip_addr_.u_addr.ip4,
sizeof(esp_ip4_addr_t));
147 operator arduino_ns::IPAddress()
const {
return ip_addr_get_ip4_u32(&
ip_addr_); }
156 "str() is deprecated: use 'char buf[IP_ADDRESS_BUFFER_SIZE]; ip.str_to(buf);' instead. Removed in 2026.8.0",
158 std::
string str()
const {
159 char buf[IP_ADDRESS_BUFFER_SIZE];
165 char *str_to(
char *buf)
const {
166 ipaddr_ntoa_r(&
ip_addr_, buf, IP_ADDRESS_BUFFER_SIZE);
175 (((u8_t *) (&
ip_addr_.u_addr.ip4))[3]) += increase;
177 (((u8_t *) (&
ip_addr_.addr))[3]) += increase;
void lowercase_ip_str(char *buf)
Lowercase hex digits in IP address string (A-F -> a-f for IPv6 per RFC 5952)
std::array< IPAddress, 5 > IPAddresses
Providing packet encoding functions for exchanging data with a remote host.
bool operator==(optional< T > const &x, optional< U > const &y)
bool operator!=(optional< T > const &x, optional< U > const &y)
std::string & operator+=(std::string &lhs, const StringRef &rhs)
bool is_multicast() const
IPAddress(const char *in_address)
IPAddress(ip6_addr_t *other_ip)
ESPDEPRECATED("str() is deprecated: use 'char buf[IP_ADDRESS_BUFFER_SIZE]; ip.str_to(buf);' instead. Removed in 2026.8.0", "2026.2.0") std
IPAddress(esp_ip_addr_t *other_ip)
IPAddress(const ip_addr_t *other_ip)
IPAddress(esp_ip6_addr_t *other_ip)
IPAddress(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth)
IPAddress(esp_ip4_addr_t *other_ip)
IPAddress(ip4_addr_t *other_ip)
IPAddress(const std::string &in_address)
IPAddress(const arduino_ns::IPAddress &other_ip)