summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui6
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp46
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h14
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp2
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp94
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h3
7 files changed, 121 insertions, 48 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
index dda7ba0..3ece270 100644
--- a/noncore/net/wellenreiter/gui/configbase.ui
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -169,6 +169,12 @@
169 <string>&lt;manual&gt;</string> 169 <string>&lt;manual&gt;</string>
170 </property> 170 </property>
171 </item> 171 </item>
172 <item>
173 <property>
174 <name>text</name>
175 <string>&lt;file&gt;</string>
176 </property>
177 </item>
172 <property stdset="1"> 178 <property stdset="1">
173 <name>name</name> 179 <name>name</name>
174 <cstring>deviceType</cstring> 180 <cstring>deviceType</cstring>
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index ba1119e..4aca526 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -15,8 +15,10 @@
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h"
18 19
19/* QT */ 20/* QT */
21#include <qapplication.h>
20#include <qcombobox.h> 22#include <qcombobox.h>
21#include <qfile.h> 23#include <qfile.h>
22#include <qlayout.h> 24#include <qlayout.h>
@@ -33,11 +35,12 @@ WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
33WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 35WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
34 :WellenreiterConfigBase( parent, name, true, f ) 36 :WellenreiterConfigBase( parent, name, true, f )
35{ 37{
36 _devicetype[ "cisco" ] = 1; 38 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
37 _devicetype[ "wlan-ng" ] = 2; 39 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
38 _devicetype[ "hostap" ] = 3; 40 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
39 _devicetype[ "orinoco" ] = 4; 41 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
40 _devicetype[ "<manual>" ] = 5; 42 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
43 _devicetype[ "<file>" ] = DEVTYPE_FILE;
41 44
42 // gather possible interface names from ONetwork 45 // gather possible interface names from ONetwork
43 ONetwork* net = ONetwork::instance(); 46 ONetwork* net = ONetwork::instance();
@@ -59,15 +62,16 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
59 while( !modules.atEnd() && !devicetype ) 62 while( !modules.atEnd() && !devicetype )
60 { 63 {
61 modules >> line; 64 modules >> line;
62 if ( line.contains( "cisco" ) ) devicetype = 1; 65 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
63 else if ( line.contains( "hostap" ) ) devicetype = 3; 66 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
64 else if ( line.contains( "prism" ) ) devicetype = 2; 67 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
65 else if ( line.contains( "orinoco" ) ) devicetype = 4; 68 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
66 } 69 }
67 if ( devicetype ) 70 if ( devicetype )
68 { 71 {
69 deviceType->setCurrentItem( devicetype ); 72 deviceType->setCurrentItem( devicetype );
70 qDebug( "Wellenreiter: guessed device type to be %d", devicetype ); 73 _guess = devicetype;
74 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
71 } 75 }
72 } 76 }
73 77
@@ -79,8 +83,11 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
79 #endif 83 #endif
80 84
81 WellenreiterConfigWindow::_instance = this; 85 WellenreiterConfigWindow::_instance = this;
86
87 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
82}; 88};
83 89
90
84int WellenreiterConfigWindow::daemonDeviceType() 91int WellenreiterConfigWindow::daemonDeviceType()
85{ 92{
86 QString name = deviceType->currentText(); 93 QString name = deviceType->currentText();
@@ -94,7 +101,26 @@ int WellenreiterConfigWindow::daemonDeviceType()
94 } 101 }
95}; 102};
96 103
104
97int WellenreiterConfigWindow::daemonHopInterval() 105int WellenreiterConfigWindow::daemonHopInterval()
98{ 106{
99 return hopInterval->cleanText().toInt(); 107 return hopInterval->cleanText().toInt();
100} 108}
109
110
111void WellenreiterConfigWindow::changedDeviceType(int t)
112{
113 if ( t != DEVTYPE_FILE ) return;
114 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
115 if ( !name.isNull() && QFile::exists( name ) )
116 {
117 interfaceName->insertItem( name );
118 interfaceName->setCurrentItem( interfaceName->count()-1 );
119 }
120 else
121 {
122 deviceType->setCurrentItem( _guess );
123 }
124
125}
126
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index 5fd0327..7df1a80 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -21,10 +21,19 @@
21#include <qcombobox.h> 21#include <qcombobox.h>
22#include <qstring.h> 22#include <qstring.h>
23 23
24const int DEVTYPE_SELECT = 0;
25const int DEVTYPE_CISCO = 1;
26const int DEVTYPE_WLAN_NG = 2;
27const int DEVTYPE_HOSTAP = 3;
28const int DEVTYPE_ORINOCO = 4;
29const int DEVTYPE_MANUAL = 5;
30const int DEVTYPE_FILE = 6;
31
24class WellenreiterConfigWindow; 32class WellenreiterConfigWindow;
25 33
26class WellenreiterConfigWindow : public WellenreiterConfigBase 34class WellenreiterConfigWindow : public WellenreiterConfigBase
27{ 35{
36 Q_OBJECT
28 37
29 public: 38 public:
30 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); 39 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 );
@@ -34,11 +43,14 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
34 const QString soundOnBeacon() const { return beaconSound->currentText(); }; 43 const QString soundOnBeacon() const { return beaconSound->currentText(); };
35 static WellenreiterConfigWindow* instance() { return _instance; }; 44 static WellenreiterConfigWindow* instance() { return _instance; };
36 45
46 public slots:
47 void changedDeviceType(int);
48
37 protected: 49 protected:
38 QMap<QString, int> _devicetype; 50 QMap<QString, int> _devicetype;
39 static WellenreiterConfigWindow* _instance; 51 static WellenreiterConfigWindow* _instance;
52 int _guess;
40 53
41}; 54};
42 55
43#endif 56#endif
44
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 94e3f28..6cd364c 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -223,6 +223,7 @@ void WellenreiterMainWindow::demoAddStations()
223 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 223 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
224} 224}
225 225
226
226QString WellenreiterMainWindow::getFileName( bool save ) 227QString WellenreiterMainWindow::getFileName( bool save )
227{ 228{
228 QMap<QString, QStringList> map; 229 QMap<QString, QStringList> map;
@@ -257,6 +258,7 @@ QString WellenreiterMainWindow::getFileName( bool save )
257 return str; 258 return str;
258} 259}
259 260
261
260void WellenreiterMainWindow::fileSaveLog() 262void WellenreiterMainWindow::fileSaveLog()
261{ 263{
262 QString fname = getFileName( true ); 264 QString fname = getFileName( true );
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 1e191e5..926bb0a 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -30,6 +30,7 @@ class WellenreiterMainWindow: public QMainWindow
30 public: 30 public:
31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); 31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
32 ~WellenreiterMainWindow(); 32 ~WellenreiterMainWindow();
33 QString getFileName( bool save );
33 34
34 protected: 35 protected:
35 Wellenreiter* mw; 36 Wellenreiter* mw;
@@ -49,9 +50,6 @@ class WellenreiterMainWindow: public QMainWindow
49 virtual void closeEvent( QCloseEvent* ); 50 virtual void closeEvent( QCloseEvent* );
50 void updateToolButtonState(); 51 void updateToolButtonState();
51 52
52 private:
53 QString getFileName( bool save );
54
55 public slots: 53 public slots:
56 void showConfigure(); 54 void showConfigure();
57 void demoAddStations(); 55 void demoAddStations();
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 3372883..5c10c3b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -221,28 +221,28 @@ void Wellenreiter::receivePacket(OPacket* p)
221 221
222void Wellenreiter::stopClicked() 222void Wellenreiter::stopClicked()
223{ 223{
224 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 224 if ( iface )
225 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 225 {
226 iface->setChannelHopping(); // stop hopping channels 226 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
227 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
228 iface->setChannelHopping(); // stop hopping channels
229 }
230 else
231 killTimers();
232
227 pcap->close(); 233 pcap->close();
228 sniffing = false; 234 sniffing = false;
229 #ifdef QWS
230 oApp->setTitle();
231 #else
232 qApp->mainWidget()->setCaption( "Wellenreiter II" );
233 #endif
234 235
235 // get interface name from config window 236 if ( iface )
236 const QString& interface = configwindow->interfaceName->currentText(); 237 {
237 ONetwork* net = ONetwork::instance(); 238 // switch off monitor mode
238 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 239 iface->setMonitorMode( false );
240 // switch off promisc flag
241 iface->setPromiscuousMode( false );
239 242
240 // switch off monitor mode 243 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
241 iface->setMonitorMode( false ); 244 }
242 // switch off promisc flag
243 iface->setPromiscuousMode( false );
244 245
245 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
246 logwindow->log( "(i) Stopped Scanning." ); 246 logwindow->log( "(i) Stopped Scanning." );
247 assert( parent() ); 247 assert( parent() );
248 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 248 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
@@ -297,25 +297,32 @@ void Wellenreiter::startClicked()
297 297
298 switch ( cardtype ) 298 switch ( cardtype )
299 { 299 {
300 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; 300 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
301 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; 301 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
302 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; 302 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
303 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; 303 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
304 default: 304 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break;
305 QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); 305 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
306 default: assert( 0 ); // shouldn't reach this
306 } 307 }
307 308
308 if ( cardtype > 0 && cardtype < 5 ) 309 // switch device into monitor mode
309 iface->setMonitorMode( true ); 310 if ( cardtype < DEVTYPE_FILE )
310
311 if ( !iface->monitorMode() )
312 { 311 {
313 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); 312 if ( cardtype != DEVTYPE_MANUAL )
314 return; 313 iface->setMonitorMode( true );
314 if ( !iface->monitorMode() )
315 {
316 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
317 return;
318 }
315 } 319 }
316 320
317 // open pcap and start sniffing 321 // open pcap and start sniffing
318 pcap->open( interface ); 322 if ( cardtype != DEVTYPE_FILE )
323 pcap->open( interface );
324 else
325 pcap->open( QFile( interface ) );
319 326
320 if ( !pcap->isOpen() ) 327 if ( !pcap->isOpen() )
321 { 328 {
@@ -327,13 +334,32 @@ void Wellenreiter::startClicked()
327 pcap->setBlocking( false ); 334 pcap->setBlocking( false );
328 335
329 // start channel hopper 336 // start channel hopper
330 iface->setChannelHopping( 1000 ); //use interval from config window 337 if ( cardtype != DEVTYPE_FILE )
338 iface->setChannelHopping( 1000 ); //use interval from config window
331 339
332 // connect 340 if ( cardtype != DEVTYPE_FILE )
333 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 341 {
334 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 342 // connect socket notifier and start channel hopper
343 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
344 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
345 }
346 else
347 {
348 // start timer for reading packets
349 startTimer( 100 );
350 }
335 351
336 logwindow->log( "(i) Started Scanning." ); 352 logwindow->log( "(i) Started Scanning." );
337 sniffing = true; 353 sniffing = true;
338 emit( startedSniffing() ); 354 emit( startedSniffing() );
339} 355}
356
357
358void Wellenreiter::timerEvent( QTimerEvent* )
359{
360 qDebug( "Wellenreiter::timerEvent()" );
361 OPacket* p = pcap->next();
362 receivePacket( p );
363 delete p;
364}
365
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 839c77e..c37a9f2 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -49,6 +49,9 @@ class Wellenreiter : public WellenreiterBase {
49 49
50 bool sniffing; 50 bool sniffing;
51 51
52 protected:
53 virtual void timerEvent( QTimerEvent* );
54
52 public slots: 55 public slots:
53 void channelHopped(int); 56 void channelHopped(int);
54 void receivePacket(OPacket*); 57 void receivePacket(OPacket*);