From: sthen Date: Fri, 9 Jan 2015 20:34:21 +0000 (+0000) Subject: Change rssi passed to ifconfig(8) to a signed value to fix printing signal X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=94fee87df0bba1a36f1edeeb2b4fad99dbce2e09;p=openbsd Change rssi passed to ifconfig(8) to a signed value to fix printing signal strengths on 802.11 interfaces. ok stsp@ Power on wireless interfaces is usually scaled in dBm. rssi (received signal strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though not all!) drivers store this as negative values, so it needs to be passed to ifconfig that way for printing, not cast to an unsigned value. Valid range is something like -40 to -90dBm, so the range available with a signed char is reasonable whether it's stored as a +ve or -ve number. --- diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index cc361b96056..755048a83ea 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.293 2015/01/06 21:26:46 stsp Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.294 2015/01/09 20:34:21 sthen Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -2087,7 +2087,7 @@ ieee80211_status(void) if (nr.nr_max_rssi) printf(" %u%%", IEEE80211_NODEREQ_RSSI(&nr)); else - printf(" %udB", nr.nr_rssi); + printf(" %ddBm", nr.nr_rssi); } } @@ -2318,7 +2318,7 @@ ieee80211_printnode(struct ieee80211_nodereq *nr) if (nr->nr_max_rssi) printf("%u%% ", IEEE80211_NODEREQ_RSSI(nr)); else - printf("%udB ", nr->nr_rssi); + printf("%ddBm ", nr->nr_rssi); if (nr->nr_pwrsave) printf("powersave "); diff --git a/sys/net80211/ieee80211_ioctl.h b/sys/net80211/ieee80211_ioctl.h index e408da7c0cc..1779c2455ee 100644 --- a/sys/net80211/ieee80211_ioctl.h +++ b/sys/net80211/ieee80211_ioctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_ioctl.h,v 1.20 2014/08/24 18:01:27 zhuk Exp $ */ +/* $OpenBSD: ieee80211_ioctl.h,v 1.21 2015/01/09 20:34:21 sthen Exp $ */ /* $NetBSD: ieee80211_ioctl.h,v 1.7 2004/04/30 22:51:04 dyoung Exp $ */ /*- @@ -295,8 +295,8 @@ struct ieee80211_nodereq { u_int8_t nr_rates[IEEE80211_RATE_MAXSIZE]; /* rate set */ /* Node status information */ - u_int8_t nr_rssi; /* received signal strength */ - u_int8_t nr_max_rssi; /* maximum rssi */ + int8_t nr_rssi; /* received signal strength */ + int8_t nr_max_rssi; /* maximum rssi */ u_int8_t nr_tstamp[8]; /* from last received beacon */ u_int16_t nr_intval; /* beacon interval */ u_int16_t nr_capinfo; /* capabilities */