summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -171,2 +171,8 @@
</item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>&lt;file&gt;</string>
+ </property>
+ </item>
<property stdset="1">
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
@@ -17,4 +17,6 @@
#include "configwindow.h"
+#include "mainwindow.h"
/* QT */
+#include <qapplication.h>
#include <qcombobox.h>
@@ -35,7 +37,8 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
{
- _devicetype[ "cisco" ] = 1;
- _devicetype[ "wlan-ng" ] = 2;
- _devicetype[ "hostap" ] = 3;
- _devicetype[ "orinoco" ] = 4;
- _devicetype[ "<manual>" ] = 5;
+ _devicetype[ "cisco" ] = DEVTYPE_CISCO;
+ _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
+ _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
+ _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
+ _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
+ _devicetype[ "<file>" ] = DEVTYPE_FILE;
@@ -61,6 +64,6 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
modules >> line;
- if ( line.contains( "cisco" ) ) devicetype = 1;
- else if ( line.contains( "hostap" ) ) devicetype = 3;
- else if ( line.contains( "prism" ) ) devicetype = 2;
- else if ( line.contains( "orinoco" ) ) devicetype = 4;
+ if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
+ else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
+ else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
+ else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
}
@@ -69,3 +72,4 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
deviceType->setCurrentItem( devicetype );
- qDebug( "Wellenreiter: guessed device type to be %d", devicetype );
+ _guess = devicetype;
+ qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
}
@@ -81,4 +85,7 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
WellenreiterConfigWindow::_instance = this;
+
+ connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
};
+
int WellenreiterConfigWindow::daemonDeviceType()
@@ -96,2 +103,3 @@ int WellenreiterConfigWindow::daemonDeviceType()
+
int WellenreiterConfigWindow::daemonHopInterval()
@@ -100 +108,19 @@ int WellenreiterConfigWindow::daemonHopInterval()
}
+
+
+void WellenreiterConfigWindow::changedDeviceType(int t)
+{
+ if ( t != DEVTYPE_FILE ) return;
+ QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
+ if ( !name.isNull() && QFile::exists( name ) )
+ {
+ interfaceName->insertItem( name );
+ interfaceName->setCurrentItem( interfaceName->count()-1 );
+ }
+ else
+ {
+ deviceType->setCurrentItem( _guess );
+ }
+
+}
+
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
@@ -23,2 +23,10 @@
+const int DEVTYPE_SELECT = 0;
+const int DEVTYPE_CISCO = 1;
+const int DEVTYPE_WLAN_NG = 2;
+const int DEVTYPE_HOSTAP = 3;
+const int DEVTYPE_ORINOCO = 4;
+const int DEVTYPE_MANUAL = 5;
+const int DEVTYPE_FILE = 6;
+
class WellenreiterConfigWindow;
@@ -27,2 +35,3 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
{
+ Q_OBJECT
@@ -36,2 +45,5 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
+ public slots:
+ void changedDeviceType(int);
+
protected:
@@ -39,2 +51,3 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
static WellenreiterConfigWindow* _instance;
+ int _guess;
@@ -43,2 +56 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
#endif
-
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
@@ -225,2 +225,3 @@ void WellenreiterMainWindow::demoAddStations()
+
QString WellenreiterMainWindow::getFileName( bool save )
@@ -259,2 +260,3 @@ QString WellenreiterMainWindow::getFileName( bool save )
+
void WellenreiterMainWindow::fileSaveLog()
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
@@ -32,2 +32,3 @@ class WellenreiterMainWindow: public QMainWindow
~WellenreiterMainWindow();
+ QString getFileName( bool save );
@@ -51,5 +52,2 @@ class WellenreiterMainWindow: public QMainWindow
- private:
- QString getFileName( bool save );
-
public slots:
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
@@ -223,24 +223,24 @@ void Wellenreiter::stopClicked()
{
- disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
- disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
- iface->setChannelHopping(); // stop hopping channels
+ if ( iface )
+ {
+ disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
+ disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
+ iface->setChannelHopping(); // stop hopping channels
+ }
+ else
+ killTimers();
+
pcap->close();
sniffing = false;
- #ifdef QWS
- oApp->setTitle();
- #else
- qApp->mainWidget()->setCaption( "Wellenreiter II" );
- #endif
- // get interface name from config window
- const QString& interface = configwindow->interfaceName->currentText();
- ONetwork* net = ONetwork::instance();
- iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
+ if ( iface )
+ {
+ // switch off monitor mode
+ iface->setMonitorMode( false );
+ // switch off promisc flag
+ iface->setPromiscuousMode( false );
- // switch off monitor mode
- iface->setMonitorMode( false );
- // switch off promisc flag
- iface->setPromiscuousMode( false );
+ system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
+ }
- system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
logwindow->log( "(i) Stopped Scanning." );
@@ -299,17 +299,21 @@ void Wellenreiter::startClicked()
{
- case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
- case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
- case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
- case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
- default:
- QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." );
+ case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
+ case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
+ case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
+ case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
+ case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break;
+ case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
+ default: assert( 0 ); // shouldn't reach this
}
- if ( cardtype > 0 && cardtype < 5 )
- iface->setMonitorMode( true );
-
- if ( !iface->monitorMode() )
+ // switch device into monitor mode
+ if ( cardtype < DEVTYPE_FILE )
{
- QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
- return;
+ if ( cardtype != DEVTYPE_MANUAL )
+ iface->setMonitorMode( true );
+ if ( !iface->monitorMode() )
+ {
+ QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
+ return;
+ }
}
@@ -317,3 +321,6 @@ void Wellenreiter::startClicked()
// open pcap and start sniffing
- pcap->open( interface );
+ if ( cardtype != DEVTYPE_FILE )
+ pcap->open( interface );
+ else
+ pcap->open( QFile( interface ) );
@@ -329,7 +336,16 @@ void Wellenreiter::startClicked()
// start channel hopper
- iface->setChannelHopping( 1000 ); //use interval from config window
+ if ( cardtype != DEVTYPE_FILE )
+ iface->setChannelHopping( 1000 ); //use interval from config window
- // connect
- connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
- connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
+ if ( cardtype != DEVTYPE_FILE )
+ {
+ // connect socket notifier and start channel hopper
+ connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
+ connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
+ }
+ else
+ {
+ // start timer for reading packets
+ startTimer( 100 );
+ }
@@ -339 +355,11 @@ void Wellenreiter::startClicked()
}
+
+
+void Wellenreiter::timerEvent( QTimerEvent* )
+{
+ qDebug( "Wellenreiter::timerEvent()" );
+ OPacket* p = pcap->next();
+ receivePacket( p );
+ delete p;
+}
+
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
@@ -51,2 +51,5 @@ class Wellenreiter : public WellenreiterBase {
+ protected:
+ virtual void timerEvent( QTimerEvent* );
+
public slots: