Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 918ba07..a85a510 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -29,16 +29,17 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/onetwork.h> +#include <opie2/ostation.h> /* QT */ #include <qfile.h> #include <qtextstream.h> /* UNIX */ @@ -876,21 +877,63 @@ int OWirelessNetworkInterface::scanNetwork() continue; } } qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); if ( results ) { + qDebug( " - result length = %d", _iwr.u.data.length ); + if ( !_iwr.u.data.length ) + { + qDebug( " - no results (empty neighbourhood)" ); + return 0; + } + qDebug( " - results are in!" ); + dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); + + int stations = 0; + + // parse results + + int offset = 0; + struct iw_event* we = (struct iw_event*) &buffer[0]; + + while ( offset < _iwr.u.data.length ) + { + //const char* cmd = *(*_ioctlmap)[we->cmd]; + //if ( !cmd ) cmd = "<unknown>"; + qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); + switch (we->cmd) + { + case SIOCGIWAP: qDebug( "SIOCGIWAP" ); stations++; break; + case SIOCGIWMODE: qDebug( "SIOCGIWMODE" ); break; + case SIOCGIWFREQ: qDebug( "SIOCGIWFREQ" ); break; + case SIOCGIWESSID: qDebug( "SIOCGIWESSID" ); break; + case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; + case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; + case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ + case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ + case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ + case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ + case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ + default: qDebug( "unhandled event" ); + } + + offset += we->len; + we = (struct iw_event*) &buffer[offset]; + } + } else { - qDebug( " - no results :(" ); + qDebug( " - no results (timeout) :(" ); + return 0; } } bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const { #ifndef NODEBUG int result = ::ioctl( _sfd, call, &iwreq ); |