Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/cardconfig.cpp | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/cardconfig.h | 58 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 48 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 10 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 30 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 228 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 31 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wlan.cpp | 57 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wlan.h | 38 |
11 files changed, 127 insertions, 420 deletions
diff --git a/noncore/net/wellenreiter/gui/cardconfig.cpp b/noncore/net/wellenreiter/gui/cardconfig.cpp deleted file mode 100644 index 1ca1d27..0000000 --- a/noncore/net/wellenreiter/gui/cardconfig.cpp +++ b/dev/null @@ -1,29 +0,0 @@ -/********************************************************************** -** 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. -** -**********************************************************************/ - -#include "cardconfig.h" - -#include <qstring.h> - -CardConfig::CardConfig( const QString& interface, Type type, int hopinterval ) - :_interface( interface ), _type( type ), _hopinterval( hopinterval ) -{ - -} - -CardConfig::~CardConfig() -{ -} - diff --git a/noncore/net/wellenreiter/gui/cardconfig.h b/noncore/net/wellenreiter/gui/cardconfig.h deleted file mode 100644 index f54ebac..0000000 --- a/noncore/net/wellenreiter/gui/cardconfig.h +++ b/dev/null @@ -1,58 +0,0 @@ -/********************************************************************** -** 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 CARDCONFIG_H -#define CARDCONFIG_H - -#include <qstring.h> - -#ifdef QWS -#include <opie/odevice.h> -using namespace Opie; -#endif - -class CardConfig -{ - public: - - typedef enum { Prism, Orinoco, HostAP, Manual } Type; - - public: - - CardConfig( const QString& interface, Type type = Manual, int hopinterval = 100 ); - virtual ~CardConfig(); - - const QString& interface() { return _interface; }; - int hopinterval() { return _hopinterval; }; - Type type() { return _type; }; - - #ifdef QWS - OSystem system() { return _system; }; - #endif - - private: - - QString _interface; - Type _type; - int _hopinterval; - - #ifdef QWS - OSystem _system; - #endif - -}; - -#endif - diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index 398118f..fa727f9 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -12,5 +12,5 @@ <x>0</x> <y>0</y> - <width>220</width> + <width>212</width> <height>267</height> </rect> @@ -104,46 +104,4 @@ <widget row="0" column="0" > <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string><select></string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>eth0</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>eth1</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wlan0</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wlan1</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wifi0</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wifi1</string> - </property> - </item> <property stdset="1"> <name>name</name> @@ -422,4 +380,8 @@ </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>text</name> <string>Beep on new network</string> diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index f86b109..6dd862f 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -14,5 +14,8 @@ **********************************************************************/ +/* LOCAL */ #include "configwindow.h" + +/* QT */ #include <qmap.h> #include <qcombobox.h> @@ -21,4 +24,7 @@ #include <qlayout.h> +/* OPIE */ +#include <opie2/onetwork.h> + WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) @@ -30,4 +36,14 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char _devicetype[ "<manual>" ] = 5; + // 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; + } + #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here QPushButton* okButton = new QPushButton( "ok", this ); diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 8861a50..200bfc1 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -12,6 +12,4 @@ HEADERS = wellenreiterbase.h \ hexwindow.h \ configwindow.h \ - wlan.h \ - cardconfig.h \ manufacturers.h @@ -24,11 +22,9 @@ SOURCES = main.cpp \ hexwindow.cpp \ configwindow.cpp \ - wlan.cpp \ - cardconfig.cpp \ manufacturers.cpp -INCLUDEPATH += $(OPIEDIR)/include ../ -DEPENDPATH += $(OPIEDIR)/include ../ -LIBS += -L. -lwellenreiter -lcornucopia +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -L. -lwellenreiter -lopiecore2 -lopieui2 -lopienet2 INTERFACES = configbase.ui TARGET = wellenreiter diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 270ce06..96a8c1c 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp @@ -15,29 +15,13 @@ #include "mainwindow.h" - -#ifdef QWS -#include <qpe/qpeapplication.h> -#else -#include <qapplication.h> -#endif +#include <opie2/oapplication.h> int main( int argc, char **argv ) { -#ifdef QWS - QPEApplication a( argc, argv ); -#else - QApplication a( argc, argv ); -#endif - - WellenreiterMainWindow w; - - w.setCaption( "Wellenreiter/Opie" ); -#ifdef QWS - a.showMainWidget(&w); -#else - a.setMainWidget(&w); - w.show(); -#endif - - return a.exec(); + OApplication a( argc, argv, "Wellenreiter II" ); + WellenreiterMainWindow* w = new WellenreiterMainWindow(); + a.showMainWidget( w ); + a.exec(); + delete w; + return 0; } diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 222217c..da9369f 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -17,5 +17,5 @@ #define SCANLIST_H -#include <cornucopia/olistview.h> +#include <opie2/olistview.h> #include <qtextstream.h> diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 09a44e6..5bdc1b3 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -22,11 +22,4 @@ #include <qsocketnotifier.h> -// Qtopia - -#ifdef QWS -#include <qpe/qpeapplication.h> -#include <qpe/global.h> -#endif - // Opie @@ -36,4 +29,8 @@ using namespace Opie; #endif +#include <opie2/oapplication.h> +#include <opie2/onetwork.h> +#include <opie2/opcap.h> + // Standard @@ -43,7 +40,5 @@ using namespace Opie; #include <string.h> #include <sys/types.h> -#include <sys/socket.h> #include <stdlib.h> -#include <fcntl.h> // Local @@ -57,12 +52,7 @@ using namespace Opie; #include "manufacturers.h" -#include <daemon/source/config.hh> -#include <libwellenreiter/source/wl_types.hh> -#include <libwellenreiter/source/wl_sock.hh> -#include <libwellenreiter/source/wl_proto.hh> - Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), - daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) + sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { @@ -92,23 +82,4 @@ Wellenreiter::Wellenreiter( QWidget* parent ) #endif - // - // setup socket for daemon communication, register socket notifier - // - - // struct sockaddr_in sockaddr; - daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); - if ( daemon_fd == -1 ) - { - logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); - } - else - { - int flags; - flags = fcntl( daemon_fd, F_GETFL, 0 ); - fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); - QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, this ); - connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); - } - // setup GUI netview->setColumnWidthMode( 1, QListView::Manual ); @@ -117,4 +88,6 @@ Wellenreiter::Wellenreiter( QWidget* parent ) netview->setManufacturerDB( manufacturerdb ); + pcap = new OPacketCapturer(); + } @@ -124,12 +97,5 @@ Wellenreiter::~Wellenreiter() delete manufacturerdb; - - if ( daemon_fd != -1 ) - { - qDebug( "closing comm socket" ); - ::shutdown( daemon_fd, 0 ); - ::close( daemon_fd ); - qDebug( "comm socket closed." ); - } + delete pcap; } @@ -139,119 +105,72 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) } -void Wellenreiter::handleMessage() +void Wellenreiter::receivePacket(OPacket* p) { - // FIXME: receive message and handle it - - qDebug( "received message from daemon." ); - - /*char buffer[10000]; - memset( &buffer, 0, sizeof( buffer ) );*/ - - char buffer[WL_SOCKBUF]; - - // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); - - /* - - struct sockaddr from; - socklen_t len; - - int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); - qDebug( "received %d from recv [%d bytes]", result, len ); - - */ - - int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); - - if ( result == -1 ) - { - qDebug( "Warning: %s", strerror( errno ) ); - return; - } - - int command = buffer[1] - 48; - -/* -typedef struct { - int net_type; 1 = Accesspoint ; 2 = Ad-Hoc - int ssid_len; Length of SSID - int channel; Channel - int wep; 1 = WEP enabled ; 0 = disabled - char mac[64]; MAC address of Accesspoint - char bssid[128]; BSSID of Accesspoint -} wl_network_t; -*/ - - qDebug( "Recv result: %d", ( result ) ); - qDebug( "Sniffer sent: '%s'", (const char*) buffer ); - hexwindow->log( (const char*) &buffer ); - - if ( command == NETFOUND ) /* new network found */ - { - qDebug( "Sniffer said: new network found." ); - wl_network_t n; - get_network_found( &n, (char*) &buffer ); - - qDebug( "Sniffer said: net_type is %d.", n.net_type ); - qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); - - //n.bssid[n.ssid_len] = "\0"; - - QString type; - - if ( n.net_type == 1 ) - type = "managed"; - else - type = "adhoc"; + logwindow->log( "(d) Received data from daemon" ); + //TODO - netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); + // check if we received a beacon frame + // static_cast is justified here + OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); + if ( !beacon ) return; + QString type; - } + //FIXME: Can stations in ESS mode can be distinguished from APs? + //FIXME: Apparently yes, but not by listening to beacons, because + //FIXME: they simply don't send beacons in infrastructure mode. + //FIXME: so we also have to listen to data packets + if ( beacon->canIBSS() ) + type = "adhoc"; else + type = "managed"; - { - qDebug( "unknown sniffer command." ); - } + OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); + QString essid = ssid ? ssid->ID() : "<unknown>"; + OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); + int channel = ds ? ds->channel() : -1; -} - -void Wellenreiter::dataReceived() -{ - logwindow->log( "(d) Received data from daemon" ); - handleMessage(); + OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); + netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); } void Wellenreiter::startStopClicked() { - if ( daemonRunning ) + if ( sniffing ) { - daemonRunning = false; + disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); - logwindow->log( "(i) Daemon has been stopped." ); - setCaption( tr( "Wellenreiter/Opie" ) ); + iface->setChannelHopping(); // stop hopping channels + pcap->close(); + sniffing = false; + oApp->setTitle(); - // Stop daemon - ugly for now... later better + // get interface name from config window + const QString& interface = configwindow->interfaceName->currentText(); + ONetwork* net = ONetwork::instance(); + iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); - system( "killall wellenreiterd" ); + // switch off monitor mode + iface->setMonitorMode( false ); + // switch off promisc flag + iface->setPromiscuousMode( false ); - // get configuration from config window + //TODO: Display "please wait..." (use owait?) - const QString& interface = configwindow->interfaceName->currentText(); - - // reset the interface trying to get it into a usable state again + /* QString cmdline; - cmdline.sprintf( "iwpriv %s monitor 0; ifdown %s; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); - system( cmdline ); + cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); + system( cmdline ); //FIXME: Use OProcess + + */ // message the user - QMessageBox::information( this, "Wellenreiter/Opie", "Your wireless card\nshould now be usable again." ); + //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); } else { - // get configuration from config window @@ -260,22 +179,49 @@ void Wellenreiter::startStopClicked() const int interval = configwindow->daemonHopInterval(); - if ( ( interface == "<select>" ) || ( cardtype == 0 ) ) + if ( ( interface == "" ) || ( cardtype == 0 ) ) { - QMessageBox::information( this, "Wellenreiter/Opie", "Your device is not\nptoperly configured. Please reconfigure!" ); + QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); return; } - // start wellenreiterd + // configure device - QString cmdline; - cmdline.sprintf( "wellenreiterd %s %d &", (const char*) interface, cardtype ); + 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: assert( 0 ); // shouldn't happen + } + + iface->setMonitorMode( true ); + + // open pcap and start sniffing + pcap->open( 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 - qDebug( "about to execute '%s' ...", (const char*) cmdline ); - system( cmdline ); - qDebug( "done!" ); + // connect + connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); logwindow->log( "(i) Daemon has been started." ); - daemonRunning = true; - setCaption( tr( "Scanning ..." ) ); + oApp->setTitle( "Scanning ..." ); + sniffing = true; } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index ee9dca9..3ec4021 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -24,21 +24,9 @@ using namespace Opie; #endif -// ugly... not here! - -#include <assert.h> -#include <errno.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <stdlib.h> -#include <fcntl.h> -#include <daemon/source/config.hh> -#include <libwellenreiter/source/wl_types.hh> -#include <libwellenreiter/source/wl_sock.hh> -#include <libwellenreiter/source/wl_proto.hh> - class QTimerEvent; class QPixmap; +class OPacket; +class OPacketCapturer; +class OWirelessNetworkInterface; class ManufacturerDB; class WellenreiterConfigWindow; @@ -54,23 +42,20 @@ class Wellenreiter : public WellenreiterBase { MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; - bool isDaemonRunning() const { return daemonRunning; }; - - protected: - bool daemonRunning; + bool isDaemonRunning() const { return sniffing; }; public slots: - void dataReceived(); + void receivePacket(OPacket*); void startStopClicked(); private: - int daemon_fd; // socket filedescriptor for udp communication socket #ifdef QWS OSystem _system; // Opie Operating System identifier #endif - void handleMessage(); + bool sniffing; + OWirelessNetworkInterface* iface; + OPacketCapturer* pcap; ManufacturerDB* manufacturerdb; WellenreiterConfigWindow* configwindow; - struct sockaddr_in sockaddr; //void readConfig(); diff --git a/noncore/net/wellenreiter/gui/wlan.cpp b/noncore/net/wellenreiter/gui/wlan.cpp deleted file mode 100644 index b046cc8..0000000 --- a/noncore/net/wellenreiter/gui/wlan.cpp +++ b/dev/null @@ -1,57 +0,0 @@ -/********************************************************************** -** 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. -** -**********************************************************************/ - -#include "wlan.h" -#include "cardconfig.h" - -// Qt -#include <qstring.h> - -// Qtopia -#ifdef QWS -#include <opie/odevice.h> -using namespace Opie; -#endif - -WLAN::WLAN( const QString& interface ) -{ - _configuration = new CardConfig( interface ); -} - -WLAN::WLAN( const CardConfig* configuration ) -{ - _configuration = configuration; - -} - -WLAN::~WLAN() -{ - delete _configuration; - -} - -void WLAN::setMonitorMode( bool enabled ) -{ - - /* - - if ( _configuration->system() == System_OpenZaurus && _configuration->type() == CardConfig::Prism ) - { - } - - */ - -} - diff --git a/noncore/net/wellenreiter/gui/wlan.h b/noncore/net/wellenreiter/gui/wlan.h deleted file mode 100644 index 139e218..0000000 --- a/noncore/net/wellenreiter/gui/wlan.h +++ b/dev/null @@ -1,38 +0,0 @@ -/********************************************************************** -** 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 WLAN_H -#define WLAN_H - -class QString; -class CardConfig; - -class WLAN -{ - public: - - WLAN( const QString& interface ); - WLAN( const CardConfig* ); - virtual ~WLAN(); - void setMonitorMode( bool enabled ); - - private: - - const CardConfig* _configuration; - -}; - -#endif - |