-rw-r--r-- | libopie2/opienet/onetwork.cpp | 23 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 4 |
2 files changed, 21 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 | |||
@@ -145,4 +145,15 @@ ONetwork::InterfaceIterator ONetwork::iterator() const | |||
145 | 145 | ||
146 | 146 | ||
147 | bool 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 | |||
147 | bool ONetwork::isWirelessInterface( const char* name ) const | 158 | bool ONetwork::isWirelessInterface( const char* name ) const |
148 | { | 159 | { |
@@ -583,9 +594,9 @@ void OWirelessNetworkInterface::dumpInformation() const | |||
583 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; | 594 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; |
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 ); |
587 | qDebug( " - driver for '%s' (V%d) has been compiled against WE V%d", | 598 | qDebug( " - driver for '%s' (V%d) has been compiled against WE V%d", |
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 ) |
591 | { | 602 | { |
@@ -973,5 +984,5 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
973 | 984 | ||
974 | int OWirelessNetworkInterface::signalStrength() const | 985 | int OWirelessNetworkInterface::signalStrength() const |
975 | { | 986 | { |
976 | iw_statistics stat; | 987 | iw_statistics stat; |
977 | ::memset( &stat, 0, sizeof stat ); | 988 | ::memset( &stat, 0, sizeof stat ); |
@@ -979,15 +990,15 @@ int OWirelessNetworkInterface::signalStrength() const | |||
979 | _iwr.u.data.flags = 0; | 990 | _iwr.u.data.flags = 0; |
980 | _iwr.u.data.length = sizeof stat; | 991 | _iwr.u.data.length = sizeof stat; |
981 | 992 | ||
982 | if ( !wioctl( SIOCGIWSTATS ) ) | 993 | if ( !wioctl( SIOCGIWSTATS ) ) |
983 | { | 994 | { |
984 | return -1; | 995 | return -1; |
985 | } | 996 | } |
986 | 997 | ||
987 | int max = _range.max_qual.qual; | 998 | int max = _range.max_qual.qual; |
988 | int cur = stat.qual.qual; | 999 | int cur = stat.qual.qual; |
989 | int lev = stat.qual.level; //FIXME: Do something with them? | 1000 | int lev = stat.qual.level; //FIXME: Do something with them? |
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; |
993 | } | 1004 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 0a51108..93b129f 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -95,4 +95,8 @@ class ONetwork : public QObject | |||
95 | InterfaceIterator iterator() const; | 95 | InterfaceIterator iterator() const; |
96 | /** | 96 | /** |
97 | * @returns true, if the @a interface is present. | ||
98 | */ | ||
99 | bool isPresent( const char* interface ) const; | ||
100 | /** | ||
97 | * @returns true, if the @a interface supports the wireless extension protocol. | 101 | * @returns true, if the @a interface supports the wireless extension protocol. |
98 | */ | 102 | */ |