From 3bc99c11580a246a92cc179af6566da622a998ef Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 23 Oct 2004 06:12:20 +0000 Subject: [PATCH] Remove compatibility code which is unused in glibc and probably bitrotten. --- resolv/res_send.c | 200 +----------------------------------------------------- 1 file changed, 2 insertions(+), 198 deletions(-) diff --git a/resolv/res_send.c b/resolv/res_send.c index 7773a2f..ca3e630 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -78,9 +78,7 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi #include #include #include -#ifdef _LIBC #include -#endif #include #include @@ -103,9 +101,6 @@ static const char rcsid[] = "$BINDId: res_send.c,v 8.38 2000/03/30 20:16:51 vixi #define MAXPACKET 65536 #endif -#ifndef _LIBC -#include -#else /* From ev_streams.c. */ @@ -170,7 +165,6 @@ evNowTime(struct timespec *res) { TIMEVAL_TO_TIMESPEC (&now, res); } -#endif /* Options. Leave them on. */ /* #undef DEBUG */ @@ -178,10 +172,6 @@ evNowTime(struct timespec *res) { #define EXT(res) ((res)->_u._ext) -#ifndef _LIBC -static const int highestFD = FD_SETSIZE - 1; -#endif - /* Forward. */ static int send_vc(res_state, const u_char *, int, @@ -194,22 +184,11 @@ static void Aerror(const res_state, FILE *, const char *, int, const struct sockaddr *); static void Perror(const res_state, FILE *, const char *, int); #endif -#ifdef _LIBC static int sock_eq(struct sockaddr_in6 *, struct sockaddr_in6 *); -#else -static int sock_eq(struct sockaddr_in *, struct sockaddr_in *); -#endif -#ifdef NEED_PSELECT -static int pselect(int, void *, void *, void *, - struct timespec *, - const sigset_t *); -#endif /* Reachover. */ -#ifdef _LIBC static void convaddr4to6(struct sockaddr_in6 *sa); -#endif void res_pquery(const res_state, const u_char *, int, FILE *); /* Public. */ @@ -224,15 +203,10 @@ void res_pquery(const res_state, const u_char *, int, FILE *); * paul vixie, 29may94 */ int -#ifdef _LIBC res_ourserver_p(const res_state statp, const struct sockaddr_in6 *inp) -#else -res_ourserver_p(const res_state statp, const struct sockaddr_in *inp) -#endif { int ns; -#ifdef _LIBC if (inp->sin6_family == AF_INET) { struct sockaddr_in *in4p = (struct sockaddr_in *) inp; in_port_t port = in4p->sin_port; @@ -260,18 +234,6 @@ res_ourserver_p(const res_state statp, const struct sockaddr_in *inp) return (1); } } -#else - struct sockaddr_in ina = *inp; - for (ns = 0; ns < statp->nscount; ns++) { - const struct sockaddr_in *srv = &statp->nsaddr_list[ns]; - - if (srv->sin_family == ina.sin_family && - srv->sin_port == ina.sin_port && - (srv->sin_addr.s_addr == INADDR_ANY || - srv->sin_addr.s_addr == ina.sin_addr.s_addr)) - return (1); - } -#endif return (0); } @@ -406,18 +368,12 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, if (EXT(statp).nscount != statp->nscount) needclose++; else -#ifdef _LIBC for (ns = 0; ns < MAXNS; ns++) { unsigned int map = EXT(statp).nsmap[ns]; if (map < MAXNS && !sock_eq((struct sockaddr_in6 *) &statp->nsaddr_list[map], EXT(statp).nsaddrs[ns])) -#else - for (ns = 0; ns < statp->nscount; ns++) { - if (!sock_eq(&statp->nsaddr_list[ns], - &EXT(statp).nsaddrs[ns])) -#endif { needclose++; break; @@ -431,7 +387,6 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, * Maybe initialize our private copy of the ns_addr_list. */ if (EXT(statp).nsinit == 0) { -#ifdef _LIBC unsigned char map[MAXNS]; memset (map, MAXNS, sizeof (map)); @@ -471,13 +426,6 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, n++; } } -#else - for (ns = 0; ns < statp->nscount; ns++) { - EXT(statp).nsaddrs[ns] = statp->nsaddr_list[ns]; - EXT(statp).nssocks[ns] = -1; - } - EXT(statp).nscount = ns; -#endif EXT(statp).nsinit = 1; } @@ -487,7 +435,6 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, */ if ((statp->options & RES_ROTATE) != 0 && (statp->options & RES_BLAST) == 0) { -#ifdef _LIBC struct sockaddr_in6 *ina; unsigned int map; @@ -511,35 +458,18 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, EXT(statp).nsaddrs[n] = ina; EXT(statp).nsmap[n] = map; } -#else - struct sockaddr_in ina; - int lastns = statp->nscount - 1; - - ina = statp->nsaddr_list[0]; - for (ns = 0; ns < lastns; ns++) - statp->nsaddr_list[ns] = statp->nsaddr_list[ns + 1]; - statp->nsaddr_list[lastns] = ina; -#endif } /* * Send request, RETRY times, or until successful. */ for (try = 0; try < statp->retry; try++) { -#ifdef _LIBC for (ns = 0; ns < MAXNS; ns++) -#else - for (ns = 0; ns < statp->nscount; ns++) -#endif { -#ifdef _LIBC struct sockaddr_in6 *nsap = EXT(statp).nsaddrs[ns]; if (nsap == NULL) goto next_ns; -#else - struct sockaddr_in *nsap = &statp->nsaddr_list[ns]; -#endif same_ns: if (statp->qhook) { int done = 0, loops = 0; @@ -547,16 +477,11 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, do { res_sendhookact act; -#ifdef _LIBC struct sockaddr_in *nsap4; nsap4 = (struct sockaddr_in *) nsap; act = (*statp->qhook)(&nsap4, &buf, &buflen, ans, anssiz, &resplen); nsap = (struct sockaddr_in6 *) nsap4; -#else - act = (*statp->qhook)(&nsap, &buf, &buflen, - ans, anssiz, &resplen); -#endif switch (act) { case res_goahead: done = 1; @@ -579,19 +504,13 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, } while (!done); } -#ifdef _LIBC -# ifdef DEBUG +#ifdef DEBUG char tmpbuf[40]; -# endif +#endif Dprint(statp->options & RES_DEBUG, (stdout, ";; Querying server (# %d) address = %s\n", ns + 1, inet_ntop(AF_INET6, &nsap->sin6_addr, tmpbuf, sizeof (tmpbuf)))); -#else - Dprint(statp->options & RES_DEBUG, - (stdout, ";; Querying server (# %d) address = %s\n", - ns + 1, inet_ntoa(nsap->sin_addr))); -#endif if (v_circuit) { /* Use VC; at most one attempt per server. */ @@ -641,14 +560,9 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, do { res_sendhookact act; -#ifdef _LIBC act = (*statp->rhook)((struct sockaddr_in *) nsap, buf, buflen, ans, anssiz, &resplen); -#else - act = (*statp->rhook)(nsap, buf, buflen, - ans, anssiz, &resplen); -#endif switch (act) { case res_goahead: case res_done: @@ -704,11 +618,7 @@ send_vc(res_state statp, u_char *ans = *ansp; int anssiz = *anssizp; HEADER *anhp = (HEADER *) ans; -#ifdef _LIBC struct sockaddr_in6 *nsap = EXT(statp).nsaddrs[ns]; -#else - struct sockaddr_in *nsap = &statp->nsaddr_list[ns]; -#endif int truncating, connreset, resplen, n; struct iovec iov[2]; u_short len; @@ -720,11 +630,7 @@ send_vc(res_state statp, /* Are we still talking to whom we want to talk to? */ if (statp->_vcsock >= 0 && (statp->_flags & RES_F_VC) != 0) { -#ifdef _LIBC struct sockaddr_in6 peer; -#else - struct sockaddr_in peer; -#endif int size = sizeof peer; if (getpeername(statp->_vcsock, @@ -739,15 +645,7 @@ send_vc(res_state statp, if (statp->_vcsock >= 0) res_nclose(statp); -#ifdef _LIBC statp->_vcsock = socket(nsap->sin6_family, SOCK_STREAM, 0); -#else - statp->_vcsock = socket(PF_INET, SOCK_STREAM, 0); - if (statp->_vcsock > highestFD) { - res_nclose(statp); - __set_errno (ENOTSOCK); - } -#endif if (statp->_vcsock < 0) { *terrno = errno; Perror(statp, stderr, "socket(vc)", errno); @@ -904,25 +802,15 @@ send_dg(res_state statp, u_char *ans = *ansp; int anssiz = *anssizp; HEADER *anhp = (HEADER *) ans; -#ifdef _LIBC struct sockaddr_in6 *nsap = EXT(statp).nsaddrs[ns]; -#else - const struct sockaddr_in *nsap = &statp->nsaddr_list[ns]; -#endif struct timespec now, timeout, finish; -#ifdef _LIBC struct pollfd pfd[1]; int ptimeout; struct sockaddr_in6 from; static int socket_pf = 0; -#else - fd_set dsmask; - struct sockaddr_in from; -#endif int fromlen, resplen, seconds, n, s; if (EXT(statp).nssocks[ns] == -1) { -#ifdef _LIBC /* only try IPv6 if IPv6 NS and if not failed before */ if ((EXT(statp).nscount6 > 0) && (socket_pf != PF_INET)) { EXT(statp).nssocks[ns] = @@ -932,24 +820,14 @@ send_dg(res_state statp, } if (EXT(statp).nssocks[ns] < 0) EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM, 0); -#else - EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM, 0); - if (EXT(statp).nssocks[ns] > highestFD) { - res_nclose(statp); - __set_errno (ENOTSOCK); - } -#endif if (EXT(statp).nssocks[ns] < 0) { *terrno = errno; Perror(statp, stderr, "socket(dg)", errno); return (-1); } -#ifndef CANNOT_CONNECT_DGRAM -#ifdef _LIBC /* If IPv6 socket and nsap is IPv4, make it IPv4-mapped */ if ((socket_pf == PF_INET6) && (nsap->sin6_family == AF_INET)) convaddr4to6(nsap); -#endif /* * On a 4.3BSD+ machine (client and server, * actually), sending to a nameserver datagram @@ -968,7 +846,6 @@ send_dg(res_state statp, res_nclose(statp); return (0); } -#endif /* !CANNOT_CONNECT_DGRAM */ /* Make socket non-blocking. */ int fl = __fcntl (EXT(statp).nssocks[ns], F_GETFL); if (fl != -1) @@ -991,7 +868,6 @@ send_dg(res_state statp, evAddTime(&finish, &now, &timeout); int need_recompute = 0; resend: -#ifdef _LIBC /* Convert struct timespec in milliseconds. */ ptimeout = timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000; @@ -1002,16 +878,6 @@ send_dg(res_state statp, n = __poll (pfd, 1, ptimeout); need_recompute = 1; } -#else - FD_ZERO(&dsmask); - FD_SET(s, &dsmask); - struct timeval zerotime = { 0, 0 }; - n = pselect(s + 1, NULL, &dsmask, NULL, &zerotime, NULL); - if (n == 0) { - n = pselect(s + 1, NULL, &dsmask, NULL, &timeout, NULL); - need_recompute = 1; - } -#endif if (n == 0) { Dprint(statp->options & RES_DEBUG, (stdout, ";; timeout sending\n")); @@ -1032,7 +898,6 @@ send_dg(res_state statp, return (0); } __set_errno (0); -#ifndef CANNOT_CONNECT_DGRAM if (send(s, (char*)buf, buflen, 0) != buflen) { if (errno == EINTR || errno == EAGAIN) goto recompute_resend; @@ -1040,23 +905,6 @@ send_dg(res_state statp, res_nclose(statp); return (0); } -#else /* !CANNOT_CONNECT_DGRAM */ -#ifdef _LIBC - /* If IPv6 socket and nsap is IPv4, make it IPv4-mapped */ - if ((socket_pf == PF_INET6) && (nsap->sin6_family == AF_INET)) - convaddr4to6(nsap); -#endif - if (sendto(s, (char*)buf, buflen, 0, - (struct sockaddr *)nsap, sizeof *nsap) != buflen) - { - if (errno == EINTR || errno == EAGAIN) - goto recompute_resend; - Aerror(statp, stderr, "sendto", errno, - (struct sockaddr *) nsap); - res_nclose(statp); - return (0); - } -#endif /* !CANNOT_CONNECT_DGRAM */ wait: if (need_recompute) { @@ -1069,15 +917,11 @@ send_dg(res_state statp, } evSubTime(&timeout, &finish, &now); } -#ifdef _LIBC /* Convert struct timespec in milliseconds. */ ptimeout = timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000; pfd[0].events = POLLIN; n = __poll (pfd, 1, ptimeout); -#else - n = pselect(s + 1, &dsmask, NULL, NULL, &timeout, NULL); -#endif if (n == 0) { Dprint(statp->options & RES_DEBUG, (stdout, ";; timeout receiving\n")); @@ -1092,11 +936,7 @@ send_dg(res_state statp, goto err_return; } __set_errno (0); -#ifdef _LIBC fromlen = sizeof(struct sockaddr_in6); -#else - fromlen = sizeof(struct sockaddr_in); -#endif if (anssiz < MAXPACKET && anscp && (ioctl (s, FIONREAD, &resplen) < 0 @@ -1239,7 +1079,6 @@ Perror(const res_state statp, FILE *file, const char *string, int error) { #endif static int -#ifdef _LIBC sock_eq(struct sockaddr_in6 *a1, struct sockaddr_in6 *a2) { if (a1->sin6_family == a2->sin6_family) { if (a1->sin6_family == AF_INET) @@ -1262,15 +1101,7 @@ sock_eq(struct sockaddr_in6 *a1, struct sockaddr_in6 *a2) { (a1->sin6_addr.s6_addr32[3] == ((struct sockaddr_in *)a2)->sin_addr.s_addr)); } -#else -sock_eq(struct sockaddr_in *a1, struct sockaddr_in *a2) { - return ((a1->sin_family == a2->sin_family) && - (a1->sin_port == a2->sin_port) && - (a1->sin_addr.s_addr == a2->sin_addr.s_addr)); -} -#endif -#ifdef _LIBC /* * Converts IPv4 family, address and port to * IPv6 family, IPv4-mapped IPv6 address and port. @@ -1289,30 +1120,3 @@ convaddr4to6(struct sockaddr_in6 *sa) sa->sin6_addr.s6_addr32[2] = htonl(0xFFFF); sa->sin6_addr.s6_addr32[3] = addr; } -#endif - -#ifdef NEED_PSELECT -/* XXX needs to move to the porting library. */ -static int -pselect(int nfds, void *rfds, void *wfds, void *efds, - struct timespec *tsp, const sigset_t *sigmask) -{ - struct timeval tv, *tvp; - sigset_t sigs; - int n; - - if (tsp) { - tvp = &tv; - tv = evTimeVal(*tsp); - } else - tvp = NULL; - if (sigmask) - sigprocmask(SIG_SETMASK, sigmask, &sigs); - n = select(nfds, rfds, wfds, efds, tvp); - if (sigmask) - sigprocmask(SIG_SETMASK, &sigs, NULL); - if (tsp) - TIMEVAL_TO_TIMESPEC (tv, *tsp); - return (n); -} -#endif -- 2.7.4