void block_dns_ipbyhost(char *host) { struct in_addr inaddr; Context; /* Check if someone passed us an IP address as hostname * and return it straight away */ if (egg_inet_aton(host, &inaddr)) { call_ipbyhost(host, my_ntohl(inaddr.s_addr), 1); return; } if (!setjmp(alarmret)) { struct hostent *hp; struct in_addr *in; IP ip = 0; alarm(resolve_timeout); hp = gethostbyname(host); alarm(0); if (hp) { in = (struct in_addr *) (hp->h_addr_list[0]); ip = (IP) (in->s_addr); call_ipbyhost(host, my_ntohl(ip), 1); return; } /* Fall through. */ } call_ipbyhost(host, 0, 0); Context; }
/* * DNS event related code */ static void dns_event_success(struct resolve *rp, int type) { if (!rp) return; if (type == T_PTR) { debug2("DNS resolved %s to %s", iptostr(rp->ip), rp->hostn); call_hostbyip(ntohl(rp->ip), rp->hostn, 1); } else if (type == T_A) { debug2("DNS resolved %s to %s", rp->hostn, iptostr(rp->ip)); call_ipbyhost(rp->hostn, ntohl(rp->ip), 1); } }
static void dns_event_failure(struct resolve *rp, int type) { if (!rp) return; if (type == T_PTR) { static char s[UHOSTLEN]; debug1("DNS resolve failed for %s", iptostr(rp->ip)); strcpy(s, iptostr(rp->ip)); call_hostbyip(ntohl(rp->ip), s, 0); } else if (type == T_A) { debug1("DNS resolve failed for %s", rp->hostn); call_ipbyhost(rp->hostn, 0, 0); } else debug2("DNS resolve failed for unknown %s / %s", iptostr(rp->ip), nonull(rp->hostn)); return; }