1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

IPAddress: allow misaligned source in constructor (#5421)

This commit is contained in:
david gauchard 2018-12-03 16:59:38 +01:00 committed by GitHub
parent ca3678f7c1
commit 31bee50102
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -22,6 +22,11 @@
#include <Print.h>
#include <StreamString.h>
IPAddress::IPAddress(const IPAddress& from)
{
ip_addr_copy(_ip, from._ip);
}
IPAddress::IPAddress() {
_ip = *IP_ANY_TYPE; // lwIP's v4-or-v6 generic address
}
@ -45,7 +50,10 @@ void IPAddress::ctor32(uint32_t address) {
IPAddress::IPAddress(const uint8_t *address) {
setV4();
v4() = *reinterpret_cast<const uint32_t*>(address);
(*this)[0] = address[0];
(*this)[1] = address[1];
(*this)[2] = address[2];
(*this)[3] = address[3];
}
bool IPAddress::fromString(const char *address) {

View File

@ -72,6 +72,7 @@ class IPAddress: public Printable {
public:
// Constructors
IPAddress();
IPAddress(const IPAddress& from);
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
IPAddress(uint32_t address) { ctor32(address); }
IPAddress(u32_t address) { ctor32(address); }