wavemon: Bump to 0.9.4

This commit is contained in:
Tee KOBAYASHI 2022-11-23 19:39:37 +09:00 committed by xtkoba
parent be52291206
commit a7ff84a1dd
5 changed files with 179 additions and 20 deletions

View File

@ -0,0 +1,11 @@
--- a/Makefile.in
+++ b/Makefile.in
@@ -9,7 +9,7 @@
install-suid-root: exec_perms = 4755
CC ?= @CC@
-CFLAGS ?= @CFLAGS@ @LIBNL3_CLI_CFLAGS@
+CFLAGS = @CFLAGS@ @LIBNL3_CLI_CFLAGS@
CPPFLAGS ?= @CPPFLAGS@
LDFLAGS ?= @LDFLAGS@
DEFS ?= @DEFS@

View File

@ -2,11 +2,10 @@ TERMUX_PKG_HOMEPAGE=https://github.com/uoaerg/wavemon
TERMUX_PKG_DESCRIPTION="Ncurses-based monitoring application for wireless network devices"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.9.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_VERSION=0.9.4
TERMUX_PKG_SRCURL=https://github.com/uoaerg/wavemon/archive/v$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=5ebd5b79d3b7c546bc16b95161872c699a75e9acdfc6e3f02ec48dad10802067
TERMUX_PKG_DEPENDS="libcap, libnl, ncurses"
TERMUX_PKG_SHA256=e7e4167292136ca7ff12ddeb880904c10f33e97620ea6aa5f7838e859fdb40ed
TERMUX_PKG_DEPENDS="libcap, libnl, libnl-cli, ncurses"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_lib_pthread_pthread_create=yes"

View File

@ -2,10 +2,10 @@ diff -uNr wavemon-0.9.0/iw_nl80211.h wavemon-0.9.0.mod/iw_nl80211.h
--- wavemon-0.9.0/iw_nl80211.h 2018-12-30 03:08:25.000000000 +0200
+++ wavemon-0.9.0.mod/iw_nl80211.h 2019-07-03 16:49:23.890816614 +0300
@@ -5,6 +5,7 @@
#include <netlink/genl/genl.h>
#include <netlink/genl/ctrl.h>
* Definitions and functions for nl80211 based routines.
*/
#include <stdbool.h>
+#include <net/ethernet.h>
#include <netinet/ether.h>
#include <stdbool.h>
#include <netlink/netlink.h>

View File

@ -0,0 +1,161 @@
--- a/info_scr.c
+++ b/info_scr.c
@@ -30,12 +30,28 @@ static struct iw_nl80211_linkstat *ls_tm
*ls_new = NULL;
static pthread_mutex_t linkstat_mutex;
+#ifdef __ANDROID__
+static void thread_signal_handler(int signum)
+{
+ pthread_exit(0);
+}
+#endif
+
/** Sampling pthread - shared by info and histogram screen. */
static void *sampling_loop(void *arg)
{
const bool do_not_swap_pointers = (bool)arg;
sigset_t blockmask;
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
+
/* See comment in iw_scan.c for rationale of blocking SIGWINCH. */
sigemptyset(&blockmask);
sigaddset(&blockmask, SIGWINCH);
@@ -48,12 +64,23 @@ static void *sampling_loop(void *arg)
if (do_not_swap_pointers)
continue;
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+#else
+ sigset_t pthread_cancel_block;
+ sigemptyset(&pthread_cancel_block);
+ sigaddset(&pthread_cancel_block, SIGUSR2);
+ sigprocmask(SIG_BLOCK, &pthread_cancel_block, NULL);
+#endif
pthread_mutex_lock(&linkstat_mutex);
ls_new = ls_tmp;
ls_tmp = NULL;
pthread_mutex_unlock(&linkstat_mutex);
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+#else
+ sigprocmask(SIG_UNBLOCK, &pthread_cancel_block, NULL);
+#endif
}
} while (usleep(conf.stat_iv * 1000) == 0);
return NULL;
@@ -77,7 +104,11 @@ void sampling_init(bool do_not_swap_poin
void sampling_stop(void)
{
+#ifndef __ANDROID__
pthread_cancel(sampling_thread);
+#else
+ pthread_kill(sampling_thread, SIGUSR2);
+#endif
pthread_join(sampling_thread, NULL);
}
--- a/iw_scan.c
+++ b/iw_scan.c
@@ -397,16 +397,34 @@ static void _write_warning_msg(struct sc
va_start(argp, format);
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+#else
+ sigset_t pthread_cancel_block;
+ sigemptyset(&pthread_cancel_block);
+ sigaddset(&pthread_cancel_block, SIGUSR2);
+ sigprocmask(SIG_BLOCK, &pthread_cancel_block, NULL);
+#endif
pthread_mutex_lock(&sr->mutex);
_clear_scan_result(sr);
vsnprintf(sr->msg, sizeof(sr->msg), format, argp);
pthread_mutex_unlock(&sr->mutex);
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+#else
+ sigprocmask(SIG_UNBLOCK, &pthread_cancel_block, NULL);
+#endif
}
+#ifdef __ANDROID__
+static void thread_signal_handler(int signum)
+{
+ pthread_exit(0);
+}
+#endif
+
/** The actual scan thread. */
void *do_scan(void *sr_ptr)
{
@@ -414,6 +432,15 @@ void *do_scan(void *sr_ptr)
sigset_t blockmask;
int ret = 0;
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
+
/* SIGWINCH is supposed to be handled in the main thread. */
sigemptyset(&blockmask);
sigaddset(&blockmask, SIGWINCH);
@@ -465,7 +492,14 @@ void *do_scan(void *sr_ptr)
compute_channel_stats(tmp);
sort_scan_list(&tmp->head);
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+#else
+ sigset_t pthread_cancel_block;
+ sigemptyset(&pthread_cancel_block);
+ sigaddset(&pthread_cancel_block, SIGUSR2);
+ sigprocmask(SIG_BLOCK, &pthread_cancel_block, NULL);
+#endif
pthread_mutex_lock(&sr->mutex);
_clear_scan_result(sr);
@@ -475,7 +509,11 @@ void *do_scan(void *sr_ptr)
memcpy(&(sr->num), &(tmp->num), sizeof(tmp->num));
pthread_mutex_unlock(&sr->mutex);
+#ifndef __ANDROID__
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+#else
+ sigprocmask(SIG_UNBLOCK, &pthread_cancel_block, NULL);
+#endif
}
free(tmp);
}
--- a/scan_scr.c
+++ b/scan_scr.c
@@ -299,7 +299,11 @@ void scr_aplst_fini(void)
/* Unlock mutex in case it was taken when scr_aplst_loop got interrupted by a SIGWINCH.
* We are ignoring the error (EPERM) here if the main thread did not acquire the mutex. */
pthread_mutex_unlock(&sr.mutex);
+#ifndef __ANDROID__
pthread_cancel(scan_thread);
+#else
+ pthread_kill(scan_thread, SIGUSR2);
+#endif
pthread_join(scan_thread, NULL);
delwin(w_aplst);
}

View File

@ -1,12 +0,0 @@
diff -uNr wavemon-0.9.0/scan_scr.c wavemon-0.9.0.mod/scan_scr.c
--- wavemon-0.9.0/scan_scr.c 2018-12-30 03:08:25.000000000 +0200
+++ wavemon-0.9.0.mod/scan_scr.c 2019-07-03 16:51:31.595109371 +0300
@@ -250,7 +250,7 @@
void scr_aplst_fini(void)
{
- pthread_cancel(scan_thread);
+ pthread_kill(scan_thread, 0);
free_scan_list(sr.head);
free(sr.channel_stats);