summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 4d786f5..7463320 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -343,770 +343,774 @@ QString OARPPacket::type() const
343 } 343 }
344} 344}
345 345
346 346
347QHostAddress OARPPacket::senderIPV4Address() const 347QHostAddress OARPPacket::senderIPV4Address() const
348{ 348{
349 return EXTRACT_32BITS( &_arphdr->ar_sip ); 349 return EXTRACT_32BITS( &_arphdr->ar_sip );
350} 350}
351 351
352 352
353QHostAddress OARPPacket::targetIPV4Address() const 353QHostAddress OARPPacket::targetIPV4Address() const
354{ 354{
355 return EXTRACT_32BITS( &_arphdr->ar_tip ); 355 return EXTRACT_32BITS( &_arphdr->ar_tip );
356} 356}
357 357
358 358
359OMacAddress OARPPacket::senderMacAddress() const 359OMacAddress OARPPacket::senderMacAddress() const
360{ 360{
361 return OMacAddress( _arphdr->ar_sha ); 361 return OMacAddress( _arphdr->ar_sha );
362} 362}
363 363
364 364
365OMacAddress OARPPacket::targetMacAddress() const 365OMacAddress OARPPacket::targetMacAddress() const
366{ 366{
367 return OMacAddress( _arphdr->ar_tha ); 367 return OMacAddress( _arphdr->ar_tha );
368} 368}
369 369
370 370
371/*====================================================================================== 371/*======================================================================================
372 * OUDPPacket 372 * OUDPPacket
373 *======================================================================================*/ 373 *======================================================================================*/
374 374
375 375
376OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) 376OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent )
377 :QObject( parent, "UDP" ), _udphdr( data ) 377 :QObject( parent, "UDP" ), _udphdr( data )
378 378
379{ 379{
380 odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl; 380 odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl;
381 odebug << "fromPort = " << fromPort() << oendl; 381 odebug << "fromPort = " << fromPort() << oendl;
382 odebug << " toPort = " << toPort() << oendl; 382 odebug << " toPort = " << toPort() << oendl;
383 383
384 // TODO: Make this a case or a hash if we know more udp protocols 384 // TODO: Make this a case or a hash if we know more udp protocols
385 385
386 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || 386 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC ||
387 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) 387 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC )
388 { 388 {
389 odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl; 389 odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl;
390 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); 390 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
391 } 391 }
392} 392}
393 393
394 394
395OUDPPacket::~OUDPPacket() 395OUDPPacket::~OUDPPacket()
396{ 396{
397} 397}
398 398
399 399
400int OUDPPacket::fromPort() const 400int OUDPPacket::fromPort() const
401{ 401{
402 return EXTRACT_16BITS( &_udphdr->source ); 402 return EXTRACT_16BITS( &_udphdr->source );
403} 403}
404 404
405 405
406int OUDPPacket::toPort() const 406int OUDPPacket::toPort() const
407{ 407{
408 return EXTRACT_16BITS( &_udphdr->dest ); 408 return EXTRACT_16BITS( &_udphdr->dest );
409} 409}
410 410
411 411
412int OUDPPacket::length() const 412int OUDPPacket::length() const
413{ 413{
414 return EXTRACT_16BITS( &_udphdr->len ); 414 return EXTRACT_16BITS( &_udphdr->len );
415} 415}
416 416
417 417
418int OUDPPacket::checksum() const 418int OUDPPacket::checksum() const
419{ 419{
420 return EXTRACT_16BITS( &_udphdr->check ); 420 return EXTRACT_16BITS( &_udphdr->check );
421} 421}
422 422
423 423
424/*====================================================================================== 424/*======================================================================================
425 * ODHCPPacket 425 * ODHCPPacket
426 *======================================================================================*/ 426 *======================================================================================*/
427 427
428 428
429ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) 429ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent )
430 :QObject( parent, "DHCP" ), _dhcphdr( data ) 430 :QObject( parent, "DHCP" ), _dhcphdr( data )
431 431
432{ 432{
433 odebug << "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." << oendl; 433 odebug << "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." << oendl;
434 odebug << "DHCP opcode seems to be " << _dhcphdr->op << ": " << ( isRequest() ? "REQUEST" : "REPLY" ) << oendl; 434 odebug << "DHCP opcode seems to be " << _dhcphdr->op << ": " << ( isRequest() ? "REQUEST" : "REPLY" ) << oendl;
435 odebug << "clientAddress = " << clientAddress().toString() << oendl; 435 odebug << "clientAddress = " << clientAddress().toString() << oendl;
436 odebug << " yourAddress = " << yourAddress().toString() << oendl; 436 odebug << " yourAddress = " << yourAddress().toString() << oendl;
437 odebug << "serverAddress = " << serverAddress().toString() << oendl; 437 odebug << "serverAddress = " << serverAddress().toString() << oendl;
438 odebug << " relayAddress = " << relayAddress().toString() << oendl; 438 odebug << " relayAddress = " << relayAddress().toString() << oendl;
439 odebug << "parsing DHCP options..." << oendl; 439 odebug << "parsing DHCP options..." << oendl;
440 440
441 _type = 0; 441 _type = 0;
442 442
443 const unsigned char* option = &_dhcphdr->options[4]; 443 const unsigned char* option = &_dhcphdr->options[4];
444 char tag = -1; 444 char tag = -1;
445 char len = -1; 445 char len = -1;
446 446
447 while ( ( tag = *option++ ) != -1 /* end of option field */ ) 447 while ( ( tag = *option++ ) != -1 /* end of option field */ )
448 { 448 {
449 len = *option++; 449 len = *option++;
450 odebug << "recognized DHCP option #" << tag << ", length " << len << oendl; 450 odebug << "recognized DHCP option #" << tag << ", length " << len << oendl;
451 451
452 if ( tag == DHO_DHCP_MESSAGE_TYPE ) 452 if ( tag == DHO_DHCP_MESSAGE_TYPE )
453 _type = *option; 453 _type = *option;
454 454
455 option += len; 455 option += len;
456 if ( option >= end ) 456 if ( option >= end )
457 { 457 {
458 owarn << "DHCP parsing ERROR: sanity check says the packet is at its end!" << oendl; 458 owarn << "DHCP parsing ERROR: sanity check says the packet is at its end!" << oendl;
459 break; 459 break;
460 } 460 }
461 } 461 }
462 462
463 odebug << "DHCP type seems to be << " << type() << oendl; 463 odebug << "DHCP type seems to be << " << type() << oendl;
464} 464}
465 465
466 466
467ODHCPPacket::~ODHCPPacket() 467ODHCPPacket::~ODHCPPacket()
468{ 468{
469} 469}
470 470
471 471
472bool ODHCPPacket::isRequest() const 472bool ODHCPPacket::isRequest() const
473{ 473{
474 return ( _dhcphdr->op == 01 ); 474 return ( _dhcphdr->op == 01 );
475} 475}
476 476
477 477
478bool ODHCPPacket::isReply() const 478bool ODHCPPacket::isReply() const
479{ 479{
480 return ( _dhcphdr->op == 02 ); 480 return ( _dhcphdr->op == 02 );
481} 481}
482 482
483 483
484QString ODHCPPacket::type() const 484QString ODHCPPacket::type() const
485{ 485{
486 switch ( _type ) 486 switch ( _type )
487 { 487 {
488 case 1: return "DISCOVER"; 488 case 1: return "DISCOVER";
489 case 2: return "OFFER"; 489 case 2: return "OFFER";
490 case 3: return "REQUEST"; 490 case 3: return "REQUEST";
491 case 4: return "DECLINE"; 491 case 4: return "DECLINE";
492 case 5: return "ACK"; 492 case 5: return "ACK";
493 case 6: return "NAK"; 493 case 6: return "NAK";
494 case 7: return "RELEASE"; 494 case 7: return "RELEASE";
495 case 8: return "INFORM"; 495 case 8: return "INFORM";
496 default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>"; 496 default: owarn << "ODHCPPacket::type(): invalid DHCP type " << _dhcphdr->op << oendl; return "<unknown>";
497 } 497 }
498} 498}
499 499
500 500
501QHostAddress ODHCPPacket::clientAddress() const 501QHostAddress ODHCPPacket::clientAddress() const
502{ 502{
503 return EXTRACT_32BITS( &_dhcphdr->ciaddr ); 503 return EXTRACT_32BITS( &_dhcphdr->ciaddr );
504} 504}
505 505
506 506
507QHostAddress ODHCPPacket::yourAddress() const 507QHostAddress ODHCPPacket::yourAddress() const
508{ 508{
509 return EXTRACT_32BITS( &_dhcphdr->yiaddr ); 509 return EXTRACT_32BITS( &_dhcphdr->yiaddr );
510} 510}
511 511
512 512
513QHostAddress ODHCPPacket::serverAddress() const 513QHostAddress ODHCPPacket::serverAddress() const
514{ 514{
515 return EXTRACT_32BITS( &_dhcphdr->siaddr ); 515 return EXTRACT_32BITS( &_dhcphdr->siaddr );
516} 516}
517 517
518 518
519QHostAddress ODHCPPacket::relayAddress() const 519QHostAddress ODHCPPacket::relayAddress() const
520{ 520{
521 return EXTRACT_32BITS( &_dhcphdr->giaddr ); 521 return EXTRACT_32BITS( &_dhcphdr->giaddr );
522} 522}
523 523
524 524
525OMacAddress ODHCPPacket::clientMacAddress() const 525OMacAddress ODHCPPacket::clientMacAddress() const
526{ 526{
527 return OMacAddress( _dhcphdr->chaddr ); 527 return OMacAddress( _dhcphdr->chaddr );
528} 528}
529 529
530 530
531/*====================================================================================== 531/*======================================================================================
532 * OTCPPacket 532 * OTCPPacket
533 *======================================================================================*/ 533 *======================================================================================*/
534 534
535 535
536OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) 536OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent )
537 :QObject( parent, "TCP" ), _tcphdr( data ) 537 :QObject( parent, "TCP" ), _tcphdr( data )
538 538
539{ 539{
540 odebug << "OTCPPacket::OTCPPacket(): decoding TCP header..." << oendl; 540 odebug << "OTCPPacket::OTCPPacket(): decoding TCP header..." << oendl;
541} 541}
542 542
543 543
544OTCPPacket::~OTCPPacket() 544OTCPPacket::~OTCPPacket()
545{ 545{
546} 546}
547 547
548 548
549int OTCPPacket::fromPort() const 549int OTCPPacket::fromPort() const
550{ 550{
551 return EXTRACT_16BITS( &_tcphdr->source ); 551 return EXTRACT_16BITS( &_tcphdr->source );
552} 552}
553 553
554 554
555int OTCPPacket::toPort() const 555int OTCPPacket::toPort() const
556{ 556{
557 return EXTRACT_16BITS( &_tcphdr->dest ); 557 return EXTRACT_16BITS( &_tcphdr->dest );
558} 558}
559 559
560 560
561int OTCPPacket::seq() const 561int OTCPPacket::seq() const
562{ 562{
563 return EXTRACT_16BITS( &_tcphdr->seq ); 563 return EXTRACT_16BITS( &_tcphdr->seq );
564} 564}
565 565
566 566
567int OTCPPacket::ack() const 567int OTCPPacket::ack() const
568{ 568{
569 return EXTRACT_16BITS( &_tcphdr->ack_seq ); 569 return EXTRACT_16BITS( &_tcphdr->ack_seq );
570} 570}
571 571
572 572
573int OTCPPacket::window() const 573int OTCPPacket::window() const
574{ 574{
575 return EXTRACT_16BITS( &_tcphdr->window ); 575 return EXTRACT_16BITS( &_tcphdr->window );
576} 576}
577 577
578 578
579int OTCPPacket::checksum() const 579int OTCPPacket::checksum() const
580{ 580{
581 return EXTRACT_16BITS( &_tcphdr->check ); 581 return EXTRACT_16BITS( &_tcphdr->check );
582} 582}
583 583
584/*====================================================================================== 584/*======================================================================================
585 * OPrismHeaderPacket 585 * OPrismHeaderPacket
586 *======================================================================================*/ 586 *======================================================================================*/
587 587
588 588
589OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) 589OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent )
590 :QObject( parent, "Prism" ), _header( data ) 590 :QObject( parent, "Prism" ), _header( data )
591 591
592{ 592{
593 odebug << "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." << oendl; 593 odebug << "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." << oendl;
594 594
595 odebug << "Signal Strength = " << data->signal.data << oendl; 595 odebug << "Signal Strength = " << data->signal.data << oendl;
596 596
597 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); 597 new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this );
598} 598}
599 599
600OPrismHeaderPacket::~OPrismHeaderPacket() 600OPrismHeaderPacket::~OPrismHeaderPacket()
601{ 601{
602} 602}
603 603
604 604
605unsigned int OPrismHeaderPacket::signalStrength() const 605unsigned int OPrismHeaderPacket::signalStrength() const
606{ 606{
607 return _header->signal.data; 607 return _header->signal.data;
608} 608}
609 609
610/*====================================================================================== 610/*======================================================================================
611 * OWaveLanPacket 611 * OWaveLanPacket
612 *======================================================================================*/ 612 *======================================================================================*/
613 613
614 614
615OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) 615OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent )
616 :QObject( parent, "802.11" ), _wlanhdr( data ) 616 :QObject( parent, "802.11" ), _wlanhdr( data )
617 617
618{ 618{
619 odebug << "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." << oendl; 619 odebug << "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." << oendl;
620 odebug << "type = " << type() << oendl; 620 odebug << "type = " << type() << oendl;
621 odebug << "subType = " << subType() << oendl; 621 odebug << "subType = " << subType() << oendl;
622 odebug << "duration = " << duration() << oendl; 622 odebug << "duration = " << duration() << oendl;
623 odebug << "powermanagement = " << usesPowerManagement() << oendl; 623 odebug << "powermanagement = " << usesPowerManagement() << oendl;
624 odebug << "payload is encrypted = " << ( usesWep() ? "yes" : "no" ) << oendl; 624 odebug << "payload is encrypted = " << ( usesWep() ? "yes" : "no" ) << oendl;
625 odebug << "MAC1 = " << macAddress1().toString() << oendl; 625 odebug << "MAC1 = " << macAddress1().toString() << oendl;
626 odebug << "MAC2 = " << macAddress2().toString() << oendl; 626 odebug << "MAC2 = " << macAddress2().toString() << oendl;
627 odebug << "MAC3 = " << macAddress3().toString() << oendl; 627 odebug << "MAC3 = " << macAddress3().toString() << oendl;
628 odebug << "MAC4 = " << macAddress4().toString() << oendl; 628 odebug << "MAC4 = " << macAddress4().toString() << oendl;
629 629
630 switch ( type() ) 630 switch ( type() )
631 { 631 {
632 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; 632 case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break;
633 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; 633 case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break;
634 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; 634 case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break;
635 default: odebug << "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type = " << type() << oendl; 635 default: odebug << "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type = " << type() << oendl;
636 } 636 }
637} 637}
638 638
639OWaveLanPacket::~OWaveLanPacket() 639OWaveLanPacket::~OWaveLanPacket()
640{ 640{
641} 641}
642 642
643 643
644int OWaveLanPacket::duration() const 644int OWaveLanPacket::duration() const
645{ 645{
646 return _wlanhdr->duration; 646 return _wlanhdr->duration;
647} 647}
648 648
649 649
650OMacAddress OWaveLanPacket::macAddress1() const 650OMacAddress OWaveLanPacket::macAddress1() const
651{ 651{
652 return OMacAddress( _wlanhdr->mac1 ); 652 return OMacAddress( _wlanhdr->mac1 );
653} 653}
654 654
655 655
656OMacAddress OWaveLanPacket::macAddress2() const 656OMacAddress OWaveLanPacket::macAddress2() const
657{ 657{
658 return OMacAddress( _wlanhdr->mac2 ); 658 return OMacAddress( _wlanhdr->mac2 );
659} 659}
660 660
661 661
662OMacAddress OWaveLanPacket::macAddress3() const 662OMacAddress OWaveLanPacket::macAddress3() const
663{ 663{
664 return OMacAddress( _wlanhdr->mac3 ); 664 return OMacAddress( _wlanhdr->mac3 );
665} 665}
666 666
667 667
668OMacAddress OWaveLanPacket::macAddress4() const 668OMacAddress OWaveLanPacket::macAddress4() const
669{ 669{
670 return OMacAddress( _wlanhdr->mac4 ); 670 return OMacAddress( _wlanhdr->mac4 );
671} 671}
672 672
673 673
674int OWaveLanPacket::subType() const 674int OWaveLanPacket::subType() const
675{ 675{
676 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 676 return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
677} 677}
678 678
679 679
680int OWaveLanPacket::type() const 680int OWaveLanPacket::type() const
681{ 681{
682 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 682 return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
683} 683}
684 684
685 685
686int OWaveLanPacket::version() const 686int OWaveLanPacket::version() const
687{ 687{
688 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 688 return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
689} 689}
690 690
691 691
692bool OWaveLanPacket::fromDS() const 692bool OWaveLanPacket::fromDS() const
693{ 693{
694 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 694 return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
695} 695}
696 696
697 697
698bool OWaveLanPacket::toDS() const 698bool OWaveLanPacket::toDS() const
699{ 699{
700 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 700 return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
701} 701}
702 702
703 703
704bool OWaveLanPacket::usesPowerManagement() const 704bool OWaveLanPacket::usesPowerManagement() const
705{ 705{
706 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 706 return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
707} 707}
708 708
709 709
710bool OWaveLanPacket::usesWep() const 710bool OWaveLanPacket::usesWep() const
711{ 711{
712 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); 712 return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) );
713} 713}
714 714
715 715
716/*====================================================================================== 716/*======================================================================================
717 * OWaveLanManagementPacket 717 * OWaveLanManagementPacket
718 *======================================================================================*/ 718 *======================================================================================*/
719 719
720OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) 720OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent )
721 :QObject( parent, "802.11 Management" ), _header( data ), 721 :QObject( parent, "802.11 Management" ), _header( data ),
722 _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) 722 _body( (const struct ieee_802_11_mgmt_body*) (data+1) )
723{ 723{
724 odebug << "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." << oendl; 724 odebug << "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." << oendl;
725 odebug << "Detected subtype is " << managementType() << oendl; 725 odebug << "Detected subtype is " << managementType() << oendl;
726 726
727 // grab tagged values 727 // Grab tagged values.
728 const unsigned char* ptr = (const unsigned char*) (_body+1); 728 // Beacons contain a 12 byte long fixed parameters set before the tagged parameters come,
729 // Other management frames don't - which is why we have to inspect the subtype here.
730
731 const unsigned char* ptr = managementType() == "Beacon" ? (const unsigned char*) (_body+1) : (const unsigned char*) (_header+1);
732
729 while (ptr < end) 733 while (ptr < end)
730 { 734 {
731 switch ( *ptr ) 735 switch ( *ptr )
732 { 736 {
733 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; 737 case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break;
734 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; 738 case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break;
735 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; 739 case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break;
736 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; 740 case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break;
737 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; 741 case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break;
738 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; 742 case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break;
739 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; 743 case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break;
740 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; 744 case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break;
741 } 745 }
742 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value 746 ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value
743 ptr+= 2; // skip tag ID and length 747 ptr+= 2; // skip tag ID and length
744 } 748 }
745} 749}
746 750
747 751
748OWaveLanManagementPacket::~OWaveLanManagementPacket() 752OWaveLanManagementPacket::~OWaveLanManagementPacket()
749{ 753{
750} 754}
751 755
752 756
753QString OWaveLanManagementPacket::managementType() const 757QString OWaveLanManagementPacket::managementType() const
754{ 758{
755 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) 759 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
756 { 760 {
757 case ST_ASSOC_REQUEST: return "AssociationRequest"; break; 761 case ST_ASSOC_REQUEST: return "AssociationRequest"; break;
758 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break; 762 case ST_ASSOC_RESPONSE: return "AssociationResponse"; break;
759 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break; 763 case ST_REASSOC_REQUEST: return "ReassociationRequest"; break;
760 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break; 764 case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break;
761 case ST_PROBE_REQUEST: return "ProbeRequest"; break; 765 case ST_PROBE_REQUEST: return "ProbeRequest"; break;
762 case ST_PROBE_RESPONSE: return "ProbeResponse"; break; 766 case ST_PROBE_RESPONSE: return "ProbeResponse"; break;
763 case ST_BEACON: return "Beacon"; break; 767 case ST_BEACON: return "Beacon"; break;
764 case ST_ATIM: return "Atim"; break; 768 case ST_ATIM: return "Atim"; break;
765 case ST_DISASSOC: return "Disassociation"; break; 769 case ST_DISASSOC: return "Disassociation"; break;
766 case ST_AUTH: return "Authentication"; break; 770 case ST_AUTH: return "Authentication"; break;
767 case ST_DEAUTH: return "Deathentication"; break; 771 case ST_DEAUTH: return "Deathentication"; break;
768 default: owarn << "OWaveLanManagementPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; return "Unknown"; 772 default: owarn << "OWaveLanManagementPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; return "Unknown";
769 } 773 }
770} 774}
771 775
772 776
773int OWaveLanManagementPacket::beaconInterval() const 777int OWaveLanManagementPacket::beaconInterval() const
774{ 778{
775 return EXTRACT_LE_16BITS( &_body->beacon_interval ); 779 return EXTRACT_LE_16BITS( &_body->beacon_interval );
776} 780}
777 781
778 782
779int OWaveLanManagementPacket::capabilities() const 783int OWaveLanManagementPacket::capabilities() const
780{ 784{
781 return EXTRACT_LE_16BITS( &_body->capability_info ); 785 return EXTRACT_LE_16BITS( &_body->capability_info );
782} 786}
783 787
784 788
785bool OWaveLanManagementPacket::canESS() const 789bool OWaveLanManagementPacket::canESS() const
786{ 790{
787 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 791 return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) );
788} 792}
789 793
790 794
791bool OWaveLanManagementPacket::canIBSS() const 795bool OWaveLanManagementPacket::canIBSS() const
792{ 796{
793 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); 797 return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) );
794} 798}
795 799
796 800
797bool OWaveLanManagementPacket::canCFP() const 801bool OWaveLanManagementPacket::canCFP() const
798{ 802{
799 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); 803 return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) );
800} 804}
801 805
802 806
803bool OWaveLanManagementPacket::canCFP_REQ() const 807bool OWaveLanManagementPacket::canCFP_REQ() const
804{ 808{
805 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); 809 return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) );
806} 810}
807 811
808 812
809bool OWaveLanManagementPacket::canPrivacy() const 813bool OWaveLanManagementPacket::canPrivacy() const
810{ 814{
811 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); 815 return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) );
812} 816}
813 817
814 818
815/*====================================================================================== 819/*======================================================================================
816 * OWaveLanManagementSSID 820 * OWaveLanManagementSSID
817 *======================================================================================*/ 821 *======================================================================================*/
818 822
819OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) 823OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
820 :QObject( parent, "802.11 SSID" ), _data( data ) 824 :QObject( parent, "802.11 SSID" ), _data( data )
821{ 825{
822 odebug << "OWaveLanManagementSSID()" << oendl; 826 odebug << "OWaveLanManagementSSID()" << oendl;
823} 827}
824 828
825 829
826OWaveLanManagementSSID::~OWaveLanManagementSSID() 830OWaveLanManagementSSID::~OWaveLanManagementSSID()
827{ 831{
828} 832}
829 833
830 834
831QString OWaveLanManagementSSID::ID( bool decloak ) const 835QString OWaveLanManagementSSID::ID( bool decloak ) const
832{ 836{
833 int length = _data->length; 837 int length = _data->length;
834 if ( length > 32 ) length = 32; 838 if ( length > 32 ) length = 32;
835 char essid[length+1]; 839 char essid[length+1];
836 memcpy( &essid, &_data->ssid, length ); 840 memcpy( &essid, &_data->ssid, length );
837 essid[length] = 0x0; 841 essid[length] = 0x0;
838 if ( !decloak || length < 2 || essid[0] != '\0' ) return essid; 842 if ( !decloak || length < 2 || essid[0] != '\0' ) return essid;
839 odebug << "OWaveLanManagementSSID:ID(): SSID is cloaked - decloaking..." << oendl; 843 odebug << "OWaveLanManagementSSID:ID(): SSID is cloaked - decloaking..." << oendl;
840 844
841 QString decloakedID; 845 QString decloakedID;
842 for ( int i = 1; i < length; ++i ) 846 for ( int i = 1; i < length; ++i )
843 { 847 {
844 if ( essid[i] >= 32 && essid[i] <= 126 ) decloakedID.append( essid[i] ); 848 if ( essid[i] >= 32 && essid[i] <= 126 ) decloakedID.append( essid[i] );
845 else decloakedID.append( '.' ); 849 else decloakedID.append( '.' );
846 } 850 }
847 return decloakedID; 851 return decloakedID;
848} 852}
849 853
850 854
851/*====================================================================================== 855/*======================================================================================
852 * OWaveLanManagementRates 856 * OWaveLanManagementRates
853 *======================================================================================*/ 857 *======================================================================================*/
854 858
855OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) 859OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
856 :QObject( parent, "802.11 Rates" ), _data( data ) 860 :QObject( parent, "802.11 Rates" ), _data( data )
857{ 861{
858 odebug << "OWaveLanManagementRates()" << oendl; 862 odebug << "OWaveLanManagementRates()" << oendl;
859} 863}
860 864
861 865
862OWaveLanManagementRates::~OWaveLanManagementRates() 866OWaveLanManagementRates::~OWaveLanManagementRates()
863{ 867{
864} 868}
865 869
866/*====================================================================================== 870/*======================================================================================
867 * OWaveLanManagementCF 871 * OWaveLanManagementCF
868 *======================================================================================*/ 872 *======================================================================================*/
869 873
870OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) 874OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
871 :QObject( parent, "802.11 CF" ), _data( data ) 875 :QObject( parent, "802.11 CF" ), _data( data )
872{ 876{
873 odebug << "OWaveLanManagementCF()" << oendl; 877 odebug << "OWaveLanManagementCF()" << oendl;
874} 878}
875 879
876 880
877OWaveLanManagementCF::~OWaveLanManagementCF() 881OWaveLanManagementCF::~OWaveLanManagementCF()
878{ 882{
879} 883}
880 884
881/*====================================================================================== 885/*======================================================================================
882 * OWaveLanManagementFH 886 * OWaveLanManagementFH
883 *======================================================================================*/ 887 *======================================================================================*/
884 888
885OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) 889OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
886 :QObject( parent, "802.11 FH" ), _data( data ) 890 :QObject( parent, "802.11 FH" ), _data( data )
887{ 891{
888 odebug << "OWaveLanManagementFH()" << oendl; 892 odebug << "OWaveLanManagementFH()" << oendl;
889} 893}
890 894
891 895
892OWaveLanManagementFH::~OWaveLanManagementFH() 896OWaveLanManagementFH::~OWaveLanManagementFH()
893{ 897{
894} 898}
895 899
896/*====================================================================================== 900/*======================================================================================
897 * OWaveLanManagementDS 901 * OWaveLanManagementDS
898 *======================================================================================*/ 902 *======================================================================================*/
899 903
900OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) 904OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
901 :QObject( parent, "802.11 DS" ), _data( data ) 905 :QObject( parent, "802.11 DS" ), _data( data )
902{ 906{
903 odebug << "OWaveLanManagementDS()" << oendl; 907 odebug << "OWaveLanManagementDS()" << oendl;
904} 908}
905 909
906 910
907OWaveLanManagementDS::~OWaveLanManagementDS() 911OWaveLanManagementDS::~OWaveLanManagementDS()
908{ 912{
909} 913}
910 914
911 915
912int OWaveLanManagementDS::channel() const 916int OWaveLanManagementDS::channel() const
913{ 917{
914 return _data->channel; 918 return _data->channel;
915} 919}
916 920
917/*====================================================================================== 921/*======================================================================================
918 * OWaveLanManagementTim 922 * OWaveLanManagementTim
919 *======================================================================================*/ 923 *======================================================================================*/
920 924
921OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) 925OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
922 :QObject( parent, "802.11 Tim" ), _data( data ) 926 :QObject( parent, "802.11 Tim" ), _data( data )
923{ 927{
924 odebug << "OWaveLanManagementTim()" << oendl; 928 odebug << "OWaveLanManagementTim()" << oendl;
925} 929}
926 930
927 931
928OWaveLanManagementTim::~OWaveLanManagementTim() 932OWaveLanManagementTim::~OWaveLanManagementTim()
929{ 933{
930} 934}
931 935
932/*====================================================================================== 936/*======================================================================================
933 * OWaveLanManagementIBSS 937 * OWaveLanManagementIBSS
934 *======================================================================================*/ 938 *======================================================================================*/
935 939
936OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) 940OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
937 :QObject( parent, "802.11 IBSS" ), _data( data ) 941 :QObject( parent, "802.11 IBSS" ), _data( data )
938{ 942{
939 odebug << "OWaveLanManagementIBSS()" << oendl; 943 odebug << "OWaveLanManagementIBSS()" << oendl;
940} 944}
941 945
942 946
943OWaveLanManagementIBSS::~OWaveLanManagementIBSS() 947OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
944{ 948{
945} 949}
946 950
947/*====================================================================================== 951/*======================================================================================
948 * OWaveLanManagementChallenge 952 * OWaveLanManagementChallenge
949 *======================================================================================*/ 953 *======================================================================================*/
950 954
951OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) 955OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
952 :QObject( parent, "802.11 Challenge" ), _data( data ) 956 :QObject( parent, "802.11 Challenge" ), _data( data )
953{ 957{
954 odebug << "OWaveLanManagementChallenge()" << oendl; 958 odebug << "OWaveLanManagementChallenge()" << oendl;
955} 959}
956 960
957 961
958OWaveLanManagementChallenge::~OWaveLanManagementChallenge() 962OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
959{ 963{
960} 964}
961 965
962/*====================================================================================== 966/*======================================================================================
963 * OWaveLanDataPacket 967 * OWaveLanDataPacket
964 *======================================================================================*/ 968 *======================================================================================*/
965 969
966OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 970OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
967 :QObject( parent, "802.11 Data" ), _header( data ) 971 :QObject( parent, "802.11 Data" ), _header( data )
968{ 972{
969 odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl; 973 odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl;
970 974
971 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); 975 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
972 976
973 #warning The next line works for most cases, but can not be correct generally! 977 #warning The next line works for most cases, but can not be correct generally!
974 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address 978 if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address
975 979
976 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); 980 new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this );
977} 981}
978 982
979 983
980OWaveLanDataPacket::~OWaveLanDataPacket() 984OWaveLanDataPacket::~OWaveLanDataPacket()
981{ 985{
982} 986}
983 987
984 988
985/*====================================================================================== 989/*======================================================================================
986 * OLLCPacket 990 * OLLCPacket
987 *======================================================================================*/ 991 *======================================================================================*/
988 992
989OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) 993OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
990 :QObject( parent, "802.11 LLC" ), _header( data ) 994 :QObject( parent, "802.11 LLC" ), _header( data )
991{ 995{
992 odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl; 996 odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl;
993 997
994 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) 998 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
995 { 999 {
996 owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl; 1000 owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl;
997 1001
998 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 1002 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
999 { 1003 {
1000 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 1004 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
1001 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 1005 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
1002 default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl; 1006 default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl;
1003 } 1007 }
1004 } 1008 }
1005} 1009}
1006 1010
1007 1011
1008OLLCPacket::~OLLCPacket() 1012OLLCPacket::~OLLCPacket()
1009{ 1013{
1010} 1014}
1011 1015
1012 1016
1013/*====================================================================================== 1017/*======================================================================================
1014 * OWaveLanControlPacket 1018 * OWaveLanControlPacket
1015 *======================================================================================*/ 1019 *======================================================================================*/
1016 1020
1017OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) 1021OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
1018 :QObject( parent, "802.11 Control" ), _header( data ) 1022 :QObject( parent, "802.11 Control" ), _header( data )
1019{ 1023{
1020 odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl; 1024 odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl;
1021 odebug << "Detected subtype is " << controlType() << oendl; 1025 odebug << "Detected subtype is " << controlType() << oendl;
1022} 1026}
1023 1027
1024 1028
1025OWaveLanControlPacket::~OWaveLanControlPacket() 1029OWaveLanControlPacket::~OWaveLanControlPacket()
1026{ 1030{
1027} 1031}
1028 1032
1029 1033
1030QString OWaveLanControlPacket::controlType() const 1034QString OWaveLanControlPacket::controlType() const
1031{ 1035{
1032 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) 1036 switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) )
1033 { 1037 {
1034 case CTRL_PS_POLL: return "PowerSavePoll"; break; 1038 case CTRL_PS_POLL: return "PowerSavePoll"; break;
1035 case CTRL_RTS: return "RequestToSend"; break; 1039 case CTRL_RTS: return "RequestToSend"; break;
1036 case CTRL_CTS: return "ClearToSend"; break; 1040 case CTRL_CTS: return "ClearToSend"; break;
1037 case CTRL_ACK: return "Acknowledge"; break; 1041 case CTRL_ACK: return "Acknowledge"; break;
1038 case CTRL_CF_END: return "ContentionFreeEnd"; break; 1042 case CTRL_CF_END: return "ContentionFreeEnd"; break;
1039 case CTRL_END_ACK: return "AcknowledgeEnd"; break; 1043 case CTRL_END_ACK: return "AcknowledgeEnd"; break;
1040 default: 1044 default:
1041 owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl; 1045 owarn << "OWaveLanControlPacket::managementType(): unhandled subtype " << FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) << oendl;
1042 return "Unknown"; 1046 return "Unknown";
1043 } 1047 }
1044} 1048}
1045 1049
1046 1050
1047/*====================================================================================== 1051/*======================================================================================
1048 * OPacketCapturer 1052 * OPacketCapturer
1049 *======================================================================================*/ 1053 *======================================================================================*/
1050 1054
1051OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 1055OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
1052 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ) 1056 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 )
1053{ 1057{
1054} 1058}
1055 1059
1056 1060
1057OPacketCapturer::~OPacketCapturer() 1061OPacketCapturer::~OPacketCapturer()
1058{ 1062{
1059 if ( _open ) 1063 if ( _open )
1060 { 1064 {
1061 odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl; 1065 odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl;
1062 close(); 1066 close();
1063 } 1067 }
1064} 1068}
1065 1069
1066 1070
1067void OPacketCapturer::setBlocking( bool b ) 1071void OPacketCapturer::setBlocking( bool b )
1068{ 1072{
1069 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 1073 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
1070 { 1074 {
1071 odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl; 1075 odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl;
1072 } 1076 }
1073 else 1077 else
1074 { 1078 {
1075 odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl; 1079 odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl;
1076 } 1080 }
1077} 1081}
1078 1082
1079 1083
1080bool OPacketCapturer::blocking() const 1084bool OPacketCapturer::blocking() const
1081{ 1085{
1082 int b = pcap_getnonblock( _pch, _errbuf ); 1086 int b = pcap_getnonblock( _pch, _errbuf );
1083 if ( b == -1 ) 1087 if ( b == -1 )
1084 { 1088 {
1085 odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl; 1089 odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl;
1086 return -1; 1090 return -1;
1087 } 1091 }
1088 return !b; 1092 return !b;
1089} 1093}
1090 1094
1091 1095
1092void OPacketCapturer::closeDumpFile() 1096void OPacketCapturer::closeDumpFile()
1093{ 1097{
1094 if ( _pcd ) 1098 if ( _pcd )
1095 { 1099 {
1096 pcap_dump_close( _pcd ); 1100 pcap_dump_close( _pcd );
1097 _pcd = 0; 1101 _pcd = 0;
1098 } 1102 }
1099 pcap_close( _pch ); 1103 pcap_close( _pch );
1100} 1104}
1101 1105
1102 1106
1103void OPacketCapturer::close() 1107void OPacketCapturer::close()
1104{ 1108{
1105 if ( _open ) 1109 if ( _open )
1106 { 1110 {
1107 if ( _sn ) 1111 if ( _sn )
1108 { 1112 {
1109 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); 1113 _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) );
1110 delete _sn; 1114 delete _sn;
1111 } 1115 }
1112 closeDumpFile(); 1116 closeDumpFile();