[Goodies-commits] r5149 - xfce4-wavelan-plugin/trunk/panel-plugin
Landry Breuil
landry at xfce.org
Mon Jul 21 19:33:56 CEST 2008
Author: landry
Date: 2008-07-21 17:33:56 +0000 (Mon, 21 Jul 2008)
New Revision: 5149
Modified:
xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c
xfce4-wavelan-plugin/trunk/panel-plugin/wi.h
xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c
Log:
- fix quality computation on OpenBSD, best effort atm..
- fix rate computation, txpower has nothing to do with rate.
- no need to include glib.h here
- add #if zero'ed code for debugging purposes in wavelan.c
Modified: xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c
===================================================================
--- xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c 2008-07-21 15:22:02 UTC (rev 5148)
+++ xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c 2008-07-21 17:33:56 UTC (rev 5149)
@@ -716,5 +716,22 @@
}
+#if 0
+int main(int argc, char** argv)
+{
+ struct wi_device *device;
+ struct wi_stats stats;
+ if ((device = wi_open(argv[1])) == NULL)
+ errx(1, "failed to open %s\n", argv[1]);
+
+
+ if (wi_query(device, &stats) != WI_OK)
+ errx(2, "wi_query failed\n");
+
+ printf("NWID:%s, quality:%d%%, rate:%dMb/s\n", stats.ws_netname, stats.ws_quality, stats.ws_rate);
+ wi_close(device);
+ return 0;
+}
+#else
XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(wavelan_construct);
-
+#endif
Modified: xfce4-wavelan-plugin/trunk/panel-plugin/wi.h
===================================================================
--- xfce4-wavelan-plugin/trunk/panel-plugin/wi.h 2008-07-21 15:22:02 UTC (rev 5148)
+++ xfce4-wavelan-plugin/trunk/panel-plugin/wi.h 2008-07-21 17:33:56 UTC (rev 5149)
@@ -27,8 +27,6 @@
#ifndef __WI_H__
#define __WI_H__
-#include <glib.h>
-
#define WI_MAXSTRLEN (512)
struct wi_device;
Modified: xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c
===================================================================
--- xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c 2008-07-21 15:22:02 UTC (rev 5148)
+++ xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c 2008-07-21 17:33:56 UTC (rev 5149)
@@ -238,7 +238,12 @@
if ((result = ioctl(device->socket, SIOCG80211NODE, (caddr_t) & nr)) != WI_OK)
return (result);
- *quality = nr.nr_rssi;
+ /* clearly broken, but stolen from ifconfig.c */
+ if (nr.nr_max_rssi)
+ *quality = IEEE80211_NODEREQ_RSSI(&nr); /* value in percentage */
+ else
+ *quality = nr.nr_rssi; /* value in decibels */
+
return(WI_OK);
}
@@ -246,15 +251,28 @@
_wi_rate(const struct wi_device *device, int *rate)
{
int result;
- struct ieee80211_txpower txpower;
+ struct ieee80211_nodereq nr;
+ struct ieee80211_bssid bssid;
- bzero((void *) &txpower, sizeof(txpower));
- strlcpy(txpower.i_name, device->interface, sizeof(txpower.i_name));
- if ((result = ioctl(device->socket, SIOCG80211TXPOWER, (caddr_t) & txpower)) != WI_OK)
+ bzero((void *) &bssid, sizeof(bssid));
+ bzero((void *) &nr, sizeof(nr));
+ /* get i_bssid from interface */
+ strlcpy(bssid.i_name, device->interface, sizeof(bssid.i_name));
+ if((result = ioctl(device->socket, SIOCG80211BSSID, (caddr_t) &bssid)) != WI_OK)
return (result);
- *rate = txpower.i_val;
+ /* put i_bssid into nr_macaddr to get nr_rssi */
+ bcopy(bssid.i_bssid, &nr.nr_macaddr, sizeof(nr.nr_macaddr));
+ strlcpy(nr.nr_ifname, device->interface, sizeof(nr.nr_ifname));
+ if ((result = ioctl(device->socket, SIOCG80211NODE, (caddr_t) & nr)) != WI_OK)
+ return (result);
+
+ /* stolen from ifconfig.c too, print only higher rate */
+ if (nr.nr_nrates)
+ *rate = (nr.nr_rates[nr.nr_nrates - 1] & IEEE80211_RATE_VAL) / 2;
+ else
+ *rate = 0;
return(WI_OK);
}
#endif
More information about the Goodies-commits
mailing list