ports/120104: [patch] sysutils/xfce4-wlan-plugin unbreak fix with >= 700042 (new wlan API)
Pietro Cerutti
gahr at gahr.ch
Mon Jan 28 22:40:01 UTC 2008
>Number: 120104
>Category: ports
>Synopsis: [patch] sysutils/xfce4-wlan-plugin unbreak fix with >= 700042 (new wlan API)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Mon Jan 28 22:40:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Pietro Cerutti
>Release: FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 8.0-CURRENT #0: Mon Jan 28 21:02:13 CET 2008
root at gahrtop.localhost:/usr/obj/usr/src/sys/MSI1034
>Description:
The patch below:
- fixes the build on FreeBSD >= 700042 by accounting for the new wireless API
- adds information about network card and datarate to the tooltip (why was the information missing?!?)
>How-To-Repeat:
>Fix:
--- _xfce4-wavelan-plugin.diff begins here ---
--- Makefile.orig 2008-01-28 23:00:48.000000000 +0100
+++ Makefile 2008-01-28 23:00:57.000000000 +0100
@@ -7,7 +7,7 @@
PORTNAME= xfce4-wavelan-plugin
PORTVERSION= 0.5.4
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= sysutils xfce
MASTER_SITES= http://goodies.xfce.org/releases/${PORTNAME}/
DIST_SUBDIR= xfce4
@@ -22,10 +22,4 @@
USE_XFCE= configenv panel
USE_XLIB= yes
-.include <bsd.port.pre.mk>
-
-.if ${OSVERSION} >= 700042
-BROKEN= Does not work with the new wlan stack on 7.0
-.endif
-
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
--- /dev/null 2008-01-28 23:23:41.000000000 +0100
+++ files/patch-panel-plugin_wavelan.c 2008-01-28 23:16:52.000000000 +0100
@@ -0,0 +1,14 @@
+--- panel-plugin/wavelan.c.orig 2007-01-10 21:23:05.000000000 +0100
++++ panel-plugin/wavelan.c 2008-01-28 23:16:14.000000000 +0100
+@@ -219,9 +219,9 @@
+ wavelan_set_state(wavelan, STATE_LINK0);
+
+ if (strlen(stats.ws_netname) > 0)
+- tip = g_strdup_printf("%d%% (%s)", stats.ws_quality, stats.ws_netname);
++ tip = g_strdup_printf("%s\n%s: %d%% at %dMB/s", stats.ws_vendor, stats.ws_netname, stats.ws_quality, stats.ws_rate);
+ else
+- tip = g_strdup_printf("%d%%", stats.ws_quality);
++ tip = g_strdup_printf("%s\n%d%% at %dMB/s", stats.ws_vendor, stats.ws_quality, stats.ws_rate);
+ }
+ }
+ else {
--- /dev/null 2008-01-28 23:23:41.000000000 +0100
+++ files/patch-panel-plugin_wi_bsd.c 2008-01-28 23:08:26.000000000 +0100
@@ -0,0 +1,218 @@
+--- panel-plugin/wi_bsd.c.orig 2008-01-28 23:01:05.000000000 +0100
++++ panel-plugin/wi_bsd.c 2008-01-28 23:01:42.000000000 +0100
+@@ -1,6 +1,8 @@
+ /* $Id: wi_bsd.c 562 2004-12-03 18:29:41Z benny $ */
+ /*-
+ * Copyright (c) 2003 Benedikt Meurer <benny at xfce.org>
++ * 2008 Pietro Cerutti <gahr at gahr.ch>
++ * (FreeBSD > 700042 adaptation)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+@@ -36,16 +38,18 @@
+ #include <net/if.h>
+ #include <net/if_media.h>
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
++#include <netinet/in.h>
++#include <netinet/if_ether.h>
++#if __FreeBSD_version >= 700042
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <net80211/ieee80211_ioctl.h>
++#else
+ #include <net/if_var.h>
+ #include <net/ethernet.h>
+-
+ #include <dev/wi/if_wavelan_ieee.h>
+-#if __FreeBSD_version >= 500033
+-#include <sys/endian.h>
+ #endif
+ #else
+-#include <netinet/in.h>
+-#include <netinet/if_ether.h>
+ #ifdef __NetBSD__
+ #include <net80211/ieee80211.h>
+ #include <net80211/ieee80211_ioctl.h>
+@@ -95,7 +99,11 @@
+ };
+
+ static int _wi_carrier(const struct wi_device *);
++#if defined(__FreeBSD__) && __FreeBSD_version > 700042
++static int _wi_getval(const struct wi_device *, struct ieee80211req_scan_result *);
++#else
+ static int _wi_getval(const struct wi_device *, struct wi_req *);
++#endif
+ static int _wi_vendor(const struct wi_device *, char *, size_t);
+ static int _wi_netname(const struct wi_device *, char *, size_t);
+ static int _wi_quality(const struct wi_device *, int *);
+@@ -193,24 +201,73 @@
+ return((ifmr.ifm_status & IFM_ACTIVE) != 0 ? WI_OK : WI_NOCARRIER);
+ }
+
++#if defined(__FreeBSD__) && __FreeBSD_version >= 700042
+ static int
+-_wi_getval(const struct wi_device *device, struct wi_req *wr)
++_wi_getval(const struct wi_device *device, struct ieee80211req_scan_result *scan)
+ {
+- struct ifreq ifr;
++ char buffer[24 * 1024];
++ const uint8_t *bp;
++ struct ieee80211req ireq;
++ size_t len;
++ bzero(&ireq, sizeof(ireq));
++ strlcpy(ireq.i_name, device->interface, sizeof(ireq.i_name));
++
++ ireq.i_type = IEEE80211_IOC_SCAN_RESULTS;
++ ireq.i_data = buffer;
++ ireq.i_len = sizeof(buffer);
++
++ if(ioctl(device->socket, SIOCG80211, &ireq) < 0)
++ return(WI_NOSUCHDEV);
+
+- bzero((void*)&ifr, sizeof(ifr));
+- strlcpy(ifr.ifr_name, device->interface, sizeof(ifr.ifr_name));
+- ifr.ifr_data = (void*)wr;
++ if(ireq.i_len < sizeof(struct ieee80211req_scan_result))
++ return(WI_NOSUCHDEV);
+
+- if (ioctl(device->socket, SIOCGWAVELAN, &ifr) < 0)
+- return(WI_NOSUCHDEV);
++ memcpy(scan, buffer, sizeof(struct ieee80211req_scan_result));
+
+- return(WI_OK);
++ return(WI_OK);
+ }
++#else
++static int
++_wi_getval(const struct wi_device *, struct wi_req *)
++{
++ struct ifreq ifr;
++
++ bzero((void*)&ifr, sizeof(ifr));
++ strlcpy(ifr.ifr_name, device->interface, sizeof(ifr.ifr_name));
++ ifr.ifr_data = (void*)wr;
++
++ if (ioctl(device->socket, SIOCGWAVELAN, &ifr) < 0)
++ return(WI_NOSUCHDEV);
++
++ return (WI_OK);
++}
++#endif
+
+ static int
+ _wi_vendor(const struct wi_device *device, char *buffer, size_t len)
+ {
++#if defined(__FreeBSD__) && __FreeBSD_version >= 700042
++ /*
++ * We use sysctl to get a device description
++ */
++ char mib[WI_MAXSTRLEN];
++ char dev_name[WI_MAXSTRLEN];
++ char *c = dev_name;
++ int dev_number;
++
++ /*
++ * Dirty hack to split the device name into name and number
++ */
++ strncpy(dev_name, device->interface, WI_MAXSTRLEN);
++ while(!isdigit(*c)) c++;
++ dev_number = (int)strtol(c, NULL, 10);
++ *c = '\0';
++
++
++ snprintf(mib, sizeof(mib), "dev.%s.%d.%%desc", dev_name, dev_number);
++ if(sysctlbyname(mib, buffer, &len, NULL, 0) == -1)
++ return (WI_NOSUCHDEV);
++#else
+ #define WI_RID_STA_IDENTITY_LUCENT 0x1
+ #define WI_RID_STA_IDENTITY_PRISMII 0x2
+ #define WI_RID_STA_IDENTITY_SAMSUNG 0x3
+@@ -250,6 +307,7 @@
+
+ snprintf(buffer, len, "%s (ID %d, version %d.%d)", vendor,
+ wr.wi_val[0], wr.wi_val[2], wr.wi_val[3]);
++#endif
+
+ return(WI_OK);
+ }
+@@ -257,6 +315,18 @@
+ static int
+ _wi_netname(const struct wi_device *device, char *buffer, size_t len)
+ {
++#if defined(__FreeBSD__) && __FreeBSD_version >= 700042
++ struct ieee80211req ireq;
++
++ memset(&ireq, 0, sizeof(ireq));
++ strncpy(ireq.i_name, device->interface, sizeof(ireq.i_name));
++ ireq.i_type = IEEE80211_IOC_SSID;
++ ireq.i_val = -1;
++ ireq.i_data = buffer;
++ ireq.i_len = len;
++ if (ioctl(device->socket, SIOCG80211, &ireq) < 0)
++ return WI_NOSUCHDEV;
++#else
+ struct wi_req wr;
+ int result;
+
+@@ -268,6 +338,7 @@
+ return(result);
+
+ strlcpy(buffer, (char *)&wr.wi_val[1], MIN(len, le16toh(wr.wi_val[0]) + 1));
++#endif
+
+ return(WI_OK);
+ }
+@@ -275,6 +346,16 @@
+ static int
+ _wi_quality(const struct wi_device *device, int *quality)
+ {
++#if defined(__FreeBSD__) && __FreeBSD_version >= 700042
++ struct ieee80211req_scan_result req;
++ int result;
++ bzero(&req, sizeof(req));
++
++ if((result = _wi_getval(device, &req)) != WI_OK)
++ return (result);
++
++ *quality = req.isr_rssi;
++#else
+ struct wi_req wr;
+ int result;
+
+@@ -289,6 +370,7 @@
+ *quality = le16toh(wr.wi_val[1]);
+ else
+ *quality = le16toh(wr.wi_val[0]);
++#endif
+
+ return(WI_OK);
+ }
+@@ -296,6 +378,20 @@
+ static int
+ _wi_rate(const struct wi_device *device, int *rate)
+ {
++#if defined(__FreeBSD__) && __FreeBSD_version >= 700042
++ struct ieee80211req_scan_result req;
++ int result, i, high;
++ bzero(&req, sizeof(req));
++
++ if((result = _wi_getval(device, &req)) != WI_OK)
++ return (result);
++
++ for(i=0, high=-1; i<req.isr_nrates; i++)
++ if((req.isr_rates[i] & IEEE80211_RATE_VAL) > high)
++ high = req.isr_rates[i] & IEEE80211_RATE_VAL;
++
++ *rate = high / 2;
++#else
+ struct wi_req wr;
+ int result;
+
+@@ -307,6 +403,7 @@
+ return(result);
+
+ *rate = le16toh(wr.wi_val[0]);
++#endif
+
+ return(WI_OK);
+ }
--- _xfce4-wavelan-plugin.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list