summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 915814d..e5b091f 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -146,2 +146,13 @@ ONetwork::InterfaceIterator ONetwork::iterator() const
+bool ONetwork::isPresent( const char* name ) const
+{
+ int sfd = socket( AF_INET, SOCK_STREAM, 0 );
+ struct ifreq ifr;
+ memset( &ifr, 0, sizeof( struct ifreq ) );
+ strcpy( (char*) &ifr.ifr_name, name );
+ int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
+ return result != -1;
+}
+
+
bool ONetwork::isWirelessInterface( const char* name ) const
@@ -584,3 +595,3 @@ void OWirelessNetworkInterface::dumpInformation() const
- qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s",
+ qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s",
_range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
@@ -588,3 +599,3 @@ void OWirelessNetworkInterface::dumpInformation() const
name(), _range.we_version_source, _range.we_version_compiled );
-
+
if ( _range.we_version_compiled != WIRELESS_EXT )
@@ -974,3 +985,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
int OWirelessNetworkInterface::signalStrength() const
-{
+{
iw_statistics stat;
@@ -980,3 +991,3 @@ int OWirelessNetworkInterface::signalStrength() const
_iwr.u.data.length = sizeof stat;
-
+
if ( !wioctl( SIOCGIWSTATS ) )
@@ -985,3 +996,3 @@ int OWirelessNetworkInterface::signalStrength() const
}
-
+
int max = _range.max_qual.qual;
@@ -990,3 +1001,3 @@ int OWirelessNetworkInterface::signalStrength() const
int noi = stat.qual.noise; //FIXME: Do something with them?
-
+
return cur*100/max;