author | mickeyl <mickeyl> | 2003-05-08 09:12:24 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-08 09:12:24 (UTC) |
commit | 215b9cbd3d1316887674b92268610c8f63a5caaf (patch) (side-by-side diff) | |
tree | 92f77edcb0f997cf180d545dd78a40fe23a44169 | |
parent | eb1dba5550e63ab7b915d55048175e2992ab5447 (diff) | |
download | opie-215b9cbd3d1316887674b92268610c8f63a5caaf.zip opie-215b9cbd3d1316887674b92268610c8f63a5caaf.tar.gz opie-215b9cbd3d1316887674b92268610c8f63a5caaf.tar.bz2 |
add fine tuning of parsing process - the semantics is not yet set in stone however...
-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 @@ -13,4 +13,4 @@ <y>0</y> - <width>209</width> - <height>287</height> + <width>261</width> + <height>280</height> </rect> @@ -97,17 +97,2 @@ </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" > @@ -123,38 +108,3 @@ </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> @@ -422,13 +372,2 @@ </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" > @@ -454,2 +393,74 @@ </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> @@ -482,2 +493,6 @@ <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>sizePolicy</name> @@ -867,2 +882,8 @@ </connection> + <connection> + <sender>writeCaptureFile</sender> + <signal>toggled(bool)</signal> + <receiver>capturePackets</receiver> + <slot>setEnabled(bool)</slot> + </connection> </connections> 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 @@ -31,3 +31,3 @@ MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const cha - // we draw everything alone + // we draw everything on our own setBackgroundMode( QWidget::NoBackground ); @@ -36,2 +36,16 @@ MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const cha +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 ) @@ -63,8 +77,9 @@ void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int heig 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 ) );*/ - } @@ -100,2 +115,18 @@ void MFrequencySpectrum::paintEvent( QPaintEvent* e ) +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 ) @@ -127,6 +158,3 @@ MGraphWindow::MGraphWindow( QWidget* parent, const char* name, WFlags f ) legende = new Legende( 14, this ); - startTimer( 50 ); //FIXME: tweak - - //testGraph(); - + startTimer( 50 ); }; @@ -148,3 +176,3 @@ void MGraphWindow::timerEvent( QTimerEvent* e ) { - spectrum->decrease( i, 1 ); //TODO: make this customizable? + spectrum->decrease( i, 1 ); } 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 @@ -45,4 +45,7 @@ class MFrequencySpectrum : public QWidget 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 ); 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 @@ -30,3 +30,3 @@ ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f { - actions = ( QString( "parsePackets" ) == QString( name ) ); + parse = ( QString( "parsePackets" ) == QString( name ) ); @@ -42,3 +42,3 @@ ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f 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 ); @@ -80,3 +80,3 @@ void ProtocolListView::addProtocol( const QString& name ) - if ( actions ) + if ( parse ) { @@ -87,2 +87,3 @@ void ProtocolListView::addProtocol( const QString& name ) combo->insertItem( "Ignore" ); + combo->insertItem( "Discard!" ); combo->insertItem( "TouchSound" ); @@ -95,2 +96,11 @@ void ProtocolListView::addProtocol( const QString& name ) } + else + { + QComboBox* combo = new QComboBox( hbox, (const char*) name ); + #ifdef QWS + combo->setFixedWidth( 75 ); + #endif + combo->insertItem( "Pass" ); + combo->insertItem( "Discard!" ); + } } @@ -107,5 +117,2 @@ 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" ); 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 @@ -20,4 +20,2 @@ #include <qdict.h> -//#include <qcheckbox.h> -//#include <qcombobox.h> class QCheckBox; @@ -41,3 +39,3 @@ class ProtocolListView : public QScrollView QVBox* vbox; - bool actions; + bool parse; }; 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 @@ -153,3 +153,3 @@ void Wellenreiter::handleNotification( OPacket* p ) 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 ); @@ -158,3 +158,3 @@ void Wellenreiter::handleNotification( OPacket* p ) { - qDebug( "protocol '%s' not checked.", (const char*) name ); + qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); } @@ -273,5 +273,43 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) -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; } @@ -283,6 +321,9 @@ void Wellenreiter::receivePacket( OPacket* p ) - 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" ) @@ -296,3 +337,3 @@ void Wellenreiter::receivePacket( OPacket* p ) // 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 ) @@ -301,2 +342,5 @@ void Wellenreiter::receivePacket( OPacket* p ) } + + handleNotification( p ); + } @@ -396,3 +440,5 @@ void Wellenreiter::startClicked() { - if ( configwindow->writeCaptureFile->isEnabled() ) //FIXME: bug!? + pcap->open( interface ); + + if ( configwindow->writeCaptureFile->isOn() ) { @@ -402,3 +448,3 @@ void Wellenreiter::startClicked() dumpname.append( ".wellenreiter" ); - pcap->open( interface, dumpname ); + pcap->openDumpFile( dumpname ); } 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 @@ -71,3 +71,4 @@ class Wellenreiter : public WellenreiterBase { QObject* childIfToParse( OPacket* p, const QString& protocol ); - + bool checkDumpPacket( OPacket* p ); + private: |