| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <pj/addr_resolv.h> |
| 20 |
#include <pj/assert.h> |
| 21 |
#include <pj/string.h> |
| 22 |
#include <pj/errno.h> |
| 23 |
#include <pj/ip_helper.h> |
| 24 |
#include <pj/compat/socket.h> |
| 25 |
|
| 26 |
#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0 |
| 27 |
# include <CoreFoundation/CFString.h> |
| 28 |
# include <CFNetwork/CFHost.h> |
| 29 |
|
| 30 |
#elif defined(PJ_GETADDRINFO_USE_ANDROID) && PJ_GETADDRINFO_USE_ANDROID!=0 |
| 31 |
# include <sys/poll.h> |
| 32 |
# include <resolv.h> |
| 33 |
# include <netdb.h> |
| 34 |
# include <android/multinetwork.h> |
| 35 |
# include <sys/system_properties.h> |
| 36 |
# include <dlfcn.h> |
| 37 |
#endif |
| 38 |
|
| 39 |
#define THIS_FILE "addr_resolv_sock.c" |
| 40 |
#define ANDROID_DNS_TIMEOUT_MS 5000 |
| 41 |
|
| 42 |
PJ_DEF(pj_status_t) pj_gethostbyname(const pj_str_t *hostname, pj_hostent *phe) |
| 43 |
{ |
| 44 |
struct hostent *he; |
| 45 |
char copy[PJ_MAX_HOSTNAME]; |
| 46 |
|
| 47 |
pj_assert(hostname && hostname ->slen < PJ_MAX_HOSTNAME); |
| 48 |
|
| 49 |
if (hostname->slen >= PJ_MAX_HOSTNAME) |
| 50 |
return PJ_ENAMETOOLONG; |
| 51 |
|
| 52 |
pj_memcpy(copy, hostname->ptr, hostname->slen); |
| 53 |
copy[ hostname->slen ] = '\0'; |
| 54 |
|
| 55 |
he = gethostbyname(copy); |
| 56 |
if (!he) { |
| 57 |
return PJ_ERESOLVE; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
phe->h_name = he->h_name; |
| 65 |
phe->h_aliases = he->h_aliases; |
| 66 |
phe->h_addrtype = he->h_addrtype; |
| 67 |
phe->h_length = he->h_length; |
| 68 |
phe->h_addr_list = he->h_addr_list; |
| 69 |
|
| 70 |
return PJ_SUCCESS; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
PJ_DEF(pj_status_t) pj_getaddrinfo(int af, const pj_str_t *nodename, |
| 75 |
unsigned *count, pj_addrinfo ai[]) |
| 76 |
{ |
| 77 |
#if defined(PJ_SOCK_HAS_GETADDRINFO) && PJ_SOCK_HAS_GETADDRINFO!=0 |
| 78 |
char nodecopy[PJ_MAX_HOSTNAME]; |
| 79 |
pj_bool_t has_addr = PJ_FALSE; |
| 80 |
unsigned i; |
| 81 |
#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0 |
| 82 |
CFStringRef hostname; |
| 83 |
CFHostRef hostRef; |
| 84 |
pj_status_t status = PJ_SUCCESS; |
| 85 |
#else |
| 86 |
int rc; |
| 87 |
struct addrinfo hint, *res, *orig_res; |
| 88 |
#endif |
| 89 |
|
| 90 |
PJ_ASSERT_RETURN(nodename && count && *count && ai, PJ_EINVAL); |
| 91 |
PJ_ASSERT_RETURN(nodename->ptr && nodename->slen, PJ_EINVAL); |
| 92 |
PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6 || |
| 93 |
af==PJ_AF_UNSPEC, PJ_EINVAL); |
| 94 |
|
| 95 |
#if PJ_WIN32_WINCE |
| 96 |
|
| 97 |
|
| 98 |
pj_bzero(&ai[0], sizeof(ai[0])); |
| 99 |
if ((af==PJ_AF_INET || af==PJ_AF_UNSPEC) && |
| 100 |
pj_inet_pton(PJ_AF_INET, nodename, |
| 101 |
&ai[0].ai_addr.ipv4.sin_addr) == PJ_SUCCESS) |
| 102 |
{ |
| 103 |
af = PJ_AF_INET; |
| 104 |
has_addr = PJ_TRUE; |
| 105 |
} else if ((af==PJ_AF_INET6 || af==PJ_AF_UNSPEC) && |
| 106 |
pj_inet_pton(PJ_AF_INET6, nodename, |
| 107 |
&ai[0].ai_addr.ipv6.sin6_addr) == PJ_SUCCESS) |
| 108 |
{ |
| 109 |
af = PJ_AF_INET6; |
| 110 |
has_addr = PJ_TRUE; |
| 111 |
} |
| 112 |
|
| 113 |
if (has_addr) { |
| 114 |
pj_str_t tmp; |
| 115 |
|
| 116 |
tmp.ptr = ai[0].ai_canonname; |
| 117 |
pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); |
| 118 |
ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; |
| 119 |
*count = 1; |
| 120 |
|
| 121 |
return PJ_SUCCESS; |
| 122 |
} |
| 123 |
|
| 124 |
#else |
| 125 |
PJ_UNUSED_ARG(has_addr); |
| 126 |
#endif |
| 127 |
|
| 128 |
|
| 129 |
if (nodename->slen >= PJ_MAX_HOSTNAME) |
| 130 |
return PJ_ENAMETOOLONG; |
| 131 |
pj_memcpy(nodecopy, nodename->ptr, nodename->slen); |
| 132 |
nodecopy[nodename->slen] = '\0'; |
| 133 |
|
| 134 |
#if defined(PJ_GETADDRINFO_USE_CFHOST) && PJ_GETADDRINFO_USE_CFHOST!=0 |
| 135 |
hostname = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, nodecopy, |
| 136 |
kCFStringEncodingASCII, |
| 137 |
kCFAllocatorNull); |
| 138 |
hostRef = CFHostCreateWithName(kCFAllocatorDefault, hostname); |
| 139 |
if (CFHostStartInfoResolution(hostRef, kCFHostAddresses, nil)) { |
| 140 |
CFArrayRef addrRef = CFHostGetAddressing(hostRef, nil); |
| 141 |
i = 0; |
| 142 |
if (addrRef != nil) { |
| 143 |
CFIndex idx, naddr; |
| 144 |
|
| 145 |
naddr = CFArrayGetCount(addrRef); |
| 146 |
for (idx = 0; idx < naddr && i < *count; idx++) { |
| 147 |
struct sockaddr *addr; |
| 148 |
size_t addr_size; |
| 149 |
|
| 150 |
addr = (struct sockaddr *) |
| 151 |
CFDataGetBytePtr(CFArrayGetValueAtIndex(addrRef, idx)); |
| 152 |
|
| 153 |
pj_assert(addr); |
| 154 |
|
| 155 |
|
| 156 |
if (af!=PJ_AF_UNSPEC && addr->sa_family != af) |
| 157 |
continue; |
| 158 |
|
| 159 |
|
| 160 |
pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy, |
| 161 |
sizeof(ai[i].ai_canonname)); |
| 162 |
|
| 163 |
|
| 164 |
addr_size = sizeof(*addr); |
| 165 |
if (addr->sa_family == PJ_AF_INET6) { |
| 166 |
addr_size = addr->sa_len; |
| 167 |
} |
| 168 |
PJ_ASSERT_ON_FAIL(addr_size <= sizeof(pj_sockaddr), continue); |
| 169 |
pj_memcpy(&ai[i].ai_addr, addr, addr_size); |
| 170 |
PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr); |
| 171 |
|
| 172 |
i++; |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
*count = i; |
| 177 |
if (*count == 0) |
| 178 |
status = PJ_ERESOLVE; |
| 179 |
|
| 180 |
} else { |
| 181 |
status = PJ_ERESOLVE; |
| 182 |
} |
| 183 |
|
| 184 |
CFRelease(hostRef); |
| 185 |
CFRelease(hostname); |
| 186 |
|
| 187 |
return status; |
| 188 |
|
| 189 |
#elif defined(PJ_GETADDRINFO_USE_ANDROID) && PJ_GETADDRINFO_USE_ANDROID!=0 |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
if (__builtin_available(android 29, *)) { |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
typedef int (*ns_initparse_fn)(const unsigned char *, int, void *); |
| 206 |
typedef int (*ns_parserr_fn)(const void *, int, int, void *); |
| 207 |
|
| 208 |
ns_initparse_fn ns_initparse_ptr = NULL; |
| 209 |
ns_parserr_fn ns_parserr_ptr = NULL; |
| 210 |
|
| 211 |
void *libc_handle = dlopen("libc.so", RTLD_NOW); |
| 212 |
if (libc_handle) { |
| 213 |
|
| 214 |
ns_initparse_ptr = (ns_initparse_fn) |
| 215 |
dlsym(libc_handle, |
| 216 |
"ns_initparse"); |
| 217 |
ns_parserr_ptr = (ns_parserr_fn) |
| 218 |
dlsym(libc_handle, |
| 219 |
"ns_parserr"); |
| 220 |
|
| 221 |
|
| 222 |
if (ns_initparse_ptr && |
| 223 |
ns_parserr_ptr) { |
| 224 |
pj_bzero(&hint, sizeof(hint)); |
| 225 |
hint.ai_family = af; |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
hint.ai_socktype = SOCK_STREAM; |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
unsigned int netid = NETWORK_UNSPECIFIED; |
| 234 |
|
| 235 |
unsigned char answer[NS_PACKETSZ]; |
| 236 |
int rcode = -1; |
| 237 |
struct addrinfo *result = NULL, *last = NULL; |
| 238 |
|
| 239 |
|
| 240 |
int resp_handle = android_res_nquery( |
| 241 |
netid, nodecopy, ns_c_in, |
| 242 |
af == PJ_AF_INET ? ns_t_a : |
| 243 |
af == PJ_AF_INET6 ? ns_t_aaaa : |
| 244 |
ns_t_a, |
| 245 |
0); |
| 246 |
if (resp_handle < 0) { |
| 247 |
printf("android_res_nquery() failed\n"); |
| 248 |
return PJ_ERESOLVE; |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
struct pollfd fds; |
| 253 |
fds.fd = resp_handle; |
| 254 |
fds.events = POLLIN; |
| 255 |
int ret = poll(&fds, 1, ANDROID_DNS_TIMEOUT_MS); |
| 256 |
|
| 257 |
if (ret <= 0) { |
| 258 |
PJ_LOG(4,(THIS_FILE,"Poll timeout or error")); |
| 259 |
android_res_cancel(resp_handle); |
| 260 |
return PJ_ERESOLVE; |
| 261 |
} |
| 262 |
|
| 263 |
int response_size = android_res_nresult( |
| 264 |
resp_handle, &rcode, answer, sizeof(answer)); |
| 265 |
if (response_size < 0) { |
| 266 |
PJ_LOG(4,(THIS_FILE, |
| 267 |
"android_res_nresult() failed")); |
| 268 |
return PJ_ERESOLVE; |
| 269 |
} |
| 270 |
|
| 271 |
|
| 272 |
ns_msg msg; |
| 273 |
ns_rr rr; |
| 274 |
int num_records, resolved_count = 0; |
| 275 |
|
| 276 |
if (ns_initparse_ptr(answer, response_size, &msg) < 0) { |
| 277 |
PJ_LOG(4,(THIS_FILE, |
| 278 |
"Failed to parse DNS response")); |
| 279 |
return PJ_ERESOLVE; |
| 280 |
} |
| 281 |
|
| 282 |
num_records = ns_msg_count(msg, ns_s_an); |
| 283 |
if (num_records == 0) { |
| 284 |
PJ_LOG(4,(THIS_FILE, |
| 285 |
"No DNS %s entries found for %s", |
| 286 |
af == PJ_AF_INET ? "A" : |
| 287 |
af == PJ_AF_INET6 ? "AAAA" : |
| 288 |
"A", |
| 289 |
nodecopy)); |
| 290 |
return PJ_ERESOLVE; |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
for (i = 0; i < num_records && resolved_count < *count; i++) { |
| 295 |
if (ns_parserr_ptr(&msg, ns_s_an, i, &rr) < 0) { |
| 296 |
continue; |
| 297 |
} |
| 298 |
|
| 299 |
int type = ns_rr_type(rr); |
| 300 |
int rdlen = ns_rr_rdlen(rr); |
| 301 |
const unsigned char *rdata = ns_rr_rdata(rr); |
| 302 |
|
| 303 |
|
| 304 |
if ((type == ns_t_a && rdlen == 4) || (type == ns_t_aaaa |
| 305 |
&& rdlen == 16)) { |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
if (type == ns_t_a) { |
| 310 |
struct sockaddr_in addr; |
| 311 |
pj_bzero(&addr, sizeof(addr)); |
| 312 |
addr.sin_family = PJ_AF_INET; |
| 313 |
pj_memcpy(&addr.sin_addr, rdata, 4); |
| 314 |
|
| 315 |
pj_memcpy(&ai[resolved_count].ai_addr, |
| 316 |
&addr, sizeof(addr)); |
| 317 |
} else { |
| 318 |
|
| 319 |
struct sockaddr_in6 addr6; |
| 320 |
pj_bzero(&addr6, sizeof(addr6)); |
| 321 |
addr6.sin6_family = PJ_AF_INET6; |
| 322 |
pj_memcpy(&addr6.sin6_addr, rdata, 16); |
| 323 |
pj_memcpy(&ai[resolved_count].ai_addr, |
| 324 |
&addr6, sizeof(addr6)); |
| 325 |
} |
| 326 |
|
| 327 |
|
| 328 |
pj_ansi_strxcpy(ai[resolved_count].ai_canonname, |
| 329 |
nodename->ptr, |
| 330 |
sizeof(ai[resolved_count].ai_canonname)); |
| 331 |
resolved_count++; |
| 332 |
} |
| 333 |
} |
| 334 |
|
| 335 |
|
| 336 |
*count = resolved_count; |
| 337 |
|
| 338 |
if (resolved_count == 0) { |
| 339 |
return PJ_ERESOLVE; |
| 340 |
} |
| 341 |
return PJ_SUCCESS; |
| 342 |
} |
| 343 |
} |
| 344 |
} |
| 345 |
|
| 346 |
pj_bzero(&hint, sizeof(hint)); |
| 347 |
hint.ai_family = af; |
| 348 |
|
| 349 |
|
| 350 |
hint.ai_socktype = 0; |
| 351 |
|
| 352 |
rc = getaddrinfo(nodecopy, NULL, &hint, &res); |
| 353 |
if (rc != 0) |
| 354 |
return PJ_ERESOLVE; |
| 355 |
|
| 356 |
orig_res = res; |
| 357 |
|
| 358 |
|
| 359 |
for (i=0; i<*count && res; res=res->ai_next) { |
| 360 |
unsigned j; |
| 361 |
pj_bool_t duplicate_found = PJ_FALSE; |
| 362 |
|
| 363 |
|
| 364 |
if (af!=PJ_AF_UNSPEC && res->ai_family != af) |
| 365 |
continue; |
| 366 |
|
| 367 |
if (res->ai_socktype != pj_SOCK_DGRAM() && |
| 368 |
res->ai_socktype != pj_SOCK_STREAM() && |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
res->ai_socktype != 0) |
| 373 |
{ |
| 374 |
continue; |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
for (j = 0; j < i; j++) { |
| 380 |
if (!pj_sockaddr_cmp(&ai[j].ai_addr, res->ai_addr)) { |
| 381 |
duplicate_found = PJ_TRUE; |
| 382 |
break; |
| 383 |
} |
| 384 |
} |
| 385 |
if (duplicate_found) { |
| 386 |
continue; |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
if (res->ai_canonname) { |
| 391 |
pj_ansi_strxcpy(ai[i].ai_canonname, res->ai_canonname, |
| 392 |
sizeof(ai[i].ai_canonname)); |
| 393 |
} else { |
| 394 |
pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy, |
| 395 |
sizeof(ai[i].ai_canonname)); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
PJ_ASSERT_ON_FAIL(res->ai_addrlen <= sizeof(pj_sockaddr), continue); |
| 400 |
pj_memcpy(&ai[i].ai_addr, res->ai_addr, res->ai_addrlen); |
| 401 |
PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr); |
| 402 |
|
| 403 |
|
| 404 |
++i; |
| 405 |
} |
| 406 |
|
| 407 |
*count = i; |
| 408 |
|
| 409 |
freeaddrinfo(orig_res); |
| 410 |
|
| 411 |
|
| 412 |
return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE); |
| 413 |
|
| 414 |
#else |
| 415 |
|
| 416 |
pj_bzero(&hint, sizeof(hint)); |
| 417 |
hint.ai_family = af; |
| 418 |
|
| 419 |
|
| 420 |
hint.ai_socktype = 0; |
| 421 |
|
| 422 |
rc = getaddrinfo(nodecopy, NULL, &hint, &res); |
| 423 |
if (rc != 0) |
| 424 |
return PJ_ERESOLVE; |
| 425 |
|
| 426 |
orig_res = res; |
| 427 |
|
| 428 |
|
| 429 |
for (i=0; i<*count && res; res=res->ai_next) { |
| 430 |
unsigned j; |
| 431 |
pj_bool_t duplicate_found = PJ_FALSE; |
| 432 |
|
| 433 |
|
| 434 |
if (af!=PJ_AF_UNSPEC && res->ai_family != af) |
| 435 |
continue; |
| 436 |
|
| 437 |
if (res->ai_socktype != pj_SOCK_DGRAM() && |
| 438 |
res->ai_socktype != pj_SOCK_STREAM() && |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
res->ai_socktype != 0) |
| 443 |
{ |
| 444 |
continue; |
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
for (j = 0; j < i; j++) { |
| 450 |
if (!pj_sockaddr_cmp(&ai[j].ai_addr, res->ai_addr)) { |
| 451 |
duplicate_found = PJ_TRUE; |
| 452 |
break; |
| 453 |
} |
| 454 |
} |
| 455 |
if (duplicate_found) { |
| 456 |
continue; |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
if (res->ai_canonname) { |
| 461 |
pj_ansi_strxcpy(ai[i].ai_canonname, res->ai_canonname, |
| 462 |
sizeof(ai[i].ai_canonname)); |
| 463 |
} else { |
| 464 |
pj_ansi_strxcpy(ai[i].ai_canonname, nodecopy, |
| 465 |
sizeof(ai[i].ai_canonname)); |
| 466 |
} |
| 467 |
|
| 468 |
|
| 469 |
PJ_ASSERT_ON_FAIL(res->ai_addrlen <= sizeof(pj_sockaddr), continue); |
| 470 |
pj_memcpy(&ai[i].ai_addr, res->ai_addr, res->ai_addrlen); |
| 471 |
PJ_SOCKADDR_RESET_LEN(&ai[i].ai_addr); |
| 472 |
|
| 473 |
|
| 474 |
++i; |
| 475 |
} |
| 476 |
|
| 477 |
*count = i; |
| 478 |
|
| 479 |
freeaddrinfo(orig_res); |
| 480 |
|
| 481 |
|
| 482 |
return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE); |
| 483 |
#endif |
| 484 |
|
| 485 |
#else |
| 486 |
pj_bool_t has_addr = PJ_FALSE; |
| 487 |
|
| 488 |
PJ_ASSERT_RETURN(count && *count, PJ_EINVAL); |
| 489 |
|
| 490 |
#if PJ_WIN32_WINCE |
| 491 |
|
| 492 |
|
| 493 |
pj_bzero(&ai[0], sizeof(ai[0])); |
| 494 |
if ((af==PJ_AF_INET || af==PJ_AF_UNSPEC) && |
| 495 |
pj_inet_pton(PJ_AF_INET, nodename, |
| 496 |
&ai[0].ai_addr.ipv4.sin_addr) == PJ_SUCCESS) |
| 497 |
{ |
| 498 |
af = PJ_AF_INET; |
| 499 |
has_addr = PJ_TRUE; |
| 500 |
} |
| 501 |
else if ((af==PJ_AF_INET6 || af==PJ_AF_UNSPEC) && |
| 502 |
pj_inet_pton(PJ_AF_INET6, nodename, |
| 503 |
&ai[0].ai_addr.ipv6.sin6_addr) == PJ_SUCCESS) |
| 504 |
{ |
| 505 |
af = PJ_AF_INET6; |
| 506 |
has_addr = PJ_TRUE; |
| 507 |
} |
| 508 |
|
| 509 |
if (has_addr) { |
| 510 |
pj_str_t tmp; |
| 511 |
|
| 512 |
tmp.ptr = ai[0].ai_canonname; |
| 513 |
pj_strncpy_with_null(&tmp, nodename, PJ_MAX_HOSTNAME); |
| 514 |
ai[0].ai_addr.addr.sa_family = (pj_uint16_t)af; |
| 515 |
*count = 1; |
| 516 |
|
| 517 |
return PJ_SUCCESS; |
| 518 |
} |
| 519 |
|
| 520 |
#else |
| 521 |
PJ_UNUSED_ARG(has_addr); |
| 522 |
#endif |
| 523 |
|
| 524 |
if (af == PJ_AF_INET || af == PJ_AF_UNSPEC) { |
| 525 |
pj_hostent he; |
| 526 |
unsigned i, max_count; |
| 527 |
pj_status_t status; |
| 528 |
|
| 529 |
|
| 530 |
#ifdef _MSC_VER |
| 531 |
pj_bzero(&he, sizeof(he)); |
| 532 |
#endif |
| 533 |
|
| 534 |
status = pj_gethostbyname(nodename, &he); |
| 535 |
if (status != PJ_SUCCESS) |
| 536 |
return status; |
| 537 |
|
| 538 |
max_count = *count; |
| 539 |
*count = 0; |
| 540 |
|
| 541 |
pj_bzero(ai, max_count * sizeof(pj_addrinfo)); |
| 542 |
|
| 543 |
for (i=0; he.h_addr_list[i] && *count<max_count; ++i) { |
| 544 |
pj_ansi_strxcpy(ai[*count].ai_canonname, he.h_name, |
| 545 |
sizeof(ai[*count].ai_canonname)); |
| 546 |
|
| 547 |
ai[*count].ai_addr.ipv4.sin_family = PJ_AF_INET; |
| 548 |
pj_memcpy(&ai[*count].ai_addr.ipv4.sin_addr, |
| 549 |
he.h_addr_list[i], he.h_length); |
| 550 |
PJ_SOCKADDR_RESET_LEN(&ai[*count].ai_addr); |
| 551 |
|
| 552 |
(*count)++; |
| 553 |
} |
| 554 |
|
| 555 |
return (*count > 0? PJ_SUCCESS : PJ_ERESOLVE); |
| 556 |
|
| 557 |
} else { |
| 558 |
|
| 559 |
*count = 0; |
| 560 |
|
| 561 |
return PJ_EIPV6NOTSUP; |
| 562 |
} |
| 563 |
#endif |
| 564 |
} |
| 565 |
|