summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authormickeyl <mickeyl>2003-10-11 23:54:03 (UTC)
committer mickeyl <mickeyl>2003-10-11 23:54:03 (UTC)
commita8fe3ba1544ca2a2ad2559e3094acbb284cc7783 (patch) (side-by-side diff)
treeef60fa83b396d16580f5ce7ab2b5c147fbceeabf /libopie2/opienet
parente6273e146d3ef3f9387fbc3b6a214f9b3d08221e (diff)
downloadopie-a8fe3ba1544ca2a2ad2559e3094acbb284cc7783.zip
opie-a8fe3ba1544ca2a2ad2559e3094acbb284cc7783.tar.gz
opie-a8fe3ba1544ca2a2ad2559e3094acbb284cc7783.tar.bz2
add scanning skeleton (wip)
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp113
-rw-r--r--libopie2/opienet/onetwork.h29
2 files changed, 119 insertions, 23 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index dc2e388..be45924 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -78,2 +78,3 @@ void ONetwork::synchronize()
//FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
+ //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
@@ -190,5 +191,5 @@ bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
if ( result == -1 )
- qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) );
+ qDebug( "ONetworkInterface::ioctl (%s) call %d (0x%04X) - Status: Failed: %d (%s)", name(), call, call, result, strerror( errno ) );
else
- qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call );
+ qDebug( "ONetworkInterface::ioctl (%s) call %d (0x%04X) - Status: Ok.", name(), call, call );
return ( result != -1 );
@@ -456,4 +457,12 @@ void OWirelessNetworkInterface::init()
memset( &_iwr, 0, sizeof( struct iwreq ) );
- buildChannelList();
+ buildInformation();
buildPrivateList();
+ dumpInformation();
+}
+
+
+bool OWirelessNetworkInterface::isAssociated() const
+{
+ //FIXME: handle different modes
+ return associatedAP() != "44:44:44:44:44:44";
}
@@ -484,3 +493,3 @@ QString OWirelessNetworkInterface::associatedAP() const
-void OWirelessNetworkInterface::buildChannelList()
+void OWirelessNetworkInterface::buildInformation()
{
@@ -507,3 +516,3 @@ void OWirelessNetworkInterface::buildChannelList()
{
- qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) );
+ qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) );
_channels.insert( 2412, 1 ); // 2.412 GHz
@@ -519,2 +528,4 @@ void OWirelessNetworkInterface::buildChannelList()
_channels.insert( 2462, 11 ); // 2.462 GHz
+
+ memset( &_range, 0, sizeof( struct iw_range ) );
}
@@ -529,4 +540,4 @@ void OWirelessNetworkInterface::buildChannelList()
{
- qWarning( "OWirelessNetworkInterface::buildChannelList(): Driver for wireless interface '%s'"
- "overwrote buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) );
+ qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n"
+ "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) );
}
@@ -537,3 +548,3 @@ void OWirelessNetworkInterface::buildChannelList()
- qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency );
+ qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency );
for ( int i = 0; i < range.num_frequency; ++i )
@@ -545,3 +556,4 @@ void OWirelessNetworkInterface::buildChannelList()
- qDebug( "OWirelessNetworkInterface::buildChannelList(): Channel list constructed." );
+ memcpy( &_range, buffer, sizeof( struct iw_range ) );
+ qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." );
free(buffer);
@@ -574,2 +586,13 @@ void OWirelessNetworkInterface::buildPrivateList()
+void OWirelessNetworkInterface::dumpInformation() const
+{
+ qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" );
+
+ 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 );
+ qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source );
+
+ qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" );
+}
+
+
int OWirelessNetworkInterface::channel() const
@@ -663,5 +686,3 @@ void OWirelessNetworkInterface::setMode( const QString& mode )
else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND;
- #if WIRELESS_EXT > 14
else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR;
- #endif
else
@@ -689,5 +710,3 @@ QString OWirelessNetworkInterface::mode() const
case IW_MODE_SECOND: return "secondary";
- #if WIRELESS_EXT > 14
case IW_MODE_MONITOR: return "monitor";
- #endif
default: assert( 0 ); // shouldn't happen
@@ -710,3 +729,4 @@ bool OWirelessNetworkInterface::monitorMode() const
return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 );
- // 802 is the header type for PRISM - Linux support for this is pending...
+ //FIXME: 802 is the header type for PRISM - Linux support for this is pending...
+ //FIXME: What is 119, by the way?
}
@@ -802,2 +822,63 @@ void OWirelessNetworkInterface::setSSID( const QString& ssid )
+int OWirelessNetworkInterface::scanNetwork()
+{
+ _iwr.u.param.flags = IW_SCAN_DEFAULT;
+ _iwr.u.param.value = 0;
+ if ( !wioctl( SIOCSIWSCAN ) )
+ {
+ return -1;
+ }
+
+ int timeout = 1000000;
+
+ qDebug( "ONetworkInterface::scanNetwork() - scan started." );
+
+ bool results = false;
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 250000; // initial timeout ~ 250ms
+ char buffer[IW_SCAN_MAX_DATA];
+
+ while ( !results && timeout > 0 )
+ {
+ timeout -= tv.tv_usec;
+ select( 0, 0, 0, 0, &tv );
+
+ _iwr.u.data.pointer = &buffer[0];
+ _iwr.u.data.flags = 0;
+ _iwr.u.data.length = sizeof buffer;
+ if ( wioctl( SIOCGIWSCAN ) )
+ {
+ results = true;
+ continue;
+ }
+ else if ( errno == EAGAIN)
+ {
+ qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." );
+ #if 0
+ if ( qApp )
+ {
+ qApp->processEvents( 100 );
+ continue;
+ }
+ #endif
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ continue;
+ }
+ }
+
+ qDebug( "ONetworkInterface::scanNetwork() - scan finished." );
+
+ if ( results )
+ {
+ qDebug( " - results are in!" );
+ }
+ else
+ {
+ qDebug( " - no results :(" );
+ }
+}
+
+
bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
@@ -806,5 +887,5 @@ bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
if ( result == -1 )
- qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) );
+ qDebug( "ONetworkInterface::wioctl (%s) call %d (0x%04X) - Status: Failed: %d (%s)", name(), call, call, result, strerror( errno ) );
else
- qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call );
+ qDebug( "ONetworkInterface::wioctl (%s) call %d (0x%04X) - Status: Ok.", name(), call, call );
return ( result != -1 );
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index b170ea2..e1545dd 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -363,3 +363,3 @@ class OWirelessNetworkInterface : public ONetworkInterface
*/
- virtual void setMonitorMode( bool ); //FIXME: ==> setMode( "monitor" );
+ virtual void setMonitorMode( bool ); //FIXME: ==> setMode( "monitor" ); Use IW_MONITOR first, if this doesn't work, then use iwpriv!
/**
@@ -399,8 +399,10 @@ class OWirelessNetworkInterface : public ONetworkInterface
virtual void getPrivate( const QString& command ); //FIXME: Implement and document this
-
- virtual bool isAssociated() const {}; //FIXME: Implement and document this
/**
- * @returns the MAC address of the Access Point if the
- * device is in infrastructure mode. @returns a (more or less random) CELL
- * address if the device is in adhoc mode.
+ * @returns true if the interface is associated to an access point
+ * @note: This information is only valid if the interface is in managed mode.
+ */
+ virtual bool isAssociated() const;
+ /**
+ * @returns the MAC address of the Access Point if the device is in infrastructure mode.
+ * @returns a (more or less random) cell ID address if the device is in adhoc mode.
*/
@@ -416,6 +418,12 @@ class OWirelessNetworkInterface : public ONetworkInterface
virtual QString SSID() const;
+ /**
+ * Perform scanning the wireless network neighbourhood.
+ * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE!
+ */
+ virtual int scanNetwork();
protected:
- void buildChannelList();
+ void buildInformation();
void buildPrivateList();
+ void dumpInformation() const;
virtual void init();
@@ -428,2 +436,3 @@ class OWirelessNetworkInterface : public ONetworkInterface
QMap<int,int> _channels;
+ struct iw_range _range;
@@ -477,2 +486,3 @@ class OCiscoMonitoringInterface : public OMonitoringInterface
+
/*======================================================================================
@@ -481,2 +491,3 @@ class OCiscoMonitoringInterface : public OMonitoringInterface
+
class OWlanNGMonitoringInterface : public OMonitoringInterface
@@ -494,2 +505,3 @@ class OWlanNGMonitoringInterface : public OMonitoringInterface
+
/*======================================================================================
@@ -498,2 +510,3 @@ class OWlanNGMonitoringInterface : public OMonitoringInterface
+
class OHostAPMonitoringInterface : public OMonitoringInterface
@@ -509,2 +522,3 @@ class OHostAPMonitoringInterface : public OMonitoringInterface
+
/*======================================================================================
@@ -513,2 +527,3 @@ class OHostAPMonitoringInterface : public OMonitoringInterface
+
class OOrinocoMonitoringInterface : public OMonitoringInterface