author | mickeyl <mickeyl> | 2003-04-04 13:46:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-04 13:46:27 (UTC) |
commit | 2349ef8fd3999798a2cbbb62a88e71807f25ae40 (patch) (unidiff) | |
tree | 25dc954dcb7028de379247cb8266b3c980505368 | |
parent | b2153d44e64c1ade3ee141ea24075add1fd33777 (diff) | |
download | opie-2349ef8fd3999798a2cbbb62a88e71807f25ae40.zip opie-2349ef8fd3999798a2cbbb62a88e71807f25ae40.tar.gz opie-2349ef8fd3999798a2cbbb62a88e71807f25ae40.tar.bz2 |
detect and warn if switching device into monitor mode doesn't work
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index e294eb8..d80a6e6 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -137,92 +137,98 @@ void Wellenreiter::receivePacket(OPacket* p) | |||
137 | 137 | ||
138 | void Wellenreiter::startStopClicked() | 138 | void Wellenreiter::startStopClicked() |
139 | { | 139 | { |
140 | if ( sniffing ) | 140 | if ( sniffing ) |
141 | { | 141 | { |
142 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 142 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
143 | 143 | ||
144 | iface->setChannelHopping(); // stop hopping channels | 144 | iface->setChannelHopping(); // stop hopping channels |
145 | pcap->close(); | 145 | pcap->close(); |
146 | sniffing = false; | 146 | sniffing = false; |
147 | #ifdef QWS | 147 | #ifdef QWS |
148 | oApp->setTitle(); | 148 | oApp->setTitle(); |
149 | #else | 149 | #else |
150 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | 150 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | // get interface name from config window | 153 | // get interface name from config window |
154 | const QString& interface = configwindow->interfaceName->currentText(); | 154 | const QString& interface = configwindow->interfaceName->currentText(); |
155 | ONetwork* net = ONetwork::instance(); | 155 | ONetwork* net = ONetwork::instance(); |
156 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 156 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
157 | 157 | ||
158 | // switch off monitor mode | 158 | // switch off monitor mode |
159 | iface->setMonitorMode( false ); | 159 | iface->setMonitorMode( false ); |
160 | // switch off promisc flag | 160 | // switch off promisc flag |
161 | iface->setPromiscuousMode( false ); | 161 | iface->setPromiscuousMode( false ); |
162 | 162 | ||
163 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 163 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
164 | 164 | ||
165 | // message the user | 165 | // message the user |
166 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | 166 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
167 | } | 167 | } |
168 | 168 | ||
169 | else | 169 | else |
170 | { | 170 | { |
171 | // get configuration from config window | 171 | // get configuration from config window |
172 | 172 | ||
173 | const QString& interface = configwindow->interfaceName->currentText(); | 173 | const QString& interface = configwindow->interfaceName->currentText(); |
174 | const int cardtype = configwindow->daemonDeviceType(); | 174 | const int cardtype = configwindow->daemonDeviceType(); |
175 | const int interval = configwindow->daemonHopInterval(); | 175 | const int interval = configwindow->daemonHopInterval(); |
176 | 176 | ||
177 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 177 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
178 | { | 178 | { |
179 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 179 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | 182 | ||
183 | // configure device | 183 | // configure device |
184 | 184 | ||
185 | ONetwork* net = ONetwork::instance(); | 185 | ONetwork* net = ONetwork::instance(); |
186 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 186 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
187 | 187 | ||
188 | // set monitor mode | 188 | // set monitor mode |
189 | 189 | ||
190 | switch ( cardtype ) | 190 | switch ( cardtype ) |
191 | { | 191 | { |
192 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | 192 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
193 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | 193 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
194 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | 194 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
195 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | 195 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; |
196 | default: assert( 0 ); // shouldn't happen | 196 | default: assert( 0 ); // shouldn't happen |
197 | } | 197 | } |
198 | 198 | ||
199 | iface->setMonitorMode( true ); | 199 | iface->setMonitorMode( true ); |
200 | 200 | ||
201 | if ( !iface->monitorMode() ) | ||
202 | { | ||
203 | QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); | ||
204 | return; | ||
205 | } | ||
206 | |||
201 | // open pcap and start sniffing | 207 | // open pcap and start sniffing |
202 | pcap->open( interface ); | 208 | pcap->open( interface ); |
203 | 209 | ||
204 | if ( !pcap->isOpen() ) | 210 | if ( !pcap->isOpen() ) |
205 | { | 211 | { |
206 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 212 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); |
207 | return; | 213 | return; |
208 | } | 214 | } |
209 | 215 | ||
210 | // set capturer to non-blocking mode | 216 | // set capturer to non-blocking mode |
211 | pcap->setBlocking( false ); | 217 | pcap->setBlocking( false ); |
212 | 218 | ||
213 | // start channel hopper | 219 | // start channel hopper |
214 | iface->setChannelHopping( 1000 ); //use interval from config window | 220 | iface->setChannelHopping( 1000 ); //use interval from config window |
215 | 221 | ||
216 | // connect | 222 | // connect |
217 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 223 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
218 | 224 | ||
219 | logwindow->log( "(i) Daemon has been started." ); | 225 | logwindow->log( "(i) Daemon has been started." ); |
220 | #ifdef QWS | 226 | #ifdef QWS |
221 | oApp->setTitle( "Scanning ..." ); | 227 | oApp->setTitle( "Scanning ..." ); |
222 | #else | 228 | #else |
223 | qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); | 229 | qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); |
224 | #endif | 230 | #endif |
225 | sniffing = true; | 231 | sniffing = true; |
226 | 232 | ||
227 | } | 233 | } |
228 | } | 234 | } |