summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui149
-rw-r--r--noncore/net/wellenreiter/gui/graphwindow.cpp50
-rw-r--r--noncore/net/wellenreiter/gui/graphwindow.h3
-rw-r--r--noncore/net/wellenreiter/gui/protolistview.cpp19
-rw-r--r--noncore/net/wellenreiter/gui/protolistview.h4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp64
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h3
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
@@ -6,18 +6,18 @@
<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>
@@ -90,78 +90,28 @@
<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>
@@ -415,27 +365,16 @@
<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>
@@ -447,16 +386,88 @@
<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>
@@ -475,16 +486,20 @@
</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" >
@@ -860,10 +875,16 @@
<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
@@ -24,21 +24,35 @@ MFrequencySpectrum::MFrequencySpectrum( int channels, QWidget* parent, const cha
{
_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 );
@@ -56,22 +70,23 @@ void MFrequencySpectrum::drawBar( QPainter* p, int x, int y, int width, int heig
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 );
@@ -93,16 +108,32 @@ void MFrequencySpectrum::paintEvent( QPaintEvent* e )
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 );
}
@@ -120,20 +151,17 @@ void Legende::drawContents( QPainter* p )
}
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;
@@ -141,17 +169,17 @@ void MGraphWindow::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
@@ -38,18 +38,21 @@ class MFrequencySpectrum : public QWidget
{
_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;
};
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
@@ -23,29 +23,29 @@
#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" );
@@ -73,45 +73,52 @@ 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
@@ -13,18 +13,16 @@
**
**********************************************************************/
#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:
@@ -34,14 +32,14 @@ class ProtocolListView : public QScrollView
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
@@ -146,22 +146,22 @@ void Wellenreiter::handleNotification( OPacket* p )
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 )
{
@@ -266,44 +266,88 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
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*) ) );
@@ -389,23 +433,25 @@ void Wellenreiter::startClicked()
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
{
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
@@ -64,17 +64,18 @@ class Wellenreiter : public WellenreiterBase {
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;