summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-06 17:38:00 (UTC)
committer mickeyl <mickeyl>2003-10-06 17:38:00 (UTC)
commite0acd0d9400bb489415d21ec715c5f6704c22b95 (patch) (unidiff)
treea6bb6077c3da3d31bc9e86d6f8276aed90bd3d5c
parent634a68b636a0fa24232029b79ffa915a5621b2be (diff)
downloadopie-e0acd0d9400bb489415d21ec715c5f6704c22b95.zip
opie-e0acd0d9400bb489415d21ec715c5f6704c22b95.tar.gz
opie-e0acd0d9400bb489415d21ec715c5f6704c22b95.tar.bz2
decode DHCP ACK packets and show the extracted client IP address
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp2
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp9
2 files changed, 7 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 9d6ed6a..1cca507 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -346,65 +346,65 @@ void MScanListView::addService( const QString& name, const OMacAddress& macaddr,
346 //TODO: Refactor that out, we need it all over the place. 346 //TODO: Refactor that out, we need it all over the place.
347 // Best to do it in a more comfortable abstraction in OListView 347 // Best to do it in a more comfortable abstraction in OListView
348 // (Hmm, didn't I already start something in this direction?) 348 // (Hmm, didn't I already start something in this direction?)
349 349
350 QListViewItemIterator it( this ); 350 QListViewItemIterator it( this );
351 for ( ; it.current(); ++it ) 351 for ( ; it.current(); ++it )
352 { 352 {
353 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 353 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
354 { 354 {
355 355
356 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); 356 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
357 357
358 while ( subitem && ( subitem->text( col_essid ) != name ) ) 358 while ( subitem && ( subitem->text( col_essid ) != name ) )
359 { 359 {
360 #ifdef DEBUG 360 #ifdef DEBUG
361 qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); 361 qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) );
362 #endif 362 #endif
363 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 363 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
364 } 364 }
365 365
366 if ( subitem ) 366 if ( subitem )
367 { 367 {
368 // we have already seen this item, it's a dupe 368 // we have already seen this item, it's a dupe
369 #ifdef DEBUG 369 #ifdef DEBUG
370 qDebug( "%s is a dupe - ignoring...", (const char*) name ); 370 qDebug( "%s is a dupe - ignoring...", (const char*) name );
371 #endif 371 #endif
372 subitem->receivedBeacon(); //FIXME: sent data bit 372 subitem->receivedBeacon(); //FIXME: sent data bit
373 return; 373 return;
374 } 374 }
375 375
376 // never seen that - add new item 376 // never seen that - add new item
377 377
378 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", false, -1, -1 ); 378 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 );
379 item->setText( col_essid, name ); 379 item->setText( col_essid, name );
380 380
381 return; 381 return;
382 } 382 }
383 } 383 }
384 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 384 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
385 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", 385 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
386 (const char*) macaddr.toString(), (const char*) ip ) ); 386 (const char*) macaddr.toString(), (const char*) ip ) );
387} 387}
388 388
389 389
390void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) 390void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
391{ 391{
392 if ( !item ) return; 392 if ( !item ) return;
393 393
394 MScanListItem* itm = static_cast<MScanListItem*>( item ); 394 MScanListItem* itm = static_cast<MScanListItem*>( item );
395 395
396 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", 396 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
397 (const char*) itm->text(0), (const char*) itm->type, col ); 397 (const char*) itm->text(0), (const char*) itm->type, col );
398 398
399 if ( itm->type == "adhoc" || itm->type == "managed" ) 399 if ( itm->type == "adhoc" || itm->type == "managed" )
400 { 400 {
401 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); 401 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
402 402
403 QPopupMenu m( this ); 403 QPopupMenu m( this );
404 m.insertItem( entry, 37773, 0 ); 404 m.insertItem( entry, 37773, 0 );
405 int result = m.exec( QCursor::pos() ); 405 int result = m.exec( QCursor::pos() );
406 if ( result == 37773 ) 406 if ( result == 37773 )
407 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); 407 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
408 } 408 }
409} 409}
410 410
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 7394742..9460f56 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -227,70 +227,73 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
227void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 227void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
228{ 228{
229 from = data->sourceAddress(); 229 from = data->sourceAddress();
230 to = data->destinationAddress(); 230 to = data->destinationAddress();
231 231
232 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) ); 232 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
233} 233}
234 234
235 235
236void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 236void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
237{ 237{
238 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 238 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
239 if ( arp ) 239 if ( arp )
240 { 240 {
241 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 241 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
242 if ( arp->type() == "REQUEST" ) 242 if ( arp->type() == "REQUEST" )
243 { 243 {
244 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 244 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
245 } 245 }
246 else if ( arp->type() == "REPLY" ) 246 else if ( arp->type() == "REPLY" )
247 { 247 {
248 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 248 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
249 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 249 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
250 } 250 }
251 } 251 }
252 252
253 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 253 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
254 if ( dhcp ) 254 if ( dhcp )
255 { 255 {
256 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 256 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
257 if ( dhcp->type() == "OFFER" ) 257 if ( dhcp->type() == "OFFER" )
258 { 258 {
259 qDebug( "ADDSERVICE: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 259 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
260 //netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( 0, 0 ) );
261
262 netView()->identify( source, dhcp->serverAddress().toString() ); 260 netView()->identify( source, dhcp->serverAddress().toString() );
263 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 261 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
264 } 262 }
263 else if ( dhcp->type() == "ACK" )
264 {
265 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
266 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
267 }
265 } 268 }
266} 269}
267 270
268 271
269QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 272QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
270{ 273{
271 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 274 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
272 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 275 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
273 return 0; 276 return 0;
274 277
275 return p->child( protocol ); 278 return p->child( protocol );
276} 279}
277 280
278 281
279bool Wellenreiter::checkDumpPacket( OPacket* p ) 282bool Wellenreiter::checkDumpPacket( OPacket* p )
280{ 283{
281 // go through all child packets and see if one is inside the child hierarchy for p 284 // go through all child packets and see if one is inside the child hierarchy for p
282 // if so, do what the user requested (protocolAction), e.g. pass or discard 285 // if so, do what the user requested (protocolAction), e.g. pass or discard
283 if ( !configwindow->writeCaptureFile->isChecked() ) 286 if ( !configwindow->writeCaptureFile->isChecked() )
284 return false; 287 return false;
285 288
286 QObjectList* l = p->queryList(); 289 QObjectList* l = p->queryList();
287 QObjectListIt it( *l ); 290 QObjectListIt it( *l );
288 QObject* o; 291 QObject* o;
289 292
290 while ( (o = it.current()) != 0 ) 293 while ( (o = it.current()) != 0 )
291 { 294 {
292 QString name = it.current()->name(); 295 QString name = it.current()->name();
293 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 296 if ( configwindow->capturePackets->isProtocolChecked( name ) )
294 { 297 {
295 QString action = configwindow->capturePackets->protocolAction( name ); 298 QString action = configwindow->capturePackets->protocolAction( name );
296 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 299 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );