Comment 9 for bug 973241

Jools Wills (jools) wrote :

some compile errors with that patch. drvinfo.driver is a char[32] and brackets are mismatched.

wifi-utils.c: In function 'wifi_utils_init':
wifi-utils.c:76:17: error: incompatible types when assigning to type 'char[32]' from type 'void *'
wifi-utils.c:85:3: error: expected ')' before 'ret'
wifi-utils.c:95:1: error: expected expression before '}' token

the unbalanced brackets at 85

i've made some changes so it compiles, but im not 100% sure if it's correct (I'm a bit under the weather at the moment).

revised patch to test

Index: network-manager-0.9.4.0/src/wifi/wifi-utils.c
===================================================================
--- network-manager-0.9.4.0.orig/src/wifi/wifi-utils.c 2012-03-01 05:26:37.000000000 +0000
+++ network-manager-0.9.4.0/src/wifi/wifi-utils.c 2012-04-06 21:01:47.808432103 +0100
@@ -25,6 +25,11 @@
 #include <string.h>
 #include <glib.h>

+#include <sys/socket.h>
+#include <linux/sockios.h>
+#include <linux/if.h>
+#include <linux/ethtool.h>
+
 #include "wifi-utils.h"
 #include "wifi-utils-private.h"
 #include "wifi-utils-nl80211.h"
@@ -57,11 +62,30 @@
 wifi_utils_init (const char *iface, int ifindex, gboolean check_scan)
 {
  WifiData *ret;
+ struct ifreq ifr;
+ struct ethtool_drvinfo drvinfo;
+ int fd;

  g_return_val_if_fail (iface != NULL, NULL);
  g_return_val_if_fail (ifindex > 0, NULL);

- ret = wifi_nl80211_init (iface, ifindex);
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+
+ strcpy(ifr.ifr_name, iface);
+ drvinfo.cmd = ETHTOOL_GDRVINFO;
+ drvinfo.driver[0] = '\0';
+
+ ifr.ifr_data = &drvinfo;
+
+ ioctl(fd, SIOCETHTOOL, &ifr);
+
+ if (drvinfo.driver[0] &&
+ (strcmp (drvinfo.driver, "ipw2200") == 0) ||
+ (strcmp (drvinfo.driver, "ipw2100") == 0))
+ ret = NULL;
+ else
+ ret = wifi_nl80211_init (iface, ifindex);
+
  if (ret == NULL) {
 #if HAVE_WEXT
   ret = wifi_wext_init (iface, ifindex, check_scan);