summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -160,24 +160,30 @@
160 <item> 160 <item>
161 <property> 161 <property>
162 <name>text</name> 162 <name>text</name>
163 <string>orinoco</string> 163 <string>orinoco</string>
164 </property> 164 </property>
165 </item> 165 </item>
166 <item> 166 <item>
167 <property> 167 <property>
168 <name>text</name> 168 <name>text</name>
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>
175 </property> 181 </property>
176 <property stdset="1"> 182 <property stdset="1">
177 <name>enabled</name> 183 <name>enabled</name>
178 <bool>true</bool> 184 <bool>true</bool>
179 </property> 185 </property>
180 <property> 186 <property>
181 <name>whatsThis</name> 187 <name>whatsThis</name>
182 <string>Choose the type of driver used for sniffing.</string> 188 <string>Choose the type of driver used for sniffing.</string>
183 </property> 189 </property>
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
@@ -6,95 +6,121 @@
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/* 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>
23#include <qmap.h> 25#include <qmap.h>
24#include <qpushbutton.h> 26#include <qpushbutton.h>
25#include <qspinbox.h> 27#include <qspinbox.h>
26#include <qtextstream.h> 28#include <qtextstream.h>
27 29
28/* OPIE */ 30/* OPIE */
29#include <opie2/onetwork.h> 31#include <opie2/onetwork.h>
30 32
31WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 33WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
32 34
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();
44 ONetwork::InterfaceIterator it = net->iterator(); 47 ONetwork::InterfaceIterator it = net->iterator();
45 while ( it.current() ) 48 while ( it.current() )
46 { 49 {
47 if ( it.current()->isWireless() ) 50 if ( it.current()->isWireless() )
48 interfaceName->insertItem( it.current()->name() ); 51 interfaceName->insertItem( it.current()->name() );
49 ++it; 52 ++it;
50 } 53 }
51 54
52 // try to guess device type 55 // try to guess device type
53 QFile m( "/proc/modules" ); 56 QFile m( "/proc/modules" );
54 if ( m.open( IO_ReadOnly ) ) 57 if ( m.open( IO_ReadOnly ) )
55 { 58 {
56 int devicetype(0); 59 int devicetype(0);
57 QString line; 60 QString line;
58 QTextStream modules( &m ); 61 QTextStream modules( &m );
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
74 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 78 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
75 QPushButton* okButton = new QPushButton( "ok", this ); 79 QPushButton* okButton = new QPushButton( "ok", this );
76 okButton->show(); 80 okButton->show();
77 Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui 81 Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
78 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 82 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
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();
87 if ( _devicetype.contains( name ) ) 94 if ( _devicetype.contains( name ) )
88 { 95 {
89 return _devicetype[name]; 96 return _devicetype[name];
90 } 97 }
91 else 98 else
92 { 99 {
93 return 0; 100 return 0;
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
@@ -12,33 +12,45 @@
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 WELLENREITERCONFIGWINDOW_H 16#ifndef WELLENREITERCONFIGWINDOW_H
17#define WELLENREITERCONFIGWINDOW_H 17#define WELLENREITERCONFIGWINDOW_H
18 18
19#include "configbase.h" 19#include "configbase.h"
20#include <qmap.h> 20#include <qmap.h>
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 );
31 int daemonDeviceType(); 40 int daemonDeviceType();
32 int daemonHopInterval(); 41 int daemonHopInterval();
33 const QString soundOnNetwork() const { return netSound->currentText(); }; 42 const QString soundOnNetwork() const { return netSound->currentText(); };
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
@@ -214,24 +214,25 @@ WellenreiterMainWindow::~WellenreiterMainWindow()
214 delete stopIconSet; 214 delete stopIconSet;
215}; 215};
216 216
217void WellenreiterMainWindow::demoAddStations() 217void WellenreiterMainWindow::demoAddStations()
218{ 218{
219 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 219 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
220 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); 220 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
221 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 221 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
222 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 222 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
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;
229 map.insert( tr("All"), QStringList() ); 230 map.insert( tr("All"), QStringList() );
230 QStringList text; 231 QStringList text;
231 text << "text/*"; 232 text << "text/*";
232 map.insert(tr("Text"), text ); 233 map.insert(tr("Text"), text );
233 text << "*"; 234 text << "*";
234 map.insert(tr("All"), text ); 235 map.insert(tr("All"), text );
235 236
236 QString str; 237 QString str;
237 if ( save ) 238 if ( save )
@@ -248,24 +249,25 @@ QString WellenreiterMainWindow::getFileName( bool save )
248 { 249 {
249 #ifdef QWS 250 #ifdef QWS
250 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 251 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
251 #else 252 #else
252 str = QFileDialog::getOpenFileName(); 253 str = QFileDialog::getOpenFileName();
253 #endif 254 #endif
254 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 255 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
255 return ""; 256 return "";
256 } 257 }
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 );
263 if ( !fname.isEmpty() ) 265 if ( !fname.isEmpty() )
264 { 266 {
265 QFile f( fname ); 267 QFile f( fname );
266 if ( f.open(IO_WriteOnly) ) 268 if ( f.open(IO_WriteOnly) )
267 { 269 {
268 QTextStream t( &f ); 270 QTextStream t( &f );
269 t << mw->logWindow()->getLog(); 271 t << mw->logWindow()->getLog();
270 f.close(); 272 f.close();
271 qDebug( "Saved log to file '%s'", (const char*) fname ); 273 qDebug( "Saved log to file '%s'", (const char*) fname );
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
@@ -21,46 +21,44 @@
21class Wellenreiter; 21class Wellenreiter;
22class WellenreiterConfigWindow; 22class WellenreiterConfigWindow;
23class QIconSet; 23class QIconSet;
24class QToolButton; 24class QToolButton;
25 25
26class WellenreiterMainWindow: public QMainWindow 26class WellenreiterMainWindow: public QMainWindow
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
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;
36 WellenreiterConfigWindow* cw; 37 WellenreiterConfigWindow* cw;
37 38
38 const QIconSet* startIconSet; 39 const QIconSet* startIconSet;
39 const QIconSet* stopIconSet; 40 const QIconSet* stopIconSet;
40 const QIconSet* infoIconSet; 41 const QIconSet* infoIconSet;
41 const QIconSet* settingsIconSet; 42 const QIconSet* settingsIconSet;
42 43
43 QToolButton* startButton; 44 QToolButton* startButton;
44 QToolButton* stopButton; 45 QToolButton* stopButton;
45 int startID; 46 int startID;
46 int stopID; 47 int stopID;
47 48
48 protected: 49 protected:
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();
58 void fileSaveLog(); 56 void fileSaveLog();
59 void fileSaveHex(); 57 void fileSaveHex();
60 void fileSaveSession(); 58 void fileSaveSession();
61 void fileLoadSession(); 59 void fileLoadSession();
62 void fileNew(); 60 void fileNew();
63 void changedSniffingState(); 61 void changedSniffingState();
64}; 62};
65 63
66#endif 64#endif
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
@@ -212,46 +212,46 @@ void Wellenreiter::receivePacket(OPacket* p)
212 (const char*) wlan->macAddress3().toString(true) ); 212 (const char*) wlan->macAddress3().toString(true) );
213 netView()->traffic( "IBSS", wlan->macAddress2().toString(), 213 netView()->traffic( "IBSS", wlan->macAddress2().toString(),
214 wlan->macAddress1().toString(), 214 wlan->macAddress1().toString(),
215 wlan->macAddress3().toString() ); 215 wlan->macAddress3().toString() );
216 } 216 }
217 return; 217 return;
218 } 218 }
219} 219}
220 220
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" );
249 249
250 // message the user 250 // message the user
251 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); 251 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
252 252
253 sniffing = false; 253 sniffing = false;
254 emit( stoppedSniffing() ); 254 emit( stoppedSniffing() );
255 255
256 // print out statistics 256 // print out statistics
257 statwindow->log( "-----------------------------------------" ); 257 statwindow->log( "-----------------------------------------" );
@@ -288,52 +288,78 @@ void Wellenreiter::startClicked()
288 return; 288 return;
289 } 289 }
290 290
291 // configure device 291 // configure device
292 292
293 ONetwork* net = ONetwork::instance(); 293 ONetwork* net = ONetwork::instance();
294 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 294 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
295 295
296 // set monitor mode 296 // set monitor mode
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 {
322 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); 329 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
323 return; 330 return;
324 } 331 }
325 332
326 // set capturer to non-blocking mode 333 // set capturer to non-blocking mode
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
@@ -40,24 +40,27 @@ class Wellenreiter : public WellenreiterBase {
40 public: 40 public:
41 Wellenreiter( QWidget* parent = 0 ); 41 Wellenreiter( QWidget* parent = 0 );
42 ~Wellenreiter(); 42 ~Wellenreiter();
43 43
44 void setConfigWindow( WellenreiterConfigWindow* cw ); 44 void setConfigWindow( WellenreiterConfigWindow* cw );
45 MScanListView* netView() const { return netview; }; 45 MScanListView* netView() const { return netview; };
46 MLogWindow* logWindow() const { return logwindow; }; 46 MLogWindow* logWindow() const { return logwindow; };
47 MHexWindow* hexWindow() const { return hexwindow; }; 47 MHexWindow* hexWindow() const { return hexwindow; };
48 bool isDaemonRunning() const { return sniffing; }; 48 bool isDaemonRunning() const { return sniffing; };
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*);
55 void startClicked(); 58 void startClicked();
56 void stopClicked(); 59 void stopClicked();
57 60
58 signals: 61 signals:
59 void startedSniffing(); 62 void startedSniffing();
60 void stoppedSniffing(); 63 void stoppedSniffing();
61 64
62 private: 65 private:
63 #ifdef QWS 66 #ifdef QWS