summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-20 00:43:12 (UTC)
committer mickeyl <mickeyl>2003-12-20 00:43:12 (UTC)
commit11c6b3b8ba56b28b160965387b4ffeffe2a2f143 (patch) (unidiff)
tree4da82e0b0f7120ec493644af44ac84e801cc4b9b
parent56762e511d9709c7141a504e609f7b850a5304f7 (diff)
downloadopie-11c6b3b8ba56b28b160965387b4ffeffe2a2f143.zip
opie-11c6b3b8ba56b28b160965387b4ffeffe2a2f143.tar.gz
opie-11c6b3b8ba56b28b160965387b4ffeffe2a2f143.tar.bz2
libopienet2 now uses the fancy odebug classes, no longer qdebug
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp128
-rw-r--r--libopie2/opienet/opcap.cpp163
-rw-r--r--libopie2/opienet/ostation.cpp7
3 files changed, 152 insertions, 146 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 6a9280f..d918193 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -32,6 +32,7 @@
32 32
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 34#include <opie2/ostation.h>
35#include <opie2/odebug.h>
35 36
36/* QT */ 37/* QT */
37 38
@@ -67,8 +68,8 @@ ONetwork* ONetwork::_instance = 0;
67 68
68ONetwork::ONetwork() 69ONetwork::ONetwork()
69{ 70{
70 qDebug( "ONetwork::ONetwork()" ); 71 odebug << "ONetwork::ONetwork()" << oendl;
71 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); 72 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
72 synchronize(); 73 synchronize();
73} 74}
74 75
@@ -85,7 +86,7 @@ void ONetwork::synchronize()
85 bool hasFile = f.open( IO_ReadOnly ); 86 bool hasFile = f.open( IO_ReadOnly );
86 if ( !hasFile ) 87 if ( !hasFile )
87 { 88 {
88 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 89 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
89 return; 90 return;
90 } 91 }
91 QTextStream s( &f ); 92 QTextStream s( &f );
@@ -95,12 +96,12 @@ void ONetwork::synchronize()
95 { 96 {
96 s >> str; 97 s >> str;
97 str.truncate( str.find( ':' ) ); 98 str.truncate( str.find( ':' ) );
98 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 99 odebug << "ONetwork: found interface '" << str << "'" << oendl;
99 ONetworkInterface* iface; 100 ONetworkInterface* iface;
100 if ( isWirelessInterface( str ) ) 101 if ( isWirelessInterface( str ) )
101 { 102 {
102 iface = new OWirelessNetworkInterface( this, (const char*) str ); 103 iface = new OWirelessNetworkInterface( this, (const char*) str );
103 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 104 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
104 } 105 }
105 else 106 else
106 { 107 {
@@ -161,7 +162,7 @@ ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
161 :QObject( parent, name ), 162 :QObject( parent, name ),
162 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 163 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
163{ 164{
164 qDebug( "ONetworkInterface::ONetworkInterface()" ); 165 odebug << "ONetworkInterface::ONetworkInterface()" << oendl;
165 init(); 166 init();
166} 167}
167 168
@@ -174,13 +175,13 @@ struct ifreq& ONetworkInterface::ifr() const
174 175
175void ONetworkInterface::init() 176void ONetworkInterface::init()
176{ 177{
177 qDebug( "ONetworkInterface::init()" ); 178 odebug << "ONetworkInterface::init()" << oendl;
178 179
179 memset( &_ifr, 0, sizeof( struct ifreq ) ); 180 memset( &_ifr, 0, sizeof( struct ifreq ) );
180 181
181 if ( _sfd == -1 ) 182 if ( _sfd == -1 )
182 { 183 {
183 qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); 184 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl;
184 return; 185 return;
185 } 186 }
186} 187}
@@ -191,9 +192,11 @@ bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
191 #ifndef NODEBUG 192 #ifndef NODEBUG
192 int result = ::ioctl( _sfd, call, &ifreq ); 193 int result = ::ioctl( _sfd, call, &ifreq );
193 if ( result == -1 ) 194 if ( result == -1 )
194 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); 195 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
196 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
195 else 197 else
196 qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); 198 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
199 << "' - Status: Ok." << oendl;
197 return ( result != -1 ); 200 return ( result != -1 );
198 #else 201 #else
199 return ::ioctl( _sfd, call, &ifreq ) != -1; 202 return ::ioctl( _sfd, call, &ifreq ) != -1;
@@ -315,7 +318,7 @@ int ONetworkInterface::dataLinkType() const
315void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) 318void ONetworkInterface::setMonitoring( OMonitoringInterface* m )
316{ 319{
317 _mon = m; 320 _mon = m;
318 qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); 321 odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl;
319} 322}
320 323
321 324
@@ -327,7 +330,7 @@ OMonitoringInterface* ONetworkInterface::monitoring() const
327 330
328ONetworkInterface::~ONetworkInterface() 331ONetworkInterface::~ONetworkInterface()
329{ 332{
330 qDebug( "ONetworkInterface::~ONetworkInterface()" ); 333 odebug << "ONetworkInterface::~ONetworkInterface()" << oendl;
331 if ( _sfd != -1 ) ::close( _sfd ); 334 if ( _sfd != -1 ) ::close( _sfd );
332} 335}
333 336
@@ -404,8 +407,7 @@ void OChannelHopper::timerEvent( QTimerEvent* )
404{ 407{
405 _iface->setChannel( *_channel ); 408 _iface->setChannel( *_channel );
406 emit( hopped( *_channel ) ); 409 emit( hopped( *_channel ) );
407 qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", 410 odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl;
408 *_channel, (const char*) _iface->name() );
409 if ( ++_channel == _channels.end() ) _channel = _channels.begin(); 411 if ( ++_channel == _channels.end() ) _channel = _channels.begin();
410} 412}
411 413
@@ -441,7 +443,7 @@ int OChannelHopper::interval() const
441OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) 443OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name )
442 :ONetworkInterface( parent, name ), _hopper( 0 ) 444 :ONetworkInterface( parent, name ), _hopper( 0 )
443{ 445{
444 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 446 odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl;
445 init(); 447 init();
446} 448}
447 449
@@ -459,7 +461,7 @@ struct iwreq& OWirelessNetworkInterface::iwr() const
459 461
460void OWirelessNetworkInterface::init() 462void OWirelessNetworkInterface::init()
461{ 463{
462 qDebug( "OWirelessNetworkInterface::init()" ); 464 odebug << "OWirelessNetworkInterface::init()" << oendl;
463 memset( &_iwr, 0, sizeof( struct iwreq ) ); 465 memset( &_iwr, 0, sizeof( struct iwreq ) );
464 buildInformation(); 466 buildInformation();
465 buildPrivateList(); 467 buildPrivateList();
@@ -506,7 +508,7 @@ void OWirelessNetworkInterface::buildInformation()
506 508
507 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) 509 if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 )
508 { 510 {
509 qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); 511 owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl;
510 _channels.insert( 2412, 1 ); // 2.412 GHz 512 _channels.insert( 2412, 1 ); // 2.412 GHz
511 _channels.insert( 2417, 2 ); // 2.417 GHz 513 _channels.insert( 2417, 2 ); // 2.417 GHz
512 _channels.insert( 2422, 3 ); // 2.422 GHz 514 _channels.insert( 2422, 3 ); // 2.422 GHz
@@ -530,15 +532,15 @@ void OWirelessNetworkInterface::buildInformation()
530 max = r; 532 max = r;
531 if (max > 0) 533 if (max > 0)
532 { 534 {
533 qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" 535 owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name()
534 "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); 536 << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl;
535 } 537 }
536 // </check if the driver overwrites stuff> 538 // </check if the driver overwrites stuff>
537 539
538 struct iw_range range; 540 struct iw_range range;
539 memcpy( &range, buffer, sizeof range ); 541 memcpy( &range, buffer, sizeof range );
540 542
541 qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); 543 odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl;
542 for ( int i = 0; i < range.num_frequency; ++i ) 544 for ( int i = 0; i < range.num_frequency; ++i )
543 { 545 {
544 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); 546 int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
@@ -547,14 +549,14 @@ void OWirelessNetworkInterface::buildInformation()
547 } 549 }
548 550
549 memcpy( &_range, buffer, sizeof( struct iw_range ) ); 551 memcpy( &_range, buffer, sizeof( struct iw_range ) );
550 qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); 552 odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl;
551 free(buffer); 553 free(buffer);
552} 554}
553 555
554 556
555void OWirelessNetworkInterface::buildPrivateList() 557void OWirelessNetworkInterface::buildPrivateList()
556{ 558{
557 qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); 559 odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl;
558 560
559 struct iw_priv_args priv[IW_MAX_PRIV_DEF]; 561 struct iw_priv_args priv[IW_MAX_PRIV_DEF];
560 562
@@ -564,7 +566,7 @@ void OWirelessNetworkInterface::buildPrivateList()
564 566
565 if ( !wioctl( SIOCGIWPRIV ) ) 567 if ( !wioctl( SIOCGIWPRIV ) )
566 { 568 {
567 qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); 569 owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information." << oendl;
568 return; 570 return;
569 } 571 }
570 572
@@ -572,18 +574,18 @@ void OWirelessNetworkInterface::buildPrivateList()
572 { 574 {
573 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 575 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
574 } 576 }
575 qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); 577 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl;
576} 578}
577 579
578 580
579void OWirelessNetworkInterface::dumpInformation() const 581void OWirelessNetworkInterface::dumpInformation() const
580{ 582{
581 qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); 583 odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl;
582 584
583 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); 585 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
584 qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); 586 qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source );
585 587
586 qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); 588 odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl;
587} 589}
588 590
589 591
@@ -610,7 +612,7 @@ void OWirelessNetworkInterface::setChannel( int c ) const
610{ 612{
611 if ( !c ) 613 if ( !c )
612 { 614 {
613 qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); 615 oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl;
614 return; 616 return;
615 } 617 }
616 618
@@ -681,7 +683,7 @@ void OWirelessNetworkInterface::setMode( const QString& newMode )
681 if ( currentMode == newMode ) return; 683 if ( currentMode == newMode ) return;
682 #endif 684 #endif
683 685
684 qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); 686 odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl;
685 687
686 _iwr.u.mode = stringToMode( newMode ); 688 _iwr.u.mode = stringToMode( newMode );
687 689
@@ -695,11 +697,11 @@ void OWirelessNetworkInterface::setMode( const QString& newMode )
695 697
696 if ( mode() == "monitor" ) 698 if ( mode() == "monitor" )
697 { 699 {
698 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); 700 odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl;
699 if ( _mon ) 701 if ( _mon )
700 _mon->setEnabled( false ); 702 _mon->setEnabled( false );
701 else 703 else
702 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 704 odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl;
703 } 705 }
704 706
705 } 707 }
@@ -707,16 +709,16 @@ void OWirelessNetworkInterface::setMode( const QString& newMode )
707 { 709 {
708 if ( wioctl( SIOCSIWMODE ) ) 710 if ( wioctl( SIOCSIWMODE ) )
709 { 711 {
710 qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); 712 odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl;
711 } 713 }
712 else 714 else
713 { 715 {
714 qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); 716 odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl;
715 717
716 if ( _mon ) 718 if ( _mon )
717 _mon->setEnabled( true ); 719 _mon->setEnabled( true );
718 else 720 else
719 qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); 721 odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl;
720 } 722 }
721 } 723 }
722} 724}
@@ -731,7 +733,7 @@ QString OWirelessNetworkInterface::mode() const
731 return "<unknown>"; 733 return "<unknown>";
732 } 734 }
733 735
734 qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); 736 odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl;
735 737
736 // legacy compatible monitor mode check 738 // legacy compatible monitor mode check
737 739
@@ -775,16 +777,18 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
775 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 777 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
776 if ( !priv ) 778 if ( !priv )
777 { 779 {
778 qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); 780 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name()
781 << "' does not support private ioctl '" << call << "'" << oendl;
779 return; 782 return;
780 } 783 }
781 if ( priv->numberSetArgs() != numargs ) 784 if ( priv->numberSetArgs() != numargs )
782 { 785 {
783 qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); 786 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '"
787 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl;
784 return; 788 return;
785 } 789 }
786 790
787 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); 791 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl;
788 memset( &_iwr, 0, sizeof _iwr ); 792 memset( &_iwr, 0, sizeof _iwr );
789 va_list argp; 793 va_list argp;
790 va_start( argp, numargs ); 794 va_start( argp, numargs );
@@ -799,7 +803,7 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
799 803
800void OWirelessNetworkInterface::getPrivate( const QString& call ) 804void OWirelessNetworkInterface::getPrivate( const QString& call )
801{ 805{
802 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); 806 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl;
803} 807}
804 808
805 809
@@ -846,7 +850,7 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
846 850
847 int timeout = 1000000; 851 int timeout = 1000000;
848 852
849 qDebug( "ONetworkInterface::scanNetwork() - scan started." ); 853 odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl;
850 854
851 bool results = false; 855 bool results = false;
852 struct timeval tv; 856 struct timeval tv;
@@ -869,7 +873,7 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
869 } 873 }
870 else if ( errno == EAGAIN) 874 else if ( errno == EAGAIN)
871 { 875 {
872 qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); 876 odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl;
873 #if 0 877 #if 0
874 if ( qApp ) 878 if ( qApp )
875 { 879 {
@@ -883,18 +887,18 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
883 } 887 }
884 } 888 }
885 889
886 qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); 890 odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl;
887 891
888 if ( results ) 892 if ( results )
889 { 893 {
890 qDebug( " - result length = %d", _iwr.u.data.length ); 894 odebug << " - result length = " << _iwr.u.data.length << oendl;
891 if ( !_iwr.u.data.length ) 895 if ( !_iwr.u.data.length )
892 { 896 {
893 qDebug( " - no results (empty neighbourhood)" ); 897 odebug << " - no results (empty neighbourhood)" << oendl;
894 return stations; 898 return stations;
895 } 899 }
896 900
897 qDebug( " - results are in!" ); 901 odebug << " - results are in!" << oendl;
898 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); 902 dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length );
899 903
900 // parse results 904 // parse results
@@ -906,42 +910,42 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
906 { 910 {
907 //const char* cmd = *(*_ioctlmap)[we->cmd]; 911 //const char* cmd = *(*_ioctlmap)[we->cmd];
908 //if ( !cmd ) cmd = "<unknown>"; 912 //if ( !cmd ) cmd = "<unknown>";
909 qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); 913 odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl;
910 switch (we->cmd) 914 switch (we->cmd)
911 { 915 {
912 case SIOCGIWAP: 916 case SIOCGIWAP:
913 { 917 {
914 qDebug( "SIOCGIWAP" ); 918 odebug << "SIOCGIWAP" << oendl;
915 stations->append( new OStation() ); 919 stations->append( new OStation() );
916 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; 920 stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0];
917 break; 921 break;
918 } 922 }
919 case SIOCGIWMODE: 923 case SIOCGIWMODE:
920 { 924 {
921 qDebug( "SIOCGIWMODE" ); 925 odebug << "SIOCGIWMODE" << oendl;
922 stations->last()->type = modeToString( we->u.mode ); 926 stations->last()->type = modeToString( we->u.mode );
923 break; 927 break;
924 } 928 }
925 case SIOCGIWFREQ: 929 case SIOCGIWFREQ:
926 { 930 {
927 qDebug( "SIOCGIWFREQ" ); 931 odebug << "SIOCGIWFREQ" << oendl;
928 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; 932 stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
929 break; 933 break;
930 } 934 }
931 case SIOCGIWESSID: 935 case SIOCGIWESSID:
932 { 936 {
933 qDebug( "SIOCGIWESSID" ); 937 odebug << "SIOCGIWESSID" << oendl;
934 stations->last()->ssid = we->u.essid.pointer; 938 stations->last()->ssid = we->u.essid.pointer;
935 break; 939 break;
936 } 940 }
937 case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; 941 case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
938 case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; 942 case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
939 case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ 943 case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
940 case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ 944 case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
941 case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ 945 case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
942 case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ 946 case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
943 case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ 947 case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
944 default: qDebug( "unhandled event" ); 948 default: odebug << "unhandled event" << oendl;
945 } 949 }
946 950
947 offset += we->len; 951 offset += we->len;
@@ -954,7 +958,7 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
954 } 958 }
955 else 959 else
956 { 960 {
957 qDebug( " - no results (timeout) :(" ); 961 odebug << " - no results (timeout) :(" << oendl;
958 return stations; 962 return stations;
959 } 963 }
960} 964}
@@ -964,10 +968,14 @@ bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
964{ 968{
965 #ifndef NODEBUG 969 #ifndef NODEBUG
966 int result = ::ioctl( _sfd, call, &iwreq ); 970 int result = ::ioctl( _sfd, call, &iwreq );
971
967 if ( result == -1 ) 972 if ( result == -1 )
968 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); 973 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
974 << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
969 else 975 else
970 qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); 976 odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
977 << debugmapper->map( call ) << "' - Status: Ok." << oendl;
978
971 return ( result != -1 ); 979 return ( result != -1 );
972 #else 980 #else
973 return ::ioctl( _sfd, call, &iwreq ) != -1; 981 return ::ioctl( _sfd, call, &iwreq ) != -1;
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 635224c..e9b3b2c 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -30,6 +30,7 @@
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/opcap.h> 32#include <opie2/opcap.h>
33#include <opie2/odebug.h>
33 34
34/* QT */ 35/* QT */
35#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 36#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
@@ -59,22 +60,22 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
59 switch ( datalink ) 60 switch ( datalink )
60 { 61 {
61 case DLT_EN10MB: 62 case DLT_EN10MB:
62 qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); 63 odebug << "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" << oendl;
63 new OEthernetPacket( _end, (const struct ether_header*) data, this ); 64 new OEthernetPacket( _end, (const struct ether_header*) data, this );
64 break; 65 break;
65 66
66 case DLT_IEEE802_11: 67 case DLT_IEEE802_11:
67 qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); 68 odebug << "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" << oendl;
68 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); 69 new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this );
69 break; 70 break;
70 71
71 case DLT_PRISM_HEADER: 72 case DLT_PRISM_HEADER:
72 qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); 73 odebug << "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" << oendl;
73 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); 74 new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this );
74 break; 75 break;
75 76
76 default: 77 default:
77 qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); 78 owarn << "OPacket::OPacket(): Received Packet over unsupported datalink, type " << datalink << "!" << oendl;
78 } 79 }
79} 80}
80 81
@@ -112,7 +113,7 @@ void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l )
112void OPacket::dumpStructure( QObjectList* l ) 113void OPacket::dumpStructure( QObjectList* l )
113{ 114{
114 QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); 115 QString packetString( "[ |" + _dumpStructure( l ) + " ]" );
115 qDebug( "OPacket::dumpStructure: %s", (const char*) packetString ); 116 odebug << "OPacket::dumpStructure: " << packetString << oendl;
116} 117}
117 118
118 119
@@ -186,20 +187,20 @@ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_h
186 :QObject( parent, "Ethernet" ), _ether( data ) 187 :QObject( parent, "Ethernet" ), _ether( data )
187{ 188{
188 189
189 qDebug( "Source = %s", (const char*) sourceAddress().toString() ); 190 odebug << "Source = " << sourceAddress().toString();
190 qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); 191 odebug << "Destination = " << destinationAddress().toString();
191 192
192 if ( sourceAddress() == OMacAddress::broadcast ) 193 if ( sourceAddress() == OMacAddress::broadcast )
193 qDebug( "Source is broadcast address" ); 194 odebug << "Source is broadcast address" << oendl;
194 if ( destinationAddress() == OMacAddress::broadcast ) 195 if ( destinationAddress() == OMacAddress::broadcast )
195 qDebug( "Destination is broadcast address" ); 196 odebug << "Destination is broadcast address" << oendl;
196 197
197 switch ( type() ) 198 switch ( type() )
198 { 199 {
199 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 200 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
200 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 201 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
201 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } 202 case ETHERTYPE_REVARP: { odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" << oendl; break; }
202 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); 203 default: odebug << "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" << oendl;
203 } 204 }
204 205
205} 206}
@@ -235,19 +236,16 @@ int OEthernetPacket::type() const
235OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) 236OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent )
236 :QObject( parent, "IP" ), _iphdr( data ) 237 :QObject( parent, "IP" ), _iphdr( data )
237{ 238{
238 qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); 239 odebug << "OIPPacket::OIPPacket(): decoding IP header..." << oendl;
239 240
240 //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); 241 odebug << "FromAddress = " << fromIPAddress().toString();
241 //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); 242 odebug << " toAddress = " << toIPAddress().toString();
242
243 qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() );
244 qDebug( " toAddress: %s", (const char*) toIPAddress().toString() );
245 243
246 switch ( protocol() ) 244 switch ( protocol() )
247 { 245 {
248 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; 246 case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break;
249 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; 247 case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break;
250 default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); 248 default: odebug << "OIPPacket::OIPPacket(): unknown IP protocol, type = " << protocol() << oendl;
251 } 249 }
252 250
253} 251}
@@ -318,10 +316,10 @@ int OIPPacket::checksum() const
318OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) 316OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent )
319 :QObject( parent, "ARP" ), _arphdr( data ) 317 :QObject( parent, "ARP" ), _arphdr( data )
320{ 318{
321 qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); 319 odebug << "OARPPacket::OARPPacket(): decoding ARP header..." << oendl;
322 qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); 320 odebug << "ARP type seems to be " << EXTRACT_16BITS( &_arphdr->ar_op ) << " = " << type() << oendl;
323 qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); 321 odebug << "Sender: MAC " << senderMacAddress().toString() << " = IP " << senderIPV4Address().toString() << oendl;
324 qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); 322 odebug << "Target: MAC " << targetMacAddress().toString() << " = IP " << targetIPV4Address().toString() << oendl;
325} 323}
326 324
327 325
@@ -379,16 +377,16 @@ OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QOb
379 :QObject( parent, "UDP" ), _udphdr( data ) 377 :QObject( parent, "UDP" ), _udphdr( data )
380 378
381{ 379{
382 qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); 380 odebug << "OUDPPacket::OUDPPacket(): decoding UDP header..." << oendl;
383 qDebug( "fromPort = %d", fromPort() ); 381 odebug << "fromPort = " << fromPort() << oendl;
384 qDebug( " toPort = %d", toPort() ); 382 odebug << " toPort = " << toPort() << oendl;
385 383
386 // 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
387 385
388 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || 386 if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC ||
389 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) 387 toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC )
390 { 388 {
391 qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." ); 389 odebug << "seems to be part of a DHCP conversation => creating DHCP packet." << oendl;
392 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); 390 new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this );
393 } 391 }
394} 392}
@@ -432,13 +430,13 @@ ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* da
432 :QObject( parent, "DHCP" ), _dhcphdr( data ) 430 :QObject( parent, "DHCP" ), _dhcphdr( data )
433 431
434{ 432{
435 qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); 433 odebug << "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." << oendl;
436 qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" ); 434 odebug << "DHCP opcode seems to be " << _dhcphdr->op << ": " << ( isRequest() ? "REQUEST" : "REPLY" ) << oendl;
437 qDebug( "clientAddress: %s", (const char*) clientAddress().toString() ); 435 odebug << "clientAddress = " << clientAddress().toString() << oendl;
438 qDebug( " yourAddress: %s", (const char*) yourAddress().toString() ); 436 odebug << " yourAddress = " << yourAddress().toString() << oendl;
439 qDebug( "serverAddress: %s", (const char*) serverAddress().toString() ); 437 odebug << "serverAddress = " << serverAddress().toString() << oendl;
440 qDebug( " relayAddress: %s", (const char*) relayAddress().toString() ); 438 odebug << " relayAddress = " << relayAddress().toString() << oendl;
441 qDebug( "parsing DHCP options..." ); 439 odebug << "parsing DHCP options..." << oendl;
442 440
443 _type = 0; 441 _type = 0;
444 442
@@ -449,7 +447,7 @@ ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* da
449 while ( ( tag = *option++ ) != -1 /* end of option field */ ) 447 while ( ( tag = *option++ ) != -1 /* end of option field */ )
450 { 448 {
451 len = *option++; 449 len = *option++;
452 qDebug( "recognized DHCP option #%d, length %d", tag, len ); 450 odebug << "recognized DHCP option #" << tag << ", length " << len << oendl;
453 451
454 if ( tag == DHO_DHCP_MESSAGE_TYPE ) 452 if ( tag == DHO_DHCP_MESSAGE_TYPE )
455 _type = *option; 453 _type = *option;
@@ -457,12 +455,12 @@ ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* da
457 option += len; 455 option += len;
458 if ( option >= end ) 456 if ( option >= end )
459 { 457 {
460 qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" ); 458 owarn << "DHCP parsing ERROR: sanity check says the packet is at its end!" << oendl;
461 break; 459 break;
462 } 460 }
463 } 461 }
464 462
465 qDebug( "DHCP type seems to be '%s'", (const char*) type() ); 463 odebug << "DHCP type seems to be << " << type() << oendl;
466} 464}
467 465
468 466
@@ -539,7 +537,7 @@ OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QOb
539 :QObject( parent, "TCP" ), _tcphdr( data ) 537 :QObject( parent, "TCP" ), _tcphdr( data )
540 538
541{ 539{
542 qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); 540 odebug << "OTCPPacket::OTCPPacket(): decoding TCP header..." << oendl;
543} 541}
544 542
545 543
@@ -592,9 +590,9 @@ OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct p
592 :QObject( parent, "Prism" ), _header( data ) 590 :QObject( parent, "Prism" ), _header( data )
593 591
594{ 592{
595 qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); 593 odebug << "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." << oendl;
596 594
597 qDebug( "Signal Strength = %d", data->signal.data ); 595 odebug << "Signal Strength = " << data->signal.data << oendl;
598 596
599 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 );
600} 598}
@@ -618,23 +616,23 @@ OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_
618 :QObject( parent, "802.11" ), _wlanhdr( data ) 616 :QObject( parent, "802.11" ), _wlanhdr( data )
619 617
620{ 618{
621 qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); 619 odebug << "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." << oendl;
622 qDebug( "type: %0X", type() ); 620 odebug << "type = " << type() << oendl;
623 qDebug( "subType: %0X", subType() ); 621 odebug << "subType = " << subType() << oendl;
624 qDebug( "duration: %d", duration() ); 622 odebug << "duration = " << duration() << oendl;
625 qDebug( "powermanagement: %d", usesPowerManagement() ); 623 odebug << "powermanagement = " << usesPowerManagement() << oendl;
626 qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); 624 odebug << "payload is encrypted = " << ( usesWep() ? "yes" : "no" ) << oendl;
627 qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); 625 odebug << "MAC1 = " << macAddress1().toString() << oendl;
628 qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); 626 odebug << "MAC2 = " << macAddress2().toString() << oendl;
629 qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); 627 odebug << "MAC3 = " << macAddress3().toString() << oendl;
630 qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); 628 odebug << "MAC4 = " << macAddress4().toString() << oendl;
631 629
632 switch ( type() ) 630 switch ( type() )
633 { 631 {
634 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;
635 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;
636 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;
637 default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); 635 default: odebug << "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type = " << type() << oendl;
638 } 636 }
639} 637}
640 638
@@ -723,8 +721,8 @@ OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, co
723 :QObject( parent, "802.11 Management" ), _header( data ), 721 :QObject( parent, "802.11 Management" ), _header( data ),
724 _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) 722 _body( (const struct ieee_802_11_mgmt_body*) (data+1) )
725{ 723{
726 qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); 724 odebug << "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." << oendl;
727 qDebug( "Detected subtype is '%s'", (const char*) managementType() ); 725 odebug << "Detected subtype is " << managementType() << oendl;
728 726
729 // grab tagged values 727 // grab tagged values
730 const unsigned char* ptr = (const unsigned char*) (_body+1); 728 const unsigned char* ptr = (const unsigned char*) (_body+1);
@@ -823,7 +821,7 @@ bool OWaveLanManagementPacket::canPrivacy() const
823OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) 821OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent )
824 :QObject( parent, "802.11 SSID" ), _data( data ) 822 :QObject( parent, "802.11 SSID" ), _data( data )
825{ 823{
826 qDebug( "OWaveLanManagementSSID()" ); 824 odebug << "OWaveLanManagementSSID()" << oendl;
827} 825}
828 826
829 827
@@ -850,7 +848,7 @@ QString OWaveLanManagementSSID::ID() const
850OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) 848OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent )
851 :QObject( parent, "802.11 Rates" ), _data( data ) 849 :QObject( parent, "802.11 Rates" ), _data( data )
852{ 850{
853 qDebug( "OWaveLanManagementRates()" ); 851 odebug << "OWaveLanManagementRates()" << oendl;
854} 852}
855 853
856 854
@@ -865,7 +863,7 @@ OWaveLanManagementRates::~OWaveLanManagementRates()
865OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) 863OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent )
866 :QObject( parent, "802.11 CF" ), _data( data ) 864 :QObject( parent, "802.11 CF" ), _data( data )
867{ 865{
868 qDebug( "OWaveLanManagementCF()" ); 866 odebug << "OWaveLanManagementCF()" << oendl;
869} 867}
870 868
871 869
@@ -880,7 +878,7 @@ OWaveLanManagementCF::~OWaveLanManagementCF()
880OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) 878OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent )
881 :QObject( parent, "802.11 FH" ), _data( data ) 879 :QObject( parent, "802.11 FH" ), _data( data )
882{ 880{
883 qDebug( "OWaveLanManagementFH()" ); 881 odebug << "OWaveLanManagementFH()" << oendl;
884} 882}
885 883
886 884
@@ -895,7 +893,7 @@ OWaveLanManagementFH::~OWaveLanManagementFH()
895OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) 893OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent )
896 :QObject( parent, "802.11 DS" ), _data( data ) 894 :QObject( parent, "802.11 DS" ), _data( data )
897{ 895{
898 qDebug( "OWaveLanManagementDS()" ); 896 odebug << "OWaveLanManagementDS()" << oendl;
899} 897}
900 898
901 899
@@ -916,7 +914,7 @@ int OWaveLanManagementDS::channel() const
916OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) 914OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent )
917 :QObject( parent, "802.11 Tim" ), _data( data ) 915 :QObject( parent, "802.11 Tim" ), _data( data )
918{ 916{
919 qDebug( "OWaveLanManagementTim()" ); 917 odebug << "OWaveLanManagementTim()" << oendl;
920} 918}
921 919
922 920
@@ -931,7 +929,7 @@ OWaveLanManagementTim::~OWaveLanManagementTim()
931OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) 929OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent )
932 :QObject( parent, "802.11 IBSS" ), _data( data ) 930 :QObject( parent, "802.11 IBSS" ), _data( data )
933{ 931{
934 qDebug( "OWaveLanManagementIBSS()" ); 932 odebug << "OWaveLanManagementIBSS()" << oendl;
935} 933}
936 934
937 935
@@ -946,7 +944,7 @@ OWaveLanManagementIBSS::~OWaveLanManagementIBSS()
946OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) 944OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent )
947 :QObject( parent, "802.11 Challenge" ), _data( data ) 945 :QObject( parent, "802.11 Challenge" ), _data( data )
948{ 946{
949 qDebug( "OWaveLanManagementChallenge()" ); 947 odebug << "OWaveLanManagementChallenge()" << oendl;
950} 948}
951 949
952 950
@@ -961,7 +959,7 @@ OWaveLanManagementChallenge::~OWaveLanManagementChallenge()
961OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) 959OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent )
962 :QObject( parent, "802.11 Data" ), _header( data ) 960 :QObject( parent, "802.11 Data" ), _header( data )
963{ 961{
964 qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." ); 962 odebug << "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." << oendl;
965 963
966 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); 964 const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header );
967 965
@@ -984,19 +982,18 @@ OWaveLanDataPacket::~OWaveLanDataPacket()
984OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) 982OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent )
985 :QObject( parent, "802.11 LLC" ), _header( data ) 983 :QObject( parent, "802.11 LLC" ), _header( data )
986{ 984{
987 qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); 985 odebug << "OLLCPacket::OLLCPacket(): decoding frame..." << oendl;
988 986
989 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) 987 if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) )
990 { 988 {
991 qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 989 owarn << "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type = " << EXTRACT_16BITS( &_header->type ) << ")" << oendl;
992 990
993 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h 991 switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h
994 { 992 {
995 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 993 case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
996 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; 994 case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
997 default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) ); 995 default: owarn << "OLLCPacket::OLLCPacket(): Unknown Encapsulation type = " << EXTRACT_16BITS( &_header->type ) << oendl;
998 } 996 }
999
1000 } 997 }
1001} 998}
1002 999
@@ -1013,7 +1010,7 @@ OLLCPacket::~OLLCPacket()
1013OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) 1010OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent )
1014 :QObject( parent, "802.11 Control" ), _header( data ) 1011 :QObject( parent, "802.11 Control" ), _header( data )
1015{ 1012{
1016 qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." ); 1013 odebug << "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." << oendl;
1017 //TODO: Implement this 1014 //TODO: Implement this
1018} 1015}
1019 1016
@@ -1038,7 +1035,7 @@ OPacketCapturer::~OPacketCapturer()
1038{ 1035{
1039 if ( _open ) 1036 if ( _open )
1040 { 1037 {
1041 qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); 1038 odebug << "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." << oendl;
1042 close(); 1039 close();
1043 } 1040 }
1044} 1041}
@@ -1048,11 +1045,11 @@ void OPacketCapturer::setBlocking( bool b )
1048{ 1045{
1049 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) 1046 if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 )
1050 { 1047 {
1051 qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); 1048 odebug << "OPacketCapturer::setBlocking(): blocking mode changed successfully." << oendl;
1052 } 1049 }
1053 else 1050 else
1054 { 1051 {
1055 qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); 1052 odebug << "OPacketCapturer::setBlocking(): can't change blocking mode: " << _errbuf << oendl;
1056 } 1053 }
1057} 1054}
1058 1055
@@ -1062,7 +1059,7 @@ bool OPacketCapturer::blocking() const
1062 int b = pcap_getnonblock( _pch, _errbuf ); 1059 int b = pcap_getnonblock( _pch, _errbuf );
1063 if ( b == -1 ) 1060 if ( b == -1 )
1064 { 1061 {
1065 qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); 1062 odebug << "OPacketCapturer::blocking(): can't get blocking mode: " << _errbuf << oendl;
1066 return -1; 1063 return -1;
1067 } 1064 }
1068 return !b; 1065 return !b;
@@ -1093,11 +1090,11 @@ void OPacketCapturer::close()
1093 _open = false; 1090 _open = false;
1094 } 1091 }
1095 1092
1096 qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); 1093 odebug << "OPacketCapturer::close() --- dumping capturing statistics..." << oendl;
1097 qDebug( "--------------------------------------------------" ); 1094 odebug << "--------------------------------------------------" << oendl;
1098 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) 1095 for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it )
1099 qDebug( "%s : %d", (const char*) it.key(), it.data() ); 1096 odebug << it.key() << " = " << it.data() << oendl;
1100 qDebug( "--------------------------------------------------" ); 1097 odebug << "--------------------------------------------------" << oendl;
1101 1098
1102} 1099}
1103 1100
@@ -1151,9 +1148,9 @@ OPacket* OPacketCapturer::next( int time )
1151OPacket* OPacketCapturer::next() 1148OPacket* OPacketCapturer::next()
1152{ 1149{
1153 packetheaderstruct header; 1150 packetheaderstruct header;
1154 qDebug( "==> OPacketCapturer::next()" ); 1151 odebug << "==> OPacketCapturer::next()" << oendl;
1155 const unsigned char* pdata = pcap_next( _pch, &header ); 1152 const unsigned char* pdata = pcap_next( _pch, &header );
1156 qDebug( "<== OPacketCapturer::next()" ); 1153 odebug << "<== OPacketCapturer::next()" << oendl;
1157 1154
1158 if ( pdata && header.len ) 1155 if ( pdata && header.len )
1159 { 1156 {
@@ -1198,11 +1195,11 @@ bool OPacketCapturer::open( const QString& name )
1198 1195
1199 if ( !handle ) 1196 if ( !handle )
1200 { 1197 {
1201 qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1198 owarn << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
1202 return false; 1199 return false;
1203 } 1200 }
1204 1201
1205 qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); 1202 odebug << "OPacketCapturer::open(): libpcap [" << name << "] opened successfully." << oendl;
1206 _pch = handle; 1203 _pch = handle;
1207 _open = true; 1204 _open = true;
1208 _stats.clear(); 1205 _stats.clear();
@@ -1223,10 +1220,10 @@ bool OPacketCapturer::openDumpFile( const QString& filename )
1223 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); 1220 pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) );
1224 if ( !dump ) 1221 if ( !dump )
1225 { 1222 {
1226 qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); 1223 owarn << "OPacketCapturer::open(): can't open dump with '" << filename << "': " << _errbuf << oendl;
1227 return false; 1224 return false;
1228 } 1225 }
1229 qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); 1226 odebug << "OPacketCapturer::open(): dump [" << filename << "] opened successfully." << oendl;
1230 _pcd = dump; 1227 _pcd = dump;
1231 1228
1232 return true; 1229 return true;
@@ -1256,7 +1253,7 @@ bool OPacketCapturer::open( const QFile& file )
1256 1253
1257 if ( handle ) 1254 if ( handle )
1258 { 1255 {
1259 qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); 1256 odebug << "OPacketCapturer::open(): libpcap opened successfully." << oendl;
1260 _pch = handle; 1257 _pch = handle;
1261 _open = true; 1258 _open = true;
1262 1259
@@ -1271,7 +1268,7 @@ bool OPacketCapturer::open( const QFile& file )
1271 } 1268 }
1272 else 1269 else
1273 { 1270 {
1274 qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); 1271 odebug << "OPacketCapturer::open(): can't open libpcap with '" << name << "': " << _errbuf << oendl;
1275 return false; 1272 return false;
1276 } 1273 }
1277 1274
@@ -1286,7 +1283,7 @@ bool OPacketCapturer::isOpen() const
1286 1283
1287void OPacketCapturer::readyToReceive() 1284void OPacketCapturer::readyToReceive()
1288{ 1285{
1289 qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" ); 1286 odebug << "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" << oendl;
1290 OPacket* p = next(); 1287 OPacket* p = next();
1291 emit receivedPacket( p ); 1288 emit receivedPacket( p );
1292 // emit is synchronous - packet has been dealt with, now it's safe to delete 1289 // emit is synchronous - packet has been dealt with, now it's safe to delete
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index c363f0c..8c989d8 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -29,6 +29,7 @@
29*/ 29*/
30 30
31#include <opie2/ostation.h> 31#include <opie2/ostation.h>
32#include <opie2/odebug.h>
32 33
33/*====================================================================================== 34/*======================================================================================
34 * OStation 35 * OStation
@@ -36,7 +37,7 @@
36 37
37OStation::OStation() 38OStation::OStation()
38{ 39{
39 qDebug( "OStation::OStation()" ); 40 odebug << "OStation::OStation()" << oendl;
40 41
41 type = "<unknown>"; 42 type = "<unknown>";
42 macAddress = OMacAddress::unknown; 43 macAddress = OMacAddress::unknown;
@@ -49,13 +50,13 @@ OStation::OStation()
49 50
50OStation::~OStation() 51OStation::~OStation()
51{ 52{
52 qDebug( "OStation::~OStation()" ); 53 odebug << "OStation::~OStation()" << oendl;
53} 54}
54 55
55 56
56void OStation::dump() 57void OStation::dump()
57{ 58{
58 qDebug( "------- OStation::dump() ------------" ); 59 odebug << "------- OStation::dump() ------------" << oendl;
59 qDebug( "type: %s", (const char*) type ); 60 qDebug( "type: %s", (const char*) type );
60 qDebug( "mac: %s", (const char*) macAddress.toString() ); 61 qDebug( "mac: %s", (const char*) macAddress.toString() );
61 qDebug( "ap: %s", (const char*) apAddress.toString() ); 62 qDebug( "ap: %s", (const char*) apAddress.toString() );