Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 16fa8ae..36f409b 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003-2004 by Michael 'Mickey' Lauer |
4 | =. | 4 | =. <mickey@Vanille.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
@@ -573,26 +573,33 @@ void OWirelessNetworkInterface::buildPrivateList() | |||
573 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 573 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
574 | { | 574 | { |
575 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 575 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
576 | } | 576 | } |
577 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; | 577 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; |
578 | } | 578 | } |
579 | 579 | ||
580 | 580 | ||
581 | void OWirelessNetworkInterface::dumpInformation() const | 581 | void OWirelessNetworkInterface::dumpInformation() const |
582 | { | 582 | { |
583 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; | 583 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; |
584 | 584 | ||
585 | 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 ); | 585 | qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", |
586 | qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); | 586 | _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", | ||
588 | name(), _range.we_version_source, _range.we_version_compiled ); | ||
589 | |||
590 | if ( _range.we_version_compiled != WIRELESS_EXT ) | ||
591 | { | ||
592 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; | ||
593 | } | ||
587 | 594 | ||
588 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; | 595 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; |
589 | } | 596 | } |
590 | 597 | ||
591 | 598 | ||
592 | int OWirelessNetworkInterface::channel() const | 599 | int OWirelessNetworkInterface::channel() const |
593 | { | 600 | { |
594 | //FIXME: When monitoring enabled, then use it | 601 | //FIXME: When monitoring enabled, then use it |
595 | //FIXME: to gather the current RF channel | 602 | //FIXME: to gather the current RF channel |
596 | //FIXME: Until then, get active channel from hopper. | 603 | //FIXME: Until then, get active channel from hopper. |
597 | if ( _hopper && _hopper->isActive() ) | 604 | if ( _hopper && _hopper->isActive() ) |
598 | return _hopper->channel(); | 605 | return _hopper->channel(); |
@@ -956,28 +963,42 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
956 | return stations; | 963 | return stations; |
957 | 964 | ||
958 | } | 965 | } |
959 | else | 966 | else |
960 | { | 967 | { |
961 | odebug << " - no results (timeout) :(" << oendl; | 968 | odebug << " - no results (timeout) :(" << oendl; |
962 | return stations; | 969 | return stations; |
963 | } | 970 | } |
964 | } | 971 | } |
965 | 972 | ||
966 | 973 | ||
967 | int OWirelessNetworkInterface::signalStrength() const | 974 | int OWirelessNetworkInterface::signalStrength() const |
968 | { | 975 | { |
969 | int max = _range.max_qual.level; | 976 | iw_statistics stat; |
970 | odebug << "signalStrength(): max quality seems to be " << max << "dBM" << oendl; | 977 | ::memset( &stat, 0, sizeof stat ); |
971 | return 50; | 978 | _iwr.u.data.pointer = (char*) &stat; |
979 | _iwr.u.data.flags = 0; | ||
980 | _iwr.u.data.length = sizeof stat; | ||
981 | |||
982 | if ( !wioctl( SIOCGIWSTATS ) ) | ||
983 | { | ||
984 | return -1; | ||
985 | } | ||
986 | |||
987 | int max = _range.max_qual.qual; | ||
988 | int cur = stat.qual.qual; | ||
989 | int lev = stat.qual.level; //FIXME: Do something with them? | ||
990 | int noi = stat.qual.noise; //FIXME: Do something with them? | ||
991 | |||
992 | return cur*100/max; | ||
972 | } | 993 | } |
973 | 994 | ||
974 | 995 | ||
975 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 996 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
976 | { | 997 | { |
977 | #ifndef NODEBUG | 998 | #ifndef NODEBUG |
978 | int result = ::ioctl( _sfd, call, &iwreq ); | 999 | int result = ::ioctl( _sfd, call, &iwreq ); |
979 | 1000 | ||
980 | if ( result == -1 ) | 1001 | if ( result == -1 ) |
981 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1002 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
982 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 1003 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
983 | else | 1004 | else |