From owner-svn-ports-head@freebsd.org Fri Aug 28 21:07:40 2015 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70F8D9C4DF1; Fri, 28 Aug 2015 21:07:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 61969AC; Fri, 28 Aug 2015 21:07:40 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7SL7e4g079111; Fri, 28 Aug 2015 21:07:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7SL7d4F079108; Fri, 28 Aug 2015 21:07:39 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201508282107.t7SL7d4F079108@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 28 Aug 2015 21:07:39 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r395523 - in head/x11/i3status: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2015 21:07:40 -0000 Author: jhb (src,doc committer) Date: Fri Aug 28 21:07:39 2015 New Revision: 395523 URL: https://svnweb.freebsd.org/changeset/ports/395523 Log: Fix multiple issues with the wireless information reported by i3status for an interface: - Instead of hoping that the currently associated AP will show up as the first AP in the list of scan results, fetch the BSSID of the currently associated AP and use that to fetch station info for the AP. This provides more frequently updated signal strength information than scan results and reliably provides information when multiple APs are in range. - Do not treat the RSSI value as a raw signal value in dBm. Instead, use the same formula as ifconfig(8) to compute a signal value. - Do not report the beacon interval value as a signal quality level. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D3369 Added: head/x11/i3status/files/patch-print_wireless_info.c (contents, props changed) Modified: head/x11/i3status/Makefile Modified: head/x11/i3status/Makefile ============================================================================== --- head/x11/i3status/Makefile Fri Aug 28 19:50:38 2015 (r395522) +++ head/x11/i3status/Makefile Fri Aug 28 21:07:39 2015 (r395523) @@ -2,7 +2,7 @@ PORTNAME= i3status PORTVERSION= 2.8 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= x11 MASTER_SITES= http://i3wm.org/i3status/ Added: head/x11/i3status/files/patch-print_wireless_info.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/x11/i3status/files/patch-print_wireless_info.c Fri Aug 28 21:07:39 2015 (r395523) @@ -0,0 +1,75 @@ +--- src/print_wireless_info.c.orig 2014-01-05 03:34:06.000000000 -0800 ++++ src/print_wireless_info.c 2015-08-13 20:12:29.854380000 -0700 +@@ -193,10 +193,14 @@ static int get_wireless_info(const char + return 1; + #endif + #if defined(__FreeBSD__) || defined(__DragonFly__) +- int s, len, inwid; +- uint8_t buf[24 * 1024], *cp; ++ int s, inwid; ++ union { ++ struct ieee80211req_sta_req req; ++ uint8_t buf[24 * 1024]; ++ } u; + struct ieee80211req na; +- char network_id[IEEE80211_NWID_LEN + 1]; ++ char bssid[IEEE80211_ADDR_LEN]; ++ size_t len; + + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) + return (0); +@@ -224,31 +228,38 @@ static int get_wireless_info(const char + + memset(&na, 0, sizeof(na)); + strlcpy(na.i_name, interface, sizeof(na.i_name)); +- na.i_type = IEEE80211_IOC_SCAN_RESULTS; +- na.i_data = buf; +- na.i_len = sizeof(buf); ++ na.i_type = IEEE80211_IOC_BSSID; ++ na.i_data = bssid; ++ na.i_len = sizeof(bssid); ++ ++ if (ioctl(s, SIOCG80211, (caddr_t)&na) == -1) { ++ close(s); ++ return (0); ++ } ++ ++ memcpy(u.req.is_u.macaddr, bssid, sizeof(bssid)); ++ memset(&na, 0, sizeof(na)); ++ strlcpy(na.i_name, interface, sizeof(na.i_name)); ++ na.i_type = IEEE80211_IOC_STA_INFO; ++ na.i_data = &u; ++ na.i_len = sizeof(u); + + if (ioctl(s, SIOCG80211, (caddr_t)&na) == -1) { +- printf("fail\n"); + close(s); + return (0); + } + + close(s); +- len = na.i_len; +- cp = buf; +- struct ieee80211req_scan_result *sr; +- uint8_t *vp; +- sr = (struct ieee80211req_scan_result *)cp; +- vp = (u_int8_t *)(sr + 1); +- strlcpy(network_id, (const char *)vp, sr->isr_ssid_len + 1); +- if (!strcmp(network_id, &info->essid[0])) { +- info->signal_level = sr->isr_rssi; ++ if (na.i_len >= sizeof(u.req)) { ++ /* ++ * Just use the first BSSID returned even if there are ++ * multiple APs sharing the same BSSID. ++ */ ++ info->signal_level = u.req.info[0].isi_rssi / 2 + ++ u.req.info[0].isi_noise; + info->flags |= WIRELESS_INFO_FLAG_HAS_SIGNAL; +- info->noise_level = sr->isr_noise; ++ info->noise_level = u.req.info[0].isi_noise; + info->flags |= WIRELESS_INFO_FLAG_HAS_NOISE; +- info->quality = sr->isr_intval; +- info->flags |= WIRELESS_INFO_FLAG_HAS_QUALITY; + } + + return 1;