Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index fad6efd..822bde8 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -89,25 +89,25 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
89 | 89 | ||
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | Wellenreiter::~Wellenreiter() | 93 | Wellenreiter::~Wellenreiter() |
94 | { | 94 | { |
95 | delete pcap; | 95 | delete pcap; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void Wellenreiter::initialTimer() | 99 | void Wellenreiter::initialTimer() |
100 | { | 100 | { |
101 | odebug << "Wellenreiter::preloading manufacturer database..." << oendl; | 101 | odebug << "Wellenreiter::preloading manufacturer database..." << oendl; |
102 | OManufacturerDB::instance(); | 102 | OManufacturerDB::instance(); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
107 | { | 107 | { |
108 | configwindow = cw; | 108 | configwindow = cw; |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void Wellenreiter::channelHopped(int c) | 112 | void Wellenreiter::channelHopped(int c) |
113 | { | 113 | { |
@@ -132,104 +132,104 @@ void Wellenreiter::channelHopped(int c) | |||
132 | void Wellenreiter::handleNotification( OPacket* p ) | 132 | void Wellenreiter::handleNotification( OPacket* p ) |
133 | { | 133 | { |
134 | QObjectList* l = p->queryList(); | 134 | QObjectList* l = p->queryList(); |
135 | QObjectListIt it( *l ); | 135 | QObjectListIt it( *l ); |
136 | QObject* o; | 136 | QObject* o; |
137 | 137 | ||
138 | while ( (o = it.current()) != 0 ) | 138 | while ( (o = it.current()) != 0 ) |
139 | { | 139 | { |
140 | QString name = it.current()->name(); | 140 | QString name = it.current()->name(); |
141 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 141 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
142 | { | 142 | { |
143 | QString action = configwindow->parsePackets->protocolAction( name ); | 143 | QString action = configwindow->parsePackets->protocolAction( name ); |
144 | odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl; | 144 | odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; |
145 | doAction( action, name, p ); | 145 | doAction( action, name, p ); |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | odebug << "protocol '" << (const char*) name << "' not checked in parsePackets." << oendl; | 149 | odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; |
150 | } | 150 | } |
151 | ++it; | 151 | ++it; |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) | 156 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) |
157 | { | 157 | { |
158 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); | 158 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); |
159 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); | 159 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); |
160 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); | 160 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); |
161 | else owarn << "Wellenreiter::handleManagementFrame(): '" << (const char*) manage->managementType() << "' - please handle me!" << oendl; | 161 | else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) | 165 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) |
166 | { | 166 | { |
167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
168 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 168 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 169 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
170 | int channel = ds ? ds->channel() : -1; | 170 | int channel = ds ? ds->channel() : -1; |
171 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 171 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
172 | 172 | ||
173 | GpsLocation loc( -111, -111 ); | 173 | GpsLocation loc( -111, -111 ); |
174 | if ( configwindow->enableGPS->isChecked() ) | 174 | if ( configwindow->enableGPS->isChecked() ) |
175 | { | 175 | { |
176 | // TODO: add check if GPS is working!? | 176 | // TODO: add check if GPS is working!? |
177 | odebug << "Wellenreiter::gathering GPS data..." << oendl; | 177 | odebug << "Wellenreiter::gathering GPS data..." << oendl; |
178 | loc = gps->position(); | 178 | loc = gps->position(); |
179 | odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; | 179 | odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; |
180 | } | 180 | } |
181 | 181 | ||
182 | if ( essid.length() ) | 182 | if ( essid.length() ) |
183 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); | 183 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); |
184 | odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; | 184 | odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) | 188 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) |
189 | { | 189 | { |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 193 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
194 | { | 194 | { |
195 | QString type; | 195 | QString type; |
196 | if ( beacon->canIBSS() ) | 196 | if ( beacon->canIBSS() ) |
197 | { | 197 | { |
198 | type = "adhoc"; | 198 | type = "adhoc"; |
199 | } | 199 | } |
200 | else if ( beacon->canESS() ) | 200 | else if ( beacon->canESS() ) |
201 | { | 201 | { |
202 | type = "managed"; | 202 | type = "managed"; |
203 | } | 203 | } |
204 | else | 204 | else |
205 | { | 205 | { |
206 | owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; | 206 | owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 210 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
211 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 211 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
212 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 212 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
213 | int channel = ds ? ds->channel() : -1; | 213 | int channel = ds ? ds->channel() : -1; |
214 | 214 | ||
215 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 215 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
216 | 216 | ||
217 | GpsLocation loc( -111, -111 ); | 217 | GpsLocation loc( -111, -111 ); |
218 | if ( configwindow->enableGPS->isChecked() ) | 218 | if ( configwindow->enableGPS->isChecked() ) |
219 | { | 219 | { |
220 | // TODO: add check if GPS is working!? | 220 | // TODO: add check if GPS is working!? |
221 | odebug << "Wellenreiter::gathering GPS data..." << oendl; | 221 | odebug << "Wellenreiter::gathering GPS data..." << oendl; |
222 | loc = gps->position(); | 222 | loc = gps->position(); |
223 | odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; | 223 | odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; |
224 | } | 224 | } |
225 | 225 | ||
226 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 226 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
227 | 227 | ||
228 | // update graph window | 228 | // update graph window |
229 | if ( ds ) | 229 | if ( ds ) |
230 | { | 230 | { |
231 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 231 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
232 | if ( prism ) | 232 | if ( prism ) |
233 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 233 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
234 | else | 234 | else |
235 | graphwindow->traffic( ds->channel(), 95 ); | 235 | graphwindow->traffic( ds->channel(), 95 ); |
@@ -238,25 +238,25 @@ void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPa | |||
238 | 238 | ||
239 | 239 | ||
240 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) | 240 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) |
241 | { | 241 | { |
242 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 242 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
243 | 243 | ||
244 | if ( control->controlType() == "Acknowledge" ) | 244 | if ( control->controlType() == "Acknowledge" ) |
245 | { | 245 | { |
246 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); | 246 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); |
247 | } | 247 | } |
248 | else | 248 | else |
249 | { | 249 | { |
250 | odebug << "Wellenreiter::handleControlFrame - please handle " << (const char*) control->controlType() << " in a future version! :D" << oendl; | 250 | odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl; |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 255 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
256 | { | 256 | { |
257 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 257 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
258 | if ( wlan->fromDS() && !wlan->toDS() ) | 258 | if ( wlan->fromDS() && !wlan->toDS() ) |
259 | { | 259 | { |
260 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 260 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
261 | from = wlan->macAddress3(); | 261 | from = wlan->macAddress3(); |
262 | to = wlan->macAddress2(); | 262 | to = wlan->macAddress2(); |
@@ -287,55 +287,55 @@ void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAd | |||
287 | from = data->sourceAddress(); | 287 | from = data->sourceAddress(); |
288 | to = data->destinationAddress(); | 288 | to = data->destinationAddress(); |
289 | 289 | ||
290 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); | 290 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); |
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) | 294 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) |
295 | { | 295 | { |
296 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 296 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
297 | if ( arp ) | 297 | if ( arp ) |
298 | { | 298 | { |
299 | odebug << "Received ARP traffic (type '" << (const char*) arp->type() << "'): " << oendl; | 299 | odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl; |
300 | if ( arp->type() == "REQUEST" ) | 300 | if ( arp->type() == "REQUEST" ) |
301 | { | 301 | { |
302 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 302 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
303 | } | 303 | } |
304 | else if ( arp->type() == "REPLY" ) | 304 | else if ( arp->type() == "REPLY" ) |
305 | { | 305 | { |
306 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 306 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
307 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 307 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 313 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
314 | { | 314 | { |
315 | //TODO: Implement more IP based protocols | 315 | //TODO: Implement more IP based protocols |
316 | 316 | ||
317 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 317 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
318 | if ( dhcp ) | 318 | if ( dhcp ) |
319 | { | 319 | { |
320 | odebug << "Received DHCP '" << (const char*) dhcp->type() << "' packet" << oendl; | 320 | odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl; |
321 | if ( dhcp->type() == "OFFER" ) | 321 | if ( dhcp->type() == "OFFER" ) |
322 | { | 322 | { |
323 | odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << (const char*) dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; | 323 | odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; |
324 | netView()->identify( source, dhcp->serverAddress().toString() ); | 324 | netView()->identify( source, dhcp->serverAddress().toString() ); |
325 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 325 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
326 | } | 326 | } |
327 | else if ( dhcp->type() == "ACK" ) | 327 | else if ( dhcp->type() == "ACK" ) |
328 | { | 328 | { |
329 | odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << (const char*) dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; | 329 | odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; |
330 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | 330 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 336 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
337 | { | 337 | { |
338 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 338 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
339 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 339 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
340 | return 0; | 340 | return 0; |
341 | 341 | ||
@@ -351,34 +351,34 @@ bool Wellenreiter::checkDumpPacket( OPacket* p ) | |||
351 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter | 351 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter |
352 | 352 | ||
353 | QObjectList* l = p->queryList(); | 353 | QObjectList* l = p->queryList(); |
354 | QObjectListIt it( *l ); | 354 | QObjectListIt it( *l ); |
355 | QObject* o; | 355 | QObject* o; |
356 | 356 | ||
357 | while ( (o = it.current()) != 0 ) | 357 | while ( (o = it.current()) != 0 ) |
358 | { | 358 | { |
359 | QString name = it.current()->name(); | 359 | QString name = it.current()->name(); |
360 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 360 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
361 | { | 361 | { |
362 | QString action = configwindow->capturePackets->protocolAction( name ); | 362 | QString action = configwindow->capturePackets->protocolAction( name ); |
363 | odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl; | 363 | odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; |
364 | if ( action == "Discard" ) | 364 | if ( action == "Discard" ) |
365 | { | 365 | { |
366 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 366 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
367 | return false; | 367 | return false; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | else | 370 | else |
371 | { | 371 | { |
372 | odebug << "protocol '" << (const char*) name << "' not checked in capturePackets." << oendl; | 372 | odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; |
373 | } | 373 | } |
374 | ++it; | 374 | ++it; |
375 | } | 375 | } |
376 | return true; | 376 | return true; |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void Wellenreiter::receivePacket( OPacket* p ) | 380 | void Wellenreiter::receivePacket( OPacket* p ) |
381 | { | 381 | { |
382 | hexWindow()->add( p ); | 382 | hexWindow()->add( p ); |
383 | 383 | ||
384 | if ( checkDumpPacket( p ) ) | 384 | if ( checkDumpPacket( p ) ) |
@@ -504,100 +504,100 @@ void Wellenreiter::startClicked() | |||
504 | QMessageBox::information( this, "Wellenreiter II", | 504 | QMessageBox::information( this, "Wellenreiter II", |
505 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 505 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
506 | return; | 506 | return; |
507 | } | 507 | } |
508 | 508 | ||
509 | // configure device | 509 | // configure device |
510 | ONetwork* net = ONetwork::instance(); | 510 | ONetwork* net = ONetwork::instance(); |
511 | 511 | ||
512 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 512 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
513 | 513 | ||
514 | if ( cardtype != DEVTYPE_FILE ) | 514 | if ( cardtype != DEVTYPE_FILE ) |
515 | { | 515 | { |
516 | 516 | ||
517 | if ( !net->isPresent( interface ) ) | 517 | if ( !net->isPresent( interface ) ) |
518 | { | 518 | { |
519 | QMessageBox::information( this, "Wellenreiter II", | 519 | QMessageBox::information( this, "Wellenreiter II", |
520 | tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); | 520 | tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); |
521 | return; | 521 | return; |
522 | } | 522 | } |
523 | 523 | ||
524 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 524 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
525 | assert( iface ); | 525 | assert( iface ); |
526 | 526 | ||
527 | // bring device UP | 527 | // bring device UP |
528 | iface->setUp( true ); | 528 | iface->setUp( true ); |
529 | if ( !iface->isUp() ) | 529 | if ( !iface->isUp() ) |
530 | { | 530 | { |
531 | QMessageBox::warning( this, "Wellenreiter II", | 531 | QMessageBox::warning( this, "Wellenreiter II", |
532 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 532 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | // set monitor mode | 536 | // set monitor mode |
537 | bool usePrism = configwindow->usePrismHeader(); | 537 | bool usePrism = configwindow->usePrismHeader(); |
538 | 538 | ||
539 | switch ( cardtype ) | 539 | switch ( cardtype ) |
540 | { | 540 | { |
541 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 541 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
542 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 542 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
543 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 543 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
544 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 544 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
545 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 545 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
546 | case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << (const char*) interface << "'" << oendl; break; | 546 | case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break; |
547 | default: assert( 0 ); // shouldn't reach this | 547 | default: assert( 0 ); // shouldn't reach this |
548 | } | 548 | } |
549 | 549 | ||
550 | // switch device into monitor mode | 550 | // switch device into monitor mode |
551 | if ( cardtype < DEVTYPE_FILE ) | 551 | if ( cardtype < DEVTYPE_FILE ) |
552 | { | 552 | { |
553 | if ( cardtype != DEVTYPE_MANUAL ) | 553 | if ( cardtype != DEVTYPE_MANUAL ) |
554 | iface->setMode( "monitor" ); | 554 | iface->setMode( "monitor" ); |
555 | if ( iface->mode() != "monitor" ) | 555 | if ( iface->mode() != "monitor" ) |
556 | { | 556 | { |
557 | if ( QMessageBox::warning( this, "Wellenreiter II", | 557 | if ( QMessageBox::warning( this, "Wellenreiter II", |
558 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 558 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
559 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 559 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | // open GPS device | 564 | // open GPS device |
565 | if ( configwindow->enableGPS->isChecked() ) | 565 | if ( configwindow->enableGPS->isChecked() ) |
566 | { | 566 | { |
567 | odebug << "Wellenreiter:GPS enabled @ " << (const char*) configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; | 567 | odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; |
568 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 568 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
569 | } | 569 | } |
570 | 570 | ||
571 | // open pcap and start sniffing | 571 | // open pcap and start sniffing |
572 | 572 | ||
573 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? | 573 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? |
574 | { | 574 | { |
575 | dumpname = configwindow->captureFileName->text(); | 575 | dumpname = configwindow->captureFileName->text(); |
576 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 576 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
577 | dumpname.append( '-' ); | 577 | dumpname.append( '-' ); |
578 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 578 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
579 | dumpname.append( ".wellenreiter" ); | 579 | dumpname.append( ".wellenreiter" ); |
580 | } | 580 | } |
581 | else // write it anyway ;) | 581 | else // write it anyway ;) |
582 | { | 582 | { |
583 | dumpname = "/var/log/dump.wellenreiter"; | 583 | dumpname = "/var/log/dump.wellenreiter"; |
584 | } | 584 | } |
585 | 585 | ||
586 | if ( cardtype != DEVTYPE_FILE ) | 586 | if ( cardtype != DEVTYPE_FILE ) |
587 | pcap->open( interface ); | 587 | pcap->open( interface ); |
588 | else | 588 | else |
589 | pcap->open( QFile( interface ) ); | 589 | pcap->open( QFile( interface ) ); |
590 | 590 | ||
591 | odebug << "Wellenreiter:: dumping to " << (const char*) dumpname << "" << oendl; | 591 | odebug << "Wellenreiter:: dumping to " << dumpname << "" << oendl; |
592 | pcap->openDumpFile( dumpname ); | 592 | pcap->openDumpFile( dumpname ); |
593 | 593 | ||
594 | if ( !pcap->isOpen() ) | 594 | if ( !pcap->isOpen() ) |
595 | { | 595 | { |
596 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( | 596 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
597 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); | 597 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
598 | return; | 598 | return; |
599 | } | 599 | } |
600 | 600 | ||
601 | // set capturer to non-blocking mode | 601 | // set capturer to non-blocking mode |
602 | pcap->setBlocking( false ); | 602 | pcap->setBlocking( false ); |
603 | 603 | ||
@@ -629,31 +629,31 @@ void Wellenreiter::startClicked() | |||
629 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | 629 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; |
630 | } | 630 | } |
631 | #else | 631 | #else |
632 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 632 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
633 | #endif | 633 | #endif |
634 | 634 | ||
635 | emit( startedSniffing() ); | 635 | emit( startedSniffing() ); |
636 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 636 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
637 | else | 637 | else |
638 | { | 638 | { |
639 | assert( parent() ); | 639 | assert( parent() ); |
640 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 640 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | 644 | ||
645 | void Wellenreiter::timerEvent( QTimerEvent* ) | 645 | void Wellenreiter::timerEvent( QTimerEvent* ) |
646 | { | 646 | { |
647 | odebug << "Wellenreiter::timerEvent()" << oendl; | 647 | odebug << "Wellenreiter::timerEvent()" << oendl; |
648 | OPacket* p = pcap->next(); | 648 | OPacket* p = pcap->next(); |
649 | if ( !p ) // no more packets available | 649 | if ( !p ) // no more packets available |
650 | { | 650 | { |
651 | stopClicked(); | 651 | stopClicked(); |
652 | } | 652 | } |
653 | else | 653 | else |
654 | { | 654 | { |
655 | receivePacket( p ); | 655 | receivePacket( p ); |
656 | // We no longer delete packets here. Ownership of the packets is | 656 | // We no longer delete packets here. Ownership of the packets is |
657 | // transferred to the PacketView. | 657 | // transferred to the PacketView. |
658 | //delete p; | 658 | //delete p; |
659 | } | 659 | } |
@@ -698,28 +698,28 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch | |||
698 | return; | 698 | return; |
699 | } | 699 | } |
700 | 700 | ||
701 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 701 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
702 | (const char*) iface->name(), | 702 | (const char*) iface->name(), |
703 | (const char*) type, | 703 | (const char*) type, |
704 | (const char*) essid, | 704 | (const char*) essid, |
705 | channel, | 705 | channel, |
706 | (const char*) macaddr ); | 706 | (const char*) macaddr ); |
707 | 707 | ||
708 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 708 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
709 | int count = 3; | 709 | int count = 3; |
710 | odebug << "sending " << count << " messages" << oendl; | 710 | odebug << "sending " << count << " messages" << oendl; |
711 | msg << QString("count") << QString::number(count); | 711 | msg << QString("count") << QString::number(count); |
712 | odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; | 712 | odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; |
713 | msg << QString(iface->name()) << QString("Mode") << type; | 713 | msg << QString(iface->name()) << QString("Mode") << type; |
714 | odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; | 714 | odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; |
715 | msg << QString(iface->name()) << QString("ESSID") << essid; | 715 | msg << QString(iface->name()) << QString("ESSID") << essid; |
716 | odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; | 716 | odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; |
717 | msg << QString(iface->name()) << QString("Channel") << channel; | 717 | msg << QString(iface->name()) << QString("Channel") << channel; |
718 | // odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; | 718 | // odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; |
719 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 719 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
720 | #else | 720 | #else |
721 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | 721 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); |
722 | #endif | 722 | #endif |
723 | 723 | ||
724 | } | 724 | } |
725 | 725 | ||