-rw-r--r-- | libopie2/opienet/onetwork.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 6a363d7..f52279a 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -74,54 +74,54 @@ void ONetwork::synchronize() | |||
74 | // gather available interfaces by inspecting /proc/net/dev | 74 | // gather available interfaces by inspecting /proc/net/dev |
75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 75 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 76 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
77 | 77 | ||
78 | _interfaces.clear(); | 78 | _interfaces.clear(); |
79 | QString str; | 79 | QString str; |
80 | QFile f( "/proc/net/dev" ); | 80 | QFile f( "/proc/net/dev" ); |
81 | bool hasFile = f.open( IO_ReadOnly ); | 81 | bool hasFile = f.open( IO_ReadOnly ); |
82 | if ( !hasFile ) | 82 | if ( !hasFile ) |
83 | { | 83 | { |
84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 84 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
85 | return; | 85 | return; |
86 | } | 86 | } |
87 | QTextStream s( &f ); | 87 | QTextStream s( &f ); |
88 | s.readLine(); | 88 | s.readLine(); |
89 | s.readLine(); | 89 | s.readLine(); |
90 | while ( !s.atEnd() ) | 90 | while ( !s.atEnd() ) |
91 | { | 91 | { |
92 | s >> str; | 92 | s >> str; |
93 | str.truncate( str.find( ':' ) ); | 93 | str.truncate( str.find( ':' ) ); |
94 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 94 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
95 | ONetworkInterface* iface; | 95 | ONetworkInterface* iface; |
96 | if ( isWirelessInterface( str ) ) | 96 | if ( isWirelessInterface( str ) ) |
97 | { | 97 | { |
98 | iface = new OWirelessNetworkInterface( this, str ); | 98 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
99 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 99 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
100 | } | 100 | } |
101 | else | 101 | else |
102 | { | 102 | { |
103 | iface = new ONetworkInterface( this, str ); | 103 | iface = new ONetworkInterface( this, (const char*) str ); |
104 | } | 104 | } |
105 | _interfaces.insert( str, iface ); | 105 | _interfaces.insert( str, iface ); |
106 | s.readLine(); | 106 | s.readLine(); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | ONetworkInterface* ONetwork::interface( QString iface ) const | 111 | ONetworkInterface* ONetwork::interface( QString iface ) const |
112 | { | 112 | { |
113 | return _interfaces[iface]; | 113 | return _interfaces[iface]; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | ONetwork* ONetwork::instance() | 117 | ONetwork* ONetwork::instance() |
118 | { | 118 | { |
119 | if ( !_instance ) _instance = new ONetwork(); | 119 | if ( !_instance ) _instance = new ONetwork(); |
120 | return _instance; | 120 | return _instance; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | ONetwork::InterfaceIterator ONetwork::iterator() const | 124 | ONetwork::InterfaceIterator ONetwork::iterator() const |
125 | { | 125 | { |
126 | return ONetwork::InterfaceIterator( _interfaces ); | 126 | return ONetwork::InterfaceIterator( _interfaces ); |
127 | } | 127 | } |
@@ -153,51 +153,51 @@ ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | |||
153 | struct ifreq& ONetworkInterface::ifr() const | 153 | struct ifreq& ONetworkInterface::ifr() const |
154 | { | 154 | { |
155 | return _ifr; | 155 | return _ifr; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | void ONetworkInterface::init() | 159 | void ONetworkInterface::init() |
160 | { | 160 | { |
161 | qDebug( "ONetworkInterface::init()" ); | 161 | qDebug( "ONetworkInterface::init()" ); |
162 | 162 | ||
163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 163 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
164 | 164 | ||
165 | if ( _sfd == -1 ) | 165 | if ( _sfd == -1 ) |
166 | { | 166 | { |
167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); | 167 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 173 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
174 | { | 174 | { |
175 | int result = ::ioctl( _sfd, call, &ifreq ); | 175 | int result = ::ioctl( _sfd, call, &ifreq ); |
176 | if ( result == -1 ) | 176 | if ( result == -1 ) |
177 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); | 177 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); |
178 | else | 178 | else |
179 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call ); | 179 | qDebug( "ONetworkInterface::ioctl (%s) call %d - Status: Ok.", name(), call ); |
180 | return ( result != -1 ); | 180 | return ( result != -1 ); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | bool ONetworkInterface::ioctl( int call ) const | 184 | bool ONetworkInterface::ioctl( int call ) const |
185 | { | 185 | { |
186 | strcpy( _ifr.ifr_name, name() ); | 186 | strcpy( _ifr.ifr_name, name() ); |
187 | return ioctl( call, _ifr ); | 187 | return ioctl( call, _ifr ); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | bool ONetworkInterface::isLoopback() const | 191 | bool ONetworkInterface::isLoopback() const |
192 | { | 192 | { |
193 | ioctl( SIOCGIFFLAGS ); | 193 | ioctl( SIOCGIFFLAGS ); |
194 | return _ifr.ifr_flags & IFF_LOOPBACK; | 194 | return _ifr.ifr_flags & IFF_LOOPBACK; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | bool ONetworkInterface::setUp( bool b ) | 198 | bool ONetworkInterface::setUp( bool b ) |
199 | { | 199 | { |
200 | ioctl( SIOCGIFFLAGS ); | 200 | ioctl( SIOCGIFFLAGS ); |
201 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 201 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
202 | else _ifr.ifr_flags &= (~IFF_UP); | 202 | else _ifr.ifr_flags &= (~IFF_UP); |
203 | return ioctl( SIOCSIFFLAGS ); | 203 | return ioctl( SIOCSIFFLAGS ); |
@@ -657,51 +657,51 @@ QString OWirelessNetworkInterface::SSID() const | |||
657 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 657 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
658 | if ( !wioctl( SIOCGIWESSID ) ) | 658 | if ( !wioctl( SIOCGIWESSID ) ) |
659 | { | 659 | { |
660 | return "<unknown>"; | 660 | return "<unknown>"; |
661 | } | 661 | } |
662 | else | 662 | else |
663 | { | 663 | { |
664 | return str; | 664 | return str; |
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | 668 | ||
669 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 669 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
670 | { | 670 | { |
671 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 671 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
672 | _iwr.u.essid.length = ssid.length(); | 672 | _iwr.u.essid.length = ssid.length(); |
673 | wioctl( SIOCSIWESSID ); | 673 | wioctl( SIOCSIWESSID ); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 677 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
678 | { | 678 | { |
679 | int result = ::ioctl( _sfd, call, &iwreq ); | 679 | int result = ::ioctl( _sfd, call, &iwreq ); |
680 | if ( result == -1 ) | 680 | if ( result == -1 ) |
681 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); | 681 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); |
682 | else | 682 | else |
683 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call ); | 683 | qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); |
684 | return ( result != -1 ); | 684 | return ( result != -1 ); |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | bool OWirelessNetworkInterface::wioctl( int call ) const | 688 | bool OWirelessNetworkInterface::wioctl( int call ) const |
689 | { | 689 | { |
690 | strcpy( _iwr.ifr_name, name() ); | 690 | strcpy( _iwr.ifr_name, name() ); |
691 | return wioctl( call, _iwr ); | 691 | return wioctl( call, _iwr ); |
692 | } | 692 | } |
693 | 693 | ||
694 | 694 | ||
695 | /*====================================================================================== | 695 | /*====================================================================================== |
696 | * OMonitoringInterface | 696 | * OMonitoringInterface |
697 | *======================================================================================*/ | 697 | *======================================================================================*/ |
698 | 698 | ||
699 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) | 699 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) |
700 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ) | 700 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ) |
701 | { | 701 | { |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | OMonitoringInterface::~OMonitoringInterface() | 705 | OMonitoringInterface::~OMonitoringInterface() |
706 | { | 706 | { |
707 | } | 707 | } |