116 |
116 |
117 // ----------------------------------------------------------------------------- |
117 // ----------------------------------------------------------------------------- |
118 // |
118 // |
119 bool IPAddress::operator< (const IPAddress& other) const |
119 bool IPAddress::operator< (const IPAddress& other) const |
120 { |
120 { |
121 for (int i = 0; i < 4; ++i) |
121 for (int i : range(4)) |
122 { |
122 { |
123 if (octet (i) != other.octet (i)) |
123 if (octet (i) != other.octet (i)) |
124 return octet (i) < other.octet (i); |
124 return octet (i) < other.octet (i); |
125 } |
125 } |
126 |
126 |
149 IPAddress value; |
149 IPAddress value; |
150 |
150 |
151 // Try scanf the IPv4 host first |
151 // Try scanf the IPv4 host first |
152 if (sscanf (addressString, "%u.%u.%u.%u", &parts[0], &parts[1], &parts[2], &parts[3])) |
152 if (sscanf (addressString, "%u.%u.%u.%u", &parts[0], &parts[1], &parts[2], &parts[3])) |
153 { |
153 { |
154 for (short i = 0; i < 4; ++i) |
154 for (int i : range(4)) |
155 value.set_octet (i, parts[i]); |
155 value.set_octet (i, parts[i]); |
156 } |
156 } |
157 else |
157 else |
158 { |
158 { |
159 // Possibly a hostname, try resolve it |
159 // Possibly a hostname, try resolve it |