Skip to content

Commit 773f306

Browse files
d-a-vdevyte
authored andcommitted
more compatibility fixes to IPAddress, restore INADDR_ANY, INADDR_NONE (#5416)
1 parent 324b3f9 commit 773f306

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

cores/esp8266/IPAddress.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_oc
3838
(*this)[3] = fourth_octet;
3939
}
4040

41-
IPAddress::IPAddress(uint32_t address) {
41+
void IPAddress::ctor32(uint32_t address) {
4242
setV4();
4343
v4() = address;
4444
}
@@ -172,7 +172,8 @@ bool IPAddress::isValid(const char* arg) {
172172
return IPAddress().fromString(arg);
173173
}
174174

175-
CONST IPAddress IPNoAddress; // generic "0.0.0.0" for v4 & v6
175+
CONST IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
176+
const IPAddress INADDR_NONE(255,255,255,255);
176177

177178
/**************************************/
178179

cores/esp8266/IPAddress.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ class IPAddress: public Printable {
6767
return reinterpret_cast<const uint8_t*>(&v4());
6868
}
6969

70+
void ctor32 (uint32_t);
71+
7072
public:
7173
// Constructors
7274
IPAddress();
7375
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
74-
IPAddress(uint32_t address);
76+
IPAddress(uint32_t address) { ctor32(address); }
77+
IPAddress(u32_t address) { ctor32(address); }
78+
IPAddress(int address) { ctor32(address); }
7579
IPAddress(const uint8_t *address);
7680

7781
bool fromString(const char *address);
@@ -200,9 +204,9 @@ class IPAddress: public Printable {
200204

201205
};
202206

203-
extern CONST IPAddress IPNoAddress;
207+
extern CONST IPAddress INADDR_ANY;
208+
extern const IPAddress INADDR_NONE;
204209

205-
#include <lwip/inet.h> // bring definition of INADDR_NONE
206210
#include <AddrList.h> // bring interface iterator
207211

208212
#endif

libraries/ESP8266WiFi/src/WiFiUdp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void WiFiUDP::flush()
234234
IPAddress WiFiUDP::remoteIP() const
235235
{
236236
if (!_ctx)
237-
return IPNoAddress;
237+
return INADDR_ANY;
238238

239239
return _ctx->getRemoteAddress();
240240
}
@@ -250,7 +250,7 @@ uint16_t WiFiUDP::remotePort() const
250250
IPAddress WiFiUDP::destinationIP() const
251251
{
252252
if (!_ctx)
253-
return IPNoAddress;
253+
return INADDR_ANY;
254254

255255
return _ctx->getDestAddress();
256256
}

libraries/Ethernet/src/Dns.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int DNSClient::getHostByName(const char* aHostname, IPAddress& aResult)
127127
}
128128

129129
// Check we've got a valid DNS server to use
130-
if (iDNSServer == IPNoAddress)
130+
if (iDNSServer == INADDR_NONE || iDNSServer == INADDR_ANY)
131131
{
132132
return INVALID_SERVER;
133133
}

0 commit comments

Comments
 (0)