| 493 | } |
| 494 | |
| 495 | inline struct hostent* resolvehost(char* name, int no_ip_test) |
| 496 | { |
| 497 | static struct hostent *he = NULL; |
| 498 | #ifdef HAVE_GETIPNODEBYNAME |
| 499 | int err; |
| 500 | static struct hostent *he2 = NULL; |
| 501 | #endif |
| 502 | struct timeval start; |
| 503 | struct ip_addr *ip; |
| 504 | str s; |
| 505 | |
| 506 | if (!no_ip_test) { |
| 507 | s.s = (char *)name; |
| 508 | s.len = strlen(name); |
| 509 | |
| 510 | /* check if it's an ip address */ |
| 511 | if ((ip = str2ip(&s)) || (ip = str2ip6(&s))) { |
| 512 | /* we are lucky, this is an ip address */ |
| 513 | return ip_addr2he(&s, ip); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | start_expire_timer(start, execdnsthreshold); |
| 518 | |
| 519 | if (dns_try_ipv6) { |
| 520 | /* try ipv6 */ |
| 521 | #ifdef HAVE_GETHOSTBYNAME2 |
| 522 | if (dnscache_fetch_func) |
| 523 | he = own_gethostbyname2(name,AF_INET6); |
| 524 | else |
| 525 | he = gethostbyname2(name, AF_INET6); |
| 526 | |
| 527 | #elif defined HAVE_GETIPNODEBYNAME |
| 528 | /* on solaris 8 getipnodebyname has a memory leak, |
| 529 | * after some time calls to it will fail with err=3 |
| 530 | * solution: patch your solaris 8 installation */ |
| 531 | if (he2) freehostent(he2); |
| 532 | he = he2 = getipnodebyname(name, AF_INET6, 0, &err); |
| 533 | #else |
| 534 | #error "neither gethostbyname2 or getipnodebyname present" |
| 535 | #endif |
| 536 | if (he != 0) |
| 537 | /* return the inet6 result if exists */ |
| 538 | goto out; |
| 539 | } |
| 540 | |
| 541 | if (dnscache_fetch_func) |
| 542 | he = own_gethostbyname2(name,AF_INET); |
| 543 | else |
| 544 | he = gethostbyname(name); |
| 545 | |
| 546 | out: |
| 547 | _stop_expire_timer(start, execdnsthreshold, "dns", |
| 548 | name, strlen(name), 0, dns_slow_queries, dns_total_queries); |
| 549 | return he; |
| 550 | } |
| 551 | |
| 552 | struct hostent * own_gethostbyaddr(void *addr, socklen_t len, int af) |
no test coverage detected