1. On Solaris, inet_ntop and inet_pton need to be linked against
-lnsl. AC_CHECK_FUNC() isn't good enough unless LIBS already
has -lnsl.
2. On IRIX, the blanket redefinition of the inet_ntop function
prototype is incorrect (compiling with MIPSpro 7.4):
cc-1143 cc: ERROR File = inet_v6defs.h, Line = 32
Declaration is incompatible with
"const char *inet_ntop(int, const void *, char *, socklen_t)"
(declared at line 89 of "/usr/include/arpa/inet.h").
extern const char *inet_ntop(int af, const void *src, char *dst,
^
1 error detected in the compilation of "inet_pton.c".
gmake[4]: *** [inet_pton.o] Error 2
On IRIX, the correct prototype is:
extern const char *inet_ntop(int, const void *, char *, socklen_t);
Rather than blindly replacing the prototype we detect if a
prototype exists and define it only if one does not exist.
Tested on Solaris 2.5.1-9/SPARC, HP-UX 10.20, 11.00, 11i, IRIX 6.5.19,
Tru64 UNIX 4.0D, 5.1, Redhat Linux 7.1.
--
albert chin (china@xxxxxxxxxxxxxxxxxx)
-- snip snip
--- epan/acconfig.h.orig Wed Feb 26 10:10:52 2003
+++ epan/acconfig.h Wed Feb 26 10:11:03 2003
@@ -32,3 +32,5 @@
#undef NEED_INET_V6DEFS_H
#undef NEED_STRPTIME_H
+
+#undef HAVE_INET_NTOP_PROTO
--- epan/configure.in.orig Wed Feb 26 09:47:12 2003
+++ epan/configure.in Wed Feb 26 10:28:15 2003
@@ -154,7 +154,7 @@
AC_SUBST(INET_ATON_C)
AC_SUBST(INET_ATON_O)
-AC_CHECK_FUNC(inet_pton, [
+AC_SEARCH_LIBS(inet_pton, [socket nsl], [
dnl check for pre-BIND82 inet_pton() bug.
AC_MSG_CHECKING(for broken inet_pton)
AC_TRY_RUN([#include <sys/types.h>
@@ -185,13 +185,31 @@
AC_SUBST(INET_PTON_C)
AC_SUBST(INET_PTON_O)
-AC_CHECK_FUNC(inet_ntop, INET_NTOP_O="",
- INET_NTOP_O="inet_ntop.o")
-if test "$ac_cv_func_inet_ntop" = no ; then
+AC_SEARCH_LIBS(inet_ntop, [socket nsl], [
+ AC_MSG_CHECKING([for inet_ntop prototype])
+ AC_TRY_COMPILE([#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+extern const char *inet_ntop(int, const void *, char *, size_t);],, [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_INET_NTOP_PROTO)], [
+ AC_TRY_COMPILE([#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+extern const char *inet_ntop(int, const void *, char *, socklen_t);],, [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_INET_NTOP_PROTO)], [
+ AC_MSG_RESULT(no)])])
+ INET_NTOP_O=""], [
INET_NTOP_C="inet_ntop.c"
INET_NTOP_O="inet_ntop.o"
- AC_DEFINE(NEED_INET_V6DEFS_H)
-fi
+ AC_DEFINE(NEED_INET_V6DEFS_H)])
AC_SUBST(INET_NTOP_C)
AC_SUBST(INET_NTOP_O)
--- epan/inet_v6defs.h.orig Wed Feb 26 10:11:46 2003
+++ epan/inet_v6defs.h Wed Feb 26 10:11:59 2003
@@ -29,8 +29,10 @@
* don't have it.
*/
extern int inet_pton(int af, const char *src, void *dst);
+#ifndef HAVE_INET_NTOP_PROTO
extern const char *inet_ntop(int af, const void *src, char *dst,
size_t size);
+#endif
/*
* Those OSes may also not have AF_INET6, so declare it here if it's not