link against libpcap from ports, that allows to convert kismetdb to pcap

and make the ticc2531 Zigbee sniffer work
This commit is contained in:
sebastia
2026-05-18 20:55:31 +00:00
parent d111cd1fc7
commit 9c14f59af8
5 changed files with 158 additions and 4 deletions
+4 -2
View File
@@ -5,7 +5,7 @@ COMMENT= 802.11 layer2 wireless network detector, sniffer, and IDS
V= 2025-09-R1
DISTNAME= kismet-${V}
PKGNAME= kismet-${V:S,-,,g}
REVISION= 0
REVISION= 1
CATEGORIES= net security
@@ -18,8 +18,9 @@ MAINTAINER= Sebastian Reitenbach <sebastia@openbsd.org>
# GPLv2+
PERMIT_PACKAGE= Yes
WANTLIB += ${COMPILER_LIBCXX} c crypto m mosquitto pcap pcre2-8
WANTLIB += ${COMPILER_LIBCXX} c crypto m mosquitto pcre2-8
WANTLIB += rtlsdr sqlite3 ssl usb-1.0 util websockets z
WANTLIB += lib/libpcap/pcap
# C++20
COMPILER= base-clang ports-gcc
@@ -47,6 +48,7 @@ FAKE_FLAGS+= ETC="${WRKINST}${PREFIX}/share/examples/kismet"
LIB_DEPENDS= comms/rtl-sdr \
devel/pcre2 \
net/mosquitto \
net/libpcap \
www/libwebsockets
RUN_DEPENDS= comms/rtl_433 \
net/wireshark,-text
@@ -0,0 +1,31 @@
Not yet upstreamed, waiting for positive feedback
that it actually works.
Index: capture_nrf_52840/capture_nrf_52840.c
--- capture_nrf_52840/capture_nrf_52840.c.orig
+++ capture_nrf_52840/capture_nrf_52840.c
@@ -17,7 +17,11 @@
volatile int STOP=FALSE;
+#if defined(SYS_OPENBSD)
+#define MODEMDEVICE "/dev/cuaU0"
+#else
#define MODEMDEVICE "/dev/ttyACM0"
+#endif
#define CRTSCTS 020000000000 /*should be defined but isn't with the C99*/
#define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
@@ -317,7 +321,12 @@ int open_callback(kis_capture_handler_t *caph, uint32_
bzero(&localnrf->newtio, sizeof(localnrf->newtio)); /* clear struct for new port settings */
/* set the baud rate and flags */
+#if defined(SYS_OPENBSD)
+ localnrf->newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD;
+ cfsetspeed(&localnrf->newtio, BAUDRATE);
+#else
localnrf->newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
+#endif
/* ignore parity errors */
localnrf->newtio.c_iflag = IGNPAR;
@@ -0,0 +1,94 @@
address double locks, double unlocks and unlocks of not previously locked
mutexes
address issue that OpenBSD doesn't handle libusb_detach_kernel_driver()
and use libusb_ref_device() to increse ref count on the device to keep it
usable at a later state
Index: capture_ti_cc_2531/capture_ti_cc_2531.c
--- capture_ti_cc_2531/capture_ti_cc_2531.c.orig
+++ capture_ti_cc_2531/capture_ti_cc_2531.c
@@ -150,6 +150,8 @@ int ticc2531_exit_promisc_mode(kis_capture_handler_t *
int ticc2531_receive_payload(kis_capture_handler_t *caph, uint8_t *rx_buf, size_t rx_max) {
local_ticc2531_t *localticc2531 = (local_ticc2531_t *) caph->userdata;
int actual_len, r;
+
+ pthread_mutex_lock(&(localticc2531->usb_mutex));
r = libusb_bulk_transfer(localticc2531->ticc2531_handle, TICC2531_DATA_EP, rx_buf,
rx_max, &actual_len, TICC2531_DATA_TIMEOUT);
@@ -169,6 +171,7 @@ int ticc2531_receive_payload(kis_capture_handler_t *ca
localticc2531->soft_reset = 0; /*we got something valid so reset*/
localticc2531->error_ctr = 0; /*we got something valid so reset*/
+ pthread_mutex_unlock(&(localticc2531->usb_mutex));
return actual_len;
}
@@ -345,7 +348,6 @@ int list_callback(kis_capture_handler_t *caph, uint32_
}
libusb_free_device_list(libusb_devs, 1);
- pthread_mutex_unlock(&(localticc2531->usb_mutex));
if (num_devs == 0) {
*interfaces = NULL;
@@ -424,7 +426,8 @@ int open_usb_device(kis_capture_handler_t *caph, char
if (libusb_kernel_driver_active(localticc2531->ticc2531_handle, 0)) {
r = libusb_detach_kernel_driver(localticc2531->ticc2531_handle, 0);
- if (r < 0) {
+ // If it's not supported (like on OpenBSD), just keep going!
+ if (r < 0 && r != LIBUSB_ERROR_NOT_SUPPORTED) {
snprintf(errstr, STATUS_MAX, "Unable to open ticc2531 USB interface, "
"could not disconnect kernel drivers: %s",
libusb_strerror((enum libusb_error) r));
@@ -478,7 +481,7 @@ int open_usb_device(kis_capture_handler_t *caph, char
int open_callback(kis_capture_handler_t *caph, uint32_t seqno, char *definition,
char *msg, uint32_t *dlt, char **uuid,
cf_params_interface_t **ret_interface,
- cf_params_spectrum_t **ret_spectrum) {
+ cf_params_spectrum_t **ret_spectrum) {
char *placeholder = NULL;
int placeholder_len;
@@ -565,7 +568,7 @@ int open_callback(kis_capture_handler_t *caph, uint32_
if (busno == libusb_get_bus_number(libusb_devs[i]) &&
devno == libusb_get_device_address(libusb_devs[i])) {
matched_device = 1;
- localticc2531->matched_dev = libusb_devs[i];
+ localticc2531->matched_dev = libusb_ref_device(libusb_devs[i]);
break;
}
} else {
@@ -573,7 +576,7 @@ int open_callback(kis_capture_handler_t *caph, uint32_
matched_device = 1;
busno = libusb_get_bus_number(libusb_devs[i]);
devno = libusb_get_device_address(libusb_devs[i]);
- localticc2531->matched_dev = libusb_devs[i];
+ localticc2531->matched_dev = libusb_ref_device(libusb_devs[i]);
break;
}
@@ -666,7 +669,7 @@ int chancontrol_callback(kis_capture_handler_t *caph,
}
if (localticc2531->ticc2531_handle == NULL) {
- pthread_mutex_unlock(&(localticc2531->usb_mutex));
+ // pthread_mutex_unlock(&(localticc2531->usb_mutex));
return 0;
}
@@ -871,6 +874,11 @@ int main(int argc, char *argv[]) {
cf_handler_loop(caph);
cf_handler_shutdown(caph);
+
+ if (localticc2531.matched_dev) {
+ libusb_unref_device(localticc2531.matched_dev);
+ localticc2531.matched_dev = NULL;
+ }
libusb_exit(localticc2531.libusb_ctx);
+17 -1
View File
@@ -1,6 +1,6 @@
- don't force -O3
- GCC's libatomic should not be pulled in just because it exists
- libstdc++ should n9t be explicitly linked (use "c++" as a linker instead)
- libstdc++ should not be explicitly linked (use "c++" as a linker instead)
Index: configure.ac
--- configure.ac.orig
@@ -59,3 +59,19 @@ Index: configure.ac
AC_SUBST(CXXLIBS)
# Does the compiler handle various std::foo namespaces properly?
@@ -1188,12 +1157,12 @@ AC_SUBST(LIBWSCFLAGS)
# Look for libpcap via pkg-config
have_libpcap=no
-PKG_CHECK_MODULES([libpcap], [libpcap], [
+PKG_CHECK_MODULES([libepcap], [libepcap], [
have_libpcap=yes
AC_DEFINE(HAVE_LIBPCAP, 1, libpcap packet capture lib)
- PCAPLIBS=`pkg-config --libs libpcap`
- PCAPCFLAGS=`pkg-config --cflags libpcap`
+ PCAPLIBS=`pkg-config --libs libepcap`
+ PCAPCFLAGS=`pkg-config --cflags libepcap`
pcap=yes
], [
AC_MSG_WARN(No libpcap found in pkg-config, will check system paths.)
+12 -1
View File
@@ -8,11 +8,22 @@ known to work capture drivers
The following capture drivers are known to work:
* openbsd_wifi (autodetected)
* sdr_rtladsb (autodetected)
* planes
* sdr_rtl433 (autodetected)
* meters
* nrf_51822 (not autodetected)
* Bluetooth LE
* use with:
* -c nrf51822:type=nrf51822,device=/dev/cuaU0,name=adafruit
* tested with Adafruit Bluefruit sniffer as well as nrf52840
nice!Nano with Bluetooth sniffer firmware
* nrf_52840 (not autodetected)
* Zigbee
* use with:
* -c nrf52840:type=nrf52840,device=/dev/cuaU0,name=niceNano
* note: haven't seen it reporting any packets yet using a nice!Nano
* ti_cc_2531 (autodetected)
* Zigbee
Many other capture drivers are enabled. They are untested,
but may work as well.