==============================================================================
-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:
/*-
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 <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-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([
+++ /dev/null
-/*
- * 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 <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-
-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);
-}
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);
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);
dup(1);
+ IPAddress ipa;
+ chat tmp[MAX_HOSTNAMELEN];
for (;;) {
memset(buf, '\0', RECV_BUF_SIZE);
memset(&R, '\0', len = sizeof(R));
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);
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");