Apparently, on systems with glibc 2.2, "inet_aton()" is declared in

<arpa/inet.h>, but is, in some fashion, declared differently from the
way we declare it in "inet_v6defs.h", but "inet_ntop()" isn't defined,
so we include "inet_v6defs.h" in "inet_pton.c", which causes
"inet_pton.c" not to compile as we get a collision between the two
declarations.

Move the declaration of "inet_aton()" to "inet_aton.h", define
"NEED_INET_ATON_H" iff we didn't find "inet_aton()" in the system
libraries, and include "inet_aton.h" in the callers of "inet_aton()" iff
"NEED_INET_ATON_H" is defined, so that it doesn't get declared by us if
"inet_aton()" is defined by a system library (which hopefully means it's
declared in <arpa/inet.h> instead).

svn path=/trunk/; revision=2137
This commit is contained in:
Guy Harris 2000-07-14 07:11:53 +00:00
parent 9b652d0958
commit a1b0b42431
8 changed files with 47 additions and 11 deletions

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
# $Id: Makefile.am,v 1.208 2000/07/06 10:03:41 girlich Exp $
# $Id: Makefile.am,v 1.209 2000/07/14 07:11:51 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@ -260,6 +260,7 @@ ETHEREAL_COMMON_SOURCES = \
exceptions.h \
follow.c \
follow.h \
inet_aton.h \
inet_v6defs.h \
ipproto.c \
ipv4.c \

View File

@ -1,7 +1,7 @@
/* acconfig.h
* #ifdefs to be controlled by "configure"
*
* $Id: acconfig.h,v 1.15 2000/01/15 10:25:41 guy Exp $
* $Id: acconfig.h,v 1.16 2000/07/14 07:11:52 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -31,6 +31,8 @@
#undef DATAFILE_DIR
#undef NEED_INET_ATON_H
#undef NEED_INET_V6DEFS_H
#undef NEED_SNPRINTF_H

View File

@ -1,4 +1,4 @@
/* $Id: config.h.win32,v 1.13 2000/07/05 17:24:29 gram Exp $ */
/* $Id: config.h.win32,v 1.14 2000/07/14 07:11:52 guy Exp $ */
/* config.h.win32 Generated manually. :-) */
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
@ -72,6 +72,7 @@
#define HAVE_WINSOCK_H 1
#define HAVE_DIRECT_H 1
#define HAVE_IO_H 1
#define NEED_INET_ATON_H 1
#define NEED_INET_V6DEFS_H 1
#define NEED_GETOPT_H 1
#define snprintf _snprintf

View File

@ -1,4 +1,4 @@
# $Id: configure.in,v 1.94 2000/07/06 10:03:43 girlich Exp $
# $Id: configure.in,v 1.95 2000/07/14 07:11:52 guy Exp $
dnl
dnl Process this file with autoconf 2.13 or later to produce a
dnl configure script; 2.12 doesn't generate a "configure" script that
@ -313,6 +313,7 @@ AC_CHECK_FUNC(inet_aton, INET_ATON_O="",
if test "$ac_cv_func_inet_aton" = no ; then
INET_ATON_C="inet_aton.c"
INET_ATON_O="inet_aton.o"
AC_DEFINE(NEED_INET_ATON_H)
fi
AC_SUBST(INET_ATON_C)
AC_SUBST(INET_ATON_O)

View File

@ -57,6 +57,8 @@ static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
#include <ctype.h>
#include "inet_aton.h"
/*
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.

28
inet_aton.h Normal file
View File

@ -0,0 +1,28 @@
/* inet_aton.h
*
* $Id: inet_aton.h,v 1.1 2000/07/14 07:11:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*
* Version of "inet_aton()", for the benefit of OSes that don't have it.
*/
struct in_addr;
extern int inet_aton(const char* cp_arg, struct in_addr *addr);

View File

@ -1,6 +1,6 @@
/* inet_pton.h
/* inet_v6defs.h
*
* $Id: inet_v6defs.h,v 1.2 2000/01/10 17:32:51 gram Exp $
* $Id: inet_v6defs.h,v 1.3 2000/07/14 07:11:53 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -22,16 +22,13 @@
*/
/*
* Version of "inet_pton()" and "inet_ntop()", for the benefit of OSes that
* Versions of "inet_pton()" and "inet_ntop()", for the benefit of OSes that
* don't have it.
*/
extern int inet_pton(int af, const char *src, void *dst);
extern const char *inet_ntop(int af, const void *src, char *dst,
size_t size);
struct in_addr;
extern int inet_aton(const char* cp_arg, struct in_addr *addr);
/*
* Those OSes may also not have AF_INET6, so declare it here if it's not
* already declared, so that we can pass it to "inet_ntop()" and "inet_pton()".

View File

@ -1,7 +1,7 @@
/* resolv.c
* Routines for network object lookup
*
* $Id: resolv.c,v 1.23 2000/01/29 16:41:14 gram Exp $
* $Id: resolv.c,v 1.24 2000/07/14 07:11:53 guy Exp $
*
* Laurent Deniel <deniel@worldnet.fr>
*
@ -69,6 +69,10 @@
# include <setjmp.h>
#endif
#ifdef NEED_INET_ATON_H
# include "inet_aton.h"
#endif
#ifdef NEED_INET_V6DEFS_H
# include "inet_v6defs.h"
#endif