author | mickeyl <mickeyl> | 2003-10-28 19:13:34 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-28 19:13:34 (UTC) |
commit | d5d9b307e950d9038215e4d63e64bc9cd5d85352 (patch) (side-by-side diff) | |
tree | ccef170352625a48c9c7ff0e7ff119f8d23e2331 | |
parent | 5acd7ce51829c317f6218ff059d0d2f63cdb0871 (diff) | |
download | opie-d5d9b307e950d9038215e4d63e64bc9cd5d85352.zip opie-d5d9b307e950d9038215e4d63e64bc9cd5d85352.tar.gz opie-d5d9b307e950d9038215e4d63e64bc9cd5d85352.tar.bz2 |
catch up with API changes in libopienet
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp2.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 7ce096f..e7d6ff5 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp @@ -306,157 +306,157 @@ void WLANImp::rescanNeighbourhood() { QString name = interface->getInterfaceName(); qDebug( "rescanNeighbourhood via '%s'", (const char*) name ); OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); assert( wiface ); // try to guess device type QString devicetype; QFile m( "/proc/modules" ); if ( m.open( IO_ReadOnly ) ) { QString line; QTextStream modules( &m ); while( !modules.atEnd() && !devicetype ) { modules >> line; if ( line.contains( "cisco" ) ) devicetype = "cisco"; else if ( line.contains( "hostap" ) ) devicetype = "hostap"; else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; } } if ( devicetype.isEmpty() ) { qWarning( "rescanNeighbourhood(): couldn't guess device type :(" ); return; } else { qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype ); } // configure interface to receive 802.11 management frames wiface->setUp( true ); wiface->setPromiscuousMode( true ); if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); else { qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" ); return; } - wiface->setMonitorMode( true ); - if ( !wiface->monitorMode() ) + wiface->setMode( "monitor" ); + if ( wiface->mode() != "monitor" ) { qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) ); return; } // open a packet capturer OPacketCapturer* cap = new OPacketCapturer(); cap->open( name ); if ( !cap->isOpen() ) { qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) ); return; } // display splash screen QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); splash->setLineWidth( 2 ); splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); vbox->addWidget( lab ); vbox->addWidget( pb ); pb->setCenterIndicator( true ); pb->setFixedHeight( pb->sizeHint().height() ); QWidget* widgetDesktop = qApp->desktop(); int dw = widgetDesktop->width(); int dh = widgetDesktop->height(); int pw = vbox->sizeHint().width(); int ph = vbox->sizeHint().height(); splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); splash->show(); splash->raise(); qApp->processEvents(); // set capturer to non-blocking mode cap->setBlocking( false ); for ( int i = 1; i <= wiface->channels(); ++i ) { wiface->setChannel( i ); pb->setProgress( i ); qApp->processEvents(); qDebug( "rescanNeighbourhood(): listening on channel %d...", i ); OPacket* p = cap->next( 1000 ); if ( !p ) { qDebug( "rescanNeighbourhood(): nothing received on channel %d", i ); } else { qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i ); handlePacket( p ); } } cap->close(); - wiface->setMonitorMode( false ); - wiface->setPromiscuousMode( true ); + wiface->setMode( "managed" ); // TODO: use previous mode + wiface->setPromiscuousMode( false ); splash->hide(); delete splash; } void WLANImp::handlePacket( OPacket* p ) { // check if we received a beacon frame OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); if ( beacon && beacon->managementType() == "Beacon" ) { QString type; if ( beacon->canIBSS() ) { type = "adhoc"; } else if ( beacon->canESS() ) { type = "managed"; } else { qWarning( "handlePacket(): invalid frame [possibly noise] detected!" ); return; } OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); QString essid = ssid ? ssid->ID() : QString("<unknown>"); OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); int channel = ds ? ds->channel() : -1; OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); displayFoundNetwork( type, channel, essid, header->macAddress2() ); } } void WLANImp::displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ) { qDebug( "found network: <%s>, chn %d, ssid '%s', mac '%s'", (const char*) mode, channel, (const char*) ssid, (const char*) mac.toString() ); QListViewItemIterator it( netView ); while ( it.current() && it.current()->text( col_ssid ) != ssid ) ++it; |