From 718049269ee3ec8bfa012ee48ad5b5a7be7dfb92 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Wed, 21 Feb 2024 12:20:22 +0000 Subject: [PATCH 1/2] Fix the Autoconf test for inet_addr(). --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 387219de..052938ff 100644 --- a/configure.ac +++ b/configure.ac @@ -627,7 +627,7 @@ AC_CHECK_FUNC(inet_addr, inet_addr=yes, inet_addr=no) -if test x$inet_addr = no ; then +if test x$inet_addr = xno ; then AC_MSG_ERROR([We need inet_addr. See bug 26]) fi From 1819eb7f17f6dd87b2b8871bbeb7b580cad62088 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Wed, 21 Feb 2024 12:21:44 +0000 Subject: [PATCH 2/2] Fix some build issues on Haiku. Link with two additional libraries if required. Do not include , which does not exist, and which the source does not require to compile. These changes allow tcpreplay to build on Haiku hrev57588 as follows: ./configure --with-libpcap=/path/to/libpcap/ --enable-static-link However, since Haiku ports do not have GNU AutoGen, the master branch would need some files either copied from the 4.4.4 release tarball or generated on a Linux host. Even after the build completes, tcpreplay is still not entirely functional because libpcap on Haiku does not implement pcap_inject() and tcpreplay fails to handle Haiku interfaces correctly: > ./src/tcpreplay --listnics Available network interfaces: /dev/net/ipro1000/1 vale:/dev/net/ipro1000/1 netmap:/dev/net/ipro1000/1 /dev/net/ipro1000/0 vale:/dev/net/ipro1000/0 netmap:/dev/net/ipro1000/0 > ./src/tcpreplay -i /dev/net/ipro1000/1 icmp-echoreply.pcap Fatal Error: failed to open device /dev/net/ipro1000/1: error opening khial device: Device/File/Resource busy So proper Haiku support would require some more work. --- configure.ac | 35 ++++++++++++++++++++++++++++++++--- src/common/sendpacket.h | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 052938ff..c8198d69 100644 --- a/configure.ac +++ b/configure.ac @@ -605,23 +605,49 @@ else fi dnl Check for inet_aton and inet_pton +dnl On Haiku these functions are in libnetwork. AC_CHECK_FUNC(inet_aton, AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?]) inet_aton=yes, - inet_aton=no) + [ + AC_CHECK_LIB(network, inet_aton, + AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?]) + use_libnetwork=yes, + [inet_aton=no] + ) + ] +) AC_CHECK_FUNC(inet_pton, AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?]) inet_pton=yes, - inet_pton=no) + [ + AC_CHECK_LIB(network, inet_pton, + AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?]) + use_libnetwork=yes, + [inet_pton=no] + ) + ] +) AC_CHECK_FUNC(inet_ntop, AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?]) inet_ntop=yes, - inet_ntop=no) + [ + AC_CHECK_LIB(network, inet_ntop, + AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?]) + use_libnetwork=yes, + [inet_ntop=no] + ) + ] +) if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then AC_MSG_ERROR([We need either inet_ntop or inet_pton]) fi +if test "$use_libnetwork" = "yes" ; then + LIBS="-lnetwork $LIBS" +fi + AC_CHECK_FUNC(inet_addr, AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?]) inet_addr=yes, @@ -631,6 +657,9 @@ if test x$inet_addr = xno ; then AC_MSG_ERROR([We need inet_addr. See bug 26]) fi +dnl On Haiku fts_*() functions are in libbsd. +AC_CHECK_FUNC(fts_read,,[AC_CHECK_LIB(bsd, fts_read)]) + dnl ##################################################### dnl Checks for tuntap device support dnl ##################################################### diff --git a/src/common/sendpacket.h b/src/common/sendpacket.h index e1dd6a42..44ff1a2c 100644 --- a/src/common/sendpacket.h +++ b/src/common/sendpacket.h @@ -26,7 +26,7 @@ #ifdef __NetBSD__ #include -#else +#elif ! defined(__HAIKU__) #include #endif