udhcp: use improved gethostbyname replacement from IPv6 code

This commit is contained in:
Denis Vlasenko
2007-02-04 02:41:57 +00:00
parent 1094452423
commit e991303406
4 changed files with 20 additions and 11 deletions

View File

@@ -21,15 +21,14 @@
/* on these functions, make sure you datatype matches */
static int read_ip(const char *line, void *arg)
{
struct in_addr *addr = arg;
struct hostent *host;
int retval = 1;
len_and_sockaddr *lsa;
int retval = 0;
if (!inet_aton(line, addr)) {
host = gethostbyname(line);
if (host)
addr->s_addr = *((unsigned long *) host->h_addr_list[0]);
else retval = 0;
lsa = host_and_af2sockaddr(line, 0, AF_INET);
if (lsa) {
*(struct in_addr*)arg = lsa->sin.sin_addr;
free(lsa);
retval = 1;
}
return retval;
}