summaryrefslogtreecommitdiff
path: root/hostmux
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2002-03-10 23:59:40 +0000
committerNeal H. Walfield <neal@gnu.org>2002-03-10 23:59:40 +0000
commitd0f5929ab76f5b91c4b931add3945bb11c887363 (patch)
tree27e7b34d1a58572c14708a8f28f36564eeb16578 /hostmux
parent269bc57032615eba2339cc150d012f4b5c3ae5db (diff)
2002-03-10 Neal H Walfield <neal@cs.uml.edu>
* mux.c (lookup_addrinfo): Renamed from lookup_hostent. Change HE from a struct hostent to a struct addrinfo. (lookup_host): Use lookup_addrinfo, not lookup_hostent. Reported by James A. Morrison <ja2morri@uwaterloo.ca>.
Diffstat (limited to 'hostmux')
-rw-r--r--hostmux/mux.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/hostmux/mux.c b/hostmux/mux.c
index 17cbc35f3..0d5906c4e 100644
--- a/hostmux/mux.c
+++ b/hostmux/mux.c
@@ -1,7 +1,7 @@
/* Root hostmux node
- Copyright (C) 1997, 1999 Free Software Foundation, Inc.
- Written by Miles Bader <miles@gnu.ai.mit.edu>
+ Copyright (C) 1997,99,2002 Free Software Foundation, Inc.
+ Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
@@ -273,8 +273,8 @@ lookup_cached (struct hostmux *mux, const char *host, int purge,
if HOST refers to the official name of the host, or a symlink node to the
official name, if it doesn't. */
static error_t
-lookup_hostent (struct hostmux *mux, const char *host, struct hostent *he,
- struct node **node)
+lookup_addrinfo (struct hostmux *mux, const char *host, struct addrinfo *he,
+ struct node **node)
{
error_t err;
struct hostmux_name *nm = malloc (sizeof (struct hostmux_name));
@@ -283,10 +283,10 @@ lookup_hostent (struct hostmux *mux, const char *host, struct hostent *he,
return ENOMEM;
nm->name = strdup (host);
- if (strcmp (host, he->h_name) == 0)
+ if (strcmp (host, he->ai_canonname) == 0)
nm->canon = nm->name;
else
- nm->canon = strdup (he->h_name);
+ nm->canon = strdup (he->ai_canonname);
err = create_host_node (mux, nm, node);
if (err)
@@ -325,9 +325,13 @@ lookup_host (struct hostmux *mux, const char *host, struct node **node)
{
int was_cached;
int h_err;
- struct hostent _he, *he;
- struct in_addr inet_addr;
- char hostent_data[2048]; /* XXX what size should this be???? */
+ struct addrinfo *ai;
+ struct addrinfo hints;
+
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = PF_INET;
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_protocol = IPPROTO_IP;
rwlock_reader_lock (&mux->names_lock);
was_cached = lookup_cached (mux, host, 0, node);
@@ -335,20 +339,15 @@ lookup_host (struct hostmux *mux, const char *host, struct node **node)
if (was_cached)
return 0;
- else if (inet_aton (host, &inet_addr))
+
+ h_err = getaddrinfo (host, NULL, &hints, &ai);
+ if (! h_err)
{
- if (gethostbyaddr_r ((char *)&inet_addr, sizeof inet_addr, AF_INET,
- &_he, hostent_data, sizeof hostent_data,
- &he, &h_err) == 0)
- return lookup_hostent (mux, host, he, node);
- else
- return ENOENT;
+ h_err = lookup_addrinfo (mux, host, ai, node);
+ freeaddrinfo (ai);
}
- else if (gethostbyname_r (host, &_he, hostent_data, sizeof hostent_data,
- &he, &h_err) == 0)
- return lookup_hostent (mux, host, he, node);
- else
- return ENOENT;
+
+ return h_err;
}
/* This should sync the entire remote filesystem. If WAIT is set, return