From: Amos Jeffries Date: Wed, 1 Apr 2009 11:49:17 +0000 (+1300) Subject: Purge last remnants of inet_ntoa X-Git-Tag: SQUID_3_2_0_1~1082 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f0b84f7ed4d332dd31c10ebeae2b1f49fea5f3c;p=thirdparty%2Fsquid.git Purge last remnants of inet_ntoa - Now fully replaced by IPAddress::NtoA and inet_ntop() - No need for the third-party emulator and license either --- diff --git a/CREDITS b/CREDITS index ede83e1061..0aac231c3a 100644 --- a/CREDITS +++ b/CREDITS @@ -242,41 +242,6 @@ http://www.io.com/~paulhart/game/algorithms/tea.html ============================================================================== -lib/inet_ntoa.c: - -/* - * Copyright (c) 1983 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. 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. - */ - -static char sccsid[] = "@(#)inet_ntoa.c 5.6 (Berkeley) 2/24/91"; - -============================================================================== - lib/strnstr.cc: /*- diff --git a/configure.in b/configure.in index e45aee1e81..4773637a95 100644 --- a/configure.in +++ b/configure.in @@ -3580,45 +3580,6 @@ AC_TRY_LINK(extern int _dns_ttl_;,return _dns_ttl_;, AC_DEFINE(LIBRESOLV_DNS_TTL_HACK,1,[If libresolv.a has been hacked to export _dns_ttl_])], AC_MSG_RESULT(no)) -AC_MSG_CHECKING(if inet_ntoa() actually works) -AC_TRY_RUN([ -#include -#include -#include -#include -#include -main () -{ - FILE *fp; - struct in_addr in; - in.s_addr = inet_addr("1.2.3.4"); - fp = fopen("conftestval", "w"); - fprintf (fp, "%s\n", inet_ntoa(in)); - exit(0); -} -], -INET_NTOA_RESULT=`cat conftestval`, -INET_NTOA_RESULT="broken", -INET_NTOA_RESULT="broken") -if test "$INET_NTOA_RESULT" = "1.2.3.4" ; then - AC_MSG_RESULT("yes") -else - AC_MSG_RESULT("no") - case "$host_os" in - mingw|mingw32) - AC_MSG_NOTICE([Using Win32 resolver instead.]) - ;; - *) - AC_MSG_NOTICE([Will use our own inet_ntoa().]) - AC_LIBOBJ(inet_ntoa) -# AC_MSG_WARN([This looks bad, and probably prevents Squid from working.]) -# AC_MSG_WARN([If you're on IRIX and using GCC 2.8, you probably need]) -# AC_MSG_WARN([to use the IRIX C compiler instead.]) -# sleep 10 - ;; - esac -fi - if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then AC_MSG_CHECKING(for working statvfs() interface) AC_TRY_COMPILE([ diff --git a/lib/inet_ntoa.c b/lib/inet_ntoa.c deleted file mode 100644 index 62131ac53f..0000000000 --- a/lib/inet_ntoa.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1983 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. 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_ntoa.c 5.6 (Berkeley) 2/24/91"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Convert network-format internet address - * to base 256 d.d.d.d representation. - */ -#include -#include -#include -#include - -char * -inet_ntoa(struct in_addr in) -{ - static char b[18]; - register char *p; - - p = (char *) ∈ -#define UC(b) (((int)b)&0xff) - (void) snprintf(b, sizeof(b), - "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); - return (b); -} diff --git a/lib/rfc1035.c b/lib/rfc1035.c index 626b8faf10..2fb034e164 100644 --- a/lib/rfc1035.c +++ b/lib/rfc1035.c @@ -810,8 +810,9 @@ main(int argc, char *argv[]) for (i = 0; i < n; i++) { if (answers[i].type == RFC1035_TYPE_A) { struct in_addr a; + char ipa_str[sizeof(a)]; memcpy(&a, answers[i].rdata, 4); - printf("A\t%d\t%s\n", answers[i].ttl, inet_ntoa(a)); + printf("A\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET,&a,tmp,sizeof(a))); } else if (answers[i].type == RFC1035_TYPE_PTR) { char ptr[128]; strncpy(ptr, answers[i].rdata, answers[i].rdlength); diff --git a/lib/rfc3596.c b/lib/rfc3596.c index c80065222c..24ca563603 100644 --- a/lib/rfc3596.c +++ b/lib/rfc3596.c @@ -347,13 +347,15 @@ while (fgets(input, 512, stdin)) if (answers[i].type == RFC1035_TYPE_A) { struct in_addr a; + char tmp[16]; memcpy(&a, answers[i].rdata, 4); - printf("A\t%d\t%s\n", answers[i].ttl, inet_ntoa(a)); + printf("A\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET,&a,tmp,16)); } else if (answers[i].type == RFC1035_TYPE_AAAA) { struct in6_addr a; + char tmp[INET6_ADDRSTRLEN]; memcpy(&a, answers[i].rdata, 16); - printf("AAAA\t%d\t%s\n", answers[i].ttl, inet_ntoa(a)); + printf("AAAA\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET6,&a,tmp,sizeof(tmp))); } else if (answers[i].type == RFC1035_TYPE_PTR) { char ptr[RFC1035_MAXHOSTNAMESZ]; strncpy(ptr, answers[i].rdata, answers[i].rdlength); diff --git a/src/recv-announce.cc b/src/recv-announce.cc index f1019c69c5..29819b4ef0 100644 --- a/src/recv-announce.cc +++ b/src/recv-announce.cc @@ -114,6 +114,8 @@ main(int argc, char *argv[]) dup(1); + IPAddress ipa; + chat tmp[MAX_HOSTNAMELEN]; for (;;) { memset(buf, '\0', RECV_BUF_SIZE); memset(&R, '\0', len = sizeof(R)); @@ -125,9 +127,10 @@ main(int argc, char *argv[]) xmemcpy(ip, &R.sin_addr.s_addr, 4); hp = gethostbyaddr(ip, 4, AF_INET); + ipa = R.sin_addr; printf("==============================================================================\n"); printf("Received from %s [%s]\n", - inet_ntoa(R.sin_addr), + ipa.NtoA(tmp,MAX_HOSTNAMELEN), (hp && hp->h_name) ? hp->h_name : "Unknown"); fputs(buf, stdout); fflush(stdout); diff --git a/test-suite/tcp-banger3.c b/test-suite/tcp-banger3.c index 72b8d8fd55..d3ac5b21a2 100644 --- a/test-suite/tcp-banger3.c +++ b/test-suite/tcp-banger3.c @@ -149,8 +149,10 @@ get_url(const char *url) memcpy(&S.sin_addr.s_addr, h->h_addr_list[0], sizeof(S.sin_addr.s_addr)); S.sin_port = htons(port); S.sin_family = AF_INET; - if (debug) - fprintf(stderr, "%s (%s) %d %s\n", host, inet_ntoa(S.sin_addr), (int) port, path); + if (debug) { + char tmp[16]; + fprintf(stderr, "%s (%s) %d %s\n", host, inet_ntop(AF_INET, &S.sin_addr,tmp,sizeof(tmp)), (int) port, path); + } s = socket(PF_INET, SOCK_STREAM, 0); if (s < 0) { perror("socket");