Ethereal-dev: [ethereal-dev] Re: [ethereal-users] Problem with inet_v6defs.h and Linux glibc 2

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Fri, 14 Jul 2000 00:05:21 -0700
On Tue, Jul 11, 2000 at 10:05:10PM -0400, Craig Rodrigues wrote:
> I recently upgraded to glibc 2.2, and when I tried to compile
> ethereal, I got the following error:
> 
> gcc -DHAVE_CONFIG_H -I. -I. -I.   -I. -I./wiretap -I/usr/local/include -I/usr/include/pcap  -Wall -g -O2 -I. -I./wiretap -I/usr/local/include -I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/include/pcap -c inet_pton.c
> In file included from inet_pton.c:56:
> inet_v6defs.h:33: conflicting types for `inet_aton'
> /usr/include/arpa/inet.h:67: previous declaration of `inet_aton'   
> 
> inet_aton is defined in the inet.h file with glibc 2.2.
> 
> The attached patch is required to get things to compile.

Hmm.

I think the correct answer here may be to

	1) move the declaration of "inet_aton()" from "inet_v6defs.h"
	   (it's an IPv4 function, not an IPv6 function) to a new
	   "inet_aton.h" file;

	2) add a new NEED_INET_ATON_H configuration #define, which is
	   set iff the platform on which you're running doesn't define
	   "inet_aton()" (which presumably means it doesn't declare it,
	   either);

	3) have the files that include calls to "inet_aton()" do

		#ifdef NEED_INET_ATON_H
		#include "inet_aton.h"
		#endif

so that we declare "inet_aton()" ourselves only if we define it
ourselves, i.e. if it doesn't come with the OS (hopefully, if there are
any platforms that define it in a library but don't declare it in
<arpa/inet.h>, this will, at most, cause whining about it not being
declared).

If you're building from the Ethereal CVS tree, here's a patch, plus the
new "inet_aton.h".
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/ethereal/Makefile.am,v
retrieving revision 1.208
diff -c -r1.208 Makefile.am
*** Makefile.am	2000/07/06 10:03:41	1.208
--- Makefile.am	2000/07/14 07:04:14
***************
*** 260,265 ****
--- 260,266 ----
  	exceptions.h	\
  	follow.c       \
  	follow.h       \
+ 	inet_aton.h    \
  	inet_v6defs.h  \
  	ipproto.c      \
  	ipv4.c         \
Index: acconfig.h
===================================================================
RCS file: /usr/local/cvsroot/ethereal/acconfig.h,v
retrieving revision 1.15
diff -c -r1.15 acconfig.h
*** acconfig.h	2000/01/15 10:25:41	1.15
--- acconfig.h	2000/07/14 07:04:14
***************
*** 31,36 ****
--- 31,38 ----
  
  #undef DATAFILE_DIR
  
+ #undef NEED_INET_ATON_H
+ 
  #undef NEED_INET_V6DEFS_H
  
  #undef NEED_SNPRINTF_H
Index: config.h.win32
===================================================================
RCS file: /usr/local/cvsroot/ethereal/config.h.win32,v
retrieving revision 1.13
diff -c -r1.13 config.h.win32
*** config.h.win32	2000/07/05 17:24:29	1.13
--- config.h.win32	2000/07/14 07:04:15
***************
*** 72,77 ****
--- 72,78 ----
  #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
Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/ethereal/configure.in,v
retrieving revision 1.94
diff -c -r1.94 configure.in
*** configure.in	2000/07/06 10:03:43	1.94
--- configure.in	2000/07/14 07:04:15
***************
*** 313,318 ****
--- 313,319 ----
  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)
Index: inet_aton.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/inet_aton.c,v
retrieving revision 1.2
diff -c -r1.2 inet_aton.c
*** inet_aton.c	2000/01/10 17:32:51	1.2
--- inet_aton.c	2000/07/14 07:04:16
***************
*** 57,62 ****
--- 57,64 ----
  
  #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.
Index: inet_v6defs.h
===================================================================
RCS file: /usr/local/cvsroot/ethereal/inet_v6defs.h,v
retrieving revision 1.2
diff -c -r1.2 inet_v6defs.h
*** inet_v6defs.h	2000/01/10 17:32:51	1.2
--- inet_v6defs.h	2000/07/14 07:04:16
***************
*** 1,4 ****
! /* inet_pton.h
   *
   * $Id: inet_v6defs.h,v 1.2 2000/01/10 17:32:51 gram Exp $
   *
--- 1,4 ----
! /* inet_v6defs.h
   *
   * $Id: inet_v6defs.h,v 1.2 2000/01/10 17:32:51 gram Exp $
   *
***************
*** 22,36 ****
   */
  
  /*
!  * Version 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
--- 22,33 ----
   */
  
  /*
!  * 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);
  
  /*
   * Those OSes may also not have AF_INET6, so declare it here if it's not
Index: resolv.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/resolv.c,v
retrieving revision 1.23
diff -c -r1.23 resolv.c
*** resolv.c	2000/01/29 16:41:14	1.23
--- resolv.c	2000/07/14 07:04:19
***************
*** 69,74 ****
--- 69,78 ----
  # include <setjmp.h>
  #endif
  
+ #ifdef NEED_INET_ATON_H
+ # include "inet_aton.h"
+ #endif
+ 
  #ifdef NEED_INET_V6DEFS_H
  # include "inet_v6defs.h"
  #endif
/* inet_aton.h
 *
 * $Id$
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@xxxxxxxx>
 * 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);