[Goodies-commits] r5142 - xfce4-wavelan-plugin/trunk/panel-plugin

Landry Breuil landry at xfce.org
Sat Jul 19 23:31:19 CEST 2008


Author: landry
Date: 2008-07-19 21:31:19 +0000 (Sat, 19 Jul 2008)
New Revision: 5142

Modified:
   xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c
Log:
Fix support for OpenBSD, using net80211 API instead of deprecated wi_*.
No change for NetBSD and FreeBSD.


Modified: xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c
===================================================================
--- xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c	2008-07-18 20:02:40 UTC (rev 5141)
+++ xfce4-wavelan-plugin/trunk/panel-plugin/wi_bsd.c	2008-07-19 21:31:19 UTC (rev 5142)
@@ -56,9 +56,9 @@
 #endif
 #endif
 #ifdef __OpenBSD__
-#include <net/if_ieee80211.h>
 #include <dev/ic/if_wi_ieee.h>
-#define le16toh(x) letoh16(x)
+#include <net80211/ieee80211.h>
+#include <net80211/ieee80211_ioctl.h>
 #endif
 #endif
 
@@ -95,8 +95,10 @@
 };
 
 static int _wi_carrier(const struct wi_device *);
+#if defined(__NetBSD__) || defined(__FreeBSD__)
 static int _wi_getval(const struct wi_device *, struct wi_req *);
 static int _wi_vendor(const struct wi_device *, char *, size_t);
+#endif
 static int _wi_netname(const struct wi_device *, char *, size_t);
 static int _wi_quality(const struct wi_device *, int *);
 static int _wi_rate(const struct wi_device *, int *);
@@ -141,8 +143,10 @@
   bzero((void *)stats, sizeof(*stats));
 
   /* check vendor (independent of carrier state) */
+#if !defined(__OpenBSD__)
   if ((result = _wi_vendor(device, stats->ws_vendor, WI_MAXSTRLEN)) != WI_OK)
     return(result);
+#endif
 
   /* check carrier */
   if ((result = _wi_carrier(device)) != WI_OK)
@@ -193,7 +197,71 @@
 	return((ifmr.ifm_status & IFM_ACTIVE) != 0 ? WI_OK : WI_NOCARRIER);
 }
 
+/* OpenBSD uses net80211 API */
+#if defined(__OpenBSD__)
 static int
+_wi_netname(const struct wi_device *device, char *buffer, size_t len)
+{
+  int result;
+  struct ifreq ifr;
+  struct ieee80211_nwid nwid;
+
+  bzero((void *) &ifr, sizeof(ifr));
+  ifr.ifr_data = (caddr_t) & nwid;
+  strlcpy(ifr.ifr_name, device->interface, sizeof(ifr.ifr_name));
+  if ((result = ioctl(device->socket, SIOCG80211NWID, (caddr_t) & ifr)) != WI_OK)
+    return (result);
+
+  strlcpy(buffer, (char *) nwid.i_nwid, MIN(len, strlen(nwid.i_nwid) + 1));
+
+  return(WI_OK);
+}
+
+static int
+_wi_quality(const struct wi_device *device, int *quality)
+{
+  int result;
+  struct ieee80211_nodereq nr;
+  struct ieee80211_bssid bssid;
+
+  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);
+
+  /* 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);
+
+  *quality = nr.nr_rssi;
+  return(WI_OK);
+}
+
+static int
+_wi_rate(const struct wi_device *device, int *rate)
+{
+  int result;
+  struct ieee80211_txpower txpower;
+
+  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)
+
+    return (result);
+
+  *rate = txpower.i_val;
+  return(WI_OK);
+}
+#endif
+
+/* NetBSD and FreeBSD use old wi_* API */
+#if defined(__NetBSD__) || defined(__FreeBSD__)
+static int
 _wi_getval(const struct wi_device *device, struct wi_req *wr)
 {
   struct ifreq ifr;
@@ -311,5 +379,5 @@
   return(WI_OK);
 }
 
-#endif  /* !defined(__NetBSD__) && !defined(__FreeBSD__) */
-
+#endif  /* defined(__NetBSD__) || defined(__FreeBSD__) */
+#endif




More information about the Goodies-commits mailing list