summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
authormickeyl <mickeyl>2004-02-24 22:56:24 (UTC)
committer mickeyl <mickeyl>2004-02-24 22:56:24 (UTC)
commit96ba6fcf27c785282c3fe05557df8b384df06852 (patch) (unidiff)
tree9b25648f8518c8d152d4774ac05f81548828f3d5 /libopie2/opienet/onetwork.cpp
parenta1a6a1013eae9a4ca4607f2d656c98821a30f431 (diff)
downloadopie-96ba6fcf27c785282c3fe05557df8b384df06852.zip
opie-96ba6fcf27c785282c3fe05557df8b384df06852.tar.gz
opie-96ba6fcf27c785282c3fe05557df8b384df06852.tar.bz2
API extension: ONetwork::isPresent( const char* name )
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
146 146
147bool ONetwork::isPresent( const char* name ) const
148{
149 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
150 struct ifreq ifr;
151 memset( &ifr, 0, sizeof( struct ifreq ) );
152 strcpy( (char*) &ifr.ifr_name, name );
153 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
154 return result != -1;
155}
156
157
147bool ONetwork::isWirelessInterface( const char* name ) const 158bool ONetwork::isWirelessInterface( const char* name ) const
@@ -584,3 +595,3 @@ void OWirelessNetworkInterface::dumpInformation() const
584 595
585 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", 596 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s",
586 _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); 597 _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
588 name(), _range.we_version_source, _range.we_version_compiled ); 599 name(), _range.we_version_source, _range.we_version_compiled );
589 600
590 if ( _range.we_version_compiled != WIRELESS_EXT ) 601 if ( _range.we_version_compiled != WIRELESS_EXT )
@@ -974,3 +985,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
974int OWirelessNetworkInterface::signalStrength() const 985int OWirelessNetworkInterface::signalStrength() const
975{ 986{
976 iw_statistics stat; 987 iw_statistics stat;
@@ -980,3 +991,3 @@ int OWirelessNetworkInterface::signalStrength() const
980 _iwr.u.data.length = sizeof stat; 991 _iwr.u.data.length = sizeof stat;
981 992
982 if ( !wioctl( SIOCGIWSTATS ) ) 993 if ( !wioctl( SIOCGIWSTATS ) )
@@ -985,3 +996,3 @@ int OWirelessNetworkInterface::signalStrength() const
985 } 996 }
986 997
987 int max = _range.max_qual.qual; 998 int max = _range.max_qual.qual;
@@ -990,3 +1001,3 @@ int OWirelessNetworkInterface::signalStrength() const
990 int noi = stat.qual.noise; //FIXME: Do something with them? 1001 int noi = stat.qual.noise; //FIXME: Do something with them?
991 1002
992 return cur*100/max; 1003 return cur*100/max;