aboutsummaryrefslogtreecommitdiff
path: root/resolv/res_init.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-26 08:05:34 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-26 08:05:34 +0000
commit438e82396b76a9b4a88b66e0e261979a0d1447c5 (patch)
treefdd8513e5e55ea3c8e61050a6d86f57ff3786e65 /resolv/res_init.c
parentec08818d20725ce34ddaa3d9bff9a4ddc4f0c58b (diff)
downloadglibc-438e82396b76a9b4a88b66e0e261979a0d1447c5.tar
glibc-438e82396b76a9b4a88b66e0e261979a0d1447c5.tar.gz
glibc-438e82396b76a9b4a88b66e0e261979a0d1447c5.tar.bz2
glibc-438e82396b76a9b4a88b66e0e261979a0d1447c5.zip
Update.
2000-07-26 Ulrich Drepper <drepper@redhat.com> * resolv/res_init.c: Add support for nameserver communication with IPv6. * resolv/res_send.c: Likewise. * resolv/resolv.h (struct __res_state): Store IPv6 address, not IPv4 in nsaddrs field. Patch by <venaas@nvg.ntnu.no>.
Diffstat (limited to 'resolv/res_init.c')
-rw-r--r--resolv/res_init.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/resolv/res_init.c b/resolv/res_init.c
index c483645ed7..b6e63d225c 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -143,6 +143,9 @@ __res_vinit(res_state statp, int preinit) {
register int n;
char buf[BUFSIZ];
int nserv = 0; /* number of nameserver records read from file */
+#ifdef _LIBC
+ int nservall = 0; /* number of NS records read, nserv IPv4 only */
+#endif
int haveenv = 0;
int havesearch = 0;
#ifdef RESOLVSORT
@@ -175,6 +178,11 @@ __res_vinit(res_state statp, int preinit) {
statp->qhook = NULL;
statp->rhook = NULL;
statp->_u._ext.nscount = 0;
+#ifdef _LIBC
+ statp->_u._ext.nscount6 = 0;
+ for (n = 0; n < MAXNS; n++)
+ statp->_u._ext.nsaddrs[n] = NULL;
+#endif
/* Allow user to override the local domain definition */
if ((cp = __secure_getenv("LOCALDOMAIN")) != NULL) {
@@ -276,7 +284,11 @@ __res_vinit(res_state statp, int preinit) {
continue;
}
/* read nameservers to query */
+#ifdef _LIBC
+ if (MATCH(buf, "nameserver") && nservall < MAXNS) {
+#else
if (MATCH(buf, "nameserver") && nserv < MAXNS) {
+#endif
struct in_addr a;
cp = buf + sizeof("nameserver") - 1;
@@ -288,6 +300,30 @@ __res_vinit(res_state statp, int preinit) {
statp->nsaddr_list[nserv].sin_port =
htons(NAMESERVER_PORT);
nserv++;
+#ifdef _LIBC
+ nservall++;
+ } else {
+ struct in6_addr a6;
+ char *el;
+
+ if ((el = strchr(cp, '\n')) != NULL)
+ *el = '\0';
+ if ((*cp != '\0') &&
+ (inet_pton(AF_INET6, cp, &a6) > 0)) {
+ struct sockaddr_in6 *sa6;
+
+ sa6 = malloc(sizeof(*sa6));
+ if (sa6 != NULL) {
+ sa6->sin6_addr = a6;
+ sa6->sin6_family = AF_INET6;
+ sa6->sin6_port = htons(NAMESERVER_PORT);
+ statp->_u._ext.nsaddrs[nservall] = sa6;
+ statp->_u._ext.nstimes[nservall] = RES_MAXTIME;
+ statp->_u._ext.nssocks[nservall] = -1;
+ nservall++;
+ }
+ }
+#endif
}
continue;
}
@@ -341,6 +377,10 @@ __res_vinit(res_state statp, int preinit) {
}
if (nserv > 1)
statp->nscount = nserv;
+#ifdef _LIBC
+ if (nservall - nserv > 0)
+ statp->_u._ext.nscount6 = nservall - nserv;
+#endif
#ifdef RESOLVSORT
statp->nsort = nsort;
#endif
@@ -491,7 +531,13 @@ res_nclose(res_state statp) {
statp->_vcsock = -1;
statp->_flags &= ~(RES_F_VC | RES_F_CONN);
}
- for (ns = 0; ns < statp->_u._ext.nscount; ns++) {
+#ifdef _LIBC
+ for (ns = 0; ns < statp->_u._ext.nscount + statp->_u._ext.nscount6;
+ ns++)
+#else
+ for (ns = 0; ns < statp->_u._ext.nscount; ns++)
+#endif
+ {
if (statp->_u._ext.nssocks[ns] != -1) {
(void) close(statp->_u._ext.nssocks[ns]);
statp->_u._ext.nssocks[ns] = -1;