98 |
98 |
99 // ----------------------------------------------------------------------------- |
99 // ----------------------------------------------------------------------------- |
100 // |
100 // |
101 bool IPAddress::operator< (const IPAddress& other) const |
101 bool IPAddress::operator< (const IPAddress& other) const |
102 { |
102 { |
103 for (int i : range(4)) |
103 for (int i = 0; i < 4; i += 1) |
104 { |
104 { |
105 if (octet (i) != other.octet (i)) |
105 if (octet (i) != other.octet (i)) |
106 return octet (i) < other.octet (i); |
106 return octet (i) < other.octet (i); |
107 } |
107 } |
108 |
108 |
131 IPAddress value; |
131 IPAddress value; |
132 |
132 |
133 // Try scanf the IPv4 host first |
133 // Try scanf the IPv4 host first |
134 if (sscanf(addressString.data(), "%u.%u.%u.%u", &parts[0], &parts[1], &parts[2], &parts[3])) |
134 if (sscanf(addressString.data(), "%u.%u.%u.%u", &parts[0], &parts[1], &parts[2], &parts[3])) |
135 { |
135 { |
136 for (int i : range(4)) |
136 for (int i = 0; i < 4; i += 1) |
137 value.set_octet (i, parts[i]); |
137 value.set_octet (i, parts[i]); |
138 } |
138 } |
139 else |
139 else |
140 { |
140 { |
141 // Possibly a hostname, try resolve it |
141 // Possibly a hostname, try resolve it |