Skip to content

IPAddress updates #5409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
#define IP4_ADDR_ANY4 IPADDR_ANY
#define IPADDR4_INIT(x) { x }
#define CONST /* nothing: lwIP-v1 does not use const */
#else
#else // lwIP-v2+
#define CONST const
#endif
#if !LWIP_IPV6
#define ip_addr ipv4_addr
#endif // !LWIP_IPV6
#endif // lwIP-v2+

// A class to make it easier to handle and pass around IP addresses
// IPv6 update:
Expand Down Expand Up @@ -96,9 +99,15 @@ class IPAddress: public Printable {
bool operator==(uint32_t addr) const {
return isV4() && v4() == addr;
}
bool operator==(u32_t addr) const {
return isV4() && v4() == addr;
}
bool operator!=(uint32_t addr) const {
return !(isV4() && v4() == addr);
}
bool operator!=(u32_t addr) const {
return !(isV4() && v4() == addr);
}
bool operator==(const uint8_t* addr) const;

// Overloaded index operator to allow getting and setting individual octets of the address
Expand Down Expand Up @@ -193,6 +202,7 @@ class IPAddress: public Printable {

extern CONST IPAddress IPNoAddress;

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

#endif
4 changes: 2 additions & 2 deletions libraries/Ethernet/src/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void DNSClient::begin(const IPAddress& aDNSServer)
}


int DNSClient::inet_aton(const char* aIPAddrString, IPAddress& aResult)
int DNSClient::inet_aton_ethlib(const char* aIPAddrString, IPAddress& aResult)
{
// See if we've been given a valid IP address
const char* p =aIPAddrString;
Expand Down Expand Up @@ -120,7 +120,7 @@ int DNSClient::getHostByName(const char* aHostname, IPAddress& aResult)
int ret =0;

// See if it's a numeric IP address
if (inet_aton(aHostname, aResult))
if (inet_aton_ethlib(aHostname, aResult))
{
// It is, our work here is done
return 1;
Expand Down
2 changes: 1 addition & 1 deletion libraries/Ethernet/src/Dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DNSClient
@result 1 if aIPAddrString was successfully converted to an IP address,
else error code
*/
int inet_aton(const char *aIPAddrString, IPAddress& aResult);
int inet_aton_ethlib(const char *aIPAddrString, IPAddress& aResult);

/** Resolve the given hostname to an IP address.
@param aHostname Name to be resolved
Expand Down