diff --git a/net-libs/libpcap/libpcap-1.8.1.recipe b/net-libs/libpcap/libpcap-1.10.1.recipe similarity index 90% rename from net-libs/libpcap/libpcap-1.8.1.recipe rename to net-libs/libpcap/libpcap-1.10.1.recipe index e84fad9dc..64ebeeba4 100644 --- a/net-libs/libpcap/libpcap-1.8.1.recipe +++ b/net-libs/libpcap/libpcap-1.10.1.recipe @@ -22,11 +22,17 @@ COPYRIGHT="1988-1998 The Regents of the University of California 2009 Felix Obenhuber 2014 Michal Labedzki for Tieto Corporation" LICENSE="BSD (3-clause)" -REVISION="4" +REVISION="1" SOURCE_URI="http://www.tcpdump.org/release/libpcap-$portVersion.tar.gz" -CHECKSUM_SHA256="673dbc69fdc3f5a86fb5759ab19899039a8e5e6c631749e48dcd9c6f0c83541e" +CHECKSUM_SHA256="ed285f4accaf05344f90975757b3dbfe772ba41d1c401c2648b7fa45b711bdd4" PATCHES="libpcap-$portVersion.patchset" +if [ $effectiveTargetArchitecture = x86_gcc2 ]; then + PATCHES+=" + libpcap-$portVersion.gcc2.patchset + " +fi + ARCHITECTURES="all" SECONDARY_ARCHITECTURES="x86_gcc2 x86" @@ -83,8 +89,3 @@ INSTALL() $binDir/pcap-config } - -TEST() -{ - make check -} diff --git a/net-libs/libpcap/patches/libpcap-1.10.1.gcc2.patchset b/net-libs/libpcap/patches/libpcap-1.10.1.gcc2.patchset new file mode 100644 index 000000000..45a502c11 --- /dev/null +++ b/net-libs/libpcap/patches/libpcap-1.10.1.gcc2.patchset @@ -0,0 +1,43 @@ +From ae92ea010665416b696fcbe2d86c884241691cd8 Mon Sep 17 00:00:00 2001 +From: David Karoly +Date: Sat, 12 Nov 2022 18:04:55 +0000 +Subject: gcc2 patch + + +diff --git a/configure.ac b/configure.ac +index 9cf303f..cccacf8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -30,7 +30,7 @@ AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS) + # + AC_PROG_CC_C99 + if test "$ac_cv_prog_cc_c99" = "no"; then +- AC_MSG_ERROR([The C compiler does not support C99]) ++ AC_MSG_WARN([The C compiler does not support C99]) + fi + case "$host_os" in + haiku*) +diff --git a/fmtutils.c b/fmtutils.c +index 5c7ddad..12c2880 100644 +--- a/fmtutils.c ++++ b/fmtutils.c +@@ -273,6 +273,7 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, + size_t msglen; + char *p; + size_t errbuflen_remaining; ++ int err; + + va_start(ap, fmt); + vsnprintf(errbuf, errbuflen, fmt, ap); +@@ -343,7 +344,7 @@ pcap_fmt_errmsg_for_errno(char *errbuf, size_t errbuflen, int errnum, + * We have a POSIX-style strerror_r(), which is guaranteed to fill + * in the buffer, but is not guaranteed to succeed. + */ +- int err = strerror_r(errnum, p, errbuflen_remaining); ++ err = strerror_r(errnum, p, errbuflen_remaining); + if (err == EINVAL) { + /* + * UNIX 03 says this isn't guaranteed to produce a +-- +2.37.3 + diff --git a/net-libs/libpcap/patches/libpcap-1.10.1.patchset b/net-libs/libpcap/patches/libpcap-1.10.1.patchset new file mode 100644 index 000000000..9254a4a66 --- /dev/null +++ b/net-libs/libpcap/patches/libpcap-1.10.1.patchset @@ -0,0 +1,246 @@ +From 830f24a86cbcb87f356ae1221abec199d5b280e3 Mon Sep 17 00:00:00 2001 +From: David Karoly +Date: Mon, 22 Nov 2021 14:22:20 +0000 +Subject: Haiku: implement pcap_lib_version + + +diff --git a/pcap-haiku.cpp b/pcap-haiku.cpp +index 701cac38..aba37b44 100644 +--- a/pcap-haiku.cpp ++++ b/pcap-haiku.cpp +@@ -280,3 +280,12 @@ pcap_platform_finddevs(pcap_if_list_t* _allDevices, char* errorBuffer) + return pcap_findalldevs_interfaces(_allDevices, errorBuffer, can_be_bound, + get_if_flags); + } ++ ++/* ++ * Libpcap version string. ++ */ ++extern "C" const char * ++pcap_lib_version(void) ++{ ++ return (PCAP_VERSION_STRING); ++} +-- +2.37.3 + + +From 88347e5a7cda2c3e912b9d53b64ddceb42123b0c Mon Sep 17 00:00:00 2001 +From: David Karoly +Date: Mon, 22 Nov 2021 14:25:46 +0000 +Subject: Haiku: adjust snaplen + + +diff --git a/pcap-haiku.cpp b/pcap-haiku.cpp +index aba37b44..8b0009c5 100644 +--- a/pcap-haiku.cpp ++++ b/pcap-haiku.cpp +@@ -160,6 +160,17 @@ pcap_activate_haiku(pcap_t *handle) + handle->getnonblock_op = pcap_getnonblock_fd; + handle->setnonblock_op = pcap_setnonblock_fd; + ++ /* ++ * Turn a negative snapshot value (invalid), a snapshot value of ++ * 0 (unspecified), or a value bigger than the normal maximum ++ * value, into the maximum allowed value. ++ * ++ * If some application really *needs* a bigger snapshot ++ * length, we should just increase MAXIMUM_SNAPLEN. ++ */ ++ if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN) ++ handle->snapshot = MAXIMUM_SNAPLEN; ++ + handlep->device = strdup(device); + if (handlep->device == NULL) { + pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE, +-- +2.37.3 + + +From 69e186892c58010477a63c578341bfb5da51e395 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= +Date: Fri, 8 Jul 2022 23:24:43 +0200 +Subject: Fix build on Haiku + +This fixes #1114. + +C++11 forbids declaring types inside typeof and offsetof, +so we drop the macro call and declare the struct separately +for the only use of the call. + +diff --git a/pcap-haiku.cpp b/pcap-haiku.cpp +index 8b0009c5..4606ca0e 100644 +--- a/pcap-haiku.cpp ++++ b/pcap-haiku.cpp +@@ -249,7 +249,11 @@ pcap_create_interface(const char *device, char *errorBuffer) + return NULL; + } + +- pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku); ++ struct wrapper_struct { pcap_t __common; struct pcap_haiku __private; }; ++ pcap_t* handle = pcap_create_common(errorBuffer, ++ sizeof (struct wrapper_struct), ++ offsetof (struct wrapper_struct, __private)); ++ + if (handle == NULL) { + snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "malloc: %s", strerror(errno)); + close(socket); +-- +2.37.3 + + +From 7f4909d3433c571f27bef46ae44064e80f6a0090 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= +Date: Sat, 9 Jul 2022 01:07:53 +0200 +Subject: On Haiku, add a check for libbsd which has getpass + + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b83fbbd7..d566d8b2 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -596,6 +596,15 @@ else(WIN32) + set(PCAP_LINK_LIBRARIES str ${PCAP_LINK_LIBRARIES}) + endif(LIBSTR_HAS_PUTMSG) + endif(NOT STDLIBS_HAVE_PUTMSG) ++ ++ # Haiku has getpass in libbsd ++ check_function_exists(getpass STDLIBS_HAVE_GETPASS) ++ if(NOT STDLIBS_HAVE_GETPASS) ++ check_library_exists(bsd getpass "" LIBBSD_HAS_GETPASS) ++ if(LIBBSD_HAS_GETPASS) ++ set(PCAP_LINK_LIBRARIES bsd ${PCAP_LINK_LIBRARIES}) ++ endif(LIBBSD_HAS_GETPASS) ++ endif(NOT STDLIBS_HAVE_GETPASS) + endif(WIN32) + + # +diff --git a/configure.ac b/configure.ac +index edb25ae4..9cf303fd 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -91,6 +91,10 @@ haiku*) + # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. + # + CFLAGS="$CFLAGS -D_BSD_SOURCE" ++ # ++ # Haiku has getpass in libbsd. ++ # ++ AC_CHECK_LIB(bsd, getpass) + ;; + esac + +-- +2.37.3 + + +From 84000a878e3c7c6a9e621d55b3479a9016ddd7db Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= +Date: Sat, 9 Jul 2022 01:23:29 +0200 +Subject: Avoid redeclaring uint8 & friends on Haiku + +Haiku declares and uses them for itself but in a different way. + +diff --git a/rpcap-protocol.h b/rpcap-protocol.h +index a69cf802..88d5133a 100644 +--- a/rpcap-protocol.h ++++ b/rpcap-protocol.h +@@ -132,10 +132,12 @@ + * XXX - use the C99 types? Microsoft's newer versions of Visual Studio + * support them. + */ ++#ifndef __HAIKU__ + typedef unsigned char uint8; /* 8-bit unsigned integer */ + typedef unsigned short uint16; /* 16-bit unsigned integer */ + typedef unsigned int uint32; /* 32-bit unsigned integer */ + typedef int int32; /* 32-bit signed integer */ ++#endif + + /* Common header for all the RPCAP messages */ + struct rpcap_header +-- +2.37.3 + + +From 8a2a3070b230fcb4e9585337187ab0eb90e1d692 Mon Sep 17 00:00:00 2001 +From: Guy Harris +Date: Fri, 8 Jul 2022 23:02:37 -0700 +Subject: Regenerate configure script. + + +diff --git a/config.h.in b/config.h.in +index a1e371a9..438141fe 100644 +--- a/config.h.in ++++ b/config.h.in +@@ -72,6 +72,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_INTTYPES_H + ++/* Define to 1 if you have the `bsd' library (-lbsd). */ ++#undef HAVE_LIBBSD ++ + /* Define to 1 if you have the `dag' library (-ldag). */ + #undef HAVE_LIBDAG + +diff --git a/configure b/configure +index 15a5e681..ad9c4d8a 100755 +--- a/configure ++++ b/configure +@@ -5326,6 +5326,54 @@ haiku*) + # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. + # + CFLAGS="$CFLAGS -D_BSD_SOURCE" ++ # ++ # Haiku has getpass in libbsd. ++ # ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpass in -lbsd" >&5 ++$as_echo_n "checking for getpass in -lbsd... " >&6; } ++if ${ac_cv_lib_bsd_getpass+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lbsd $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char getpass (); ++int ++main () ++{ ++return getpass (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_bsd_getpass=yes ++else ++ ac_cv_lib_bsd_getpass=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_getpass" >&5 ++$as_echo "$ac_cv_lib_bsd_getpass" >&6; } ++if test "x$ac_cv_lib_bsd_getpass" = xyes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_LIBBSD 1 ++_ACEOF ++ ++ LIBS="-lbsd $LIBS" ++ ++fi ++ + ;; + esac + +-- +2.37.3 + diff --git a/net-libs/libpcap/patches/libpcap-1.8.1.patchset b/net-libs/libpcap/patches/libpcap-1.8.1.patchset deleted file mode 100644 index 19344b41a..000000000 --- a/net-libs/libpcap/patches/libpcap-1.8.1.patchset +++ /dev/null @@ -1,419 +0,0 @@ -From a7ead691803de7e0f099aeda9ca7e2be437ea8ff Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Tue, 28 Apr 2015 18:39:03 +0000 -Subject: Haiku patch - - -diff --git a/Makefile.in b/Makefile.in -index e71d973..9be5f3a 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -63,6 +63,7 @@ PROG=libpcap - - # Standard CFLAGS - FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) -+CXXFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) - - INSTALL = @INSTALL@ - INSTALL_PROGRAM = @INSTALL_PROGRAM@ -@@ -79,7 +80,12 @@ YACC = @YACC@ - @rm -f $@ - $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c - --PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ -+ifeq (@V_PCAP@,haiku) -+PCAPSRC = pcap-@V_PCAP@.cpp -+else -+PCAPSRC = pcap-@V_PCAP@.c -+endif -+PSRC = $(PCAPSRC) @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ - FSRC = @V_FINDALLDEVS@ - SSRC = @SSRC@ - CSRC = pcap.c inet.c fad-helpers.c gencode.c optimize.c nametoaddr.c \ -@@ -92,7 +98,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC) - - # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot - # hack the extra indirection --OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS) -+OBJ = $(patsubst %.cpp,%.o,$(PSRC:.c=.o)) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS) - PUBHDR = \ - pcap.h \ - pcap-bpf.h \ -diff --git a/aclocal.m4 b/aclocal.m4 -index 83f5761..5da7783 100644 ---- a/aclocal.m4 -+++ b/aclocal.m4 -@@ -447,7 +447,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, - aix*) - ;; - -- freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*) -+ freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*) - # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like -@@ -1065,7 +1065,7 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [ - AC_CHECK_LIB(socket, gethostbyname, - LIBS="-lsocket -lnsl $LIBS", , -lnsl) - fi -- AC_SEARCH_LIBS(socket, socket, , -+ AC_SEARCH_LIBS(socket, socket network, , - AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)) - # DLPI needs putmsg under HPUX so test for -lstr while we're at it - AC_SEARCH_LIBS(putmsg, str) -diff --git a/configure.ac b/configure.ac -index da2f940..ccdf999 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -381,6 +381,8 @@ elif test -c /dev/enet ; then # check again in case not readable - V_PCAP=enet - elif test -c /dev/nit ; then # check again in case not readable - V_PCAP=snit -+elif test -r /boot/system ; then -+ V_PCAP=haiku - else - V_PCAP=null - fi -@@ -1384,7 +1386,7 @@ irix*) - MAN_MISC_INFO=5 - ;; - --linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*) -+linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*) - DYEXT="so" - - # -diff --git a/pcap-haiku.cpp b/pcap-haiku.cpp -new file mode 100644 -index 0000000..983a7dc ---- /dev/null -+++ b/pcap-haiku.cpp -@@ -0,0 +1,287 @@ -+/* -+ * Copyright 2006-2010, Haiku, Inc. All Rights Reserved. -+ * Distributed under the terms of the MIT License. -+ * -+ * Authors: -+ * Axel Dörfler, axeld@pinc-software.de -+ * James Woodcock -+ */ -+ -+ -+#include "config.h" -+#include "pcap-int.h" -+ -+#include -+ -+#include -+#include -+ -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+ -+/* -+ * Private data for capturing on Haiku sockets. -+ */ -+struct pcap_haiku { -+ struct pcap_stat stat; -+ char *device; /* device name */ -+}; -+ -+ -+bool -+prepare_request(struct ifreq& request, const char* name) -+{ -+ if (strlen(name) >= IF_NAMESIZE) -+ return false; -+ -+ strcpy(request.ifr_name, name); -+ return true; -+} -+ -+ -+static int -+pcap_read_haiku(pcap_t* handle, int maxPackets, pcap_handler callback, -+ u_char* userdata) -+{ -+ // Receive a single packet -+ -+ struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv; -+ u_char* buffer = (u_char*)handle->buffer + handle->offset; -+ struct sockaddr_dl from; -+ ssize_t bytesReceived; -+ do { -+ if (handle->break_loop) { -+ // Clear the break loop flag, and return -2 to indicate our -+ // reasoning -+ handle->break_loop = 0; -+ return -2; -+ } -+ -+ socklen_t fromLength = sizeof(from); -+ bytesReceived = recvfrom(handle->fd, buffer, handle->bufsize, MSG_TRUNC, -+ (struct sockaddr*)&from, &fromLength); -+ } while (bytesReceived < 0 && errno == B_INTERRUPTED); -+ -+ if (bytesReceived < 0) { -+ if (errno == B_WOULD_BLOCK) { -+ // there is no packet for us -+ return 0; -+ } -+ -+ snprintf(handle->errbuf, sizeof(handle->errbuf), -+ "recvfrom: %s", strerror(errno)); -+ return -1; -+ } -+ -+ int32 captureLength = bytesReceived; -+ if (captureLength > handle->snapshot) -+ captureLength = handle->snapshot; -+ -+/* -+ // run the packet filter -+ if (!handle->md.use_bpf && handle->fcode.bf_insns) { -+ if (bpf_filter(handle->fcode.bf_insns, buffer, bytesReceived, -+ captureLength) == 0) { -+ // packet got rejected -+ return 0; -+ } -+ } -+*/ -+ -+ // fill in pcap_header -+ -+ pcap_pkthdr header; -+ header.caplen = captureLength; -+ header.len = bytesReceived; -+ header.ts.tv_usec = system_time() % 1000000; -+ header.ts.tv_sec = system_time() / 1000000; -+ // TODO: get timing from packet!!! -+ -+ /* Call the user supplied callback function */ -+ callback(userdata, &header, buffer); -+ return 1; -+} -+ -+ -+static int -+pcap_inject_haiku(pcap_t *handle, const void *buffer, size_t size) -+{ -+ // we don't support injecting packets yet -+ // TODO: use the AF_LINK protocol (we need another socket for this) to -+ // inject the packets -+ strlcpy(handle->errbuf, "Sending packets isn't supported yet", -+ PCAP_ERRBUF_SIZE); -+ return -1; -+} -+ -+ -+static int -+pcap_setfilter_haiku(pcap_t *handle, struct bpf_program *filter) -+{ -+ // Make our private copy of the filter -+ if (install_bpf_program(handle, filter) < 0) { -+ // install_bpf_program() filled in errbuf -+ return -1; -+ } -+ -+ // we don't support kernel filters at all -+ //handle->md.use_bpf = 0; -+ return 0; -+} -+ -+ -+static int -+pcap_stats_haiku(pcap_t *handle, struct pcap_stat *stats) -+{ -+ struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv; -+ ifreq request; -+ int socket = ::socket(AF_INET, SOCK_DGRAM, 0); -+ if (socket < 0) { -+ return -1; -+ } -+ prepare_request(request, handlep->device); -+ if (ioctl(socket, SIOCGIFSTATS, &request, sizeof(struct ifreq)) < 0) { -+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "pcap_stats: %s", -+ strerror(errno)); -+ close(socket); -+ return -1; -+ } -+ -+ close(socket); -+ handlep->stat.ps_recv += request.ifr_stats.receive.packets; -+ handlep->stat.ps_drop += request.ifr_stats.receive.dropped; -+ *stats = handlep->stat; -+ return 0; -+} -+ -+ -+static int -+pcap_activate_haiku(pcap_t *handle) -+{ -+ struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv; -+ -+ const char* device = handle->opt.device; -+ -+ handle->read_op = pcap_read_haiku; -+ handle->setfilter_op = pcap_setfilter_haiku; -+ handle->inject_op = pcap_inject_haiku; -+ handle->stats_op = pcap_stats_haiku; -+ -+ // use default hooks where possible -+ handle->getnonblock_op = pcap_getnonblock_fd; -+ handle->setnonblock_op = pcap_setnonblock_fd; -+ //handle->close_op = pcap_close_common; -+ -+ handlep->device = strdup(device); -+ if (handlep->device == NULL) { -+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s", -+ pcap_strerror(errno) ); -+ return PCAP_ERROR; -+ } -+ -+ handle->bufsize = 65536; -+ // TODO: should be determined by interface MTU -+ -+ // allocate buffer for monitoring the device -+ handle->buffer = (u_char*)malloc(handle->bufsize); -+ if (handle->buffer == NULL) { -+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "buffer malloc: %s", -+ strerror(errno)); -+ return PCAP_ERROR; -+ } -+ -+ handle->offset = 0; -+ handle->linktype = DLT_EN10MB; -+ // TODO: check interface type! -+ -+ return 0; -+} -+ -+ -+// #pragma mark - pcap API -+ -+ -+extern "C" pcap_t * -+pcap_create_interface(const char *device, char *errorBuffer) -+{ -+ // TODO: handle promiscous mode! -+ -+ // we need a socket to talk to the networking stack -+ int socket = ::socket(AF_INET, SOCK_DGRAM, 0); -+ if (socket < 0) { -+ snprintf(errorBuffer, PCAP_ERRBUF_SIZE, -+ "The networking stack doesn't seem to be available.\n"); -+ return NULL; -+ } -+ -+ struct ifreq request; -+ if (!prepare_request(request, device)) { -+ snprintf(errorBuffer, PCAP_ERRBUF_SIZE, -+ "Interface name \"%s\" is too long.", device); -+ close(socket); -+ return NULL; -+ } -+ -+ // check if the interface exist -+ if (ioctl(socket, SIOCGIFINDEX, &request, sizeof(request)) < 0) { -+ snprintf(errorBuffer, PCAP_ERRBUF_SIZE, -+ "Interface \"%s\" does not exist.\n", device); -+ close(socket); -+ return NULL; -+ } -+ -+ close(socket); -+ // no longer needed after this point -+ -+ // get link level interface for this interface -+ -+ socket = ::socket(AF_LINK, SOCK_DGRAM, 0); -+ if (socket < 0) { -+ snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "No link level: %s\n", -+ strerror(errno)); -+ return NULL; -+ } -+ -+ // start monitoring -+ if (ioctl(socket, SIOCSPACKETCAP, &request, sizeof(struct ifreq)) < 0) { -+ snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "Cannot start monitoring: %s\n", -+ strerror(errno)); -+ close(socket); -+ return NULL; -+ } -+ -+ pcap_t* handle = pcap_create_common(errorBuffer, -+ sizeof (struct pcap_haiku)); -+ if (handle == NULL) { -+ snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "malloc: %s", strerror(errno)); -+ close(socket); -+ return NULL; -+ } -+ -+ handle->selectable_fd = socket; -+ handle->fd = socket; -+ -+ handle->activate_op = pcap_activate_haiku; -+ //handle->can_set_rfmon_op = pcap_can_set_rfmon_linux; -+ -+ return handle; -+} -+ -+static int -+canBeBound(const char *name) -+{ -+ return 1; -+} -+ -+extern "C" int -+pcap_platform_finddevs(pcap_if_t** _allDevices, char* errorBuffer) -+{ -+ return pcap_findalldevs_interfaces(_allDevices, errorBuffer, canBeBound); -+} --- -2.26.0 - - -From 96ccd9be2fd19e5dc644463cbd81940cfa0b1612 Mon Sep 17 00:00:00 2001 -From: Adrien Destugues -Date: Tue, 26 Feb 2019 20:07:07 +0100 -Subject: libpcap: fix 32bit x86 build - -Confusion around the definition of int32... - -diff --git a/bpf/net/bpf_filter.c b/bpf/net/bpf_filter.c -index 01a1b64..3503839 100644 ---- a/bpf/net/bpf_filter.c -+++ b/bpf/net/bpf_filter.c -@@ -81,7 +81,9 @@ - #include - #endif - -+#ifndef __HAIKU__ - #define int32 bpf_int32 -+#endif - #define u_int32 bpf_u_int32 - - #ifndef LBL_ALIGN -diff --git a/pcap/bpf.h b/pcap/bpf.h -index 78ad890..fc05d7c 100644 ---- a/pcap/bpf.h -+++ b/pcap/bpf.h -@@ -81,7 +81,7 @@ extern "C" { - /* BSD style release date */ - #define BPF_RELEASE 199606 - --#ifdef MSDOS /* must be 32-bit */ -+#if defined(MSDOS) || (defined(__HAIKU__) && defined(__X86__)) /* must be 32-bit */ - typedef long bpf_int32; - typedef unsigned long bpf_u_int32; - #else --- -2.26.0 -