-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 155 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 32 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 24 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 16 |
6 files changed, 166 insertions, 72 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index fa727f9..dda7ba0 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -1,79 +1,79 @@ <!DOCTYPE UI><UI> <class>WellenreiterConfigBase</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>WellenreiterConfigBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>212</width> - <height>267</height> + <width>220</width> + <height>306</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Form1</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> - <number>4</number> + <number>3</number> </property> <property stdset="1"> <name>spacing</name> <number>1</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout5</cstring> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>4</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>Sniffer</string> </property> </widget> <widget> <class>Line</class> <property stdset="1"> <name>name</name> <cstring>Line9</cstring> </property> <property stdset="1"> @@ -280,136 +280,181 @@ <property stdset="1"> <name>name</name> <cstring>Layout6</cstring> </property> <property> <name>layoutSpacing</name> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3_2_2</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>4</hsizetype> <vsizetype>1</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>GUI</string> </property> </widget> <widget> <class>Line</class> <property stdset="1"> <name>name</name> <cstring>Line9_2</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> </widget> </hbox> </widget> <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>groupNetworks</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Group Detected Networks</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>enableActivity</cstring> + </property> + <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> + <name>text</name> + <string>Enable Activity Display</string> + </property> + </widget> + <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout5</cstring> </property> - <property> - <name>layoutSpacing</name> - </property> - <vbox> + <grid> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>-1</number> + <number>6</number> </property> - <widget> - <class>QCheckBox</class> + <widget row="0" column="1" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>groupNetworks</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> - <string>Group Detected Networks</string> + <string>sound on new net</string> </property> </widget> - <widget> - <class>QCheckBox</class> + <widget row="1" column="0" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Ignore</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Touch</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Key</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Alarm</string> + </property> + </item> <property stdset="1"> <name>name</name> - <cstring>enableActivity</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> - <property stdset="1"> - <name>text</name> - <string>Enable Activity Display</string> + <cstring>beaconSound</cstring> </property> </widget> - <widget> - <class>QCheckBox</class> + <widget row="0" column="0" > + <class>QComboBox</class> + <item> + <property> + <name>text</name> + <string>Ignore</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Touch</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Key</string> + </property> + </item> + <item> + <property> + <name>text</name> + <string>Alarm</string> + </property> + </item> <property stdset="1"> <name>name</name> - <cstring>beepOnFound</cstring> + <cstring>netSound</cstring> </property> + </widget> + <widget row="1" column="1" > + <class>QLabel</class> <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <name>name</name> + <cstring>TextLabel1_3</cstring> </property> <property stdset="1"> <name>text</name> - <string>Beep on new network</string> + <string>sound on beacon</string> </property> </widget> - </vbox> + </grid> </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer2</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> </vbox> </widget> </UI> diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 6dd862f..e287b47 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -1,72 +1,100 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ /* LOCAL */ #include "configwindow.h" /* QT */ -#include <qmap.h> #include <qcombobox.h> +#include <qfile.h> +#include <qlayout.h> +#include <qmap.h> #include <qpushbutton.h> #include <qspinbox.h> -#include <qlayout.h> +#include <qtextstream.h> /* OPIE */ #include <opie2/onetwork.h> +WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; + WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { _devicetype[ "cisco" ] = 1; _devicetype[ "wlan-ng" ] = 2; _devicetype[ "hostap" ] = 3; _devicetype[ "orinoco" ] = 4; _devicetype[ "<manual>" ] = 5; // gather possible interface names from ONetwork ONetwork* net = ONetwork::instance(); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { if ( it.current()->isWireless() ) interfaceName->insertItem( it.current()->name() ); ++it; } + // try to guess device type + QFile m( "/proc/modules" ); + if ( m.open( IO_ReadOnly ) ) + { + int devicetype(0); + QString line; + QTextStream modules( &m ); + while( !modules.atEnd() && !devicetype ) + { + modules >> line; + if ( line.contains( "cisco" ) ) devicetype = 1; + else if ( line.contains( "wlan" ) ) devicetype = 2; + else if ( line.contains( "hostap" ) ) devicetype = 3; + else if ( line.contains( "orinoco" ) ) devicetype = 4; + } + if ( devicetype ) + { + deviceType->setCurrentItem( devicetype ); + qDebug( "Wellenreiter: guessed device type to be %d", devicetype ); + } + } + #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here QPushButton* okButton = new QPushButton( "ok", this ); okButton->show(); Layout5_2->addWidget( okButton ); //FIXME: rename this in configbase.ui connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); #endif + + WellenreiterConfigWindow::_instance = this; }; int WellenreiterConfigWindow::daemonDeviceType() { QString name = deviceType->currentText(); if ( _devicetype.contains( name ) ) { return _devicetype[name]; } else { return 0; } }; int WellenreiterConfigWindow::daemonHopInterval() { return hopInterval->cleanText().toInt(); } diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index c627901..5fd0327 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h @@ -1,36 +1,44 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef WELLENREITERCONFIGWINDOW_H #define WELLENREITERCONFIGWINDOW_H #include "configbase.h" #include <qmap.h> +#include <qcombobox.h> +#include <qstring.h> + +class WellenreiterConfigWindow; class WellenreiterConfigWindow : public WellenreiterConfigBase { public: WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); int daemonDeviceType(); int daemonHopInterval(); + const QString soundOnNetwork() const { return netSound->currentText(); }; + const QString soundOnBeacon() const { return beaconSound->currentText(); }; + static WellenreiterConfigWindow* instance() { return _instance; }; protected: QMap<QString, int> _devicetype; + static WellenreiterConfigWindow* _instance; }; #endif diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index be1245e..a006a3c 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -1,70 +1,76 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "scanlist.h" +#include "configwindow.h" #include <assert.h> #include "manufacturers.h" #include <qdatetime.h> #include <qtextstream.h> +#ifdef QWS +#include <opie/odevice.h> +using namespace Opie; +#endif + MScanListView::MScanListView( QWidget* parent, const char* name ) :OListView( parent, name ), _manufacturerdb( 0 ) { setFrameShape( QListView::StyledPanel ); setFrameShadow( QListView::Sunken ); addColumn( tr( "Net/Station" ) ); setColumnAlignment( 0, AlignLeft || AlignVCenter ); addColumn( tr( "B" ) ); setColumnAlignment( 1, AlignCenter ); addColumn( tr( "AP" ) ); setColumnAlignment( 2, AlignCenter ); addColumn( tr( "Chn" ) ); setColumnAlignment( 3, AlignCenter ); addColumn( tr( "W" ) ); setColumnAlignment( 4, AlignCenter ); addColumn( tr( "T" ) ); setColumnAlignment( 5, AlignCenter ); addColumn( tr( "Manufacturer" ) ); setColumnAlignment( 6, AlignCenter ); addColumn( tr( "First Seen" ) ); setColumnAlignment( 7, AlignCenter ); addColumn( tr( "Last Seen" ) ); setColumnAlignment( 8, AlignCenter ); setRootIsDecorated( true ); setAllColumnsShowFocus( true ); }; MScanListView::~MScanListView() { }; OListViewItem* MScanListView::childFactory() { return new MScanListItem( this ); } void MScanListView::serializeTo( QDataStream& s) const { qDebug( "serializing MScanListView" ); OListView::serializeTo( s ); } void MScanListView::serializeFrom( QDataStream& s) { qDebug( "serializing MScanListView" ); OListView::serializeFrom( s ); @@ -97,192 +103,208 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo item = static_cast<MScanListItem*> ( item->itemBelow() ); } if ( item ) { // animate the item /* const QPixmap* pixmap = item->pixmap( 0 ); const QPixmap* nextpixmap = ani2; if ( pixmap == ani1 ) nextpixmap = ani2; else if ( pixmap == ani2 ) nextpixmap = ani3; else if ( pixmap == ani3 ) nextpixmap = ani4; else if ( pixmap == ani4 ) nextpixmap = ani1; item->setPixmap( 0, *nextpixmap ); */ //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); // we have already seen this net, check all childs if MAC exists network = item; item = static_cast<MScanListItem*> ( item->firstChild() ); assert( item ); // this shouldn't fail while ( item && ( item->text( 2 ) != macaddr ) ) { qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); item = static_cast<MScanListItem*> ( item->itemBelow() ); } if ( item ) { // we have already seen this item, it's a dupe #ifdef DEBUG qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); #endif item->receivedBeacon(); return; } } else { s.sprintf( "(i) new network: '%s'", (const char*) essid ); - network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); } // insert new station as child from network // no essid to reduce clutter, maybe later we have a nick or stationname to display!? qDebug( "inserting new station %s", (const char*) macaddr ); MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); if ( _manufacturerdb ) station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); if ( type == "managed" ) { s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); } else { s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); } } #ifdef QWS #include <qpe/resource.h> #else #include "resource.h" #endif const int col_type = 0; const int col_essid = 0; const int col_sig = 1; const int col_ap = 2; const int col_channel = 3; const int col_wep = 4; const int col_traffic = 5; const int col_manuf = 6; const int col_firstseen = 7; const int col_lastseen = 8; MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), _channel( channel ), _signal( signal ), _beacons( 0 ) { qDebug( "creating scanlist item" ); + if ( WellenreiterConfigWindow::instance() && type == "networks" ) + playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); decorateItem( type, essid, macaddr, wep, channel, signal ); } MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) { qDebug( "creating scanlist item" ); decorateItem( type, essid, macaddr, wep, channel, signal ); } OListViewItem* MScanListItem::childFactory() { return new MScanListItem( this ); } void MScanListItem::serializeTo( QDataStream& s ) const { qDebug( "serializing MScanListItem" ); OListViewItem::serializeTo( s ); s << _type; s << (Q_UINT8) _wep; } void MScanListItem::serializeFrom( QDataStream& s ) { qDebug( "serializing MScanListItem" ); OListViewItem::serializeFrom( s ); s >> _type; s >> (Q_UINT8) _wep; QString name; name.sprintf( "wellenreiter/%s", (const char*) _type ); setPixmap( col_type, Resource::loadPixmap( name ) ); if ( _wep ) setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! listView()->triggerUpdate(); } void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) { qDebug( "decorating scanlist item %s / %s / %s [%d]", (const char*) type, (const char*) essid, (const char*) macaddr, channel ); // set icon for managed or adhoc mode QString name; name.sprintf( "wellenreiter/%s", (const char*) type ); setPixmap( col_type, Resource::loadPixmap( name ) ); // set icon for wep (wireless encryption protocol) if ( wep ) setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! // set channel and signal text if ( signal != -1 ) setText( col_sig, QString::number( signal ) ); if ( channel != -1 ) setText( col_channel, QString::number( channel ) ); setText( col_firstseen, QTime::currentTime().toString() ); //setText( col_lastseen, QTime::currentTime().toString() ); listView()->triggerUpdate(); this->type = type; _type = type; _essid = essid; _macaddr = macaddr; _channel = channel; _beacons = 0; _signal = 0; } + void MScanListItem::setManufacturer( const QString& manufacturer ) { setText( col_manuf, manufacturer ); } + +void MScanListItem::playSound( const QString& sound ) const +{ + #ifdef QWS + if ( sound == "Ignore" ) return; + else if ( sound == "Touch" ) ODevice::inst()->touchSound(); + else if ( sound == "Key" ) ODevice::inst()->keySound(); + else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); + #endif +} + + void MScanListItem::receivedBeacon() { _beacons++; #ifdef DEBUG qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); #endif setText( col_sig, QString::number( _beacons ) ); setText( col_lastseen, QTime::currentTime().toString() ); + if ( WellenreiterConfigWindow::instance() ) + playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); } diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index da9369f..01db172 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -46,76 +46,79 @@ class MScanListView: public OListView }; //****************************** MScanListItem **************************************************************** class MScanListItem: public OListViewItem { public: MScanListItem::MScanListItem( QListView* parent, QString type = "unknown", QString essid = "unknown", QString macaddr = "unknown", bool wep = false, int channel = 0, int signal = 0 ); MScanListItem::MScanListItem( QListViewItem* parent, QString type = "unknown", QString essid = "unknown", QString macaddr = "unknown", bool wep = false, int channel = 0, int signal = 0 ); protected: virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); public: QString type; public: //const QString& type() { return _type; }; const QString& essid() { return _essid; }; const QString& macaddr() { return _macaddr; }; bool wep() { return _wep; }; int channel() { return _channel; }; int signal() { return _signal; }; int beacons() { return _beacons; }; void setSignal( int signal ) { /* TODO */ }; void receivedBeacon(); void setManufacturer( const QString& manufacturer ); virtual OListViewItem* childFactory(); virtual void serializeTo( QDataStream& s ) const; virtual void serializeFrom( QDataStream& s ); + protected: + void playSound( const QString& ) const; + private: QString _type; QString _essid; QString _macaddr; bool _wep; int _channel; int _signal; int _beacons; }; //****************************** MScanListViewFactory **************************************************************** /* class MScanListViewFactory : public OListViewFactory { public: virtual QListView* listViewFactory(); virtual QListViewItem* listViewItemFactory( QListView* lv ); virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); } */ #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 41ffdcc..d1dd73a 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -65,162 +65,150 @@ Wellenreiter::Wellenreiter( QWidget* parent ) // QString manufile; #ifdef QWS manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); #else manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); #endif manufacturerdb = new ManufacturerDB( manufile ); logwindow->log( "(i) Wellenreiter has been started." ); // // detect operating system // #ifdef QWS QString sys; sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); _system = ODevice::inst()->system(); logwindow->log( sys ); #endif // setup GUI netview->setColumnWidthMode( 1, QListView::Manual ); if ( manufacturerdb ) netview->setManufacturerDB( manufacturerdb ); pcap = new OPacketCapturer(); } Wellenreiter::~Wellenreiter() { // no need to delete child widgets, Qt does it all for us delete manufacturerdb; delete pcap; } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) { configwindow = cw; } void Wellenreiter::receivePacket(OPacket* p) { - logwindow->log( "(d) Received data from daemon" ); - //TODO - // check if we received a beacon frame // static_cast is justified here OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); if ( !beacon ) return; QString type; //FIXME: Can stations in ESS mode can be distinguished from APs? //FIXME: Apparently yes, but not by listening to beacons, because //FIXME: they simply don't send beacons in infrastructure mode. //FIXME: so we also have to listen to data packets if ( beacon->canIBSS() ) type = "adhoc"; else type = "managed"; 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" ) ); netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); } void Wellenreiter::startStopClicked() { if ( sniffing ) { disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); iface->setChannelHopping(); // stop hopping channels pcap->close(); sniffing = false; #ifdef QWS oApp->setTitle(); #else qApp->mainWidget()->setCaption( "Wellenreiter II" ); #endif // get interface name from config window const QString& interface = configwindow->interfaceName->currentText(); ONetwork* net = ONetwork::instance(); iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // switch off monitor mode iface->setMonitorMode( false ); // switch off promisc flag iface->setPromiscuousMode( false ); - //TODO: Display "please wait..." (use owait?) - - /* - - QString cmdline; - cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); - system( cmdline ); //FIXME: Use OProcess - - */ + system( "cardctl reset; sleep 1; dhclient; udhcpc" ); //FIXME: Use OProcess // message the user - - //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); + QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); } else { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->daemonDeviceType(); const int interval = configwindow->daemonHopInterval(); if ( ( interface == "" ) || ( cardtype == 0 ) ) { QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); return; } // configure device ONetwork* net = ONetwork::instance(); iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // set monitor mode switch ( cardtype ) { case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; default: assert( 0 ); // shouldn't happen } iface->setMonitorMode( true ); // open pcap and start sniffing pcap->open( interface ); if ( !pcap->isOpen() ) { QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); return; } // set capturer to non-blocking mode pcap->setBlocking( false ); // start channel hopper iface->setChannelHopping( 1000 ); //use interval from config window |