summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authormickeyl <mickeyl>2003-03-30 14:48:08 (UTC)
committer mickeyl <mickeyl>2003-03-30 14:48:08 (UTC)
commitf921599651459b393e6a9846a1ecf7551323f4c2 (patch) (side-by-side diff)
tree1fe6c881d29597c289a2dbbc30ad020996faac91 /libopie2/opienet
parent9e3dc048e171af6d88f0cc3f16ad0c9fb6a15ce2 (diff)
downloadopie-f921599651459b393e6a9846a1ecf7551323f4c2.zip
opie-f921599651459b393e6a9846a1ecf7551323f4c2.tar.gz
opie-f921599651459b393e6a9846a1ecf7551323f4c2.tar.bz2
- implement switching monitor mode on hostap
- work around damn buggy hostap drivers needing more space for SIOCGIWRANGE than defined by sizeof(struct iw_range)...
Diffstat (limited to 'libopie2/opienet') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 21fa390..cd36f16 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -377,12 +377,14 @@ void OWirelessNetworkInterface::init()
memset( &_iwr, 0, sizeof( struct iwreq ) );
// IEEE802.11(b) radio frequency channels
- //FIXME: get these directly from the interface
- //FIXME: check if these channels are off-by-one
iwrangestruct range;
+ //ML: work around an ugly HostAP bug, which needs
+ //ML: extra space or will complain with "invalid argument length"... :-(
+ char __extraBufferForBuggyDrivers[sizeof range];
_iwr.u.data.pointer = (char*) &range;
- _iwr.u.data.length = sizeof( iwrangestruct );
+ _iwr.u.data.length = (sizeof range) * 2;
+ _iwr.u.data.flags = 0;
if ( !wioctl( SIOCGIWRANGE ) )
{
qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) );
@@ -721,6 +723,8 @@ void OHostAPMonitoringInterface::setEnabled( bool b )
// IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
// Wireless Extensions < Version 15 need iwpriv commandos for monitoring
+ if ( b )
+ {
#if WIRELESS_EXT > 14
_if->_iwr.u.mode = IW_MODE_MONITOR;
_if->wioctl( SIOCSIWMODE );
@@ -730,6 +734,19 @@ void OHostAPMonitoringInterface::setEnabled( bool b )
args[1] = 0;
_if->wioctl( SIOCDEVPRIVATE );
#endif
+ }
+ else
+ {
+ #if WIRELESS_EXT > 14
+ _if->_iwr.u.mode = IW_MODE_INFRA;
+ _if->wioctl( SIOCSIWMODE );
+ #else
+ int* args = (int*) &_if->_iwr.u.name;
+ args[0] = 0;
+ args[1] = 0;
+ _if->wioctl( SIOCDEVPRIVATE );
+ #endif
+ }
OMonitoringInterface::setEnabled( b );
}