-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 17 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 9 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/protolistview.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 1 |
6 files changed, 45 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index 422826a..590ca92 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -1,845 +1,853 @@ <!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>261</width> <height>280</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Wellenreiter II COnfiguration Dialog</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="0" column="0" > <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Interface</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_2</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Name:</string> </property> </widget> <widget row="1" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Driver:</string> </property> </widget> <widget row="2" column="0" rowspan="1" colspan="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>prismHeader</cstring> </property> <property stdset="1"> <name>text</name> <string>Use additional PRISM header</string> </property> </widget> <widget row="6" column="0" rowspan="1" colspan="4" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox1</cstring> </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>title</name> <string>Scan on channel</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>4</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget row="1" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel6</cstring> </property> <property stdset="1"> <name>text</name> <string>6</string> </property> </widget> <widget row="1" column="3" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel8</cstring> </property> <property stdset="1"> <name>text</name> <string>8</string> </property> </widget> <widget row="0" column="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel2</cstring> </property> <property stdset="1"> <name>text</name> <string>2</string> </property> </widget> <widget row="1" column="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel9</cstring> </property> <property stdset="1"> <name>text</name> <string>9</string> </property> </widget> <widget row="0" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel1</cstring> </property> <property stdset="1"> <name>text</name> <string>1</string> </property> </widget> <widget row="0" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channelAll</cstring> </property> <property stdset="1"> <name>text</name> <string>All</string> </property> </widget> <widget row="2" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel11</cstring> </property> <property stdset="1"> <name>text</name> <string>11</string> </property> </widget> <widget row="2" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel10</cstring> </property> <property stdset="1"> <name>text</name> <string>10</string> </property> </widget> <widget row="1" column="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel7</cstring> </property> <property stdset="1"> <name>text</name> <string>7</string> </property> </widget> <widget row="0" column="3" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel3</cstring> </property> <property stdset="1"> <name>text</name> <string>3</string> </property> </widget> <widget row="1" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel5</cstring> </property> <property stdset="1"> <name>text</name> <string>5</string> </property> </widget> <widget row="0" column="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel4</cstring> </property> <property stdset="1"> <name>text</name> <string>4</string> </property> </widget> <widget row="2" column="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel12</cstring> </property> <property stdset="1"> <name>text</name> <string>12</string> </property> </widget> <widget row="2" column="3" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel13</cstring> </property> <property stdset="1"> <name>text</name> <string>13</string> </property> </widget> <widget row="2" column="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>channel14</cstring> </property> <property stdset="1"> <name>text</name> <string>14</string> </property> </widget> </grid> </widget> <widget row="0" column="1" rowspan="1" colspan="3" > <class>QComboBox</class> <property stdset="1"> <name>name</name> <cstring>interfaceName</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property> <name>whatsThis</name> <string>Choose the interface used for sniffing.</string> </property> </widget> <widget row="1" column="1" rowspan="1" colspan="3" > <class>QComboBox</class> <item> <property> <name>text</name> <string><select></string> </property> </item> <item> <property> <name>text</name> <string>cisco</string> </property> </item> <item> <property> <name>text</name> <string>wlan-ng</string> </property> </item> <item> <property> <name>text</name> <string>hostap</string> </property> </item> <item> <property> <name>text</name> <string>orinoco</string> </property> </item> <item> <property> <name>text</name> <string><manual></string> </property> </item> <item> <property> <name>text</name> <string><file></string> </property> </item> <property stdset="1"> <name>name</name> <cstring>deviceType</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property> <name>whatsThis</name> <string>Choose the type of driver used for sniffing.</string> </property> </widget> <spacer row="3" column="0" > <property> <name>name</name> <cstring>Spacer4</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> <widget row="4" column="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1</cstring> </property> <property stdset="1"> <name>text</name> <string>every</string> </property> </widget> <widget row="4" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>hopChannels</cstring> </property> <property stdset="1"> <name>text</name> <string>Hop Channels</string> </property> <property stdset="1"> <name>checked</name> <bool>true</bool> </property> </widget> <widget row="4" column="3" > <class>QSpinBox</class> <property stdset="1"> <name>name</name> <cstring>hopInterval</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>suffix</name> <string> ms</string> </property> <property stdset="1"> <name>maxValue</name> <number>2000</number> </property> <property stdset="1"> <name>minValue</name> <number>100</number> </property> <property stdset="1"> <name>lineStep</name> <number>100</number> </property> <property stdset="1"> <name>value</name> <number>1000</number> </property> <property> <name>whatsThis</name> <string>Choose the channel hop interval.</string> </property> </widget> <widget row="5" column="0" rowspan="1" colspan="4" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>adaptiveHopping</cstring> </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>text</name> <string>Use Adaptive(TM) Hop Scheme</string> </property> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Capture</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="2" column="0" rowspan="1" colspan="3" > <class>ProtocolListView</class> <property stdset="1"> <name>name</name> <cstring>capturePackets</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>7</vsizetype> </sizepolicy> </property> </widget> <widget row="1" column="0" rowspan="1" colspan="3" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>captureFileName</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>text</name> <string>/tmp/capture</string> </property> </widget> <widget row="0" column="2" > <class>QToolButton</class> <property stdset="1"> <name>name</name> <cstring>getCaptureFileName</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>text</name> <string>Browse</string> </property> </widget> <spacer row="0" column="1" > <property> <name>name</name> <cstring>Spacer2</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</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> <widget row="0" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>writeCaptureFile</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Write Capture Files To</string> </property> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Parse</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="0" column="0" > <class>ProtocolListView</class> <property stdset="1"> <name>name</name> <cstring>parsePackets</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>7</vsizetype> </sizepolicy> </property> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Intrusion</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="1" column="0" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>Link Level</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5</cstring> </property> <property stdset="1"> <name>text</name> <string>Fake Mac:</string> </property> </widget> <widget row="1" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>sendProbeRequests</cstring> </property> <property stdset="1"> <name>text</name> <string>Send proble requests</string> </property> </widget> <widget row="0" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string><automatic></string> </property> </item> <item> <property> <name>text</name> <string>44:44:44:44:44:44</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>fakeMac</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>1</number> </property> <property stdset="1"> <name>autoCompletion</name> <bool>true</bool> </property> </widget> <widget row="2" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>tryToAuthenticate</cstring> </property> <property stdset="1"> <name>text</name> <string>Try to authenticate</string> </property> </widget> </grid> </widget> <widget row="0" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>enableActiveScanning</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>text</name> <string>Enable active scanning</string> </property> </widget> <widget row="2" column="0" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox4</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>IP Level</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="1" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>CheckBox24</cstring> </property> <property stdset="1"> <name>text</name> <string>Request DHCP Address</string> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Fake IP:</string> </property> </widget> <widget row="0" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string>192.168.125.1</string> </property> </item> <item> <property> <name>text</name> <string><automatic></string> </property> </item> <property stdset="1"> <name>name</name> <cstring>fakeIP</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> </widget> </grid> </widget> </grid> </widget> </widget> </grid> </widget> <customwidgets> <customwidget> <class>ProtocolListView</class> <header location="local">protolistview.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>3</hordata> <verdata>3</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 96ebb3f..55a5260 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp @@ -1,99 +1,114 @@ /********************************************************************** ** 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 "mainwindow.h" #ifdef QWS #include <opie2/oapplication.h> #else #include <qapplication.h> #endif #include <qmessagebox.h> #include <qstringlist.h> // ==> OProcess #include <qdir.h> #include <qfileinfo.h> #include <qregexp.h> #include <qtextstream.h> #include <errno.h> #include <signal.h> #include <string.h> #include <unistd.h> int main( int argc, char **argv ) { #ifdef QWS OApplication a( argc, argv, "Wellenreiter II" ); #else QApplication a( argc, argv ); #endif WellenreiterMainWindow* w = new WellenreiterMainWindow(); #ifdef QWS a.showMainWidget( w ); #else a.setMainWidget( w ); + w->setCaption( "Wellenreiter II" ); w->show(); #endif a.processEvents(); // show the window before doing the safety checks int result = -1; // root check if ( getuid() ) { qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::No ) return -1; } // dhcp check - NOT HERE! This really belongs as a static member to OProcess // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... + static int killed = false; + QString line; QDir d = QDir( "/proc" ); QStringList dirs = d.entryList( QDir::Dirs ); QStringList::Iterator it; for ( it = dirs.begin(); it != dirs.end(); ++it ) { //qDebug( "next entry: %s", (const char*) *it ); QFile file( "/proc/"+*it+"/cmdline" ); file.open( IO_ReadOnly ); if ( !file.isOpen() ) continue; QTextStream t( &file ); line = t.readLine(); //qDebug( "cmdline = %s", (const char*) line ); if ( line.contains( "dhcp" ) ) break; } if ( line.contains( "dhcp" ) ) { qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() ); result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" "This can severly limit scanning!\nShould I kill it for you?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::Yes ) { if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) - qWarning( "Wellenreiter: can't kill process (%s)", result, strerror( errno ) ); + qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); + else + killed = true; } } a.exec(); + + if ( killed ) + { + result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); + if ( result == QMessageBox::Yes ) + { + system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); + } + } + delete w; return 0; } diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 7241f7a..3e36f5b 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -1,361 +1,366 @@ /********************************************************************** ** 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 "configwindow.h" #include "logwindow.h" #include "hexwindow.h" #include "mainwindow.h" #include "wellenreiter.h" #include "scanlist.h" #include <qcombobox.h> #include <qdatastream.h> #include <qfile.h> #include <qfileinfo.h> #include <qiconset.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qstatusbar.h> #include <qtextstream.h> #include <qtoolbutton.h> #ifdef QWS #include <qpe/resource.h> #include <opie/ofiledialog.h> #else #include "resource.h" #include <qapplication.h> #include <qfiledialog.h> #endif WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) :QMainWindow( parent, name, f ) { cw = new WellenreiterConfigWindow( this ); mw = new Wellenreiter( this ); mw->setConfigWindow( cw ); setCentralWidget( mw ); // setup application icon #ifndef QWS setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); setIconText( "Wellenreiter/X11" ); #endif // setup icon sets infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); // setup tool buttons startButton = new QToolButton( 0 ); #ifdef QWS startButton->setAutoRaise( true ); #endif startButton->setIconSet( *startIconSet ); startButton->setEnabled( false ); connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); stopButton = new QToolButton( 0 ); #ifdef QWS stopButton->setAutoRaise( true ); #endif stopButton->setIconSet( *stopIconSet ); stopButton->setEnabled( false ); connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); QToolButton* c = new QToolButton( 0 ); #ifdef QWS c->setAutoRaise( true ); #endif c->setIconSet( *infoIconSet ); c->setEnabled( false ); QToolButton* d = new QToolButton( 0 ); #ifdef QWS d->setAutoRaise( true ); #endif d->setIconSet( *settingsIconSet ); connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); // setup menu bar int id; QMenuBar* mb = menuBar(); QPopupMenu* fileSave = new QPopupMenu( mb ); fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); QPopupMenu* fileLoad = new QPopupMenu( mb ); fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); QPopupMenu* file = new QPopupMenu( mb ); file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); id = file->insertItem( tr( "&Load" ), fileLoad ); file->insertItem( tr( "&Save" ), fileSave ); file->insertSeparator(); file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); QPopupMenu* view = new QPopupMenu( mb ); view->insertItem( tr( "&Configure..." ) ); QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); sniffer->setItemEnabled( startID, false ); stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); sniffer->setItemEnabled( stopID, false ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); id = mb->insertItem( tr( "&File" ), file ); //id = mb->insertItem( tr( "&View" ), view ); //mb->setItemEnabled( id, false ); id = mb->insertItem( tr( "&Sniffer" ), sniffer ); - //id = mb->insertItem( tr( "&Demo" ), demo ); - //mb->setItemEnabled( id, true ); + + id = mb->insertItem( tr( "&Demo" ), demo ); + mb->setItemEnabled( id, true ); #ifdef QWS mb->insertItem( startButton ); mb->insertItem( stopButton ); mb->insertItem( c ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); mb->insertItem( c ); mb->insertItem( stopButton ); mb->insertItem( startButton ); #endif updateToolButtonState(); // setup status bar (for now only on X11) #ifndef QWS statusBar()->message( tr( "Ready." ) ); #endif connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; void WellenreiterMainWindow::showConfigure() { qDebug( "show configure..." ); cw->setCaption( tr( "Configure" ) ); #ifdef QWS cw->showMaximized(); #endif int result = cw->exec(); if ( result ) updateToolButtonState(); } void WellenreiterMainWindow::updateToolButtonState() { const QString& interface = cw->interfaceName->currentText(); const int cardtype = cw->driverType(); if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) { startButton->setEnabled( true ); menuBar()->setItemEnabled( startID, true ); } else { startButton->setEnabled( false ); menuBar()->setItemEnabled( startID, false ); } } void WellenreiterMainWindow::changedSniffingState() { startButton->setEnabled( !mw->sniffing ); menuBar()->setItemEnabled( startID, !mw->sniffing ); stopButton->setEnabled( mw->sniffing ); menuBar()->setItemEnabled( stopID, mw->sniffing ); } WellenreiterMainWindow::~WellenreiterMainWindow() { delete infoIconSet; delete settingsIconSet; delete startIconSet; delete stopIconSet; }; void WellenreiterMainWindow::demoAddStations() { + mw = 0; + mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); } QString WellenreiterMainWindow::getFileName( bool save ) { QMap<QString, QStringList> map; map.insert( tr("All"), QStringList() ); QStringList text; text << "text/*"; map.insert( tr("Text"), text ); text << "*"; map.insert( tr("All"), text ); QString str; if ( save ) { #ifdef QWS str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); #else str = QFileDialog::getSaveFileName(); #endif if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) return ""; } else { #ifdef QWS str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); #else str = QFileDialog::getOpenFileName(); #endif if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) return ""; } return str; } void WellenreiterMainWindow::fileSaveLog() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->logWindow()->getLog(); f.close(); qDebug( "Saved log to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving log to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileSaveSession() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QDataStream t( &f ); t << *mw->netView(); f.close(); qDebug( "Saved session to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving session to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileSaveHex() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->hexWindow()->getLog(); f.close(); qDebug( "Saved hex log to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileLoadSession() { QString fname = getFileName( false ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_ReadOnly) ) { QDataStream t( &f ); t >> *mw->netView(); f.close(); qDebug( "Loaded session from file '%s'", (const char*) fname ); } else { qDebug( "Problem loading session from file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileNew() { mw->netView()->clear(); mw->logWindow()->clear(); mw->hexWindow()->clear(); } void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) { if ( mw->isDaemonRunning() ) { QMessageBox::warning( this, "Wellenreiter/Opie", tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); e->ignore(); } else { QMainWindow::closeEvent( e ); } } + + diff --git a/noncore/net/wellenreiter/gui/protolistview.cpp b/noncore/net/wellenreiter/gui/protolistview.cpp index f4b45d0..daca095 100644 --- a/noncore/net/wellenreiter/gui/protolistview.cpp +++ b/noncore/net/wellenreiter/gui/protolistview.cpp @@ -1,124 +1,124 @@ /********************************************************************** ** 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 "protolistview.h" #include <qcheckbox.h> #include <qcombobox.h> #include <qhbox.h> #include <qvbox.h> #include <qpalette.h> #include <qcolor.h> #include <qlabel.h> #include <qframe.h> ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f ) :QScrollView( parent, name, f ) { parse = ( QString( "parsePackets" ) == QString( name ) ); setMargins( 3, 3, 0, 0 ); viewport()->setBackgroundColor( QCheckBox(0).palette().color( QPalette::Active, QColorGroup::Background ) ); vbox = new QVBox( viewport() ); vbox->setSpacing( 1 ); addChild( vbox ); QHBox* hbox = new QHBox( vbox ); hbox->setSpacing( 40 ); new QLabel( tr( "Protocol Family" ), hbox ); new QLabel( tr( "Perform Action" ), hbox ); QFrame* frame = new QFrame( vbox ); frame->setFrameStyle( QFrame::HLine + QFrame::Sunken ); //TODO: hardcoded for now...a protocol database would be nice!? //addProtocol( "Ethernet" ); addProtocol( "Prism" ); //addProtocol( "802.11" ); addProtocol( "802.11 Management" ); addProtocol( "802.11 SSID" ); addProtocol( "802.11 Rates" ); addProtocol( "802.11 CF" ); addProtocol( "802.11 FH" ); addProtocol( "802.11 DS" ); addProtocol( "802.11 Tim" ); addProtocol( "802.11 IBSS" ); addProtocol( "802.11 Challenge" ); addProtocol( "802.11 Data" ); addProtocol( "802.11 LLC" ); addProtocol( "802.11 Data" ); addProtocol( "IP" ); addProtocol( "ARP" ); addProtocol( "UDP" ); addProtocol( "TCP" ); } ProtocolListView::~ProtocolListView() { } void ProtocolListView::addProtocol( const QString& name ) { QHBox* hbox = new QHBox( vbox ); new QCheckBox( name, hbox, (const char*) name ); if ( parse ) { QComboBox* combo = new QComboBox( hbox, (const char*) name ); #ifdef QWS combo->setFixedWidth( 75 ); #endif - combo->insertItem( "Ignore" ); + combo->insertItem( "Pass" ); combo->insertItem( "Discard!" ); combo->insertItem( "TouchSound" ); combo->insertItem( "AlarmSound" ); combo->insertItem( "KeySound" ); combo->insertItem( "LedOn" ); combo->insertItem( "LedOff" ); combo->insertItem( "LogMessage" ); combo->insertItem( "MessageBox" ); } else { QComboBox* combo = new QComboBox( hbox, (const char*) name ); #ifdef QWS combo->setFixedWidth( 75 ); #endif combo->insertItem( "Pass" ); combo->insertItem( "Discard!" ); } } bool ProtocolListView::isProtocolChecked( const QString& name ) { QCheckBox* box = (QCheckBox*) child( (const char*) name ); return ( box && box->isOn() ); } QString ProtocolListView::protocolAction( const QString& name ) { QComboBox* combo = (QComboBox*) child( (const char*) name, "QComboBox" ); if ( combo ) return combo->currentText(); else return "<unknown>"; } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 965f6b0..4257be1 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -22,511 +22,519 @@ #include "configwindow.h" #include "statwindow.h" #include "graphwindow.h" #include "manufacturers.h" #include "protolistview.h" // Opie #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif #ifdef QWS #include <opie2/oapplication.h> #else #include <qapplication.h> #endif #include <opie2/onetwork.h> #include <opie2/opcap.h> // Qt #include <qcheckbox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qmessagebox.h> #include <qobjectlist.h> #include <qregexp.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <qmainwindow.h> // Standard #include <assert.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // // construct manufacturer database // 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::channelHopped(int c) { QString title = "Wellenreiter II -scan- ["; QString left; if ( c > 1 ) left.fill( '.', c-1 ); title.append( left ); title.append( '|' ); if ( c < iface->channels() ) { QString right; right.fill( '.', iface->channels()-c ); title.append( right ); } title.append( "]" ); //title.append( QString().sprintf( " %02d", c ) ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( title ); } void Wellenreiter::handleNotification( OPacket* p ) { QObjectList* l = p->queryList(); QObjectListIt it( *l ); QObject* o; while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->parsePackets->isProtocolChecked( name ) ) { QString action = configwindow->parsePackets->protocolAction( name ); qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); doAction( action, name, p ); } else { qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); } ++it; } } void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) { QString type; if ( beacon->canIBSS() ) { type = "adhoc"; } else if ( beacon->canESS() ) { type = "managed"; } else { qWarning( "Wellenreiter::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" ) ); netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); // update graph window if ( ds ) { OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); if ( prism ) graphwindow->traffic( ds->channel(), prism->signalStrength() ); else graphwindow->traffic( ds->channel(), 95 ); } } void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) { OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); if ( wlan->fromDS() && !wlan->toDS() ) { qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", (const char*) wlan->macAddress3().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress2().toString(true) ); netView()->fromDStraffic( wlan->macAddress3().toString(), wlan->macAddress1().toString(), wlan->macAddress2().toString() ); } else if ( !wlan->fromDS() && wlan->toDS() ) { qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", (const char*) wlan->macAddress2().toString(true), (const char*) wlan->macAddress3().toString(true), (const char*) wlan->macAddress1().toString(true) ); netView()->toDStraffic( wlan->macAddress2().toString(), wlan->macAddress3().toString(), wlan->macAddress1().toString() ); } else if ( wlan->fromDS() && wlan->toDS() ) { qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", (const char*) wlan->macAddress4().toString(true), (const char*) wlan->macAddress3().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress2().toString(true) ); netView()->WDStraffic( wlan->macAddress4().toString(), wlan->macAddress3().toString(), wlan->macAddress1().toString(), wlan->macAddress2().toString() ); } else { qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", (const char*) wlan->macAddress2().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress3().toString(true) ); netView()->IBSStraffic( wlan->macAddress2().toString(), wlan->macAddress1().toString(), wlan->macAddress3().toString() ); } OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); if ( arp ) { qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); if ( arp->type() == "REQUEST" ) { netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); } else if ( arp->type() == "REPLY" ) { netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); netView()->identify( arp->targetMacAddress().toString(), arp->targetIPV4Address().toString() ); } } OIPPacket* ip = (OIPPacket*) p->child( "IP" ); if ( ip ) { qDebug( "Received IP packet." ); } } QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) { if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) return 0; return p->child( protocol ); } bool Wellenreiter::checkDumpPacket( OPacket* p ) { // go through all child packets and see if one is inside the child hierarchy for p // if so, do what the user requested (protocolAction), e.g. pass or discard if ( !configwindow->writeCaptureFile->isOn() ) return false; QObjectList* l = p->queryList(); QObjectListIt it( *l ); QObject* o; while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->capturePackets->isProtocolChecked( name ) ) { QString action = configwindow->capturePackets->protocolAction( name ); qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); if ( action == "Discard" ) { logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); return false; } } else { qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); } ++it; } return true; } void Wellenreiter::receivePacket( OPacket* p ) { hexWindow()->log( p->dump( 8 ) ); if ( checkDumpPacket( p ) ) { pcap->dump( p ); } // check if we received a beacon frame OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); if ( beacon && beacon->managementType() == "Beacon" ) { handleBeacon( p, beacon ); return; } //TODO: WEP check here // check for a data frame OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); if ( data ) { handleData( p, data ); } handleNotification( p ); } void Wellenreiter::stopClicked() { if ( iface ) { disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); iface->setChannelHopping(); // stop hopping channels } else killTimers(); pcap->close(); sniffing = false; if ( iface ) { // switch off monitor mode iface->setMonitorMode( false ); // switch off promisc flag iface->setPromiscuousMode( false ); system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess } logwindow->log( "(i) Stopped Scanning." ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); // message the user QMessageBox::information( this, "Wellenreiter II", tr( "Your wireless card\nshould now be usable again." ) ); sniffing = false; emit( stoppedSniffing() ); // print out statistics for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) statwindow->updateCounter( it.key(), it.data() ); } void Wellenreiter::startClicked() { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->driverType(); const int interval = configwindow->hoppingInterval(); if ( ( interface == "" ) || ( cardtype == 0 ) ) { QMessageBox::information( this, "Wellenreiter II", tr( "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 + // bring device UP + iface->setUp( true ); + if ( !iface->isUp() ) + { + QMessageBox::warning( this, "Wellenreiter II", + tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); + return; + } + // set monitor mode bool usePrism = configwindow->usePrismHeader(); switch ( cardtype ) { case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; default: assert( 0 ); // shouldn't reach this } // switch device into monitor mode if ( cardtype < DEVTYPE_FILE ) { if ( cardtype != DEVTYPE_MANUAL ) iface->setMonitorMode( true ); if ( !iface->monitorMode() ) { QMessageBox::warning( this, "Wellenreiter II", - tr( "Can't set device into monitor mode." ) ); + tr( "Can't set interface '%1' into monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); return; } } // open pcap and start sniffing if ( cardtype != DEVTYPE_FILE ) { pcap->open( interface ); if ( configwindow->writeCaptureFile->isOn() ) { QString dumpname( configwindow->captureFileName->text() ); dumpname.append( '-' ); dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); dumpname.append( ".wellenreiter" ); pcap->openDumpFile( dumpname ); } else { pcap->open( interface ); } } else { pcap->open( QFile( interface ) ); } if ( !pcap->isOpen() ) { QMessageBox::warning( this, "Wellenreiter II", - tr( "Can't open packet capturer:\n" ) + QString(strerror( errno ) )); + tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); return; } // set capturer to non-blocking mode pcap->setBlocking( false ); // start channel hopper if ( cardtype != DEVTYPE_FILE ) iface->setChannelHopping( 1000 ); //use interval from config window if ( cardtype != DEVTYPE_FILE ) { // connect socket notifier and start channel hopper connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); } else { // start timer for reading packets startTimer( 100 ); } logwindow->log( "(i) Started Scanning." ); sniffing = true; emit( startedSniffing() ); if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title else { assert( parent() ); ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); } } void Wellenreiter::timerEvent( QTimerEvent* ) { qDebug( "Wellenreiter::timerEvent()" ); OPacket* p = pcap->next(); if ( !p ) // no more packets available { stopClicked(); } else { receivePacket( p ); delete p; } } void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) { if ( action == "TouchSound" ) ODevice::inst()->touchSound(); else if ( action == "AlarmSound" ) ODevice::inst()->alarmSound(); else if ( action == "KeySound" ) ODevice::inst()->keySound(); else if ( action == "LedOn" ) ODevice::inst()->setLedState( Led_Mail, Led_On ); else if ( action == "LedOff" ) ODevice::inst()->setLedState( Led_Mail, Led_Off ); else if ( action == "LogMessage" ) logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); else if ( action == "MessageBox" ) QMessageBox::information ( this, "Notification!", QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); } + diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 37e692c..d776492 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -1,90 +1,91 @@ /********************************************************************** ** 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 WELLENREITER_H #define WELLENREITER_H #include "wellenreiterbase.h" #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif class QTimerEvent; class QPixmap; class OPacket; class OWaveLanManagementPacket; class OWaveLanDataPacket; class OPacketCapturer; class OWirelessNetworkInterface; class ManufacturerDB; class WellenreiterConfigWindow; class MLogWindow; class MHexWindow; class Wellenreiter : public WellenreiterBase { Q_OBJECT public: Wellenreiter( QWidget* parent = 0 ); ~Wellenreiter(); void setConfigWindow( WellenreiterConfigWindow* cw ); MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; MHexWindow* hexWindow() const { return hexwindow; }; bool isDaemonRunning() const { return sniffing; }; + public: bool sniffing; protected: virtual void timerEvent( QTimerEvent* ); public slots: void channelHopped(int); void receivePacket(OPacket*); void startClicked(); void stopClicked(); signals: void startedSniffing(); void stoppedSniffing(); private: void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); void handleData( OPacket* p, OWaveLanDataPacket* data ); void handleNotification( OPacket* p ); void doAction( const QString& action, const QString& protocol, OPacket* p ); QObject* childIfToParse( OPacket* p, const QString& protocol ); bool checkDumpPacket( OPacket* p ); private: #ifdef QWS OSystem _system; // Opie Operating System identifier #endif OWirelessNetworkInterface* iface; OPacketCapturer* pcap; ManufacturerDB* manufacturerdb; WellenreiterConfigWindow* configwindow; //void readConfig(); //void writeConfig(); }; #endif |