-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 149 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/graphwindow.cpp | 50 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/graphwindow.h | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/protolistview.cpp | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/protolistview.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 64 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 3 |
7 files changed, 198 insertions, 94 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index 7504ebc..422826a 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -1,223 +1,173 @@ <!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>209</width> - <height>287</height> + <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="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="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="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" > + <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>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"> @@ -359,188 +309,253 @@ <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> - <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> <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>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> @@ -804,66 +819,72 @@ </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> <connections> <connection> <sender>hopChannels</sender> <signal>toggled(bool)</signal> <receiver>hopInterval</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>hopChannels</sender> <signal>toggled(bool)</signal> <receiver>TextLabel1</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>enableActiveScanning</sender> <signal>toggled(bool)</signal> <receiver>GroupBox3</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>enableActiveScanning</sender> <signal>toggled(bool)</signal> <receiver>GroupBox4</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>getCaptureFileName</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>captureFileName</receiver> <slot>setEnabled(bool)</slot> </connection> + <connection> + <sender>writeCaptureFile</sender> + <signal>toggled(bool)</signal> + <receiver>capturePackets</receiver> + <slot>setEnabled(bool)</slot> + </connection> </connections> </UI> diff --git a/noncore/net/wellenreiter/gui/graphwindow.cpp b/noncore/net/wellenreiter/gui/graphwindow.cpp index 7e1f378..b116b91 100644 --- a/noncore/net/wellenreiter/gui/graphwindow.cpp +++ b/noncore/net/wellenreiter/gui/graphwindow.cpp @@ -1,159 +1,187 @@ /********************************************************************** ** 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 "graphwindow.h" #include <qpainter.h> #include <qpixmap.h> #include <qtimer.h> MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const char* name, WFlags f) :QWidget( parent, name,f ), _channels( channels ) { _values = new int[_channels]; _dirty = new bool[_channels]; for ( int i = 0; i < channels; ++i ) { _values[i] = 0; _dirty[i] = true; } - // we draw everything alone + // we draw everything on our own setBackgroundMode( QWidget::NoBackground ); } +void MFrequencySpectrum::drawTopLine( QPainter* p, int x, int y, int width, const QColor& c ) +{ + p->setPen( c.light() ); + p->drawLine( x, y, x+width-1, y ); +} + + +void MFrequencySpectrum::drawBottomLine( QPainter* p, int x, int y, int width, const QColor& c ) +{ + p->setPen( c.dark() ); + p->drawLine( x, y, x+width-1, y ); +} + + void MFrequencySpectrum::drawLine( QPainter* p, int x, int y, int width, const QColor& c ) { p->setPen( c.light() ); p->drawPoint( x++, y ); p->setPen( c ); p->drawLine( x, y, x+width-2, y ); p->setPen( c.dark() ); p->drawPoint( x+width-1, y ); } void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight ) { int h1 = 133; int h2 = 0; int s1 = 200; int s2 = 255; int v1 = 140; int v2 = 255; /*int h1 = 196; int h2 = 194; int s1 = 85; int s2 = 15; int v1 = 95; int v2 = 237;*/ QColor c( 120, 60, 200 ); for ( int i = 0; i < height; ++i ) { int h = (h2-h1)*i/maxheight + h1; int s = (s2-s1)*i/maxheight + s1; int v = (v2-v1)*i/maxheight + v1; - drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); + if ( i == 0 ) + drawBottomLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); + else if ( i == height-1 ) + drawTopLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); + else + drawLine( p, x, y-i, width, QColor( h,s,v, QColor::Hsv ) ); } - - /*for ( int i = height; i < maxheight; ++i ) - drawLine( p, x, y-i, width, QColor( 47, 68, 76 ) );*/ - } void MFrequencySpectrum::paintEvent( QPaintEvent* e ) { QPixmap pm( size() ); QPainter p; p.begin( &pm ); p.drawTiledPixmap( 0, 0, size().width(), size().height(), QPixmap( (const char**) &background ) ); int xmargin = 5; int ymargin = 2; int y = size().height() - 2 * ymargin; int x = 0; int width = ( size().width() - 2 * xmargin ) / _channels; for ( int i = 0; i < _channels; ++i ) { if ( _dirty[i] ) { drawBar( &p, xmargin + x, y - ymargin, width-3, _values[i]*y/100, y ); _dirty[i] = false; } x+= width; } p.end(); bitBlt( this, 0, 0, &pm ); } +void MFrequencySpectrum::mousePressEvent( QMouseEvent* e ) +{ + int xmargin = 5; + int ymargin = 2; + int y = size().height() - 2 * ymargin; + int x = 0; + int width = ( size().width() - 2 * xmargin ) / _channels; + + QPoint pos = e->pos(); + int channel = ( pos.x()-xmargin ) / width; + int height = 100 - ( pos.y()-ymargin )*100/y; + if ( channel < 15 ) _values[channel] = height; + +} + + Legende::Legende( int channels, QWidget* parent, const char* name, WFlags f ) :QFrame( parent, name, f ), _channels( channels ) { setLineWidth( 2 ); setFrameStyle( Panel + Sunken ); setFixedHeight( 16 ); } void Legende::drawContents( QPainter* p ) { int xmargin = 5; int ymargin = 2; int x = 0; int width = ( contentsRect().width() - 2 * xmargin ) / _channels; for ( int i = 0; i < _channels; ++i ) p->drawText( xmargin + (width*i), 12, QString().sprintf( "%02d", i+1 ) ); } MGraphWindow::MGraphWindow( QWidget* parent, const char* name, WFlags f ) :QVBox( parent, name, f ) { spectrum = new MFrequencySpectrum( 14, this ); legende = new Legende( 14, this ); - startTimer( 50 ); //FIXME: tweak - - //testGraph(); - + startTimer( 50 ); }; void MGraphWindow::testGraph() { static int i = 0; spectrum->setValue( i++, 100 ); if ( i == 14 ) i = 0; QTimer::singleShot( 2000, this, SLOT( testGraph() ) ); } void MGraphWindow::timerEvent( QTimerEvent* e ) { for ( int i = 0; i < 14; i++ ) { - spectrum->decrease( i, 1 ); //TODO: make this customizable? + spectrum->decrease( i, 1 ); } spectrum->repaint(); } void MGraphWindow::traffic( int channel, int signal ) { spectrum->setValue( channel-1, signal ); } diff --git a/noncore/net/wellenreiter/gui/graphwindow.h b/noncore/net/wellenreiter/gui/graphwindow.h index 4050065..1e00ae7 100644 --- a/noncore/net/wellenreiter/gui/graphwindow.h +++ b/noncore/net/wellenreiter/gui/graphwindow.h @@ -1,111 +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. ** **********************************************************************/ #ifndef GRAPHWINDOW_H #define GRAPHWINDOW_H #include <qwidget.h> #include <qvbox.h> class MFrequencySpectrum : public QWidget { public: MFrequencySpectrum( int channels, QWidget* parent = 0, const char* name = "MFrequencySpectrum", WFlags f = 0 ); int value( int channel ) const { return _values[channel]; }; void setValue( int channel, int value ) { if ( value > _values[channel] ) { _values[channel] = value; _dirty[channel] = true; } }; void decrease( int channel, int amount ) { if ( _values[channel] >= amount ) { _values[channel] -= amount; _dirty[channel] = true; } }; protected: virtual void paintEvent( QPaintEvent* ); + virtual void mousePressEvent( QMouseEvent* ); void drawLine( QPainter* p, int x, int y, int width, const QColor& c ); + void drawTopLine( QPainter* p, int x, int y, int width, const QColor& c ); + void drawBottomLine( QPainter* p, int x, int y, int width, const QColor& c ); void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int height, int maxheight ); private: int _channels; int* _values; bool* _dirty; }; class Legende : public QFrame { public: Legende( int channels, QWidget* parent = 0, const char* name = "Legende", WFlags f = 0 ); protected: virtual void drawContents( QPainter* ); private: int _channels; }; class MGraphWindow : public QVBox { Q_OBJECT public: MGraphWindow( QWidget* parent = 0, const char* name = "MGraphWindow", WFlags f = 0 ); void traffic( int channel, int signal ); protected: virtual void timerEvent( QTimerEvent* e ); protected slots: virtual void testGraph(); protected: MFrequencySpectrum* spectrum; Legende* legende; }; /* XPM */ static char * background[] = { "16 16 6 1", " c None", ". c #52676E", "+ c #3F545B", "@ c #394E56", "# c #2F454C", "$ c #364B52", ".+++++++++++++++", "@###############", "+$$$$$$$$$$$$$$$", "@###############", "+$$$$$$$$$$$$$$$", "@###############", "+$$$$$$$$$$$$$$$", "@###############", "+$$$$$$$$$$$$$$$", "@###############", "+$$$$$$$$$$$$$$$", "@###############", "+$$$$$$$$$$$$$$$", diff --git a/noncore/net/wellenreiter/gui/protolistview.cpp b/noncore/net/wellenreiter/gui/protolistview.cpp index d4b0dfe..f4b45d0 100644 --- a/noncore/net/wellenreiter/gui/protolistview.cpp +++ b/noncore/net/wellenreiter/gui/protolistview.cpp @@ -1,117 +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 ) { - actions = ( QString( "parsePackets" ) == QString( name ) ); + 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 ); - if ( actions ) new QLabel( tr( "Perform Action" ), 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 ( actions ) + if ( parse ) { QComboBox* combo = new QComboBox( hbox, (const char*) name ); #ifdef QWS combo->setFixedWidth( 75 ); #endif combo->insertItem( "Ignore" ); + 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 ) { - //QObject * child ( const char * objName, const char * inheritsClass = 0, - // bool recursiveSearch = TRUE ) - QComboBox* combo = (QComboBox*) child( (const char*) name, "QComboBox" ); if ( combo ) return combo->currentText(); else return "<unknown>"; } diff --git a/noncore/net/wellenreiter/gui/protolistview.h b/noncore/net/wellenreiter/gui/protolistview.h index 166b648..8b460cb 100644 --- a/noncore/net/wellenreiter/gui/protolistview.h +++ b/noncore/net/wellenreiter/gui/protolistview.h @@ -1,47 +1,45 @@ /********************************************************************** ** 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 PROTOLISTVIEW_H #define PROTOLISTVIEW_H #include <qscrollview.h> #include <qdict.h> -//#include <qcheckbox.h> -//#include <qcombobox.h> class QCheckBox; class QComboBox; class QVBox; class ProtocolListView : public QScrollView { public: ProtocolListView( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); virtual ~ProtocolListView(); bool isProtocolChecked( const QString& name ); QString protocolAction( const QString& name ); protected: virtual void addProtocol( const QString& name ); private: QVBox* vbox; - bool actions; + bool parse; }; #endif // PROTOLISTVIEW_H diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index edf7dcf..965f6b0 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -90,378 +90,424 @@ Wellenreiter::Wellenreiter( QWidget* parent ) 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( "action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); + 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.", (const char*) name ); + 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* childIfToParse( OPacket* p, const QString& protocol ) +QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) { - //FIXME: Implement + 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 ) ); - handleNotification( p ); + if ( checkDumpPacket( p ) ) + { + pcap->dump( p ); + } // check if we received a beacon frame - OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); + 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*>( p->child( "802.11 Data" ) ); + 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 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." ) ); return; } } // open pcap and start sniffing if ( cardtype != DEVTYPE_FILE ) { - if ( configwindow->writeCaptureFile->isEnabled() ) //FIXME: bug!? + 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->open( interface, dumpname ); + 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 ) )); 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; } } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index e227a24..37e692c 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -8,82 +8,83 @@ ** 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; }; 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 |