Skip to content

Commit

Permalink
Fix some build issues on Haiku.
Browse files Browse the repository at this point in the history
Link with two additional libraries if required.  Do not include
<netinet/if_ether.h>, 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.
  • Loading branch information
infrastation committed Feb 21, 2024
1 parent 7180492 commit 1819eb7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
35 changes: 32 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 #####################################################
Expand Down
2 changes: 1 addition & 1 deletion src/common/sendpacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#ifdef __NetBSD__
#include <net/if_ether.h>
#else
#elif ! defined(__HAIKU__)
#include <netinet/if_ether.h>
#endif

Expand Down

0 comments on commit 1819eb7

Please sign in to comment.