Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 64 |
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 ) | |||
148 | while ( (o = it.current()) != 0 ) | 148 | while ( (o = it.current()) != 0 ) |
149 | { | 149 | { |
150 | QString name = it.current()->name(); | 150 | QString name = it.current()->name(); |
151 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 151 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
152 | { | 152 | { |
153 | QString action = configwindow->parsePackets->protocolAction( name ); | 153 | QString action = configwindow->parsePackets->protocolAction( name ); |
154 | qDebug( "action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 154 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
155 | doAction( action, name, p ); | 155 | doAction( action, name, p ); |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
159 | qDebug( "protocol '%s' not checked.", (const char*) name ); | 159 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
160 | } | 160 | } |
161 | ++it; | 161 | ++it; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
@@ -268,40 +268,84 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) | |||
268 | { | 268 | { |
269 | qDebug( "Received IP packet." ); | 269 | qDebug( "Received IP packet." ); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | QObject* childIfToParse( OPacket* p, const QString& protocol ) | 274 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
275 | { | 275 | { |
276 | //FIXME: Implement | 276 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
277 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | ||
278 | return 0; | ||
279 | |||
280 | return p->child( protocol ); | ||
281 | } | ||
282 | |||
283 | |||
284 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | ||
285 | { | ||
286 | // go through all child packets and see if one is inside the child hierarchy for p | ||
287 | // if so, do what the user requested (protocolAction), e.g. pass or discard | ||
288 | if ( !configwindow->writeCaptureFile->isOn() ) | ||
289 | return false; | ||
290 | |||
291 | QObjectList* l = p->queryList(); | ||
292 | QObjectListIt it( *l ); | ||
293 | QObject* o; | ||
294 | |||
295 | while ( (o = it.current()) != 0 ) | ||
296 | { | ||
297 | QString name = it.current()->name(); | ||
298 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | ||
299 | { | ||
300 | QString action = configwindow->capturePackets->protocolAction( name ); | ||
301 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | ||
302 | if ( action == "Discard" ) | ||
303 | { | ||
304 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | ||
305 | return false; | ||
306 | } | ||
307 | } | ||
308 | else | ||
309 | { | ||
310 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | ||
311 | } | ||
312 | ++it; | ||
313 | } | ||
314 | return true; | ||
277 | } | 315 | } |
278 | 316 | ||
279 | 317 | ||
280 | void Wellenreiter::receivePacket( OPacket* p ) | 318 | void Wellenreiter::receivePacket( OPacket* p ) |
281 | { | 319 | { |
282 | hexWindow()->log( p->dump( 8 ) ); | 320 | hexWindow()->log( p->dump( 8 ) ); |
283 | 321 | ||
284 | handleNotification( p ); | 322 | if ( checkDumpPacket( p ) ) |
323 | { | ||
324 | pcap->dump( p ); | ||
325 | } | ||
285 | 326 | ||
286 | // check if we received a beacon frame | 327 | // check if we received a beacon frame |
287 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 328 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
288 | if ( beacon && beacon->managementType() == "Beacon" ) | 329 | if ( beacon && beacon->managementType() == "Beacon" ) |
289 | { | 330 | { |
290 | handleBeacon( p, beacon ); | 331 | handleBeacon( p, beacon ); |
291 | return; | 332 | return; |
292 | } | 333 | } |
293 | 334 | ||
294 | //TODO: WEP check here | 335 | //TODO: WEP check here |
295 | 336 | ||
296 | // check for a data frame | 337 | // check for a data frame |
297 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); | 338 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
298 | if ( data ) | 339 | if ( data ) |
299 | { | 340 | { |
300 | handleData( p, data ); | 341 | handleData( p, data ); |
301 | } | 342 | } |
343 | |||
344 | handleNotification( p ); | ||
345 | |||
302 | } | 346 | } |
303 | 347 | ||
304 | 348 | ||
305 | void Wellenreiter::stopClicked() | 349 | void Wellenreiter::stopClicked() |
306 | { | 350 | { |
307 | if ( iface ) | 351 | if ( iface ) |
@@ -391,19 +435,21 @@ void Wellenreiter::startClicked() | |||
391 | } | 435 | } |
392 | } | 436 | } |
393 | 437 | ||
394 | // open pcap and start sniffing | 438 | // open pcap and start sniffing |
395 | if ( cardtype != DEVTYPE_FILE ) | 439 | if ( cardtype != DEVTYPE_FILE ) |
396 | { | 440 | { |
397 | if ( configwindow->writeCaptureFile->isEnabled() ) //FIXME: bug!? | 441 | pcap->open( interface ); |
442 | |||
443 | if ( configwindow->writeCaptureFile->isOn() ) | ||
398 | { | 444 | { |
399 | QString dumpname( configwindow->captureFileName->text() ); | 445 | QString dumpname( configwindow->captureFileName->text() ); |
400 | dumpname.append( '-' ); | 446 | dumpname.append( '-' ); |
401 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 447 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
402 | dumpname.append( ".wellenreiter" ); | 448 | dumpname.append( ".wellenreiter" ); |
403 | pcap->open( interface, dumpname ); | 449 | pcap->openDumpFile( dumpname ); |
404 | } | 450 | } |
405 | else | 451 | else |
406 | { | 452 | { |
407 | pcap->open( interface ); | 453 | pcap->open( interface ); |
408 | } | 454 | } |
409 | } | 455 | } |