summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
authormickeyl <mickeyl>2005-05-06 09:27:12 (UTC)
committer mickeyl <mickeyl>2005-05-06 09:27:12 (UTC)
commit543d9d7c58c9601dba6f47b3a4011313d1d75499 (patch) (unidiff)
tree6b9d259a91b220264c961d542e25b69fe070320f /libopie2/opienet/onetwork.cpp
parentc199fa0b0ef971c3a121af6c31a9a9822561a1be (diff)
downloadopie-543d9d7c58c9601dba6f47b3a4011313d1d75499.zip
opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.tar.gz
opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.tar.bz2
- OManufacturerDB: check if there is a QApplication before calling Global::statusMessage or qApp->processEvents()
- ONetwork: skip hostap control interfaces 'wifi*' - OWirelessNetworkInterface: set \0 in SSID() and nickName() to work around (buggy) drivers not returning a zero-terminated string
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 0a74019..f4bdbe0 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -83,48 +83,54 @@ ONetwork::ONetwork()
83void ONetwork::synchronize() 83void ONetwork::synchronize()
84{ 84{
85 // gather available interfaces by inspecting /proc/net/dev 85 // gather available interfaces by inspecting /proc/net/dev
86 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 86 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
87 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 87 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
88 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 88 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
89 89
90 _interfaces.clear(); 90 _interfaces.clear();
91 QString str; 91 QString str;
92 QFile f( "/proc/net/dev" ); 92 QFile f( "/proc/net/dev" );
93 bool hasFile = f.open( IO_ReadOnly ); 93 bool hasFile = f.open( IO_ReadOnly );
94 if ( !hasFile ) 94 if ( !hasFile )
95 { 95 {
96 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 96 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
97 return; 97 return;
98 } 98 }
99 QTextStream s( &f ); 99 QTextStream s( &f );
100 s.readLine(); 100 s.readLine();
101 s.readLine(); 101 s.readLine();
102 while ( !s.atEnd() ) 102 while ( !s.atEnd() )
103 { 103 {
104 s >> str; 104 s >> str;
105 str.truncate( str.find( ':' ) ); 105 str.truncate( str.find( ':' ) );
106 odebug << "ONetwork: found interface '" << str << "'" << oendl; 106 odebug << "ONetwork: found interface '" << str << "'" << oendl;
107 if ( str.startsWith( "wifi" ) )
108 {
109 odebug << "ONetwork: ignoring hostap control interface" << oendl;
110 s.readLine();
111 continue;
112 }
107 ONetworkInterface* iface = 0; 113 ONetworkInterface* iface = 0;
108 if ( isWirelessInterface( str ) ) 114 if ( isWirelessInterface( str ) )
109 { 115 {
110 iface = new OWirelessNetworkInterface( this, (const char*) str ); 116 iface = new OWirelessNetworkInterface( this, (const char*) str );
111 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 117 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
112 } 118 }
113 else 119 else
114 { 120 {
115 iface = new ONetworkInterface( this, (const char*) str ); 121 iface = new ONetworkInterface( this, (const char*) str );
116 } 122 }
117 _interfaces.insert( str, iface ); 123 _interfaces.insert( str, iface );
118 s.readLine(); 124 s.readLine();
119 } 125 }
120} 126}
121 127
122 128
123short ONetwork::wirelessExtensionCompileVersion() 129short ONetwork::wirelessExtensionCompileVersion()
124{ 130{
125 return WIRELESS_EXT; 131 return WIRELESS_EXT;
126} 132}
127 133
128 134
129int ONetwork::count() const 135int ONetwork::count() const
130{ 136{
@@ -787,49 +793,49 @@ QString OWirelessNetworkInterface::mode() const
787 { 793 {
788 return modeToString( _iwr.u.mode ); 794 return modeToString( _iwr.u.mode );
789 } 795 }
790} 796}
791 797
792void OWirelessNetworkInterface::setNickName( const QString& nickname ) 798void OWirelessNetworkInterface::setNickName( const QString& nickname )
793{ 799{
794 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); 800 _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname );
795 _iwr.u.essid.length = nickname.length(); 801 _iwr.u.essid.length = nickname.length();
796 wioctl( SIOCSIWNICKN ); 802 wioctl( SIOCSIWNICKN );
797} 803}
798 804
799 805
800QString OWirelessNetworkInterface::nickName() const 806QString OWirelessNetworkInterface::nickName() const
801{ 807{
802 char str[IW_ESSID_MAX_SIZE]; 808 char str[IW_ESSID_MAX_SIZE];
803 _iwr.u.data.pointer = &str[0]; 809 _iwr.u.data.pointer = &str[0];
804 _iwr.u.data.length = IW_ESSID_MAX_SIZE; 810 _iwr.u.data.length = IW_ESSID_MAX_SIZE;
805 if ( !wioctl( SIOCGIWNICKN ) ) 811 if ( !wioctl( SIOCGIWNICKN ) )
806 { 812 {
807 return "<unknown>"; 813 return "<unknown>";
808 } 814 }
809 else 815 else
810 { 816 {
811 str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string 817 str[_iwr.u.data.length] = '\0'; // some drivers don't zero-terminate the string
812 return str; 818 return str;
813 } 819 }
814} 820}
815 821
816 822
817void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) 823void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... )
818{ 824{
819 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); 825 OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) );
820 if ( !priv ) 826 if ( !priv )
821 { 827 {
822 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() 828 owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name()
823 << "' does not support private ioctl '" << call << "'" << oendl; 829 << "' does not support private ioctl '" << call << "'" << oendl;
824 return; 830 return;
825 } 831 }
826 if ( priv->numberSetArgs() != numargs ) 832 if ( priv->numberSetArgs() != numargs )
827 { 833 {
828 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" 834 owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '"
829 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; 835 << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl;
830 return; 836 return;
831 } 837 }
832 838
833 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; 839 odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl;
834 memset( &_iwr, 0, sizeof _iwr ); 840 memset( &_iwr, 0, sizeof _iwr );
835 va_list argp; 841 va_list argp;
@@ -845,48 +851,49 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
845 851
846void OWirelessNetworkInterface::getPrivate( const QString& ) 852void OWirelessNetworkInterface::getPrivate( const QString& )
847{ 853{
848 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; 854 oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl;
849} 855}
850 856
851 857
852bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 858bool OWirelessNetworkInterface::hasPrivate( const QString& call )
853{ 859{
854 return child( call.local8Bit() ); 860 return child( call.local8Bit() );
855} 861}
856 862
857 863
858QString OWirelessNetworkInterface::SSID() const 864QString OWirelessNetworkInterface::SSID() const
859{ 865{
860 char str[IW_ESSID_MAX_SIZE]; 866 char str[IW_ESSID_MAX_SIZE];
861 _iwr.u.essid.pointer = &str[0]; 867 _iwr.u.essid.pointer = &str[0];
862 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 868 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
863 if ( !wioctl( SIOCGIWESSID ) ) 869 if ( !wioctl( SIOCGIWESSID ) )
864 { 870 {
865 return "<unknown>"; 871 return "<unknown>";
866 } 872 }
867 else 873 else
868 { 874 {
875 str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string
869 return str; 876 return str;
870 } 877 }
871} 878}
872 879
873 880
874void OWirelessNetworkInterface::setSSID( const QString& ssid ) 881void OWirelessNetworkInterface::setSSID( const QString& ssid )
875{ 882{
876 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 883 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
877 _iwr.u.essid.length = ssid.length()+1; // zero byte 884 _iwr.u.essid.length = ssid.length()+1; // zero byte
878 wioctl( SIOCSIWESSID ); 885 wioctl( SIOCSIWESSID );
879} 886}
880 887
881 888
882OStationList* OWirelessNetworkInterface::scanNetwork() 889OStationList* OWirelessNetworkInterface::scanNetwork()
883{ 890{
884 _iwr.u.param.flags = IW_SCAN_DEFAULT; 891 _iwr.u.param.flags = IW_SCAN_DEFAULT;
885 _iwr.u.param.value = 0; 892 _iwr.u.param.value = 0;
886 if ( !wioctl( SIOCSIWSCAN ) ) 893 if ( !wioctl( SIOCSIWSCAN ) )
887 { 894 {
888 return 0; 895 return 0;
889 } 896 }
890 897
891 OStationList* stations = new OStationList(); 898 OStationList* stations = new OStationList();
892 899