summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-10 15:49:08 (UTC)
committer mickeyl <mickeyl>2003-04-10 15:49:08 (UTC)
commit4e8e3741dca909782e15bb197e5b6a78750536c2 (patch) (unidiff)
tree37285f8d053b3995aee46487277b57248862848c
parent3733471135ea180709fcf4695607cce0c5fc7fb5 (diff)
downloadopie-4e8e3741dca909782e15bb197e5b6a78750536c2.zip
opie-4e8e3741dca909782e15bb197e5b6a78750536c2.tar.gz
opie-4e8e3741dca909782e15bb197e5b6a78750536c2.tar.bz2
Wellenreiter can now open and replay capture files as written by tcpdump, ethereal, etc.
Next task: writing capture files
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
@@ -168,8 +168,14 @@
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>
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
@@ -14,10 +14,12 @@
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>
@@ -32,13 +34,14 @@ WellenreiterConfigWindow* 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();
@@ -58,17 +61,18 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
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
@@ -78,10 +82,13 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
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 ) )
@@ -93,8 +100,27 @@ int WellenreiterConfigWindow::daemonDeviceType()
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
@@ -20,12 +20,21 @@
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();
@@ -33,12 +42,15 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
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
@@ -222,8 +222,9 @@ void WellenreiterMainWindow::demoAddStations()
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() );
@@ -256,8 +257,9 @@ QString WellenreiterMainWindow::getFileName( bool save )
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() )
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
@@ -29,8 +29,9 @@ class WellenreiterMainWindow: public QMainWindow
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;
@@ -48,11 +49,8 @@ class WellenreiterMainWindow: public QMainWindow
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();
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
@@ -220,30 +220,30 @@ void Wellenreiter::receivePacket(OPacket* p)
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
@@ -296,27 +296,34 @@ void Wellenreiter::startClicked()
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 ) ));
@@ -326,14 +333,33 @@ void Wellenreiter::startClicked()
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
@@ -48,8 +48,11 @@ class Wellenreiter : public WellenreiterBase {
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();