Unverified Commit 16b1aeb7 authored by Mathieu Carbou's avatar Mathieu Carbou Committed by GitHub

fix(net): Fix IPv4 address construction from ip_addr_t and comparison (#9724) (#9725)

parent f1cb6b83
......@@ -266,7 +266,7 @@ IPAddress &IPAddress::operator=(const IPAddress &address) {
}
bool IPAddress::operator==(const IPAddress &addr) const {
return (addr._type == _type) && (memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0);
return (addr._type == _type) && (_type == IPType::IPv4 ? addr._address.dword[IPADDRESS_V4_DWORD_INDEX] == _address.dword[IPADDRESS_V4_DWORD_INDEX] : memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0);
}
bool IPAddress::operator==(const uint8_t *addr) const {
......@@ -395,6 +395,7 @@ IPAddress &IPAddress::from_ip_addr_t(const ip_addr_t *addr) {
#endif /* LWIP_IPV6_SCOPES */
} else {
_type = IPv4;
memset(_address.bytes, 0, sizeof(_address.bytes));
_address.dword[IPADDRESS_V4_DWORD_INDEX] = addr->u_addr.ip4.addr;
}
return *this;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment