-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 | |||
@@ -34,2 +34,3 @@ | |||
34 | #include <opie2/ostation.h> | 34 | #include <opie2/ostation.h> |
35 | #include <opie2/odebug.h> | ||
35 | 36 | ||
@@ -69,4 +70,4 @@ 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(); |
@@ -87,3 +88,3 @@ void ONetwork::synchronize() | |||
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; |
@@ -97,3 +98,3 @@ void ONetwork::synchronize() | |||
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; |
@@ -102,3 +103,3 @@ void ONetwork::synchronize() | |||
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 | } |
@@ -163,3 +164,3 @@ ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | |||
163 | { | 164 | { |
164 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 165 | odebug << "ONetworkInterface::ONetworkInterface()" << oendl; |
165 | init(); | 166 | init(); |
@@ -176,3 +177,3 @@ void ONetworkInterface::init() | |||
176 | { | 177 | { |
177 | qDebug( "ONetworkInterface::init()" ); | 178 | odebug << "ONetworkInterface::init()" << oendl; |
178 | 179 | ||
@@ -182,3 +183,3 @@ void ONetworkInterface::init() | |||
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; |
@@ -193,5 +194,7 @@ bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | |||
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 ); |
@@ -317,3 +320,3 @@ void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | |||
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 | } |
@@ -329,3 +332,3 @@ 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 ); |
@@ -406,4 +409,3 @@ void OChannelHopper::timerEvent( QTimerEvent* ) | |||
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(); |
@@ -443,3 +445,3 @@ OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const cha | |||
443 | { | 445 | { |
444 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 446 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; |
445 | init(); | 447 | init(); |
@@ -461,3 +463,3 @@ 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 ) ); |
@@ -508,3 +510,3 @@ void OWirelessNetworkInterface::buildInformation() | |||
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 |
@@ -532,4 +534,4 @@ void OWirelessNetworkInterface::buildInformation() | |||
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 | } |
@@ -540,3 +542,3 @@ void OWirelessNetworkInterface::buildInformation() | |||
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 ) |
@@ -549,3 +551,3 @@ void OWirelessNetworkInterface::buildInformation() | |||
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); |
@@ -556,3 +558,3 @@ void OWirelessNetworkInterface::buildPrivateList() | |||
556 | { | 558 | { |
557 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); | 559 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; |
558 | 560 | ||
@@ -566,3 +568,3 @@ void OWirelessNetworkInterface::buildPrivateList() | |||
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; |
@@ -574,3 +576,3 @@ void OWirelessNetworkInterface::buildPrivateList() | |||
574 | } | 576 | } |
575 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); | 577 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; |
576 | } | 578 | } |
@@ -580,3 +582,3 @@ void OWirelessNetworkInterface::dumpInformation() const | |||
580 | { | 582 | { |
581 | qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); | 583 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; |
582 | 584 | ||
@@ -585,3 +587,3 @@ void OWirelessNetworkInterface::dumpInformation() const | |||
585 | 587 | ||
586 | qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); | 588 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; |
587 | } | 589 | } |
@@ -612,3 +614,3 @@ void OWirelessNetworkInterface::setChannel( int c ) const | |||
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; |
@@ -683,3 +685,3 @@ void OWirelessNetworkInterface::setMode( const QString& newMode ) | |||
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 | ||
@@ -697,3 +699,3 @@ void OWirelessNetworkInterface::setMode( const QString& newMode ) | |||
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 ) |
@@ -701,3 +703,3 @@ void OWirelessNetworkInterface::setMode( const QString& newMode ) | |||
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 | } |
@@ -709,3 +711,3 @@ void OWirelessNetworkInterface::setMode( const QString& newMode ) | |||
709 | { | 711 | { |
710 | qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); | 712 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; |
711 | } | 713 | } |
@@ -713,3 +715,3 @@ void OWirelessNetworkInterface::setMode( const QString& newMode ) | |||
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 | ||
@@ -718,3 +720,3 @@ void OWirelessNetworkInterface::setMode( const QString& newMode ) | |||
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 | } |
@@ -733,3 +735,3 @@ QString OWirelessNetworkInterface::mode() const | |||
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 | ||
@@ -777,3 +779,4 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, .. | |||
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; |
@@ -782,3 +785,4 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int 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; |
@@ -786,3 +790,3 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, .. | |||
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 ); |
@@ -801,3 +805,3 @@ 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 | } |
@@ -848,3 +852,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
848 | 852 | ||
849 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); | 853 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; |
850 | 854 | ||
@@ -871,3 +875,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
871 | { | 875 | { |
872 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); | 876 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; |
873 | #if 0 | 877 | #if 0 |
@@ -885,3 +889,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
885 | 889 | ||
886 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); | 890 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; |
887 | 891 | ||
@@ -889,6 +893,6 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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; |
@@ -896,3 +900,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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 ); |
@@ -908,3 +912,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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) |
@@ -913,3 +917,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
913 | { | 917 | { |
914 | qDebug( "SIOCGIWAP" ); | 918 | odebug << "SIOCGIWAP" << oendl; |
915 | stations->append( new OStation() ); | 919 | stations->append( new OStation() ); |
@@ -920,3 +924,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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 ); |
@@ -926,3 +930,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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) ]; |
@@ -932,3 +936,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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; |
@@ -936,10 +940,10 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
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 | } |
@@ -956,3 +960,3 @@ OStationList* OWirelessNetworkInterface::scanNetwork() | |||
956 | { | 960 | { |
957 | qDebug( " - no results (timeout) :(" ); | 961 | odebug << " - no results (timeout) :(" << oendl; |
958 | return stations; | 962 | return stations; |
@@ -966,6 +970,10 @@ bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | |||
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 ); |