net/wavemon: update to version 0.7.2, include some upstream patches
git-svn-id: svn://svn.openwrt.org/openwrt/packages@26500 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
044f2f0f65
commit
0d47242575
@ -8,12 +8,12 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=wavemon
|
PKG_NAME:=wavemon
|
||||||
PKG_VERSION:=0.7.1
|
PKG_VERSION:=0.7.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||||
PKG_SOURCE_URL:=http://eden-feed.erg.abdn.ac.uk/wavemon/stable-releases
|
PKG_SOURCE_URL:=http://eden-feed.erg.abdn.ac.uk/wavemon/stable-releases
|
||||||
PKG_MD5SUM:=bdd9fcaf5dd7c609fea1f401d57cc094
|
PKG_MD5SUM:=0dec700364df7bfb2e066624d0acf7bb
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
32
net/wavemon/patches/000-upstream-config_menu.patch
Normal file
32
net/wavemon/patches/000-upstream-config_menu.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
|
||||||
|
Date: Sat, 12 Mar 2011 19:32:56 +0000 (+0100)
|
||||||
|
Subject: Configuration screen: memorize last active line
|
||||||
|
X-Git-Url: http://eden-feed.erg.abdn.ac.uk/cgi-bin/gitweb.cgi?p=wavemon.git;a=commitdiff_plain;h=094538edab8a590ffb14af2101725563d2453104
|
||||||
|
|
||||||
|
Configuration screen: memorize last active line
|
||||||
|
|
||||||
|
This fixes a bug in the configuration menu - the last active line was not
|
||||||
|
reset properly when switching back from another window. Changed it in such
|
||||||
|
a way that it now memorizes the last active position, which is handy when
|
||||||
|
trying out different values for a given parameter.
|
||||||
|
---
|
||||||
|
|
||||||
|
diff --git a/conf_scr.c b/conf_scr.c
|
||||||
|
index b9aba23..a338771 100644
|
||||||
|
--- a/conf_scr.c
|
||||||
|
+++ b/conf_scr.c
|
||||||
|
@@ -165,9 +165,11 @@ void scr_conf_init(void)
|
||||||
|
w_conf = newwin_title(0, WAV_HEIGHT, "Preferences", false);
|
||||||
|
w_confpad = newpad(num_items + 1, CONF_SCREEN_WIDTH);
|
||||||
|
|
||||||
|
- while ((item = ll_get(conf_items, active_item)) && item->type == t_sep)
|
||||||
|
- active_item++;
|
||||||
|
- first_item = active_item;
|
||||||
|
+ if (first_item) /* already initialized */
|
||||||
|
+ return;
|
||||||
|
+ while ((item = ll_get(conf_items, first_item)) && item->type == t_sep)
|
||||||
|
+ first_item++;
|
||||||
|
+ active_item = first_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
int scr_conf_loop(WINDOW *w_menu)
|
40
net/wavemon/patches/000-upstream-negative.patch
Normal file
40
net/wavemon/patches/000-upstream-negative.patch
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
|
||||||
|
Date: Sat, 12 Mar 2011 19:00:32 +0000 (+0100)
|
||||||
|
Subject: Info screen: fix a bug in the random level code
|
||||||
|
X-Git-Url: http://eden-feed.erg.abdn.ac.uk/cgi-bin/gitweb.cgi?p=wavemon.git;a=commitdiff_plain;h=cc8235c4b4ab30898fd60f3ad71b7899cf1bdd66
|
||||||
|
|
||||||
|
Info screen: fix a bug in the random level code
|
||||||
|
|
||||||
|
The link quality was not converted back correctly, causing negative
|
||||||
|
values, which then overran the maximum value.
|
||||||
|
---
|
||||||
|
|
||||||
|
diff --git a/iw_if.c b/iw_if.c
|
||||||
|
index ae5950a..2008c14 100644
|
||||||
|
--- a/iw_if.c
|
||||||
|
+++ b/iw_if.c
|
||||||
|
@@ -369,7 +369,6 @@ static int rand_wave(float *rlvl, float *step, float *rlvl_next, float range)
|
||||||
|
static void iw_getstat_random(struct iw_stat *iw)
|
||||||
|
{
|
||||||
|
static float rnd_sig, snext, sstep = 1.0, rnd_noise, nnext, nstep = 1.0;
|
||||||
|
- uint8_t smin = dbm_to_u8(conf.sig_min), smax = dbm_to_u8(conf.sig_max);
|
||||||
|
|
||||||
|
rand_wave(&rnd_sig, &sstep, &snext, conf.sig_max - conf.sig_min);
|
||||||
|
rand_wave(&rnd_noise, &nstep, &nnext, conf.noise_max - conf.noise_min);
|
||||||
|
@@ -377,11 +376,12 @@ static void iw_getstat_random(struct iw_stat *iw)
|
||||||
|
if (iw->range.max_qual.qual == 0)
|
||||||
|
iw->range.max_qual.qual = WAVE_RAND_QUAL_MAX;
|
||||||
|
|
||||||
|
- iw->stat.qual.level = smin + rnd_sig;
|
||||||
|
- iw->stat.qual.noise = dbm_to_u8(conf.noise_min) + rnd_noise;
|
||||||
|
- iw->stat.qual.qual = map_range(iw->stat.qual.level, smin, smax,
|
||||||
|
- 0, iw->range.max_qual.qual);
|
||||||
|
+ iw->stat.qual.level = dbm_to_u8(conf.sig_min + rnd_sig);
|
||||||
|
+ iw->stat.qual.noise = dbm_to_u8(conf.noise_min + rnd_noise);
|
||||||
|
iw->stat.qual.updated = IW_QUAL_DBM;
|
||||||
|
+ iw->stat.qual.qual = map_range(conf.sig_min + rnd_sig,
|
||||||
|
+ conf.sig_min, conf.sig_max,
|
||||||
|
+ 0, iw->range.max_qual.qual);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void iw_getstat_real(struct iw_statistics *stat)
|
90
net/wavemon/patches/000-upstream-terminate.patch
Normal file
90
net/wavemon/patches/000-upstream-terminate.patch
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
|
||||||
|
Date: Sun, 27 Feb 2011 20:41:48 +0000 (+0100)
|
||||||
|
Subject: Better termination
|
||||||
|
X-Git-Url: http://eden-feed.erg.abdn.ac.uk/cgi-bin/gitweb.cgi?p=wavemon.git;a=commitdiff_plain;h=633c66a214c68af9a54d123307dc1e1209240472
|
||||||
|
|
||||||
|
Better termination
|
||||||
|
|
||||||
|
This fixes two flaws in the attempt to terminate the other wavemon processes
|
||||||
|
on error: (i) it was not ensured that wavemon runs in its own process group;
|
||||||
|
(ii) sending the signal to self is ugly.
|
||||||
|
---
|
||||||
|
|
||||||
|
diff --git a/error.c b/error.c
|
||||||
|
index 592d3e4..5408c07 100644
|
||||||
|
--- a/error.c
|
||||||
|
+++ b/error.c
|
||||||
|
@@ -59,6 +59,34 @@ void err_msg(const char *format, ...)
|
||||||
|
sleep(WARN_DISPLAY_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * terminate_all_processes - terminate wavemon and reset screen
|
||||||
|
+ * @fmt: printf-like format string
|
||||||
|
+ * @strerr: set to non-0 if termination is due to failed system call
|
||||||
|
+ * @ap: argument list for @fmt
|
||||||
|
+ */
|
||||||
|
+static void terminate_all_processes(const char *fmt, int strerr, va_list ap)
|
||||||
|
+{
|
||||||
|
+ int saved_errno = strerr ? errno : 0;
|
||||||
|
+ /*
|
||||||
|
+ * wavemon runs in its own process group. Block TERM in this process,
|
||||||
|
+ * but send to all others (parent or child), which by default do not
|
||||||
|
+ * block TERM.
|
||||||
|
+ */
|
||||||
|
+ xsignal(SIGTERM, SIG_IGN);
|
||||||
|
+ endwin();
|
||||||
|
+ kill(0, SIGTERM);
|
||||||
|
+ reset_shell_mode();
|
||||||
|
+ if (saved_errno) {
|
||||||
|
+ errno = saved_errno;
|
||||||
|
+ vwarn(fmt, ap);
|
||||||
|
+ } else {
|
||||||
|
+ vwarnx(fmt, ap);
|
||||||
|
+ }
|
||||||
|
+ va_end(ap);
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Abort on fatal error unrelated to system call.
|
||||||
|
*/
|
||||||
|
@@ -66,13 +94,8 @@ void err_quit(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list argp;
|
||||||
|
|
||||||
|
- endwin();
|
||||||
|
-
|
||||||
|
va_start(argp, format);
|
||||||
|
- vwarnx(format, argp);
|
||||||
|
- va_end(argp);
|
||||||
|
- /* Exit via kill to terminate any child processes. */
|
||||||
|
- kill(0, SIGTERM);
|
||||||
|
+ terminate_all_processes(format, false, argp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -82,10 +105,6 @@ void err_sys(const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list argp;
|
||||||
|
|
||||||
|
- endwin();
|
||||||
|
-
|
||||||
|
va_start(argp, format);
|
||||||
|
- vwarn(format, argp);
|
||||||
|
- va_end(argp);
|
||||||
|
- kill(0, SIGTERM);
|
||||||
|
+ terminate_all_processes(format, true, argp);
|
||||||
|
}
|
||||||
|
diff --git a/wavemon.c b/wavemon.c
|
||||||
|
index 6c3196e..4e1f492 100644
|
||||||
|
--- a/wavemon.c
|
||||||
|
+++ b/wavemon.c
|
||||||
|
@@ -139,6 +139,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
|
if (!isatty(STDIN_FILENO))
|
||||||
|
errx(1, "input is not from a terminal");
|
||||||
|
+ setpgid(0, 0);
|
||||||
|
|
||||||
|
/* honour numeric separators if the environment defines them */
|
||||||
|
setlocale(LC_NUMERIC, "");
|
397
net/wavemon/patches/000-upstream-wrapper.patch
Normal file
397
net/wavemon/patches/000-upstream-wrapper.patch
Normal file
@ -0,0 +1,397 @@
|
|||||||
|
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
|
||||||
|
Date: Sun, 13 Mar 2011 17:39:40 +0000 (+0100)
|
||||||
|
Subject: Configuration: decouple configuration items
|
||||||
|
X-Git-Url: http://eden-feed.erg.abdn.ac.uk/cgi-bin/gitweb.cgi?p=wavemon.git;a=commitdiff_plain;h=74610068abe331927f72aa617689566a2b2a7771
|
||||||
|
|
||||||
|
Configuration: decouple configuration items
|
||||||
|
|
||||||
|
This puts access to WiFi interface list and currently selected interface
|
||||||
|
into wrapper functions, to better separate the code blocks.
|
||||||
|
---
|
||||||
|
|
||||||
|
diff --git a/conf.c b/conf.c
|
||||||
|
index 4004c73..45fa42e 100644
|
||||||
|
--- a/conf.c
|
||||||
|
+++ b/conf.c
|
||||||
|
@@ -22,6 +22,7 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* GLOBALS */
|
||||||
|
+static char **if_list; /* array of WiFi interface names */
|
||||||
|
int conf_items; /* index into array storing menu items */
|
||||||
|
|
||||||
|
static char *on_off_names[] = { [false] = "Off", [true] = "On", NULL };
|
||||||
|
@@ -116,6 +117,39 @@ static void getargs(int argc, char *argv[])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/** Populate interface list */
|
||||||
|
+void conf_get_interface_list(void)
|
||||||
|
+{
|
||||||
|
+ char *old_if = NULL;
|
||||||
|
+ int idx;
|
||||||
|
+
|
||||||
|
+ if (if_list) {
|
||||||
|
+ for (idx = 0; if_list[idx]; idx++)
|
||||||
|
+ if (idx == conf.if_idx)
|
||||||
|
+ old_if = if_list[idx];
|
||||||
|
+ else
|
||||||
|
+ free(if_list[idx]);
|
||||||
|
+ free(if_list);
|
||||||
|
+ }
|
||||||
|
+ if_list = iw_get_interface_list();
|
||||||
|
+ if (if_list == NULL)
|
||||||
|
+ err_quit("no wireless interfaces found!");
|
||||||
|
+
|
||||||
|
+ conf.if_idx = 0;
|
||||||
|
+ if (old_if) {
|
||||||
|
+ idx = argv_find(if_list, old_if);
|
||||||
|
+ if (idx > 0)
|
||||||
|
+ conf.if_idx = idx;
|
||||||
|
+ free(old_if);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/** Return currently selected interface name */
|
||||||
|
+const char *conf_ifname(void)
|
||||||
|
+{
|
||||||
|
+ return if_list ? if_list[conf.if_idx] : "(none)";
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* Return full path of rcfile. Allocates string which must bee free()-d. */
|
||||||
|
static char *get_confname(void)
|
||||||
|
{
|
||||||
|
@@ -520,7 +554,7 @@ static void init_conf_items(void)
|
||||||
|
|
||||||
|
void getconf(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
- iw_get_interface_list();
|
||||||
|
+ conf_get_interface_list();
|
||||||
|
init_conf_items();
|
||||||
|
read_cf();
|
||||||
|
getargs(argc, argv);
|
||||||
|
diff --git a/conf_scr.c b/conf_scr.c
|
||||||
|
index a338771..674137c 100644
|
||||||
|
--- a/conf_scr.c
|
||||||
|
+++ b/conf_scr.c
|
||||||
|
@@ -159,7 +159,7 @@ static int m_pref(WINDOW *w_conf, int list_offset, int active_item, int num_item
|
||||||
|
|
||||||
|
void scr_conf_init(void)
|
||||||
|
{
|
||||||
|
- iw_get_interface_list(); /* may have changed in the meantime */
|
||||||
|
+ conf_get_interface_list(); /* may have changed in the meantime */
|
||||||
|
|
||||||
|
num_items = ll_size(conf_items);
|
||||||
|
w_conf = newwin_title(0, WAV_HEIGHT, "Preferences", false);
|
||||||
|
diff --git a/info_scr.c b/info_scr.c
|
||||||
|
index 8171373..d17fdfa 100644
|
||||||
|
--- a/info_scr.c
|
||||||
|
+++ b/info_scr.c
|
||||||
|
@@ -30,7 +30,7 @@ void sampling_init(void (*sampling_handler)(int))
|
||||||
|
div_t d = div(conf.stat_iv, 1000); /* conf.stat_iv in msec */
|
||||||
|
|
||||||
|
xsignal(SIGALRM, SIG_IGN);
|
||||||
|
- iw_getinf_range(if_list[conf.if_idx], &cur.range);
|
||||||
|
+ iw_getinf_range(conf_ifname(), &cur.range);
|
||||||
|
i.it_interval.tv_sec = i.it_value.tv_sec = d.quot;
|
||||||
|
i.it_interval.tv_usec = i.it_value.tv_usec = d.rem * 1000;
|
||||||
|
xsignal(SIGALRM, sampling_handler);
|
||||||
|
@@ -139,7 +139,7 @@ static void display_stats(void)
|
||||||
|
struct if_stat nstat;
|
||||||
|
char tmp[0x100];
|
||||||
|
|
||||||
|
- if_getstat(if_list[conf.if_idx], &nstat);
|
||||||
|
+ if_getstat(conf_ifname(), &nstat);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Interface RX stats
|
||||||
|
@@ -197,10 +197,10 @@ static void display_info(WINDOW *w_if, WINDOW *w_info)
|
||||||
|
char tmp[0x100];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- dyn_info_get(&info, if_list[conf.if_idx], &cur.range);
|
||||||
|
+ dyn_info_get(&info, conf_ifname(), &cur.range);
|
||||||
|
|
||||||
|
wmove(w_if, 1, 1);
|
||||||
|
- waddstr_b(w_if, if_list[conf.if_idx]);
|
||||||
|
+ waddstr_b(w_if, conf_ifname());
|
||||||
|
if (cur.range.enc_capa & IW_WPA_MASK)
|
||||||
|
sprintf(tmp, " (%s, %s)", info.name, format_wpa(&cur.range));
|
||||||
|
else
|
||||||
|
@@ -416,11 +416,11 @@ static void display_netinfo(WINDOW *w_net)
|
||||||
|
struct if_info info;
|
||||||
|
char tmp[0x40];
|
||||||
|
|
||||||
|
- if_getinf(if_list[conf.if_idx], &info);
|
||||||
|
+ if_getinf(conf_ifname(), &info);
|
||||||
|
|
||||||
|
wmove(w_net, 1, 1);
|
||||||
|
if (getmaxy(w_net) == WH_NET_MAX) {
|
||||||
|
- waddstr(w_net, if_list[conf.if_idx]);
|
||||||
|
+ waddstr(w_net, conf_ifname());
|
||||||
|
|
||||||
|
waddstr_b(w_net, " (");
|
||||||
|
waddstr(w_net, info.flags & IFF_UP ? "UP" : "DOWN");
|
||||||
|
diff --git a/iw_if.c b/iw_if.c
|
||||||
|
index 2008c14..708ff85 100644
|
||||||
|
--- a/iw_if.c
|
||||||
|
+++ b/iw_if.c
|
||||||
|
@@ -24,9 +24,6 @@
|
||||||
|
/* Fallback maximum quality level when using random samples. */
|
||||||
|
#define WAVE_RAND_QUAL_MAX 100
|
||||||
|
|
||||||
|
-/* GLOBALS */
|
||||||
|
-char **if_list = NULL; /* array of WiFi interface names */
|
||||||
|
-
|
||||||
|
/*
|
||||||
|
* Obtain network device information
|
||||||
|
*/
|
||||||
|
@@ -65,7 +62,7 @@ int if_set_up(int skfd, const char *ifname)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Interface information */
|
||||||
|
-void if_getinf(char *ifname, struct if_info *info)
|
||||||
|
+void if_getinf(const char *ifname, struct if_info *info)
|
||||||
|
{
|
||||||
|
struct ifreq ifr;
|
||||||
|
int skfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
@@ -114,49 +111,27 @@ static FILE *open_proc_net(const char *filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
- * iw_get_interface_list - Populate NULL-terminated array of WiFi interfaces.
|
||||||
|
- * Rebuild if already set, exit if no interfaces present.
|
||||||
|
+ * iw_get_interface_list - Return NULL-terminated array of WiFi interfaces.
|
||||||
|
*/
|
||||||
|
-void iw_get_interface_list(void)
|
||||||
|
+char **iw_get_interface_list(void)
|
||||||
|
{
|
||||||
|
- char *p, tmp[IFNAMSIZ], *old_if = NULL;
|
||||||
|
- int idx, nifs;
|
||||||
|
+ char **if_list = NULL, *p, tmp[BUFSIZ];
|
||||||
|
+ int nifs = 1; /* if_list[nifs-1] = NULL */
|
||||||
|
FILE *fp = open_proc_net("wireless");
|
||||||
|
|
||||||
|
- if (if_list) {
|
||||||
|
- for (idx = 0; if_list[idx]; idx++)
|
||||||
|
- if (idx == conf.if_idx)
|
||||||
|
- old_if = if_list[idx];
|
||||||
|
- else
|
||||||
|
- free(if_list[idx]);
|
||||||
|
- free(if_list);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- for (nifs = 0; fgets(tmp, sizeof(tmp), fp); )
|
||||||
|
- nifs += strchr(tmp, ':') != NULL;
|
||||||
|
- if (!nifs)
|
||||||
|
- err_quit("no wireless interfaces found!");
|
||||||
|
- rewind(fp);
|
||||||
|
-
|
||||||
|
- if_list = calloc(nifs + 1, sizeof(*if_list));
|
||||||
|
- if (if_list == NULL)
|
||||||
|
- err_sys("unable to memorize %d interfaces", nifs);
|
||||||
|
-
|
||||||
|
- for (conf.if_idx = idx = 0; fgets(tmp, sizeof(tmp), fp); ) {
|
||||||
|
+ while (fgets(tmp, sizeof(tmp), fp))
|
||||||
|
if ((p = strchr(tmp, ':'))) {
|
||||||
|
+ if_list = realloc(if_list, sizeof(char *) * (nifs + 1));
|
||||||
|
for (*p = '\0', p = tmp; isspace(*p); )
|
||||||
|
p++;
|
||||||
|
- if (old_if && strcmp(old_if, p) == 0)
|
||||||
|
- conf.if_idx = idx;
|
||||||
|
- if_list[idx++] = strdup(p);
|
||||||
|
+ if_list[nifs-1] = strdup(p);
|
||||||
|
+ if_list[nifs++] = NULL;
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
- assert(idx == nifs);
|
||||||
|
fclose(fp);
|
||||||
|
- free(old_if);
|
||||||
|
+ return if_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
-void if_getstat(char *ifname, struct if_stat *stat)
|
||||||
|
+void if_getstat(const char *ifname, struct if_stat *stat)
|
||||||
|
{
|
||||||
|
char line[0x100];
|
||||||
|
unsigned long d;
|
||||||
|
@@ -187,7 +162,8 @@ void if_getstat(char *ifname, struct if_stat *stat)
|
||||||
|
* @ifname: interface name
|
||||||
|
* @if: range information to use (number of encryption keys)
|
||||||
|
*/
|
||||||
|
-void dyn_info_get(struct iw_dyn_info *info, char *ifname, struct iw_range *ir)
|
||||||
|
+void dyn_info_get(struct iw_dyn_info *info,
|
||||||
|
+ const char *ifname, struct iw_range *ir)
|
||||||
|
{
|
||||||
|
struct iwreq iwr;
|
||||||
|
int i, skfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
@@ -321,7 +297,7 @@ void dyn_info_cleanup(struct iw_dyn_info *info)
|
||||||
|
/*
|
||||||
|
* get range information
|
||||||
|
*/
|
||||||
|
-void iw_getinf_range(char *ifname, struct iw_range *range)
|
||||||
|
+void iw_getinf_range(const char *ifname, struct iw_range *range)
|
||||||
|
{
|
||||||
|
struct iwreq iwr;
|
||||||
|
int skfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
@@ -395,7 +371,7 @@ static void iw_getstat_real(struct iw_statistics *stat)
|
||||||
|
wrq.u.data.pointer = (caddr_t) stat;
|
||||||
|
wrq.u.data.length = sizeof(*stat);
|
||||||
|
wrq.u.data.flags = 0;
|
||||||
|
- strncpy(wrq.ifr_name, if_list[conf.if_idx], IFNAMSIZ);
|
||||||
|
+ strncpy(wrq.ifr_name, conf_ifname(), IFNAMSIZ);
|
||||||
|
|
||||||
|
if (ioctl(skfd, SIOCGIWSTATS, &wrq) < 0) {
|
||||||
|
/*
|
||||||
|
@@ -490,13 +466,13 @@ void dump_parameters(void)
|
||||||
|
struct if_stat nstat;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- iw_getinf_range(if_list[conf.if_idx], &iw.range);
|
||||||
|
- dyn_info_get(&info, if_list[conf.if_idx], &iw.range);
|
||||||
|
+ iw_getinf_range(conf_ifname(), &iw.range);
|
||||||
|
+ dyn_info_get(&info, conf_ifname(), &iw.range);
|
||||||
|
iw_getstat(&iw);
|
||||||
|
- if_getstat(if_list[conf.if_idx], &nstat);
|
||||||
|
+ if_getstat(conf_ifname(), &nstat);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
- printf("Configured device: %s (%s)\n", if_list[conf.if_idx], info.name);
|
||||||
|
+ printf("Configured device: %s (%s)\n", conf_ifname(), info.name);
|
||||||
|
printf(" Security: %s\n", iw.range.enc_capa ?
|
||||||
|
format_enc_capab(iw.range.enc_capa, ", ") : "WEP");
|
||||||
|
if (iw.range.num_encoding_sizes &&
|
||||||
|
diff --git a/iw_if.h b/iw_if.h
|
||||||
|
index 80e6595..636a63a 100644
|
||||||
|
--- a/iw_if.h
|
||||||
|
+++ b/iw_if.h
|
||||||
|
@@ -71,7 +71,7 @@ struct if_info {
|
||||||
|
};
|
||||||
|
extern bool if_is_up(int skfd, const char *ifname);
|
||||||
|
extern int if_set_up(int skfd, const char *ifname);
|
||||||
|
-extern void if_getinf(char *ifname, struct if_info *info);
|
||||||
|
+extern void if_getinf(const char *ifname, struct if_info *info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct iw_key - Encoding information
|
||||||
|
@@ -174,7 +174,8 @@ static inline uint8_t dyn_info_wep_keys(struct iw_dyn_info *info)
|
||||||
|
info->keys[i].size == 13;
|
||||||
|
return num_wep;
|
||||||
|
}
|
||||||
|
-extern void dyn_info_get(struct iw_dyn_info *, char *ifname, struct iw_range *);
|
||||||
|
+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);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -188,7 +189,7 @@ struct if_stat {
|
||||||
|
tx_bytes;
|
||||||
|
};
|
||||||
|
|
||||||
|
-extern void if_getstat(char *ifname, struct if_stat *stat);
|
||||||
|
+extern void if_getstat(const char *ifname, struct if_stat *stat);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structs to communicate WiFi statistics
|
||||||
|
@@ -200,7 +201,7 @@ struct iw_levelstat {
|
||||||
|
};
|
||||||
|
#define IW_LSTAT_INIT { 0, 0, IW_QUAL_LEVEL_INVALID | IW_QUAL_NOISE_INVALID }
|
||||||
|
|
||||||
|
-extern void iw_getinf_range(char *ifname, struct iw_range *range);
|
||||||
|
+extern void iw_getinf_range(const char *ifname, struct iw_range *range);
|
||||||
|
extern void iw_sanitize(struct iw_range *range,
|
||||||
|
struct iw_quality *qual,
|
||||||
|
struct iw_levelstat *dbm);
|
||||||
|
@@ -250,7 +251,7 @@ struct scan_result {
|
||||||
|
|
||||||
|
struct scan_result *next;
|
||||||
|
};
|
||||||
|
-extern struct scan_result *get_scan_list(int skfd, char *ifname, int weversion);
|
||||||
|
+extern struct scan_result *get_scan_list(int skfd, const char *ifname, int ver);
|
||||||
|
extern void free_scan_result(struct scan_result *head);
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/iw_scan.c b/iw_scan.c
|
||||||
|
index d75ab6b..8423e6a 100644
|
||||||
|
--- a/iw_scan.c
|
||||||
|
+++ b/iw_scan.c
|
||||||
|
@@ -553,7 +553,7 @@ static int cmp_scan_sig(struct scan_result *a, struct scan_result *b)
|
||||||
|
return a->qual.level - b->qual.level;
|
||||||
|
}
|
||||||
|
|
||||||
|
-struct scan_result *get_scan_list(int skfd, char *ifname, int we_version)
|
||||||
|
+struct scan_result *get_scan_list(int skfd, const char *ifname, int we_version)
|
||||||
|
{
|
||||||
|
struct scan_result *head = NULL;
|
||||||
|
struct iwreq wrq;
|
||||||
|
diff --git a/scan_scr.c b/scan_scr.c
|
||||||
|
index 879c2f6..b9a4eee 100644
|
||||||
|
--- a/scan_scr.c
|
||||||
|
+++ b/scan_scr.c
|
||||||
|
@@ -80,9 +80,9 @@ static void display_aplist(WINDOW *w_aplst)
|
||||||
|
if (skfd < 0)
|
||||||
|
err_sys("%s: can not open socket", __func__);
|
||||||
|
|
||||||
|
- iw_getinf_range(if_list[conf.if_idx], &range);
|
||||||
|
+ iw_getinf_range(conf_ifname(), &range);
|
||||||
|
|
||||||
|
- head = get_scan_list(skfd, if_list[conf.if_idx], range.we_version_compiled);
|
||||||
|
+ head = get_scan_list(skfd, conf_ifname(), range.we_version_compiled);
|
||||||
|
if (head) {
|
||||||
|
;
|
||||||
|
} else if (errno == EPERM || !has_net_admin_capability()) {
|
||||||
|
@@ -93,13 +93,13 @@ static void display_aplist(WINDOW *w_aplst)
|
||||||
|
} else if (errno == EINTR || errno == EAGAIN || errno == EBUSY) {
|
||||||
|
/* Ignore temporary errors */
|
||||||
|
goto done;
|
||||||
|
- } else if (!if_is_up(skfd, if_list[conf.if_idx])) {
|
||||||
|
- sprintf(s, "Interface '%s' is down ", if_list[conf.if_idx]);
|
||||||
|
+ } else if (!if_is_up(skfd, conf_ifname())) {
|
||||||
|
+ sprintf(s, "Interface '%s' is down ", conf_ifname());
|
||||||
|
if (!has_net_admin_capability())
|
||||||
|
strcat(s, "- can not scan");
|
||||||
|
- else if (if_set_up(skfd, if_list[conf.if_idx]) < 0)
|
||||||
|
+ else if (if_set_up(skfd, conf_ifname()) < 0)
|
||||||
|
sprintf(s, "Can not bring up '%s' for scanning: %s",
|
||||||
|
- if_list[conf.if_idx], strerror(errno));
|
||||||
|
+ conf_ifname(), strerror(errno));
|
||||||
|
else
|
||||||
|
strcat(s, "- setting it up ...");
|
||||||
|
} else if (errno == EFAULT) {
|
||||||
|
@@ -110,9 +110,9 @@ static void display_aplist(WINDOW *w_aplst)
|
||||||
|
*/
|
||||||
|
goto done;
|
||||||
|
} else if (errno) {
|
||||||
|
- sprintf(s, "No scan on %s: %s", if_list[conf.if_idx], strerror(errno));
|
||||||
|
+ sprintf(s, "No scan on %s: %s", conf_ifname(), strerror(errno));
|
||||||
|
} else {
|
||||||
|
- sprintf(s, "No scan results on %s", if_list[conf.if_idx]);
|
||||||
|
+ sprintf(s, "No scan results on %s", conf_ifname());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 1; i <= MAXYLEN; i++)
|
||||||
|
diff --git a/wavemon.h b/wavemon.h
|
||||||
|
index 22a783f..ad0b488 100644
|
||||||
|
--- a/wavemon.h
|
||||||
|
+++ b/wavemon.h
|
||||||
|
@@ -103,7 +103,7 @@ static inline void threshold_action(enum threshold_action action)
|
||||||
|
* Global in-memory representation of current wavemon configuration state
|
||||||
|
*/
|
||||||
|
extern struct wavemon_conf {
|
||||||
|
- int if_idx; /* Index into if_list */
|
||||||
|
+ int if_idx; /* Index into interface list */
|
||||||
|
|
||||||
|
int stat_iv,
|
||||||
|
info_iv;
|
||||||
|
@@ -256,8 +256,9 @@ static inline int cp_from_scale(float value, const char *cscale, bool reverse)
|
||||||
|
/*
|
||||||
|
* Wireless interfaces
|
||||||
|
*/
|
||||||
|
-extern char **if_list;
|
||||||
|
-extern void iw_get_interface_list(void);
|
||||||
|
+extern const char *conf_ifname(void);
|
||||||
|
+extern void conf_get_interface_list(void);
|
||||||
|
+extern char **iw_get_interface_list(void);
|
||||||
|
extern void dump_parameters(void);
|
||||||
|
|
||||||
|
/*
|
Loading…
x
Reference in New Issue
Block a user