[PC-BSD Commits] r2063 - pcbsd/trunk/libpcbsd

svn at pcbsd.org svn at pcbsd.org
Mon Jun 9 08:12:07 PDT 2008


Author: tim
Date: 2008-06-09 08:12:06 -0700 (Mon, 09 Jun 2008)
New Revision: 2063

Modified:
   pcbsd/trunk/libpcbsd/netif.cpp
Log:
Implemented isUp() and isWireless()

Modified: pcbsd/trunk/libpcbsd/netif.cpp
===================================================================
--- pcbsd/trunk/libpcbsd/netif.cpp	2008-06-09 14:48:52 UTC (rev 2062)
+++ pcbsd/trunk/libpcbsd/netif.cpp	2008-06-09 15:12:06 UTC (rev 2063)
@@ -147,3 +147,29 @@
    }
    return status;
 }
+
+bool NetworkInterface::isWireless()
+{
+   struct ifmediareq ifm;
+   memset(&ifm, 0, sizeof(struct ifmediareq));
+
+   strncpy(ifm.ifm_name, name, IFNAMSIZ);
+   int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+   ioctl(s, SIOCGIFMEDIA, &ifm);
+
+   return IFM_TYPE(ifm.ifm_active) == IFM_IEEE80211;
+}
+
+bool NetworkInterface::isUp()
+{
+   struct ifreq ifr;
+   memset(&ifr, 0, sizeof(struct ifreq));
+
+   strncpy(ifr.ifr_name, name, IFNAMSIZ);
+   int s = socket(AF_INET, SOCK_DGRAM, 0);
+
+   ioctl(s, SIOCGIFFLAGS, &ifr);
+
+   return (ifr.ifr_flags & IFF_UP) ? 1 : 0;
+}



More information about the Commits mailing list