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
@@ -140,64 +140,70 @@
</property>
</item>
<item>
<property>
<name>text</name>
<string>cisco</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>wlan-ng</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>hostap</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>orinoco</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>&lt;manual&gt;</string>
</property>
</item>
+ <item>
+ <property>
+ <name>text</name>
+ <string>&lt;file&gt;</string>
+ </property>
+ </item>
<property stdset="1">
<name>name</name>
<cstring>deviceType</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property>
<name>whatsThis</name>
<string>Choose the type of driver used for sniffing.</string>
</property>
</widget>
<widget row="3" column="0" rowspan="1" colspan="2" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>additionalInfo</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>text</name>
<string>Gather Additional Info</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QSpinBox</class>
<property stdset="1">
<name>name</name>
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
@@ -1,100 +1,126 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
/* LOCAL */
#include "configwindow.h"
+#include "mainwindow.h"
/* QT */
+#include <qapplication.h>
#include <qcombobox.h>
#include <qfile.h>
#include <qlayout.h>
#include <qmap.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qtextstream.h>
/* OPIE */
#include <opie2/onetwork.h>
WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
:WellenreiterConfigBase( parent, name, true, f )
{
- _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;
// gather possible interface names from ONetwork
ONetwork* net = ONetwork::instance();
ONetwork::InterfaceIterator it = net->iterator();
while ( it.current() )
{
if ( it.current()->isWireless() )
interfaceName->insertItem( it.current()->name() );
++it;
}
// try to guess device type
QFile m( "/proc/modules" );
if ( m.open( IO_ReadOnly ) )
{
int devicetype(0);
QString line;
QTextStream modules( &m );
while( !modules.atEnd() && !devicetype )
{
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;
}
if ( devicetype )
{
deviceType->setCurrentItem( devicetype );
- qDebug( "Wellenreiter: guessed device type to be %d", devicetype );
+ _guess = devicetype;
+ qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
}
}
#ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
QPushButton* okButton = new QPushButton( "ok", this );
okButton->show();
Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
#endif
WellenreiterConfigWindow::_instance = this;
+
+ connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
};
+
int WellenreiterConfigWindow::daemonDeviceType()
{
QString name = deviceType->currentText();
if ( _devicetype.contains( name ) )
{
return _devicetype[name];
}
else
{
return 0;
}
};
+
int WellenreiterConfigWindow::daemonHopInterval()
{
return hopInterval->cleanText().toInt();
}
+
+
+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
@@ -1,44 +1,56 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#ifndef WELLENREITERCONFIGWINDOW_H
#define WELLENREITERCONFIGWINDOW_H
#include "configbase.h"
#include <qmap.h>
#include <qcombobox.h>
#include <qstring.h>
+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;
class WellenreiterConfigWindow : public WellenreiterConfigBase
{
+ Q_OBJECT
public:
WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 );
int daemonDeviceType();
int daemonHopInterval();
const QString soundOnNetwork() const { return netSound->currentText(); };
const QString soundOnBeacon() const { return beaconSound->currentText(); };
static WellenreiterConfigWindow* instance() { return _instance; };
+ public slots:
+ void changedDeviceType(int);
+
protected:
QMap<QString, int> _devicetype;
static WellenreiterConfigWindow* _instance;
+ int _guess;
};
#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
@@ -194,98 +194,100 @@ void WellenreiterMainWindow::updateToolButtonState()
startButton->setEnabled( false );
menuBar()->setItemEnabled( startID, false );
}
}
void WellenreiterMainWindow::changedSniffingState()
{
startButton->setEnabled( !mw->sniffing );
menuBar()->setItemEnabled( startID, !mw->sniffing );
stopButton->setEnabled( mw->sniffing );
menuBar()->setItemEnabled( stopID, mw->sniffing );
}
WellenreiterMainWindow::~WellenreiterMainWindow()
{
delete infoIconSet;
delete settingsIconSet;
delete startIconSet;
delete stopIconSet;
};
void WellenreiterMainWindow::demoAddStations()
{
mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
}
+
QString WellenreiterMainWindow::getFileName( bool save )
{
QMap<QString, QStringList> map;
map.insert( tr("All"), QStringList() );
QStringList text;
text << "text/*";
map.insert(tr("Text"), text );
text << "*";
map.insert(tr("All"), text );
QString str;
if ( save )
{
#ifdef QWS
str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
#else
str = QFileDialog::getSaveFileName();
#endif
if ( str.isEmpty() || QFileInfo(str).isDir() )
return "";
}
else
{
#ifdef QWS
str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
#else
str = QFileDialog::getOpenFileName();
#endif
if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
return "";
}
return str;
}
+
void WellenreiterMainWindow::fileSaveLog()
{
QString fname = getFileName( true );
if ( !fname.isEmpty() )
{
QFile f( fname );
if ( f.open(IO_WriteOnly) )
{
QTextStream t( &f );
t << mw->logWindow()->getLog();
f.close();
qDebug( "Saved log to file '%s'", (const char*) fname );
}
else
{
qDebug( "Problem saving log to file '%s'", (const char*) fname );
}
}
}
void WellenreiterMainWindow::fileSaveSession()
{
QString fname = getFileName( true );
if ( !fname.isEmpty() )
{
QFile f( fname );
if ( f.open(IO_WriteOnly) )
{
QDataStream t( &f );
t << *mw->netView();
f.close();
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
@@ -1,66 +1,64 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
class Wellenreiter;
class WellenreiterConfigWindow;
class QIconSet;
class QToolButton;
class WellenreiterMainWindow: public QMainWindow
{
Q_OBJECT
public:
WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
~WellenreiterMainWindow();
+ QString getFileName( bool save );
protected:
Wellenreiter* mw;
WellenreiterConfigWindow* cw;
const QIconSet* startIconSet;
const QIconSet* stopIconSet;
const QIconSet* infoIconSet;
const QIconSet* settingsIconSet;
QToolButton* startButton;
QToolButton* stopButton;
int startID;
int stopID;
protected:
virtual void closeEvent( QCloseEvent* );
void updateToolButtonState();
- private:
- QString getFileName( bool save );
-
public slots:
void showConfigure();
void demoAddStations();
void fileSaveLog();
void fileSaveHex();
void fileSaveSession();
void fileLoadSession();
void fileNew();
void changedSniffingState();
};
#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
@@ -192,148 +192,174 @@ void Wellenreiter::receivePacket(OPacket* p)
wlan->macAddress1().toString() );
}
else
if ( wlan->fromDS() && wlan->toDS() )
{
qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
(const char*) wlan->macAddress4().toString(true),
(const char*) wlan->macAddress3().toString(true),
(const char*) wlan->macAddress1().toString(true),
(const char*) wlan->macAddress2().toString(true) );
netView()->traffic( "WSD", wlan->macAddress4().toString(),
wlan->macAddress3().toString(),
wlan->macAddress1().toString(),
wlan->macAddress2().toString() );
}
else
{
qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
(const char*) wlan->macAddress2().toString(true),
(const char*) wlan->macAddress1().toString(true),
(const char*) wlan->macAddress3().toString(true) );
netView()->traffic( "IBSS", wlan->macAddress2().toString(),
wlan->macAddress1().toString(),
wlan->macAddress3().toString() );
}
return;
}
}
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." );
assert( parent() );
( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
// message the user
QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
sniffing = false;
emit( stoppedSniffing() );
// print out statistics
statwindow->log( "-----------------------------------------" );
statwindow->log( "- Wellenreiter II Capturing Statistic -" );
statwindow->log( "-----------------------------------------" );
statwindow->log( "Packet Type | Receive Count" );
for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
{
QString left;
left.sprintf( "%s", (const char*) it.key() );
left = left.leftJustify( 20 );
left.append( '|' );
QString right;
right.sprintf( "%d", it.data() );
right = right.rightJustify( 7 );
statwindow->log( left + right );
}
}
void Wellenreiter::startClicked()
{
// get configuration from config window
const QString& interface = configwindow->interfaceName->currentText();
const int cardtype = configwindow->daemonDeviceType();
const int interval = configwindow->daemonHopInterval();
if ( ( interface == "" ) || ( cardtype == 0 ) )
{
QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
return;
}
// configure device
ONetwork* net = ONetwork::instance();
iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
// set monitor mode
switch ( cardtype )
{
- 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;
+ }
}
// open pcap and start sniffing
- pcap->open( interface );
+ if ( cardtype != DEVTYPE_FILE )
+ pcap->open( interface );
+ else
+ pcap->open( QFile( interface ) );
if ( !pcap->isOpen() )
{
QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
return;
}
// set capturer to non-blocking mode
pcap->setBlocking( false );
// 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 );
+ }
logwindow->log( "(i) Started Scanning." );
sniffing = true;
emit( startedSniffing() );
}
+
+
+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
@@ -20,59 +20,62 @@
#ifdef QWS
#include <opie/odevice.h>
using namespace Opie;
#endif
class QTimerEvent;
class QPixmap;
class OPacket;
class OPacketCapturer;
class OWirelessNetworkInterface;
class ManufacturerDB;
class WellenreiterConfigWindow;
class MLogWindow;
class MHexWindow;
class Wellenreiter : public WellenreiterBase {
Q_OBJECT
public:
Wellenreiter( QWidget* parent = 0 );
~Wellenreiter();
void setConfigWindow( WellenreiterConfigWindow* cw );
MScanListView* netView() const { return netview; };
MLogWindow* logWindow() const { return logwindow; };
MHexWindow* hexWindow() const { return hexwindow; };
bool isDaemonRunning() const { return sniffing; };
bool sniffing;
+ protected:
+ virtual void timerEvent( QTimerEvent* );
+
public slots:
void channelHopped(int);
void receivePacket(OPacket*);
void startClicked();
void stopClicked();
signals:
void startedSniffing();
void stoppedSniffing();
private:
#ifdef QWS
OSystem _system; // Opie Operating System identifier
#endif
OWirelessNetworkInterface* iface;
OPacketCapturer* pcap;
ManufacturerDB* manufacturerdb;
WellenreiterConfigWindow* configwindow;
//void readConfig();
//void writeConfig();
};
#endif