| 166 | } |
| 167 | |
| 168 | EndPointStr endpoint2str(const EndPoint& point) { |
| 169 | EndPointStr str; |
| 170 | if (ExtendedEndPoint::is_extended(point)) { |
| 171 | ExtendedEndPoint* eep = ExtendedEndPoint::address(point); |
| 172 | if (eep) { |
| 173 | eep->to(&str); |
| 174 | } else { |
| 175 | str._buf[0] = '\0'; |
| 176 | } |
| 177 | return str; |
| 178 | } |
| 179 | if (inet_ntop(AF_INET, &point.ip, str._buf, INET_ADDRSTRLEN) == NULL) { |
| 180 | return endpoint2str(EndPoint(IP_NONE, 0)); |
| 181 | } |
| 182 | char* buf = str._buf + strlen(str._buf); |
| 183 | *buf++ = ':'; |
| 184 | snprintf(buf, 16, "%d", point.port); |
| 185 | return str; |
| 186 | } |
| 187 | |
| 188 | int hostname2ip(const char* hostname, ip_t* ip) { |
| 189 | char buf[256]; |