summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp74
1 files changed, 12 insertions, 62 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 4257be1..2f26702 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -13,25 +13,24 @@
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Local 16// Local
17 17
18#include "wellenreiter.h" 18#include "wellenreiter.h"
19#include "scanlist.h" 19#include "scanlist.h"
20#include "logwindow.h" 20#include "logwindow.h"
21#include "hexwindow.h" 21#include "hexwindow.h"
22#include "configwindow.h" 22#include "configwindow.h"
23#include "statwindow.h" 23#include "statwindow.h"
24#include "graphwindow.h" 24#include "graphwindow.h"
25#include "manufacturers.h"
26#include "protolistview.h" 25#include "protolistview.h"
27 26
28// Opie 27// Opie
29 28
30#ifdef QWS 29#ifdef QWS
31#include <opie/odevice.h> 30#include <opie/odevice.h>
32using namespace Opie; 31using namespace Opie;
33#endif 32#endif
34 33
35#ifdef QWS 34#ifdef QWS
36#include <opie2/oapplication.h> 35#include <opie2/oapplication.h>
37#else 36#else
@@ -56,68 +55,47 @@ using namespace Opie;
56 55
57// Standard 56// Standard
58 57
59#include <assert.h> 58#include <assert.h>
60#include <errno.h> 59#include <errno.h>
61#include <unistd.h> 60#include <unistd.h>
62#include <string.h> 61#include <string.h>
63#include <sys/types.h> 62#include <sys/types.h>
64#include <stdlib.h> 63#include <stdlib.h>
65 64
66Wellenreiter::Wellenreiter( QWidget* parent ) 65Wellenreiter::Wellenreiter( QWidget* parent )
67 : WellenreiterBase( parent, 0, 0 ), 66 : WellenreiterBase( parent, 0, 0 ),
68 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) 67 sniffing( false ), iface( 0 ), configwindow( 0 )
69{ 68{
70 69
71 //
72 // construct manufacturer database
73 //
74
75 QString manufile;
76 #ifdef QWS
77 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
78 #else
79 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" );
80 #endif
81 manufacturerdb = new ManufacturerDB( manufile );
82
83 logwindow->log( "(i) Wellenreiter has been started." ); 70 logwindow->log( "(i) Wellenreiter has been started." );
84 71
85 // 72 //
86 // detect operating system 73 // detect operating system
87 // 74 //
88 75
89 #ifdef QWS 76 #ifdef QWS
90 QString sys; 77 QString sys;
91 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 78 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
92 _system = ODevice::inst()->system(); 79 _system = ODevice::inst()->system();
93 logwindow->log( sys ); 80 logwindow->log( sys );
94 #endif 81 #endif
95 82
96 // setup GUI
97 netview->setColumnWidthMode( 1, QListView::Manual ); 83 netview->setColumnWidthMode( 1, QListView::Manual );
98
99 if ( manufacturerdb )
100 netview->setManufacturerDB( manufacturerdb );
101
102 pcap = new OPacketCapturer(); 84 pcap = new OPacketCapturer();
103
104} 85}
105 86
106 87
107Wellenreiter::~Wellenreiter() 88Wellenreiter::~Wellenreiter()
108{ 89{
109 // no need to delete child widgets, Qt does it all for us
110
111 delete manufacturerdb;
112 delete pcap; 90 delete pcap;
113} 91}
114 92
115 93
116void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 94void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
117{ 95{
118 configwindow = cw; 96 configwindow = cw;
119} 97}
120 98
121 99
122void Wellenreiter::channelHopped(int c) 100void Wellenreiter::channelHopped(int c)
123{ 101{
@@ -177,98 +155,70 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
177 else 155 else
178 { 156 {
179 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 157 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
180 return; 158 return;
181 } 159 }
182 160
183 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 161 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
184 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 162 QString essid = ssid ? ssid->ID() : QString("<unknown>");
185 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 163 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
186 int channel = ds ? ds->channel() : -1; 164 int channel = ds ? ds->channel() : -1;
187 165
188 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 166 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
189 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); 167 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 );
190 168
191 // update graph window 169 // update graph window
192 if ( ds ) 170 if ( ds )
193 { 171 {
194 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 172 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
195 if ( prism ) 173 if ( prism )
196 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 174 graphwindow->traffic( ds->channel(), prism->signalStrength() );
197 else 175 else
198 graphwindow->traffic( ds->channel(), 95 ); 176 graphwindow->traffic( ds->channel(), 95 );
199 } 177 }
200} 178}
201 179
202 180
203void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) 181void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
204{ 182{
205 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 183 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
206 if ( wlan->fromDS() && !wlan->toDS() ) 184 if ( wlan->fromDS() && !wlan->toDS() )
207 { 185 {
208 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", 186 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
209 (const char*) wlan->macAddress3().toString(true),
210 (const char*) wlan->macAddress1().toString(true),
211 (const char*) wlan->macAddress2().toString(true) );
212 netView()->fromDStraffic( wlan->macAddress3().toString(),
213 wlan->macAddress1().toString(),
214 wlan->macAddress2().toString() );
215 } 187 }
216 else 188 else if ( !wlan->fromDS() && wlan->toDS() )
217 if ( !wlan->fromDS() && wlan->toDS() )
218 { 189 {
219 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", 190 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
220 (const char*) wlan->macAddress2().toString(true),
221 (const char*) wlan->macAddress3().toString(true),
222 (const char*) wlan->macAddress1().toString(true) );
223 netView()->toDStraffic( wlan->macAddress2().toString(),
224 wlan->macAddress3().toString(),
225 wlan->macAddress1().toString() );
226 } 191 }
227 else 192 else if ( wlan->fromDS() && wlan->toDS() )
228 if ( wlan->fromDS() && wlan->toDS() )
229 { 193 {
230 qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", 194 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
231 (const char*) wlan->macAddress4().toString(true),
232 (const char*) wlan->macAddress3().toString(true),
233 (const char*) wlan->macAddress1().toString(true),
234 (const char*) wlan->macAddress2().toString(true) );
235 netView()->WDStraffic( wlan->macAddress4().toString(),
236 wlan->macAddress3().toString(),
237 wlan->macAddress1().toString(),
238 wlan->macAddress2().toString() );
239 } 195 }
240 else 196 else
241 { 197 {
242 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", 198 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
243 (const char*) wlan->macAddress2().toString(true),
244 (const char*) wlan->macAddress1().toString(true),
245 (const char*) wlan->macAddress3().toString(true) );
246 netView()->IBSStraffic( wlan->macAddress2().toString(),
247 wlan->macAddress1().toString(),
248 wlan->macAddress3().toString() );
249 } 199 }
250 200
251 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 201 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
252 if ( arp ) 202 if ( arp )
253 { 203 {
254 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 204 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
255 if ( arp->type() == "REQUEST" ) 205 if ( arp->type() == "REQUEST" )
256 { 206 {
257 netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); 207 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
258 } 208 }
259 else if ( arp->type() == "REPLY" ) 209 else if ( arp->type() == "REPLY" )
260 { 210 {
261 netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); 211 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
262 netView()->identify( arp->targetMacAddress().toString(), arp->targetIPV4Address().toString() ); 212 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
263 } 213 }
264 } 214 }
265 215
266 OIPPacket* ip = (OIPPacket*) p->child( "IP" ); 216 OIPPacket* ip = (OIPPacket*) p->child( "IP" );
267 if ( ip ) 217 if ( ip )
268 { 218 {
269 qDebug( "Received IP packet." ); 219 qDebug( "Received IP packet." );
270 } 220 }
271} 221}
272 222
273 223
274QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 224QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
@@ -428,25 +378,25 @@ void Wellenreiter::startClicked()
428 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 378 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
429 default: assert( 0 ); // shouldn't reach this 379 default: assert( 0 ); // shouldn't reach this
430 } 380 }
431 381
432 // switch device into monitor mode 382 // switch device into monitor mode
433 if ( cardtype < DEVTYPE_FILE ) 383 if ( cardtype < DEVTYPE_FILE )
434 { 384 {
435 if ( cardtype != DEVTYPE_MANUAL ) 385 if ( cardtype != DEVTYPE_MANUAL )
436 iface->setMonitorMode( true ); 386 iface->setMonitorMode( true );
437 if ( !iface->monitorMode() ) 387 if ( !iface->monitorMode() )
438 { 388 {
439 QMessageBox::warning( this, "Wellenreiter II", 389 QMessageBox::warning( this, "Wellenreiter II",
440 tr( "Can't set interface '%1' into monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); 390 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) );
441 return; 391 return;
442 } 392 }
443 } 393 }
444 394
445 // open pcap and start sniffing 395 // open pcap and start sniffing
446 if ( cardtype != DEVTYPE_FILE ) 396 if ( cardtype != DEVTYPE_FILE )
447 { 397 {
448 pcap->open( interface ); 398 pcap->open( interface );
449 399
450 if ( configwindow->writeCaptureFile->isOn() ) 400 if ( configwindow->writeCaptureFile->isOn() )
451 { 401 {
452 QString dumpname( configwindow->captureFileName->text() ); 402 QString dumpname( configwindow->captureFileName->text() );