summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-06 18:08:05 (UTC)
committer mickeyl <mickeyl>2003-10-06 18:08:05 (UTC)
commitb8ac6724a0aaed78a1df712d87110fe39b16955f (patch) (unidiff)
treef8607b34284882bd4ce99281d0377f83b6b2c086
parent42aefe8bc6a8089b771d6f109fed22a770295cc8 (diff)
downloadopie-b8ac6724a0aaed78a1df712d87110fe39b16955f.zip
opie-b8ac6724a0aaed78a1df712d87110fe39b16955f.tar.gz
opie-b8ac6724a0aaed78a1df712d87110fe39b16955f.tar.bz2
fix ARP decoding for wired networks. Interestingly, 802.11 encapsulates
these in IP packets, while wired ethernet just tags the type_of_protocol.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp16
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
2 files changed, 17 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 9460f56..60bf231 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -204,80 +204,86 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
204 to = wlan->macAddress2(); 204 to = wlan->macAddress2();
205 } 205 }
206 else if ( !wlan->fromDS() && wlan->toDS() ) 206 else if ( !wlan->fromDS() && wlan->toDS() )
207 { 207 {
208 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 208 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
209 from = wlan->macAddress2(); 209 from = wlan->macAddress2();
210 to = wlan->macAddress3(); 210 to = wlan->macAddress3();
211 } 211 }
212 else if ( wlan->fromDS() && wlan->toDS() ) 212 else if ( wlan->fromDS() && wlan->toDS() )
213 { 213 {
214 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 214 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
215 from = wlan->macAddress4(); 215 from = wlan->macAddress4();
216 to = wlan->macAddress3(); 216 to = wlan->macAddress3();
217 } 217 }
218 else 218 else
219 { 219 {
220 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 220 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
221 from = wlan->macAddress2(); 221 from = wlan->macAddress2();
222 to = wlan->macAddress1(); 222 to = wlan->macAddress1();
223 } 223 }
224} 224}
225 225
226 226
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::handleARPData( OPacket* p, OARPPacket*, 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}
253
254
255void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
256{
257 //TODO: Implement more IP based protocols
252 258
253 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 259 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
254 if ( dhcp ) 260 if ( dhcp )
255 { 261 {
256 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 262 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
257 if ( dhcp->type() == "OFFER" ) 263 if ( dhcp->type() == "OFFER" )
258 { 264 {
259 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 265 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
260 netView()->identify( source, dhcp->serverAddress().toString() ); 266 netView()->identify( source, dhcp->serverAddress().toString() );
261 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 267 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
262 } 268 }
263 else if ( dhcp->type() == "ACK" ) 269 else if ( dhcp->type() == "ACK" )
264 { 270 {
265 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 271 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() ); 272 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
267 } 273 }
268 } 274 }
269} 275}
270 276
271 277
272QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 278QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
273{ 279{
274 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 280 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
275 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 281 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
276 return 0; 282 return 0;
277 283
278 return p->child( protocol ); 284 return p->child( protocol );
279} 285}
280 286
281 287
282bool Wellenreiter::checkDumpPacket( OPacket* p ) 288bool Wellenreiter::checkDumpPacket( OPacket* p )
283{ 289{
@@ -320,64 +326,72 @@ void Wellenreiter::receivePacket( OPacket* p )
320 if ( checkDumpPacket( p ) ) 326 if ( checkDumpPacket( p ) )
321 { 327 {
322 pcap->dump( p ); 328 pcap->dump( p );
323 } 329 }
324 330
325 // check if we received a beacon frame 331 // check if we received a beacon frame
326 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 332 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
327 if ( beacon && beacon->managementType() == "Beacon" ) 333 if ( beacon && beacon->managementType() == "Beacon" )
328 { 334 {
329 handleBeacon( p, beacon ); 335 handleBeacon( p, beacon );
330 return; 336 return;
331 } 337 }
332 338
333 OMacAddress source; 339 OMacAddress source;
334 OMacAddress dest; 340 OMacAddress dest;
335 341
336 //TODO: WEP check here 342 //TODO: WEP check here
337 343
338 // check for a wireless data frame 344 // check for a wireless data frame
339 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 345 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
340 if ( wlan ) 346 if ( wlan )
341 { 347 {
342 handleWlanData( p, wlan, source, dest ); 348 handleWlanData( p, wlan, source, dest );
343 } 349 }
344 350
345 // check for a wired data frame 351 // check for a wired data frame
346 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 352 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
347 if ( eth ) 353 if ( eth )
348 { 354 {
349 handleEthernetData( p, eth, source, dest ); 355 handleEthernetData( p, eth, source, dest );
350 } 356 }
351 357
358 // check for an arp frame since arp frames come in two flavours:
359 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
360 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
361 if ( arp )
362 {
363 handleARPData( p, arp, source, dest );
364 }
365
352 // check for a ip frame 366 // check for a ip frame
353 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 367 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
354 if ( ip ) 368 if ( ip )
355 { 369 {
356 handleIPData( p, ip, source, dest ); 370 handleIPData( p, ip, source, dest );
357 } 371 }
358 372
359 //handleNotification( p ); 373 //handleNotification( p );
360 374
361} 375}
362 376
363 377
364void Wellenreiter::stopClicked() 378void Wellenreiter::stopClicked()
365{ 379{
366 if ( iface ) 380 if ( iface )
367 { 381 {
368 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 382 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
369 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 383 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
370 iface->setChannelHopping(); // stop hopping channels 384 iface->setChannelHopping(); // stop hopping channels
371 } 385 }
372 else 386 else
373 killTimers(); 387 killTimers();
374 388
375 pcap->close(); 389 pcap->close();
376 sniffing = false; 390 sniffing = false;
377 391
378 if ( iface ) 392 if ( iface )
379 { 393 {
380 // switch off monitor mode 394 // switch off monitor mode
381 iface->setMonitorMode( false ); 395 iface->setMonitorMode( false );
382 // switch off promisc flag 396 // switch off promisc flag
383 iface->setPromiscuousMode( false ); 397 iface->setPromiscuousMode( false );
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index ed96375..25a5e8d 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,98 +1,100 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26class QTimerEvent; 26class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OWaveLanManagementPacket; 29class OWaveLanManagementPacket;
30class OWaveLanDataPacket; 30class OWaveLanDataPacket;
31class OEthernetPacket; 31class OEthernetPacket;
32class OARPPacket;
32class OMacAddress; 33class OMacAddress;
33class OIPPacket; 34class OIPPacket;
34class OPacketCapturer; 35class OPacketCapturer;
35class OWirelessNetworkInterface; 36class OWirelessNetworkInterface;
36class WellenreiterConfigWindow; 37class WellenreiterConfigWindow;
37class MLogWindow; 38class MLogWindow;
38class MHexWindow; 39class MHexWindow;
39class GPS; 40class GPS;
40 41
41class Wellenreiter : public WellenreiterBase { 42class Wellenreiter : public WellenreiterBase {
42 Q_OBJECT 43 Q_OBJECT
43 44
44 public: 45 public:
45 Wellenreiter( QWidget* parent = 0 ); 46 Wellenreiter( QWidget* parent = 0 );
46 ~Wellenreiter(); 47 ~Wellenreiter();
47 48
48 void setConfigWindow( WellenreiterConfigWindow* cw ); 49 void setConfigWindow( WellenreiterConfigWindow* cw );
49 MScanListView* netView() const { return netview; }; 50 MScanListView* netView() const { return netview; };
50 MLogWindow* logWindow() const { return logwindow; }; 51 MLogWindow* logWindow() const { return logwindow; };
51 MHexWindow* hexWindow() const { return hexwindow; }; 52 MHexWindow* hexWindow() const { return hexwindow; };
52 bool isDaemonRunning() const { return sniffing; }; 53 bool isDaemonRunning() const { return sniffing; };
53 54
54 public: 55 public:
55 bool sniffing; 56 bool sniffing;
56 57
57 protected: 58 protected:
58 virtual void timerEvent( QTimerEvent* ); 59 virtual void timerEvent( QTimerEvent* );
59 60
60 public slots: 61 public slots:
61 void channelHopped(int); 62 void channelHopped(int);
62 void receivePacket(OPacket*); 63 void receivePacket(OPacket*);
63 void startClicked(); 64 void startClicked();
64 void stopClicked(); 65 void stopClicked();
65 66
66 void joinNetwork(const QString&,const QString&,int,const QString&); 67 void joinNetwork(const QString&,const QString&,int,const QString&);
67 68
68 signals: 69 signals:
69 void startedSniffing(); 70 void startedSniffing();
70 void stoppedSniffing(); 71 void stoppedSniffing();
71 72
72 private: 73 private:
73 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 74 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
74 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); 75 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
75 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); 76 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
77 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to );
76 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); 78 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
77 void handleNotification( OPacket* p ); 79 void handleNotification( OPacket* p );
78 void doAction( const QString& action, const QString& protocol, OPacket* p ); 80 void doAction( const QString& action, const QString& protocol, OPacket* p );
79 QObject* childIfToParse( OPacket* p, const QString& protocol ); 81 QObject* childIfToParse( OPacket* p, const QString& protocol );
80 bool checkDumpPacket( OPacket* p ); 82 bool checkDumpPacket( OPacket* p );
81 83
82 private: 84 private:
83 #ifdef QWS 85 #ifdef QWS
84 OSystem _system; // Opie Operating System identifier 86 OSystem _system; // Opie Operating System identifier
85 #endif 87 #endif
86 88
87 OWirelessNetworkInterface* iface; 89 OWirelessNetworkInterface* iface;
88 OPacketCapturer* pcap; 90 OPacketCapturer* pcap;
89 WellenreiterConfigWindow* configwindow; 91 WellenreiterConfigWindow* configwindow;
90 GPS* gps; 92 GPS* gps;
91 93
92 //void readConfig(); 94 //void readConfig();
93 //void writeConfig(); 95 //void writeConfig();
94}; 96};
95 97
96 98
97 99
98#endif 100#endif