diff --git a/configure b/configure index 7ed1440286..b4a014d70f 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh -# From configure.in Revision: 1.9 +# From configure.in Revision: 1.10 # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.12 @@ -1421,11 +1421,66 @@ ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.o" EOF +fi + +echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 +echo "configure:1428: checking for inet_aton" >&5 +if eval "test \"`echo '$''{'ac_cv_func_inet_aton'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char inet_aton(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_inet_aton) || defined (__stub___inet_aton) +choke me +#else +inet_aton(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1456: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_inet_aton=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_inet_aton=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'inet_aton`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_aton.o" + + cat >> confdefs.h <<\EOF +#define NEED_INET_ATON 1 +EOF + + fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1429: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1484: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1454,7 +1509,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1458: checking for $ac_word" >&5 +echo "configure:1513: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1491,7 +1546,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1495: checking for a BSD compatible install" >&5 +echo "configure:1550: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 diff --git a/configure.in b/configure.in index d1c64d6fc6..4b346dc7e9 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ -AC_REVISION($Revision: 1.10 $) +AC_REVISION($Revision: 1.11 $) AC_INIT(lib/dns/name.c) AC_CONFIG_HEADER(config.h) @@ -29,6 +29,11 @@ AC_CHECK_FUNC(inet_ntop, , AC_SUBST(ISC_EXTRA_OBJS) AC_DEFINE(NEED_INET_NTOP)] ) +AC_CHECK_FUNC(inet_aton, , + [ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_aton.o" + AC_SUBST(ISC_EXTRA_OBJS) + AC_DEFINE(NEED_INET_ATON)] +) AC_PROG_MAKE_SET AC_PROG_RANLIB diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 40fcdb380c..6ce6eff81b 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a_1.c,v 1.8 1999/01/22 05:02:49 marka Exp $ */ + /* $Id: a_1.c,v 1.9 1999/01/30 04:27:47 explorer Exp $ */ #ifndef RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H @@ -46,7 +46,7 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - if (inet_aton(token.value.as_pointer , &addr) != 1) + if (isc_inet_aton(token.value.as_pointer, &addr) != 1) return (DNS_R_UNEXPECTED); isc_buffer_available(target, ®ion); if (region.length < 4) diff --git a/lib/dns/rdata/in_1/a_1.h b/lib/dns/rdata/in_1/a_1.h index 2d4817f1ba..e4c9e916c3 100644 --- a/lib/dns/rdata/in_1/a_1.h +++ b/lib/dns/rdata/in_1/a_1.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a_1.h,v 1.8 1999/01/22 05:02:49 marka Exp $ */ + /* $Id: a_1.h,v 1.9 1999/01/30 04:27:47 explorer Exp $ */ #ifndef RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H @@ -46,7 +46,7 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - if (inet_aton(token.value.as_pointer , &addr) != 1) + if (isc_inet_aton(token.value.as_pointer, &addr) != 1) return (DNS_R_UNEXPECTED); isc_buffer_available(target, ®ion); if (region.length < 4) diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 785aa6e0c7..c681292eaf 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: wks_11.c,v 1.4 1999/01/22 05:02:49 marka Exp $ */ + /* $Id: wks_11.c,v 1.5 1999/01/30 04:27:47 explorer Exp $ */ #ifndef RDATA_IN_1_WKS_11_H #define RDATA_IN_1_WKS_11_H @@ -59,7 +59,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); isc_buffer_available(target, ®ion); - if (inet_aton(token.value.as_pointer , &addr) != 1) + if (isc_inet_aton(token.value.as_pointer, &addr) != 1) return (DNS_R_BADDOTTEDQUAD); if (region.length < 4) return (DNS_R_NOSPACE); diff --git a/lib/dns/rdata/in_1/wks_11.h b/lib/dns/rdata/in_1/wks_11.h index ca2fa4ddcb..5a91edfd8c 100644 --- a/lib/dns/rdata/in_1/wks_11.h +++ b/lib/dns/rdata/in_1/wks_11.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: wks_11.h,v 1.4 1999/01/22 05:02:49 marka Exp $ */ + /* $Id: wks_11.h,v 1.5 1999/01/30 04:27:47 explorer Exp $ */ #ifndef RDATA_IN_1_WKS_11_H #define RDATA_IN_1_WKS_11_H @@ -59,7 +59,7 @@ fromtext_in_wks(dns_rdataclass_t class, dns_rdatatype_t type, RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); isc_buffer_available(target, ®ion); - if (inet_aton(token.value.as_pointer , &addr) != 1) + if (isc_inet_aton(token.value.as_pointer, &addr) != 1) return (DNS_R_BADDOTTEDQUAD); if (region.length < 4) return (DNS_R_NOSPACE); diff --git a/lib/isc/include/isc/inet.h b/lib/isc/include/isc/inet.h index 9fc277af33..18b4da6d33 100644 --- a/lib/isc/include/isc/inet.h +++ b/lib/isc/include/isc/inet.h @@ -33,4 +33,10 @@ char *isc_inet_ntop(int af, const void *src, char *dst, size_t size); #define isc_inet_ntop inet_ntop #endif +#ifdef NEED_INET_ATON +int isc_inet_aton(const char *cp, struct in_addr *addr); +#else +#define isc_inet_aton inet_aton +#endif + #endif /* ISC_INET_H */ diff --git a/lib/isc/inet_aton.c b/lib/isc/inet_aton.c new file mode 100644 index 0000000000..655145309c --- /dev/null +++ b/lib/isc/inet_aton.c @@ -0,0 +1,192 @@ +/* + * Copyright (c) 1983, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Portions Copyright (c) 1996-1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; +static char rcsid[] = "$Id: inet_aton.c,v 1.1 1999/01/30 04:27:48 explorer Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +#include +#include + +#include + +#include + +/* + * Check whether "cp" is a valid ascii representation + * of an Internet address and convert to a binary address. + * Returns 1 if the address is valid, 0 if not. + * This replaces inet_addr, the return value from which + * cannot distinguish between failure and a local broadcast address. + */ +int +inet_aton(const char *cp, struct in_addr *addr) +{ + unsigned long val; + int base, n; + char c; + isc_uint8_t parts[4]; + isc_uint8_t *pp = parts; + int digit; + + c = *cp; + for (;;) { + /* + * Collect number up to ``.''. + * Values are specified as for C: + * 0x=hex, 0=octal, isdigit=decimal. + */ + if (!isdigit(c)) + return (0); + val = 0; base = 10; digit = 0; + if (c == '0') { + c = *++cp; + if (c == 'x' || c == 'X') + base = 16, c = *++cp; + else { + base = 8; + digit = 1 ; + } + } + for (;;) { + if (isascii(c) && isdigit(c)) { + if (base == 8 && (c == '8' || c == '9')) + return (0); + val = (val * base) + (c - '0'); + c = *++cp; + digit = 1; + } else if (base == 16 && isascii(c) && isxdigit(c)) { + val = (val << 4) | + (c + 10 - (islower(c) ? 'a' : 'A')); + c = *++cp; + digit = 1; + } else + break; + } + if (c == '.') { + /* + * Internet format: + * a.b.c.d + * a.b.c (with c treated as 16 bits) + * a.b (with b treated as 24 bits) + */ + if (pp >= parts + 3 || val > 0xff) + return (0); + *pp++ = val; + c = *++cp; + } else + break; + } + /* + * Check for trailing characters. + */ + if (c != '\0' && (!isascii(c) || !isspace(c))) + return (0); + /* + * Did we get a valid digit? + */ + if (!digit) + return (0); + /* + * Concoct the address according to + * the number of parts specified. + */ + n = pp - parts + 1; + switch (n) { + case 1: /* a -- 32 bits */ + break; + + case 2: /* a.b -- 8.24 bits */ + if (val > 0xffffff) + return (0); + val |= parts[0] << 24; + break; + + case 3: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff) + return (0); + val |= (parts[0] << 24) | (parts[1] << 16); + break; + + case 4: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff) + return (0); + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + } + if (addr != NULL) + addr->s_addr = htonl(val); + + return (1); +} diff --git a/lib/isc/inet_ntop.c b/lib/isc/inet_ntop.c index c1fc07af4f..4fcaf0affa 100644 --- a/lib/isc/inet_ntop.c +++ b/lib/isc/inet_ntop.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$Id: inet_ntop.c,v 1.1 1999/01/22 04:35:11 explorer Exp $"; +static char rcsid[] = "$Id: inet_ntop.c,v 1.2 1999/01/30 04:27:48 explorer Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -40,7 +40,9 @@ static char rcsid[] = "$Id: inet_ntop.c,v 1.1 1999/01/22 04:35:11 explorer Exp $ */ static const char *isc_inet_ntop4(const u_char *src, char *dst, size_t size); +#ifdef AF_INET6 static const char *isc_inet_ntop6(const u_char *src, char *dst, size_t size); +#endif /* char * * isc_inet_ntop(af, src, dst, size) @@ -56,8 +58,10 @@ isc_inet_ntop(int af, const void *src, char *dst, size_t size) switch (af) { case AF_INET: return (isc_inet_ntop4(src, dst, size)); +#ifdef AF_INET6 case AF_INET6: return (isc_inet_ntop6(src, dst, size)); +#endif default: errno = EAFNOSUPPORT; return (NULL); @@ -97,6 +101,7 @@ isc_inet_ntop4(const u_char *src, char *dst, size_t size) * author: * Paul Vixie, 1996. */ +#ifdef AF_INET6 static const char * isc_inet_ntop6(const u_char *src, char *dst, size_t size) { @@ -185,3 +190,4 @@ isc_inet_ntop6(const u_char *src, char *dst, size_t size) strcpy(dst, tmp); return (dst); } +#endif /* AF_INET6 */