mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
more compatibility fixes to IPAddress, restore INADDR_ANY, INADDR_NONE (#5416)
This commit is contained in:
parent
324b3f9678
commit
773f306ef9
@ -38,7 +38,7 @@ IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_oc
|
|||||||
(*this)[3] = fourth_octet;
|
(*this)[3] = fourth_octet;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress::IPAddress(uint32_t address) {
|
void IPAddress::ctor32(uint32_t address) {
|
||||||
setV4();
|
setV4();
|
||||||
v4() = address;
|
v4() = address;
|
||||||
}
|
}
|
||||||
@ -172,7 +172,8 @@ bool IPAddress::isValid(const char* arg) {
|
|||||||
return IPAddress().fromString(arg);
|
return IPAddress().fromString(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
CONST IPAddress IPNoAddress; // generic "0.0.0.0" for v4 & v6
|
CONST IPAddress INADDR_ANY; // generic "0.0.0.0" for IPv4 & IPv6
|
||||||
|
const IPAddress INADDR_NONE(255,255,255,255);
|
||||||
|
|
||||||
/**************************************/
|
/**************************************/
|
||||||
|
|
||||||
|
@ -67,11 +67,15 @@ class IPAddress: public Printable {
|
|||||||
return reinterpret_cast<const uint8_t*>(&v4());
|
return reinterpret_cast<const uint8_t*>(&v4());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctor32 (uint32_t);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors
|
// Constructors
|
||||||
IPAddress();
|
IPAddress();
|
||||||
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
||||||
IPAddress(uint32_t address);
|
IPAddress(uint32_t address) { ctor32(address); }
|
||||||
|
IPAddress(u32_t address) { ctor32(address); }
|
||||||
|
IPAddress(int address) { ctor32(address); }
|
||||||
IPAddress(const uint8_t *address);
|
IPAddress(const uint8_t *address);
|
||||||
|
|
||||||
bool fromString(const char *address);
|
bool fromString(const char *address);
|
||||||
@ -200,9 +204,9 @@ class IPAddress: public Printable {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CONST IPAddress IPNoAddress;
|
extern CONST IPAddress INADDR_ANY;
|
||||||
|
extern const IPAddress INADDR_NONE;
|
||||||
|
|
||||||
#include <lwip/inet.h> // bring definition of INADDR_NONE
|
|
||||||
#include <AddrList.h> // bring interface iterator
|
#include <AddrList.h> // bring interface iterator
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,7 +234,7 @@ void WiFiUDP::flush()
|
|||||||
IPAddress WiFiUDP::remoteIP() const
|
IPAddress WiFiUDP::remoteIP() const
|
||||||
{
|
{
|
||||||
if (!_ctx)
|
if (!_ctx)
|
||||||
return IPNoAddress;
|
return INADDR_ANY;
|
||||||
|
|
||||||
return _ctx->getRemoteAddress();
|
return _ctx->getRemoteAddress();
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ uint16_t WiFiUDP::remotePort() const
|
|||||||
IPAddress WiFiUDP::destinationIP() const
|
IPAddress WiFiUDP::destinationIP() const
|
||||||
{
|
{
|
||||||
if (!_ctx)
|
if (!_ctx)
|
||||||
return IPNoAddress;
|
return INADDR_ANY;
|
||||||
|
|
||||||
return _ctx->getDestAddress();
|
return _ctx->getDestAddress();
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ int DNSClient::getHostByName(const char* aHostname, IPAddress& aResult)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check we've got a valid DNS server to use
|
// Check we've got a valid DNS server to use
|
||||||
if (iDNSServer == IPNoAddress)
|
if (iDNSServer == INADDR_NONE || iDNSServer == INADDR_ANY)
|
||||||
{
|
{
|
||||||
return INVALID_SERVER;
|
return INVALID_SERVER;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user