diff options
Diffstat (limited to 'core/io/ip_address.cpp')
-rw-r--r-- | core/io/ip_address.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index 817c2f060a..89b317bf93 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -39,19 +39,23 @@ IP_Address::operator Variant() const { #include <string.h> IP_Address::operator String() const { - if (wildcard) + if (wildcard) { return "*"; + } - if (!valid) + if (!valid) { return ""; + } - if (is_ipv4()) + if (is_ipv4()) { // IPv4 address mapped to IPv6 return itos(field8[12]) + "." + itos(field8[13]) + "." + itos(field8[14]) + "." + itos(field8[15]); + } String ret; for (int i = 0; i < 8; i++) { - if (i > 0) + if (i > 0) { ret = ret + ":"; + } uint16_t num = (field8[i * 2] << 8) + field8[i * 2 + 1]; ret = ret + String::num_int64(num, 16); }; @@ -187,8 +191,9 @@ const uint8_t *IP_Address::get_ipv6() const { void IP_Address::set_ipv6(const uint8_t *p_buf) { clear(); valid = true; - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { field8[i] = p_buf[i]; + } } IP_Address::IP_Address(const String &p_string) { |