summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp74
1 files changed, 33 insertions, 41 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index fff7c35..fad6efd 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -8,40 +8,39 @@
**
** 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 "gps.h"
#include "wellenreiter.h"
#include "scanlist.h"
#include "logwindow.h"
#include "packetview.h"
#include "configwindow.h"
#include "statwindow.h"
#include "graphwindow.h"
#include "protolistview.h"
-// Opie
-
+/* OPIE */
#ifdef QWS
#include <opie2/oapplication.h>
+#include <opie2/odebug.h>
#include <opie2/odevice.h>
#else
#include <qapplication.h>
#endif
#include <opie2/omanufacturerdb.h>
#include <opie2/onetwork.h>
#include <opie2/opcap.h>
#include <qpe/qcopenvelope_qws.h>
-using namespace Opie;
-
-// Qt
+using namespace Opie::Core;
+using namespace Opie::Net;
+using namespace Opie::Ui;
+/* QT */
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdatetime.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qmessagebox.h>
@@ -49,27 +48,20 @@ using namespace Opie;
#include <qregexp.h>
#include <qspinbox.h>
#include <qtimer.h>
#include <qtoolbutton.h>
#include <qmainwindow.h>
-// Standard
-
+/* STD */
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <stdlib.h>
-using namespace Opie::Core;
-using namespace Opie::Net;
-using namespace Opie::Net;
-using namespace Opie::Core;
-using namespace Opie::Net;
-using namespace Opie::Core;
Wellenreiter::Wellenreiter( QWidget* parent )
: WellenreiterBase( parent, 0, 0 ),
sniffing( false ), iface( 0 ), configwindow( 0 )
{
logwindow->log( "(i) Wellenreiter has been started." );
@@ -103,13 +95,13 @@ Wellenreiter::~Wellenreiter()
delete pcap;
}
void Wellenreiter::initialTimer()
{
- qDebug( "Wellenreiter::preloading manufacturer database..." );
+ odebug << "Wellenreiter::preloading manufacturer database..." << oendl;
OManufacturerDB::instance();
}
void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
{
@@ -146,30 +138,30 @@ void Wellenreiter::handleNotification( OPacket* p )
while ( (o = it.current()) != 0 )
{
QString name = it.current()->name();
if ( configwindow->parsePackets->isProtocolChecked( name ) )
{
QString action = configwindow->parsePackets->protocolAction( name );
- qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
+ odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl;
doAction( action, name, p );
}
else
{
- qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
+ odebug << "protocol '" << (const char*) name << "' not checked in parsePackets." << oendl;
}
++it;
}
}
void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
{
if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
- else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() );
+ else owarn << "Wellenreiter::handleManagementFrame(): '" << (const char*) manage->managementType() << "' - please handle me!" << oendl;
}
void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request )
{
OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
@@ -179,20 +171,20 @@ void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManage
OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
GpsLocation loc( -111, -111 );
if ( configwindow->enableGPS->isChecked() )
{
// TODO: add check if GPS is working!?
- qDebug( "Wellenreiter::gathering GPS data..." );
+ odebug << "Wellenreiter::gathering GPS data..." << oendl;
loc = gps->position();
- qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
+ odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
}
if ( essid.length() )
netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
- qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" );
+ odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
}
void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response )
{
}
@@ -208,13 +200,13 @@ void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPa
else if ( beacon->canESS() )
{
type = "managed";
}
else
{
- qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
+ owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
return;
}
OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
@@ -223,15 +215,15 @@ void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPa
OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
GpsLocation loc( -111, -111 );
if ( configwindow->enableGPS->isChecked() )
{
// TODO: add check if GPS is working!?
- qDebug( "Wellenreiter::gathering GPS data..." );
+ odebug << "Wellenreiter::gathering GPS data..." << oendl;
loc = gps->position();
- qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
+ odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
}
netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
// update graph window
if ( ds )
@@ -252,13 +244,13 @@ void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* contro
if ( control->controlType() == "Acknowledge" )
{
netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
}
else
{
- qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() );
+ odebug << "Wellenreiter::handleControlFrame - please handle " << (const char*) control->controlType() << " in a future version! :D" << oendl;
}
}
void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
{
@@ -301,13 +293,13 @@ void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAd
void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
{
OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
if ( arp )
{
- qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
+ odebug << "Received ARP traffic (type '" << (const char*) arp->type() << "'): " << oendl;
if ( arp->type() == "REQUEST" )
{
netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
}
else if ( arp->type() == "REPLY" )
{
@@ -322,22 +314,22 @@ void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source,
{
//TODO: Implement more IP based protocols
ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
if ( dhcp )
{
- qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
+ odebug << "Received DHCP '" << (const char*) dhcp->type() << "' packet" << oendl;
if ( dhcp->type() == "OFFER" )
{
- qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
+ odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << (const char*) dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl;
netView()->identify( source, dhcp->serverAddress().toString() );
netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
}
else if ( dhcp->type() == "ACK" )
{
- qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
+ odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << (const char*) dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl;
netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
}
}
}
@@ -365,22 +357,22 @@ bool Wellenreiter::checkDumpPacket( OPacket* p )
while ( (o = it.current()) != 0 )
{
QString name = it.current()->name();
if ( configwindow->capturePackets->isProtocolChecked( name ) )
{
QString action = configwindow->capturePackets->protocolAction( name );
- qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
+ odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << (const char*) action << "'" << oendl;
if ( action == "Discard" )
{
logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
return false;
}
}
else
{
- qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
+ odebug << "protocol '" << (const char*) name << "' not checked in capturePackets." << oendl;
}
++it;
}
return true;
}
@@ -548,13 +540,13 @@ void Wellenreiter::startClicked()
{
case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
- case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
+ case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << (const char*) interface << "'" << oendl; break;
default: assert( 0 ); // shouldn't reach this
}
// switch device into monitor mode
if ( cardtype < DEVTYPE_FILE )
{
@@ -569,13 +561,13 @@ void Wellenreiter::startClicked()
}
}
// open GPS device
if ( configwindow->enableGPS->isChecked() )
{
- qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
+ odebug << "Wellenreiter:GPS enabled @ " << (const char*) configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl;
gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
}
// open pcap and start sniffing
if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
@@ -593,13 +585,13 @@ void Wellenreiter::startClicked()
if ( cardtype != DEVTYPE_FILE )
pcap->open( interface );
else
pcap->open( QFile( interface ) );
- qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
+ odebug << "Wellenreiter:: dumping to " << (const char*) dumpname << "" << oendl;
pcap->openDumpFile( dumpname );
if ( !pcap->isOpen() )
{
QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
@@ -649,13 +641,13 @@ void Wellenreiter::startClicked()
}
}
void Wellenreiter::timerEvent( QTimerEvent* )
{
- qDebug( "Wellenreiter::timerEvent()" );
+ odebug << "Wellenreiter::timerEvent()" << oendl;
OPacket* p = pcap->next();
if ( !p ) // no more packets available
{
stopClicked();
}
else
@@ -712,21 +704,21 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch
(const char*) essid,
channel,
(const char*) macaddr );
QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
int count = 3;
- qDebug("sending %d messages",count);
+ odebug << "sending " << count << " messages" << oendl;
msg << QString("count") << QString::number(count);
- qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
+ odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl;
msg << QString(iface->name()) << QString("Mode") << type;
- qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
+ odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl;
msg << QString(iface->name()) << QString("ESSID") << essid;
- qDebug("msg >%s< channel >%d<", iface->name(),channel);
+ odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl;
msg << QString(iface->name()) << QString("Channel") << channel;
-// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
+// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl;
// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
#else
QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
#endif
}