diff -Nru wavemon-0.8.1/about_scr.c wavemon-0.8.2/about_scr.c --- wavemon-0.8.1/about_scr.c 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/about_scr.c 2018-02-18 00:23:56.000000000 +0000 @@ -29,9 +29,6 @@ "original by jan morgenstern ", "distributed under the GNU general public license v3", "", - "please send suggestions and bug reports to ", - PACKAGE_BUGREPORT, - "", PACKAGE_URL }; diff -Nru wavemon-0.8.1/configure wavemon-0.8.2/configure --- wavemon-0.8.1/configure 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/configure 2018-02-18 00:23:56.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for wavemon 0.8.0. +# Generated by GNU Autoconf 2.69 for wavemon 0.8.2. # -# Report bugs to . +# Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -267,10 +267,10 @@ $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: gerrit@erg.abdn.ac.uk about your system, including any -$0: error possibly output before this message. Then install -$0: a modern shell, or manually run the script under such a -$0: shell if you do have one." +$0: https://github.com/uoaerg/wavemon about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." fi exit 1 fi @@ -580,9 +580,9 @@ # Identity of this package. PACKAGE_NAME='wavemon' PACKAGE_TARNAME='wavemon-current' -PACKAGE_VERSION='0.8.0' -PACKAGE_STRING='wavemon 0.8.0' -PACKAGE_BUGREPORT='gerrit@erg.abdn.ac.uk' +PACKAGE_VERSION='0.8.2' +PACKAGE_STRING='wavemon 0.8.2' +PACKAGE_BUGREPORT='https://github.com/uoaerg/wavemon' PACKAGE_URL='https://github.com/uoaerg/wavemon' # Factoring default headers for most tests. @@ -1249,7 +1249,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures wavemon 0.8.0 to adapt to many kinds of systems. +\`configure' configures wavemon 0.8.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1314,7 +1314,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of wavemon 0.8.0:";; + short | recursive ) echo "Configuration of wavemon 0.8.2:";; esac cat <<\_ACEOF @@ -1343,7 +1343,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . wavemon home page: . _ACEOF ac_status=$? @@ -1407,7 +1407,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -wavemon configure 0.8.0 +wavemon configure 0.8.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1608,9 +1608,9 @@ $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( $as_echo "## ------------------------------------ ## -## Report this to gerrit@erg.abdn.ac.uk ## -## ------------------------------------ ##" +( $as_echo "## ------------------------------------------------ ## +## Report this to https://github.com/uoaerg/wavemon ## +## ------------------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac @@ -1830,7 +1830,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by wavemon $as_me 0.8.0, which was +It was created by wavemon $as_me 0.8.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4955,7 +4955,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by wavemon $as_me 0.8.0, which was +This file was extended by wavemon $as_me 0.8.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5002,14 +5002,14 @@ Configuration files: $config_files -Report bugs to . +Report bugs to . wavemon home page: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -wavemon config.status 0.8.0 +wavemon config.status 0.8.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru wavemon-0.8.1/configure.ac wavemon-0.8.2/configure.ac --- wavemon-0.8.1/configure.ac 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/configure.ac 2018-02-18 00:23:56.000000000 +0000 @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.64) -AC_INIT([wavemon], [0.8.0], [gerrit@erg.abdn.ac.uk], [wavemon-current], +AC_INIT([wavemon], [0.8.2], [https://github.com/uoaerg/wavemon], [wavemon-current], [https://github.com/uoaerg/wavemon]) diff -Nru wavemon-0.8.1/debian/changelog wavemon-0.8.2/debian/changelog --- wavemon-0.8.1/debian/changelog 2018-05-03 14:20:13.000000000 +0000 +++ wavemon-0.8.2/debian/changelog 2018-04-07 18:16:24.000000000 +0000 @@ -1,12 +1,20 @@ -wavemon (0.8.1-1build1) cosmic; urgency=medium +wavemon (0.8.2-1) unstable; urgency=medium - * No-change rebuild for ncurses soname changes. + * New upstream release (Closes: #825544) + * d/control: update homepage to reflect move to github (Closes: #794535) + * d/changelog: remove trailing spaces + * d/compat: bump to dh compat level to 11 + * d/control: bump Standards-Version to 4.0.1 + - Change Priority from Extra to Optional + * d/control: remove autotools-dev as a dependency + * d/patches: refresh patches + * d/patches: add patch from Helmut Grohne to fix FTCBFS (Closes: #852784) - -- Matthias Klose Thu, 03 May 2018 14:20:13 +0000 + -- Jonathan McCrohan Sat, 07 Apr 2018 19:16:24 +0100 wavemon (0.8.1-1) unstable; urgency=medium - * New upstream release + * New upstream release * d/control: bump Standards-Version to 3.9.8 - No changes required @@ -18,7 +26,7 @@ - Majority of WEXT functions now replaced by nl80211 - Updated scan and info screens - Drop random signals functionality - * d/watch: upstream has moved to github; update accordingly + * d/watch: upstream has moved to github; update accordingly * d/patches: - refresh 01-patch-makefile.in-to-not-install-docs.patch - drop 02-patch-configure.ac-to-allow-external-build_date.patch; applied @@ -132,7 +140,7 @@ * New maintainer: Jonathan McCrohan - Many thanks to Rene Engelhard for his great work. - -- Jonathan McCrohan Tue, 21 Feb 2012 22:08:12 +0000 + -- Jonathan McCrohan Tue, 21 Feb 2012 22:08:12 +0000 wavemon (0.6.10-1) unstable; urgency=low @@ -177,7 +185,7 @@ * build-depend on linux-libc-dev as first alternative. Fixes the FTBFS on the ia64 buildd... - * fix wavemonrc(5)'s section + * fix wavemonrc(5)'s section -- Rene Engelhard Mon, 02 Jul 2007 14:06:09 +0200 diff -Nru wavemon-0.8.1/debian/compat wavemon-0.8.2/debian/compat --- wavemon-0.8.1/debian/compat 2012-06-10 22:15:47.000000000 +0000 +++ wavemon-0.8.2/debian/compat 2018-03-18 20:57:39.000000000 +0000 @@ -1 +1 @@ -9 +11 diff -Nru wavemon-0.8.1/debian/control wavemon-0.8.2/debian/control --- wavemon-0.8.1/debian/control 2017-01-02 22:48:06.000000000 +0000 +++ wavemon-0.8.2/debian/control 2018-03-19 01:30:44.000000000 +0000 @@ -1,12 +1,11 @@ Source: wavemon Section: net -Priority: extra +Priority: optional Maintainer: Jonathan McCrohan -Build-Depends: autotools-dev, libncurses5-dev, - debhelper (>= 9), linux-libc-dev, libnl-3-dev, libnl-genl-3-dev, - pkg-config -Standards-Version: 3.9.8 -Homepage: http://www.erg.abdn.ac.uk/ergcms/wavemon/ +Build-Depends: libncurses5-dev, debhelper (>= 11), linux-libc-dev, libnl-3-dev, + libnl-genl-3-dev, pkg-config +Standards-Version: 4.0.1 +Homepage: https://github.com/uoaerg/wavemon/ Package: wavemon Architecture: linux-any diff -Nru wavemon-0.8.1/debian/patches/01-patch-makefile.in-to-not-install-docs.patch wavemon-0.8.2/debian/patches/01-patch-makefile.in-to-not-install-docs.patch --- wavemon-0.8.1/debian/patches/01-patch-makefile.in-to-not-install-docs.patch 2016-01-30 18:24:29.000000000 +0000 +++ wavemon-0.8.2/debian/patches/01-patch-makefile.in-to-not-install-docs.patch 2018-03-19 01:31:38.000000000 +0000 @@ -3,12 +3,12 @@ Subject: Patch Makefile.in to not install docs; install using dh instead diff --git a/Makefile.in b/Makefile.in -index d2e1c01..d8a579b 100644 +index c9ecc37..d790ccd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,7 +22,6 @@ MAIN = @PACKAGE_NAME@.c HEADERS = $(wildcard *.h) - PURESRC = $(filter-out $(MAIN),$(wildcard *.c)) + PURESRC = $(filter-out $(MAIN),$(sort $(wildcard *.c))) OBJS = $(PURESRC:.c=.o) -DOCS = README.md NEWS THANKS AUTHORS COPYING ChangeLog diff -Nru wavemon-0.8.1/debian/patches/02-honour-CC.patch wavemon-0.8.2/debian/patches/02-honour-CC.patch --- wavemon-0.8.1/debian/patches/02-honour-CC.patch 1970-01-01 00:00:00.000000000 +0000 +++ wavemon-0.8.2/debian/patches/02-honour-CC.patch 2018-04-07 18:10:19.000000000 +0000 @@ -0,0 +1,19 @@ +From: Helmut Grohne +Subject: honour the CC variable from configure + +A ?= assignment to CC is a noop, because CC has a make default of "cc". This +breaks e.g. cross compilation. + +Index: wavemon-0.8.1/Makefile.in +=================================================================== +--- wavemon-0.8.1.orig/Makefile.in ++++ wavemon-0.8.1/Makefile.in +@@ -8,7 +8,7 @@ + exec_perms = 0755 + install-suid-root: exec_perms = 4755 + +-CC ?= @CC@ ++CC = @CC@ + CFLAGS ?= @CFLAGS@ @LIBNL3_CFLAGS@ + CPPFLAGS ?= @CPPFLAGS@ + LDFLAGS ?= @LDFLAGS@ diff -Nru wavemon-0.8.1/debian/patches/series wavemon-0.8.2/debian/patches/series --- wavemon-0.8.1/debian/patches/series 2016-01-30 18:25:56.000000000 +0000 +++ wavemon-0.8.2/debian/patches/series 2018-04-07 18:10:19.000000000 +0000 @@ -1 +1,2 @@ 01-patch-makefile.in-to-not-install-docs.patch +02-honour-CC.patch diff -Nru wavemon-0.8.1/debian/rules wavemon-0.8.2/debian/rules --- wavemon-0.8.1/debian/rules 2016-02-06 02:02:00.000000000 +0000 +++ wavemon-0.8.2/debian/rules 2018-03-19 01:31:01.000000000 +0000 @@ -7,4 +7,4 @@ export BUILD_DATE = $(shell LC_ALL=C date -u --date="`dpkg-parsechangelog -SDate`") %: - dh $@ --with autotools_dev + dh $@ diff -Nru wavemon-0.8.1/info_scr.c wavemon-0.8.2/info_scr.c --- wavemon-0.8.1/info_scr.c 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/info_scr.c 2018-02-18 00:23:56.000000000 +0000 @@ -53,6 +53,7 @@ void sampling_init(void) { + pthread_mutex_init(&linkstat.mutex, NULL); linkstat.run = true; pthread_create(&sampling_thread, NULL, sampling_loop, NULL); } @@ -61,6 +62,7 @@ { linkstat.run = false; pthread_join(sampling_thread, NULL); + pthread_mutex_destroy(&linkstat.mutex); } static void display_levels(void) @@ -78,7 +80,6 @@ bool noise_data_valid; int sig_qual = -1, sig_qual_max, sig_level; - noise_data_valid = iw_nl80211_have_survey_data(&linkstat.data); sig_level = linkstat.data.signal_avg ?: linkstat.data.signal; @@ -103,12 +104,6 @@ sig_qual_max = 70; } - if (sig_qual == -1 && !sig_level && !noise_data_valid) { - wattron(w_levels, A_BOLD); - waddstr_center(w_levels, (WH_LEVEL + 1)/2, "NO INTERFACE DATA"); - goto done_levels; - } - line = 1; /* Noise data is rare. Use the space for spreading out. */ @@ -173,7 +168,6 @@ waddstr_b(w_levels, tmp); } -done_levels: wrefresh(w_levels); } @@ -211,7 +205,8 @@ if (linkstat.data.rx_drop_misc) { waddstr(w_stats, ", drop: "); - sprintf(tmp, "%'llu", (unsigned long long)linkstat.data.rx_drop_misc); + sprintf(tmp, "%'llu (%.1f%%)", (unsigned long long)linkstat.data.rx_drop_misc, + (1e2 * linkstat.data.rx_drop_misc)/linkstat.data.rx_packets); waddstr_b(w_stats, tmp); } @@ -237,7 +232,8 @@ if (linkstat.data.tx_retries) { waddstr(w_stats, ", retries: "); - sprintf(tmp, "%'u", linkstat.data.tx_retries); + sprintf(tmp, "%'u (%.1f%%)", linkstat.data.tx_retries, + (1e2 * linkstat.data.tx_retries)/linkstat.data.tx_packets); waddstr_b(w_stats, tmp); } @@ -257,10 +253,9 @@ struct iw_nl80211_ifstat ifs; struct iw_nl80211_reg ir; char tmp[0x100]; - int i; iw_getinf_range(conf_ifname(), &range); - dyn_info_get(&info, conf_ifname(), &range); + dyn_info_get(&info, conf_ifname()); iw_nl80211_getifstat(&ifs); iw_nl80211_getreg(&ir); @@ -530,63 +525,11 @@ } wclrtoborder(w_info); + /* FIXME: re-enable encryption information (issue #8) wmove(w_info, 7, 1); waddstr(w_info, "encryption: "); - if (info.keys) { - int cnt = dyn_info_active_keys(&info); - - if (cnt == 0) { - waddstr_b(w_info, "off (no key set)"); - } else if (info.active_key) { - i = info.active_key - 1; - waddstr_b(w_info, curtail(format_key(info.keys + i), - "..", MAXXLEN/2)); - - if (info.keys[i].flags & IW_ENCODE_RESTRICTED) - waddstr(w_info, ", restricted"); - if (info.keys[i].flags & IW_ENCODE_OPEN) - waddstr(w_info, ", open"); - - /* First key = default */ - if (cnt > 1 || info.active_key != 1) { - sprintf(tmp, " [%d]", info.active_key); - waddstr_b(w_info, tmp); - } - if (cnt > 1) { - sprintf(tmp, " (%d other key%s)", cnt - 1, - cnt == 2 ? "" : "s"); - waddstr(w_info, tmp); - } - } else if (dyn_info_wep_keys(&info) == cnt) { - waddstr_b(w_info, "off "); - sprintf(tmp, "(%d disabled WEP key%s)", cnt, - cnt == 1 ? "" : "s"); - waddstr(w_info, tmp); - } else { - uint8_t j = 0, k = 0; - - do if (info.keys[j].size && - !(info.keys[j].flags & IW_ENCODE_DISABLED)) - info.keys[k++].size = info.keys[j].size; - while (k < cnt && ++j < info.nkeys); - - if (cnt == 1) - j = sprintf(tmp, "1 key (index #%u), ", j + 1); - else - j = sprintf(tmp, "%d keys with ", k); - for (i = 0; i < k; i++) - j += sprintf(tmp + j, "%s%d", i ? "/" : "", - info.keys[i].size * 8); - sprintf(tmp + j, " bits"); - waddstr_b(w_info, tmp); - } - } else if (has_net_admin_capability()) { - waddstr(w_info, "no information available"); - } else { - waddstr(w_info, "n/a (requires CAP_NET_ADMIN permissions)"); - } + */ - dyn_info_cleanup(&info); wclrtoborder(w_info); wrefresh(w_info); } diff -Nru wavemon-0.8.1/iw_if.c wavemon-0.8.2/iw_if.c --- wavemon-0.8.1/iw_if.c 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/iw_if.c 2018-02-18 00:23:56.000000000 +0000 @@ -154,11 +154,10 @@ * @ifname: interface name * @if: range information to use (number of encryption keys) */ -void dyn_info_get(struct iw_dyn_info *info, - const char *ifname, struct iw_range *ir) +void dyn_info_get(struct iw_dyn_info *info, const char *ifname) { struct iwreq iwr; - int i, skfd = socket(AF_INET, SOCK_DGRAM, 0); + int skfd = socket(AF_INET, SOCK_DGRAM, 0); if (skfd < 0) err_sys("%s: can not open socket", __func__); @@ -230,43 +229,6 @@ info->mode = iwr.u.mode; } - info->nkeys = ir->max_encoding_tokens; - if (info->nkeys) { - info->keys = calloc(info->nkeys, sizeof(*info->keys)); - if (info->keys == NULL) - err_sys("malloc(key array)"); - - /* Get index of default key first */ - iwr.u.data.pointer = info->keys[0].key; - iwr.u.data.length = sizeof(info->keys[0].key); - iwr.u.data.flags = 0; - if (ioctl(skfd, SIOCGIWENCODE, &iwr) < 0) { - free(info->keys); - info->keys = NULL; - info->nkeys = 0; - } else { - info->active_key = iwr.u.data.flags & IW_ENCODE_INDEX; - } - } - /* If successful, populate the key array */ - for (i = 0; i < info->nkeys; i++) { - iwr.u.data.pointer = info->keys[i].key; - iwr.u.data.length = sizeof(info->keys->key); - iwr.u.data.flags = i + 1; /* counts 1..n instead of 0..n-1 */ - if (ioctl(skfd, SIOCGIWENCODE, &iwr) < 0) { - free(info->keys); - info->nkeys = 0; - break; - } - info->keys[i].size = iwr.u.data.length; - info->keys[i].flags = iwr.u.data.flags; - - /* Validate whether the current key is indeed active */ - if (i + 1 == info->active_key && (info->keys[i].size == 0 || - (info->keys[i].flags & IW_ENCODE_DISABLED))) - info->active_key = 0; - } - if (ioctl(skfd, SIOCGIWAP, &iwr) >= 0) { info->cap_ap = 1; memcpy(&info->ap_addr, &iwr.u.ap_addr, sizeof(struct sockaddr)); @@ -274,13 +236,6 @@ close(skfd); } -void dyn_info_cleanup(struct iw_dyn_info *info) -{ - if (info) - free(info->keys); -} - - /* * Request range information for a given wireless interface. * @ifname: name of the wireless argument diff -Nru wavemon-0.8.1/iw_if.h wavemon-0.8.2/iw_if.h --- wavemon-0.8.1/iw_if.h 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/iw_if.h 2018-02-18 00:23:56.000000000 +0000 @@ -148,37 +148,9 @@ float freq; int32_t sens; unsigned long bitrate; - - struct iw_key *keys; - uint8_t nkeys; - uint8_t active_key; }; -/* Return the number of encryption keys marked 'active' in @info */ -static inline uint8_t dyn_info_active_keys(struct iw_dyn_info *info) -{ - int i, num_active = 0; - - for (i = 0; i < info->nkeys; i++) - num_active += info->keys[i].size && - !(info->keys[i].flags & IW_ENCODE_DISABLED); - return num_active; -} - -/* Return the number of 40-bit/104-bit keys in @info */ -static inline uint8_t dyn_info_wep_keys(struct iw_dyn_info *info) -{ - int i, num_wep = 0; - - for (i = 0; i < info->nkeys; i++) - if (!(info->keys[i].flags & IW_ENCODE_DISABLED)) - num_wep += info->keys[i].size == 5 || - info->keys[i].size == 13; - return num_wep; -} -extern void dyn_info_get(struct iw_dyn_info *info, - const char *ifname, struct iw_range *ir); -extern void dyn_info_cleanup(struct iw_dyn_info *info); +extern void dyn_info_get(struct iw_dyn_info *info, const char *ifname); /* @@ -278,8 +250,8 @@ pthread_mutex_t mutex; }; -extern void scan_result_init(struct scan_result *sr); -extern void scan_result_fini(struct scan_result *sr); +extern void init_scan_list(struct scan_result *sr); +extern void free_scan_list(struct scan_entry *head); extern void *do_scan(void *sr_ptr); /* diff -Nru wavemon-0.8.1/iw_nl80211.c wavemon-0.8.2/iw_nl80211.c --- wavemon-0.8.1/iw_nl80211.c 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/iw_nl80211.c 2018-02-18 00:23:56.000000000 +0000 @@ -128,7 +128,7 @@ rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]); if (rate > 0) pos += snprintf(pos, buflen - (pos - buf), - "%d.%d MBit/s", rate / 10, rate % 10); + "%d.%d Mbit/s", rate / 10, rate % 10); if (rinfo[NL80211_RATE_INFO_MCS]) pos += snprintf(pos, buflen - (pos - buf), diff -Nru wavemon-0.8.1/iw_scan.c wavemon-0.8.2/iw_scan.c --- wavemon-0.8.1/iw_scan.c 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/iw_scan.c 2018-02-18 00:23:56.000000000 +0000 @@ -105,7 +105,7 @@ * Returns true if scan results are available, false if scan was aborted. * Taken from iw:event.c:__do_listen_events */ -static bool wait_for_scan_events(struct scan_result *sr) +static bool wait_for_scan_events(void) { static const uint32_t cmds[] = { NL80211_CMD_NEW_SCAN_RESULTS, @@ -293,7 +293,8 @@ *headp = head; } -static void free_scan_list(struct scan_entry *head) +/** De-allocate list. Use after all threads are terminated. */ +void free_scan_list(struct scan_entry *head) { if (head) { free_scan_list(head->next); @@ -301,9 +302,9 @@ } } -static void clear_scan_list(struct scan_result *sr) +/** Initialize scan results. Requires lock to be taken. */ +void init_scan_list(struct scan_result *sr) { - pthread_mutex_lock(&sr->mutex); free_scan_list(sr->head); free(sr->channel_stats); sr->head = NULL; @@ -311,7 +312,7 @@ sr->msg[0] = '\0'; sr->max_essid_len = MAX_ESSID_LEN; memset(&(sr->num), 0, sizeof(sr->num)); - pthread_mutex_unlock(&sr->mutex); + sr->mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER; } /* @@ -366,28 +367,6 @@ sr->num.ch_stats = n < MAX_CH_STATS ? n : MAX_CH_STATS; } -/* - * Scan results. - */ -void scan_result_init(struct scan_result *sr) -{ - pthread_mutexattr_t ma; - - memset(sr, 0, sizeof(*sr)); - pthread_mutexattr_init(&ma); - if (pthread_mutexattr_setrobust(&ma, PTHREAD_MUTEX_ROBUST) < 0) - err_sys("Failed to set the mutex robust attribute"); - pthread_mutex_init(&sr->mutex, &ma); -} - -void scan_result_fini(struct scan_result *sr) -{ - /* FIXME: this may have a bug on resource de-allocation, if the main thread still holds the lock */ - free_scan_list(sr->head); - free(sr->channel_stats); - pthread_mutex_destroy(&sr->mutex); -} - /** The actual scan thread. */ void *do_scan(void *sr_ptr) { @@ -402,15 +381,21 @@ pthread_detach(pthread_self()); do { - clear_scan_list(sr); - ret = iw_nl80211_scan_trigger(); + + pthread_mutex_lock(&sr->mutex); + init_scan_list(sr); switch(-ret) { case 0: case EBUSY: /* Trigger returns -EBUSY if a scan request is pending or ready. */ - if (!wait_for_scan_events(sr)) { + pthread_mutex_unlock(&sr->mutex); + + /* Do not hold the lock while awaiting results. */ + if (!wait_for_scan_events()) { + pthread_mutex_lock(&sr->mutex); snprintf(sr->msg, sizeof(sr->msg), "Waiting for scan data..."); + pthread_mutex_unlock(&sr->mutex); } else { pthread_mutex_lock(&sr->mutex); ret = iw_nl80211_get_scan_data(sr); @@ -426,8 +411,8 @@ break; case EPERM: if (!has_net_admin_capability()) - snprintf(sr->msg, sizeof(sr->msg), - "This screen requires CAP_NET_ADMIN permissions"); + snprintf(sr->msg, sizeof(sr->msg), "This screen requires CAP_NET_ADMIN permissions"); + pthread_mutex_unlock(&sr->mutex); return NULL; case EFAULT: /* EFAULT can occur after a window resizing event: temporary, fall through. */ @@ -435,18 +420,21 @@ case EAGAIN: /* Temporary errors. */ snprintf(sr->msg, sizeof(sr->msg), "Waiting for device to become ready ..."); + pthread_mutex_unlock(&sr->mutex); break; case ENETDOWN: if (!if_is_up(conf_ifname())) { snprintf(sr->msg, sizeof(sr->msg), "Interface %s is down - setting it up ...", conf_ifname()); + pthread_mutex_unlock(&sr->mutex); + if (if_set_up(conf_ifname()) < 0) err_sys("Can not bring up interface '%s'", conf_ifname()); break; } /* fall through */ default: - snprintf(sr->msg, sizeof(sr->msg), - "Scan trigger failed on %s: %s", conf_ifname(), strerror(-ret)); + snprintf(sr->msg, sizeof(sr->msg), "Scan trigger failed on %s: %s", conf_ifname(), strerror(-ret)); + pthread_mutex_unlock(&sr->mutex); } } while (usleep(conf.stat_iv * 1000) == 0); diff -Nru wavemon-0.8.1/Makefile.in wavemon-0.8.2/Makefile.in --- wavemon-0.8.1/Makefile.in 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/Makefile.in 2018-02-18 00:23:56.000000000 +0000 @@ -20,7 +20,7 @@ MAIN = @PACKAGE_NAME@.c HEADERS = $(wildcard *.h) -PURESRC = $(filter-out $(MAIN),$(wildcard *.c)) +PURESRC = $(filter-out $(MAIN),$(sort $(wildcard *.c))) OBJS = $(PURESRC:.c=.o) DOCS = README.md NEWS THANKS AUTHORS COPYING ChangeLog diff -Nru wavemon-0.8.1/scan_scr.c wavemon-0.8.2/scan_scr.c --- wavemon-0.8.1/scan_scr.c 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/scan_scr.c 2018-02-18 00:23:56.000000000 +0000 @@ -203,7 +203,7 @@ mvwaddstr(w_aplst, START_LINE, 1, "Waiting for scan data ..."); wrefresh(w_aplst); - scan_result_init(&sr); + init_scan_list(&sr); pthread_create(&scan_thread, NULL, do_scan, &sr); } @@ -251,6 +251,8 @@ void scr_aplst_fini(void) { pthread_cancel(scan_thread); - scan_result_fini(&sr); + free_scan_list(sr.head); + free(sr.channel_stats); + delwin(w_aplst); } diff -Nru wavemon-0.8.1/wavemon.h wavemon-0.8.2/wavemon.h --- wavemon-0.8.1/wavemon.h 2016-12-15 19:21:36.000000000 +0000 +++ wavemon-0.8.2/wavemon.h 2018-02-18 00:23:56.000000000 +0000 @@ -51,7 +51,7 @@ WH_IFACE = 2, /* 'Interface' area at the top */ WH_LEVEL = 9, /* Level meters */ WH_STATS = 3, /* WiFi statistics area */ - WH_INFO_MIN = 8, /* WiFi information area */ + WH_INFO_MIN = 7, /* WiFi information area */ WH_NET_MIN = 3, /* Network interface information area */ WH_NET_MAX = 5, /* Network interface information area */ WH_MENU = 1 /* Menu bar at the bottom */