author | mickeyl <mickeyl> | 2003-04-04 23:20:06 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-04 23:20:06 (UTC) |
commit | e4c19111590664371c359878e5c79428bc7b02c9 (patch) (unidiff) | |
tree | 359c86228f9587415e60ffa1f6614e7e2cbc0153 | |
parent | 998e0da2ba2823f6048f420d69386b2265247e81 (diff) | |
download | opie-e4c19111590664371c359878e5c79428bc7b02c9.zip opie-e4c19111590664371c359878e5c79428bc7b02c9.tar.gz opie-e4c19111590664371c359878e5c79428bc7b02c9.tar.bz2 |
fix segfault due to giving a QString as opposed to a char* as the Qbject name
-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 | |||
@@ -2,274 +2,274 @@ | |||
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003 by the Wellenreiter team: | 3 | Copyright (C) 2003 by the Wellenreiter team: |
4 | Martin J. Muench <mjm@remote-exploit.org> | 4 | Martin J. Muench <mjm@remote-exploit.org> |
5 | Max Moser <mmo@remote-exploit.org | 5 | Max Moser <mmo@remote-exploit.org |
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/onetwork.h> | 36 | #include <opie2/onetwork.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* UNIX */ | 43 | /* UNIX */ |
44 | 44 | ||
45 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
46 | #include <cerrno> | 46 | #include <cerrno> |
47 | #include <cstring> | 47 | #include <cstring> |
48 | #include <cstdlib> | 48 | #include <cstdlib> |
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 54 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | 55 | #include <net/if_arp.h> |
56 | #include <stdarg.h> | 56 | #include <stdarg.h> |
57 | 57 | ||
58 | using namespace std; | 58 | using namespace std; |
59 | 59 | ||
60 | /*====================================================================================== | 60 | /*====================================================================================== |
61 | * ONetwork | 61 | * ONetwork |
62 | *======================================================================================*/ | 62 | *======================================================================================*/ |
63 | 63 | ||
64 | ONetwork* ONetwork::_instance = 0; | 64 | ONetwork* ONetwork::_instance = 0; |
65 | 65 | ||
66 | ONetwork::ONetwork() | 66 | ONetwork::ONetwork() |
67 | { | 67 | { |
68 | qDebug( "ONetwork::ONetwork()" ); | 68 | qDebug( "ONetwork::ONetwork()" ); |
69 | synchronize(); | 69 | synchronize(); |
70 | } | 70 | } |
71 | 71 | ||
72 | void ONetwork::synchronize() | 72 | void ONetwork::synchronize() |
73 | { | 73 | { |
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 | } |
128 | 128 | ||
129 | 129 | ||
130 | bool ONetwork::isWirelessInterface( const char* name ) const | 130 | bool ONetwork::isWirelessInterface( const char* name ) const |
131 | { | 131 | { |
132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 132 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
133 | struct iwreq iwr; | 133 | struct iwreq iwr; |
134 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 134 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
135 | strcpy( (char*) &iwr.ifr_name, name ); | 135 | strcpy( (char*) &iwr.ifr_name, name ); |
136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 136 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
137 | return result != -1; | 137 | return result != -1; |
138 | } | 138 | } |
139 | 139 | ||
140 | /*====================================================================================== | 140 | /*====================================================================================== |
141 | * ONetworkInterface | 141 | * ONetworkInterface |
142 | *======================================================================================*/ | 142 | *======================================================================================*/ |
143 | 143 | ||
144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 144 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
145 | :QObject( parent, name ), | 145 | :QObject( parent, name ), |
146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 146 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
147 | { | 147 | { |
148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 148 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
149 | init(); | 149 | init(); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
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 ); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | bool ONetworkInterface::isUp() const | 207 | bool ONetworkInterface::isUp() const |
208 | { | 208 | { |
209 | ioctl( SIOCGIFFLAGS ); | 209 | ioctl( SIOCGIFFLAGS ); |
210 | return _ifr.ifr_flags & IFF_UP; | 210 | return _ifr.ifr_flags & IFF_UP; |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | QString ONetworkInterface::ipV4Address() const | 214 | QString ONetworkInterface::ipV4Address() const |
215 | { | 215 | { |
216 | if ( ioctl( SIOCGIFADDR ) ) | 216 | if ( ioctl( SIOCGIFADDR ) ) |
217 | { | 217 | { |
218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 218 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
219 | //FIXME: Use QHostAddress here | 219 | //FIXME: Use QHostAddress here |
220 | return QString( inet_ntoa( sa->sin_addr ) ); | 220 | return QString( inet_ntoa( sa->sin_addr ) ); |
221 | } | 221 | } |
222 | else | 222 | else |
223 | return "<unknown>"; | 223 | return "<unknown>"; |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | OMacAddress ONetworkInterface::macAddress() const | 227 | OMacAddress ONetworkInterface::macAddress() const |
228 | { | 228 | { |
229 | if ( ioctl( SIOCGIFHWADDR ) ) | 229 | if ( ioctl( SIOCGIFHWADDR ) ) |
230 | { | 230 | { |
231 | return OMacAddress( _ifr ); | 231 | return OMacAddress( _ifr ); |
232 | } | 232 | } |
233 | else | 233 | else |
234 | { | 234 | { |
235 | return OMacAddress::unknown; | 235 | return OMacAddress::unknown; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | int ONetworkInterface::dataLinkType() const | 240 | int ONetworkInterface::dataLinkType() const |
241 | { | 241 | { |
242 | if ( ioctl( SIOCGIFHWADDR ) ) | 242 | if ( ioctl( SIOCGIFHWADDR ) ) |
243 | { | 243 | { |
244 | return _ifr.ifr_hwaddr.sa_family; | 244 | return _ifr.ifr_hwaddr.sa_family; |
245 | } | 245 | } |
246 | else | 246 | else |
247 | { | 247 | { |
248 | return -1; | 248 | return -1; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | 252 | ||
253 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 253 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
254 | { | 254 | { |
255 | _mon = m; | 255 | _mon = m; |
256 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 256 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | OMonitoringInterface* ONetworkInterface::monitoring() const | 260 | OMonitoringInterface* ONetworkInterface::monitoring() const |
261 | { | 261 | { |
262 | return _mon; | 262 | return _mon; |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | ONetworkInterface::~ONetworkInterface() | 266 | ONetworkInterface::~ONetworkInterface() |
267 | { | 267 | { |
268 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 268 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
269 | if ( _sfd != -1 ) ::close( _sfd ); | 269 | if ( _sfd != -1 ) ::close( _sfd ); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 273 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
274 | { | 274 | { |
275 | ioctl( SIOCGIFFLAGS ); | 275 | ioctl( SIOCGIFFLAGS ); |
@@ -585,195 +585,195 @@ int OWirelessNetworkInterface::channelHopping() const | |||
585 | } | 585 | } |
586 | 586 | ||
587 | 587 | ||
588 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 588 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
589 | { | 589 | { |
590 | if ( _mon ) | 590 | if ( _mon ) |
591 | _mon->setEnabled( b ); | 591 | _mon->setEnabled( b ); |
592 | else | 592 | else |
593 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 593 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | bool OWirelessNetworkInterface::monitorMode() const | 597 | bool OWirelessNetworkInterface::monitorMode() const |
598 | { | 598 | { |
599 | qDebug( "dataLinkType = %d", dataLinkType() ); | 599 | qDebug( "dataLinkType = %d", dataLinkType() ); |
600 | return dataLinkType() == ARPHRD_IEEE80211; | 600 | return dataLinkType() == ARPHRD_IEEE80211; |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | QString OWirelessNetworkInterface::nickName() const | 604 | QString OWirelessNetworkInterface::nickName() const |
605 | { | 605 | { |
606 | char str[IW_ESSID_MAX_SIZE]; | 606 | char str[IW_ESSID_MAX_SIZE]; |
607 | _iwr.u.data.pointer = &str[0]; | 607 | _iwr.u.data.pointer = &str[0]; |
608 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 608 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
609 | if ( !wioctl( SIOCGIWNICKN ) ) | 609 | if ( !wioctl( SIOCGIWNICKN ) ) |
610 | { | 610 | { |
611 | return "<unknown>"; | 611 | return "<unknown>"; |
612 | } | 612 | } |
613 | else | 613 | else |
614 | { | 614 | { |
615 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 615 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
616 | return str; | 616 | return str; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | 619 | ||
620 | 620 | ||
621 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 621 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
622 | { | 622 | { |
623 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 623 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
624 | if ( !priv ) | 624 | if ( !priv ) |
625 | { | 625 | { |
626 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); | 626 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); |
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | if ( priv->numberSetArgs() != numargs ) | 629 | if ( priv->numberSetArgs() != numargs ) |
630 | { | 630 | { |
631 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); | 631 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); |
632 | return; | 632 | return; |
633 | } | 633 | } |
634 | 634 | ||
635 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); | 635 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); |
636 | memset( &_iwr, 0, sizeof _iwr ); | 636 | memset( &_iwr, 0, sizeof _iwr ); |
637 | va_list argp; | 637 | va_list argp; |
638 | va_start( argp, numargs ); | 638 | va_start( argp, numargs ); |
639 | for ( int i = 0; i < numargs; ++i ) | 639 | for ( int i = 0; i < numargs; ++i ) |
640 | { | 640 | { |
641 | priv->setParameter( i, va_arg( argp, int ) ); | 641 | priv->setParameter( i, va_arg( argp, int ) ); |
642 | } | 642 | } |
643 | va_end( argp ); | 643 | va_end( argp ); |
644 | priv->invoke(); | 644 | priv->invoke(); |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 648 | void OWirelessNetworkInterface::getPrivate( const QString& call ) |
649 | { | 649 | { |
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | QString OWirelessNetworkInterface::SSID() const | 653 | QString OWirelessNetworkInterface::SSID() const |
654 | { | 654 | { |
655 | char str[IW_ESSID_MAX_SIZE]; | 655 | char str[IW_ESSID_MAX_SIZE]; |
656 | _iwr.u.essid.pointer = &str[0]; | 656 | _iwr.u.essid.pointer = &str[0]; |
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 | } |
708 | 708 | ||
709 | 709 | ||
710 | void OMonitoringInterface::setChannel( int c ) | 710 | void OMonitoringInterface::setChannel( int c ) |
711 | { | 711 | { |
712 | // use standard WE channel switching protocol | 712 | // use standard WE channel switching protocol |
713 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 713 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
714 | _if->_iwr.u.freq.m = c; | 714 | _if->_iwr.u.freq.m = c; |
715 | _if->_iwr.u.freq.e = 0; | 715 | _if->_iwr.u.freq.e = 0; |
716 | _if->wioctl( SIOCSIWFREQ ); | 716 | _if->wioctl( SIOCSIWFREQ ); |
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | bool OMonitoringInterface::enabled() const | 720 | bool OMonitoringInterface::enabled() const |
721 | { | 721 | { |
722 | return _if->monitorMode(); | 722 | return _if->monitorMode(); |
723 | } | 723 | } |
724 | 724 | ||
725 | 725 | ||
726 | void OMonitoringInterface::setEnabled( bool b ) | 726 | void OMonitoringInterface::setEnabled( bool b ) |
727 | { | 727 | { |
728 | } | 728 | } |
729 | 729 | ||
730 | 730 | ||
731 | /*====================================================================================== | 731 | /*====================================================================================== |
732 | * OCiscoMonitoringInterface | 732 | * OCiscoMonitoringInterface |
733 | *======================================================================================*/ | 733 | *======================================================================================*/ |
734 | 734 | ||
735 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) | 735 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) |
736 | :OMonitoringInterface( iface ) | 736 | :OMonitoringInterface( iface ) |
737 | { | 737 | { |
738 | iface->setMonitoring( this ); | 738 | iface->setMonitoring( this ); |
739 | } | 739 | } |
740 | 740 | ||
741 | 741 | ||
742 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 742 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
743 | { | 743 | { |
744 | } | 744 | } |
745 | 745 | ||
746 | 746 | ||
747 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 747 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
748 | { | 748 | { |
749 | QString fname; | 749 | QString fname; |
750 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 750 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
751 | QFile f( fname ); | 751 | QFile f( fname ); |
752 | if ( !f.exists() ) return; | 752 | if ( !f.exists() ) return; |
753 | 753 | ||
754 | if ( f.open( IO_WriteOnly ) ) | 754 | if ( f.open( IO_WriteOnly ) ) |
755 | { | 755 | { |
756 | QTextStream s( &f ); | 756 | QTextStream s( &f ); |
757 | s << "Mode: r"; | 757 | s << "Mode: r"; |
758 | s << "Mode: y"; | 758 | s << "Mode: y"; |
759 | s << "XmitPower: 1"; | 759 | s << "XmitPower: 1"; |
760 | } | 760 | } |
761 | 761 | ||
762 | // flushing and closing will be done automatically when f goes out of scope | 762 | // flushing and closing will be done automatically when f goes out of scope |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | QString OCiscoMonitoringInterface::name() const | 766 | QString OCiscoMonitoringInterface::name() const |
767 | { | 767 | { |
768 | return "cisco"; | 768 | return "cisco"; |
769 | } | 769 | } |
770 | 770 | ||
771 | 771 | ||
772 | void OCiscoMonitoringInterface::setChannel( int ) | 772 | void OCiscoMonitoringInterface::setChannel( int ) |
773 | { | 773 | { |
774 | // cisco devices automatically switch channels when in monitor mode | 774 | // cisco devices automatically switch channels when in monitor mode |
775 | } | 775 | } |
776 | 776 | ||
777 | 777 | ||
778 | /*====================================================================================== | 778 | /*====================================================================================== |
779 | * OWlanNGMonitoringInterface | 779 | * OWlanNGMonitoringInterface |