summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp64
1 files changed, 55 insertions, 9 deletions
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
@@ -148,18 +148,18 @@ void Wellenreiter::handleNotification( OPacket* p )
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;
}
}
@@ -268,40 +268,84 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
{
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 )
@@ -391,19 +435,21 @@ void Wellenreiter::startClicked()
}
}
// 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 );
}
}