-rw-r--r-- | libopie2/opienet/onetwork.cpp | 128 |
1 files changed, 68 insertions, 60 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 | ||
68 | ONetwork::ONetwork() | 69 | ONetwork::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 | ||
175 | void ONetworkInterface::init() | 176 | void 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 | |||
315 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 318 | void 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 | ||
328 | ONetworkInterface::~ONetworkInterface() | 331 | ONetworkInterface::~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 | |||
441 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 443 | OWirelessNetworkInterface::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 | ||
460 | void OWirelessNetworkInterface::init() | 462 | void 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 | ||
555 | void OWirelessNetworkInterface::buildPrivateList() | 557 | void 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 | ||
579 | void OWirelessNetworkInterface::dumpInformation() const | 581 | void 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 | ||
800 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 804 | void 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; |