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

svn at pcbsd.org svn at pcbsd.org
Tue Jun 10 07:38:39 PDT 2008


Author: tim
Date: 2008-06-10 07:38:38 -0700 (Tue, 10 Jun 2008)
New Revision: 2077

Modified:
   pcbsd/trunk/libpcbsd/netif.cpp
   pcbsd/trunk/libpcbsd/netif.h
Log:
Added library functionality

Modified: pcbsd/trunk/libpcbsd/netif.cpp
===================================================================
--- pcbsd/trunk/libpcbsd/netif.cpp	2008-06-10 11:44:24 UTC (rev 2076)
+++ pcbsd/trunk/libpcbsd/netif.cpp	2008-06-10 14:38:38 UTC (rev 2077)
@@ -35,7 +35,10 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+#include <qregexp.h>
+
 #include "netif.h"
+#include "utils.h"
 
 QStringList NetworkInterface::getInterfaces()
 {
@@ -150,6 +153,19 @@
    return status;
 }
 
+QString NetworkInterface::desc()
+{
+   return Utils::sysctl("dev." + devName() + "." + QString::number(devNum()) + ".%desc");
+}
+
+QString NetworkInterface::devName()
+{
+   uint pos = name.find(QRegExp("[0-9]+$"));
+   QString result = name;
+   result.truncate(pos);
+   return result;
+}
+
 bool NetworkInterface::isWireless()
 {
    struct ifmediareq ifm;
@@ -271,3 +287,9 @@
 
    return ifm->ifm_data.ifi_oerrors;
 }
+
+uint NetworkInterface::devNum()
+{
+   uint pos = name.find(QRegExp("[0-9]+$"));
+   return name.mid(pos).toInt();
+}

Modified: pcbsd/trunk/libpcbsd/netif.h
===================================================================
--- pcbsd/trunk/libpcbsd/netif.h	2008-06-10 11:44:24 UTC (rev 2076)
+++ pcbsd/trunk/libpcbsd/netif.h	2008-06-10 14:38:38 UTC (rev 2077)
@@ -34,10 +34,11 @@
    QString ipAsString();
    QString ipv6AsString();
    QString netmaskAsString();
-   QString getDesc();
+   QString desc();
    QString macAsString();
    QString mediaTypeAsString();
    QString mediaStatusAsString();
+   QString devName();
    bool isWireless();
    bool usesDHCP();
    bool isUp();
@@ -45,6 +46,7 @@
    long packetsTx();
    long errorsRx();
    long errorsTx();
+   uint devNum();
    
    static QStringList getInterfaces();
 



More information about the Commits mailing list