shill: Ignore WiFi devices in "monitor" mode

Ignore WiFi devices setup for capture.  These are useful
for debugging, and shill should not try to manage them as
client interfaces or cause wpa_supplicant to try to convert
them.  In the future we could use these internall in shill
for debugging, so create a new interface type for them.

BUG=chromium-os:24289
TEST=Start up with mon0, install mon0 while shill is running

Change-Id: I91e2d2c4a691d2cf9b25588a6ce6675e60b73df9
Reviewed-on: https://gerrit.chromium.org/gerrit/12991
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
diff --git a/device_info.cc b/device_info.cc
index 22fd0d4..193afb8 100644
--- a/device_info.cc
+++ b/device_info.cc
@@ -21,6 +21,7 @@
 #include <base/logging.h>
 #include <base/memory/scoped_ptr.h>
 #include <base/stl_util-inl.h>
+#include <base/string_number_conversions.h>
 #include <base/string_util.h>
 #include <base/stringprintf.h>
 
@@ -49,6 +50,8 @@
 // static
 const char DeviceInfo::kInterfaceDriver[] = "/sys/class/net/%s/device/driver";
 // static
+const char DeviceInfo::kInterfaceType[] = "/sys/class/net/%s/type";
+// static
 const char *DeviceInfo::kModemDrivers[] = {
     "gobi",
     "QCUSBNet2k",
@@ -119,6 +122,17 @@
   if (contents.find(kInterfaceUeventWifiSignature) != string::npos) {
     VLOG(2) << StringPrintf("%s: device %s has wifi signature in uevent file",
                             __func__, iface_name.c_str());
+    FilePath type_file(StringPrintf(kInterfaceType, iface_name.c_str()));
+    string type_string;
+    int type_val = 0;
+    if (file_util::ReadFileToString(type_file, &type_string) &&
+        TrimString(type_string, "\n", &type_string) &&
+        base::StringToInt(type_string, &type_val) &&
+        type_val == ARPHRD_IEEE80211_RADIOTAP) {
+      VLOG(2) << StringPrintf("%s: wifi device %s is in monitor mode",
+                              __func__, iface_name.c_str());
+      return Technology::kWiFiMonitor;
+    }
     return Technology::kWifi;
   }