Skip to content
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
11 changes: 11 additions & 0 deletions api/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ IPAddress::IPAddress(IPType ip_type, const uint8_t *address)
}
}

IPAddress::IPAddress(const char *address)
{
fromString(address);
}

bool IPAddress::fromString(const char *address) {
if (!fromString4(address)) {
return fromString6(address);
Expand Down Expand Up @@ -225,6 +230,12 @@ IPAddress& IPAddress::operator=(const uint8_t *address)
return *this;
}

IPAddress& IPAddress::operator=(const char *address)
{
fromString(address);
return *this;
}

IPAddress& IPAddress::operator=(uint32_t address)
{
// IPv4 conversion
Expand Down
4 changes: 4 additions & 0 deletions api/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class IPAddress : public Printable {
// Default IPv4
IPAddress(const uint8_t *address);
IPAddress(IPType ip_type, const uint8_t *address);
// If IPv4 fails tries IPv6 see fromString function
IPAddress(const char *address);

bool fromString(const char *address);
bool fromString(const String &address) { return fromString(address.c_str()); }
Expand All @@ -90,6 +92,8 @@ class IPAddress : public Printable {
IPAddress& operator=(const uint8_t *address);
// NOTE: IPv4 only; see implementation note
IPAddress& operator=(uint32_t address);
// If IPv4 fails tries IPv6 see fromString function
IPAddress& operator=(const char *address);

virtual size_t printTo(Print& p) const;

Expand Down