From d11a0154e2d9732854c9a3d598857bc20f359849 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 30 Mar 2003 01:51:14 +0000 Subject: - the network work for libopie2 pays off... - good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain - good bye to libwellenreiter --- (limited to 'noncore/net/wellenreiter/gui') 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 - -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 - -#ifdef QWS -#include -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 @@ -11,7 +11,7 @@ 0 0 - 220 + 212 267 @@ -103,48 +103,6 @@ QComboBox - - - text - <select> - - - - - text - eth0 - - - - - text - eth1 - - - - - text - wlan0 - - - - - text - wlan1 - - - - - text - wifi0 - - - - - text - wifi1 - - name interfaceName @@ -421,6 +379,10 @@ beepOnFound + enabled + false + + text Beep on new network 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 @@ -13,13 +13,19 @@ ** **********************************************************************/ +/* LOCAL */ #include "configwindow.h" + +/* QT */ #include #include #include #include #include +/* OPIE */ +#include + WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { @@ -29,6 +35,16 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char _devicetype[ "orinoco" ] = 4; _devicetype[ "" ] = 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 ); okButton->show(); 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 @@ -11,8 +11,6 @@ HEADERS = wellenreiterbase.h \ logwindow.h \ hexwindow.h \ configwindow.h \ - wlan.h \ - cardconfig.h \ manufacturers.h SOURCES = main.cpp \ @@ -23,13 +21,11 @@ SOURCES = main.cpp \ logwindow.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 @@ -14,30 +14,14 @@ **********************************************************************/ #include "mainwindow.h" - -#ifdef QWS -#include -#else -#include -#endif +#include 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 @@ -16,7 +16,7 @@ #ifndef SCANLIST_H #define SCANLIST_H -#include +#include #include 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 @@ -21,13 +21,6 @@ #include #include -// Qtopia - -#ifdef QWS -#include -#include -#endif - // Opie #ifdef QWS @@ -35,6 +28,10 @@ using namespace Opie; #endif +#include +#include +#include + // Standard #include @@ -42,9 +39,7 @@ using namespace Opie; #include #include #include -#include #include -#include // Local @@ -56,14 +51,9 @@ using namespace Opie; #include "manufacturers.h" -#include -#include -#include -#include - Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), - daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) + sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // @@ -91,31 +81,14 @@ Wellenreiter::Wellenreiter( QWidget* parent ) logwindow->log( sys ); #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 ); if ( manufacturerdb ) netview->setManufacturerDB( manufacturerdb ); + pcap = new OPacketCapturer(); + } Wellenreiter::~Wellenreiter() @@ -123,14 +96,7 @@ Wellenreiter::~Wellenreiter() // no need to delete child widgets, Qt does it all for us delete manufacturerdb; - - if ( daemon_fd != -1 ) - { - qDebug( "closing comm socket" ); - ::shutdown( daemon_fd, 0 ); - ::close( daemon_fd ); - qDebug( "comm socket closed." ); - } + delete pcap; } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) @@ -138,145 +104,125 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) configwindow = 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( 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( p->child( "802.11 SSID" ) ); + QString essid = ssid ? ssid->ID() : ""; + OWaveLanManagementDS* ds = static_cast( 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( 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(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 const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->daemonDeviceType(); const int interval = configwindow->daemonHopInterval(); - if ( ( interface == "