summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/protolistview.cpp12
-rw-r--r--noncore/net/wellenreiter/gui/protolistview.h2
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp75
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h3
4 files changed, 77 insertions, 15 deletions
diff --git a/noncore/net/wellenreiter/gui/protolistview.cpp b/noncore/net/wellenreiter/gui/protolistview.cpp
index 05ff5e7..d4b0dfe 100644
--- a/noncore/net/wellenreiter/gui/protolistview.cpp
+++ b/noncore/net/wellenreiter/gui/protolistview.cpp
@@ -90,22 +90,28 @@ void ProtocolListView::addProtocol( const QString& name )
90 combo->insertItem( "KeySound" ); 90 combo->insertItem( "KeySound" );
91 combo->insertItem( "LedOn" ); 91 combo->insertItem( "LedOn" );
92 combo->insertItem( "LedOff" ); 92 combo->insertItem( "LedOff" );
93 combo->insertItem( "LogMessage" ); 93 combo->insertItem( "LogMessage" );
94 combo->insertItem( "MessageBox" ); 94 combo->insertItem( "MessageBox" );
95 } 95 }
96} 96}
97 97
98 98
99bool ProtocolListView::isProtocolChecked( const QString& name ) 99bool ProtocolListView::isProtocolChecked( const QString& name )
100{ 100{
101 QCheckBox* box = (QCheckBox*) child( (const char*) name ); 101 QCheckBox* box = (QCheckBox*) child( (const char*) name );
102 return ( box && box->isOn() ); 102 return ( box && box->isOn() );
103} 103}
104 104
105 105
106QString ProtocolListView::protocolAction( const QString& name ) const 106QString ProtocolListView::protocolAction( const QString& name )
107{ 107{
108 //FIXME 108 //QObject * child ( const char * objName, const char * inheritsClass = 0,
109 // bool recursiveSearch = TRUE )
110
111 QComboBox* combo = (QComboBox*) child( (const char*) name, "QComboBox" );
112 if ( combo )
113 return combo->currentText();
114 else
115 return "<unknown>";
109} 116}
110 117
111
diff --git a/noncore/net/wellenreiter/gui/protolistview.h b/noncore/net/wellenreiter/gui/protolistview.h
index 723e8cd..166b648 100644
--- a/noncore/net/wellenreiter/gui/protolistview.h
+++ b/noncore/net/wellenreiter/gui/protolistview.h
@@ -19,29 +19,29 @@
19#include <qscrollview.h> 19#include <qscrollview.h>
20#include <qdict.h> 20#include <qdict.h>
21//#include <qcheckbox.h> 21//#include <qcheckbox.h>
22//#include <qcombobox.h> 22//#include <qcombobox.h>
23class QCheckBox; 23class QCheckBox;
24class QComboBox; 24class QComboBox;
25 25
26class QVBox; 26class QVBox;
27 27
28class ProtocolListView : public QScrollView 28class ProtocolListView : public QScrollView
29{ 29{
30 public: 30 public:
31 ProtocolListView( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); 31 ProtocolListView( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
32 virtual ~ProtocolListView(); 32 virtual ~ProtocolListView();
33 33
34 bool isProtocolChecked( const QString& name ); 34 bool isProtocolChecked( const QString& name );
35 QString protocolAction( const QString& name ) const; 35 QString protocolAction( const QString& name );
36 36
37 protected: 37 protected:
38 virtual void addProtocol( const QString& name ); 38 virtual void addProtocol( const QString& name );
39 39
40 private: 40 private:
41 QVBox* vbox; 41 QVBox* vbox;
42 bool actions; 42 bool actions;
43}; 43};
44 44
45 45
46 46
47#endif // PROTOLISTVIEW_H 47#endif // PROTOLISTVIEW_H
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 2f3d093..edf7dcf 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,79 +1,81 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Local
17
18#include "wellenreiter.h"
19#include "scanlist.h"
20#include "logwindow.h"
21#include "hexwindow.h"
22#include "configwindow.h"
23#include "statwindow.h"
24#include "graphwindow.h"
25#include "manufacturers.h"
26#include "protolistview.h"
27
16// Opie 28// Opie
17 29
18#ifdef QWS 30#ifdef QWS
19#include <opie/odevice.h> 31#include <opie/odevice.h>
20using namespace Opie; 32using namespace Opie;
21#endif 33#endif
22 34
23#ifdef QWS 35#ifdef QWS
24#include <opie2/oapplication.h> 36#include <opie2/oapplication.h>
25#else 37#else
26#include <qapplication.h> 38#include <qapplication.h>
27#endif 39#endif
28#include <opie2/onetwork.h> 40#include <opie2/onetwork.h>
29#include <opie2/opcap.h> 41#include <opie2/opcap.h>
30 42
31// Qt 43// Qt
32 44
33#include <qcheckbox.h> 45#include <qcheckbox.h>
34#include <qcombobox.h> 46#include <qcombobox.h>
35#include <qdatetime.h> 47#include <qdatetime.h>
36#include <qpushbutton.h> 48#include <qpushbutton.h>
37#include <qlineedit.h> 49#include <qlineedit.h>
38#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qobjectlist.h>
39#include <qregexp.h> 52#include <qregexp.h>
40#include <qspinbox.h> 53#include <qspinbox.h>
41#include <qtoolbutton.h> 54#include <qtoolbutton.h>
42#include <qmainwindow.h> 55#include <qmainwindow.h>
43 56
44// Standard 57// Standard
45 58
46#include <assert.h> 59#include <assert.h>
47#include <errno.h> 60#include <errno.h>
48#include <unistd.h> 61#include <unistd.h>
49#include <string.h> 62#include <string.h>
50#include <sys/types.h> 63#include <sys/types.h>
51#include <stdlib.h> 64#include <stdlib.h>
52 65
53// Local
54
55#include "wellenreiter.h"
56#include "scanlist.h"
57#include "logwindow.h"
58#include "hexwindow.h"
59#include "configwindow.h"
60#include "statwindow.h"
61#include "graphwindow.h"
62#include "manufacturers.h"
63
64Wellenreiter::Wellenreiter( QWidget* parent ) 66Wellenreiter::Wellenreiter( QWidget* parent )
65 : WellenreiterBase( parent, 0, 0 ), 67 : WellenreiterBase( parent, 0, 0 ),
66 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) 68 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 )
67{ 69{
68 70
69 // 71 //
70 // construct manufacturer database 72 // construct manufacturer database
71 // 73 //
72 74
73 QString manufile; 75 QString manufile;
74 #ifdef QWS 76 #ifdef QWS
75 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); 77 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
76 #else 78 #else
77 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); 79 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" );
78 #endif 80 #endif
79 manufacturerdb = new ManufacturerDB( manufile ); 81 manufacturerdb = new ManufacturerDB( manufile );
@@ -124,32 +126,56 @@ void Wellenreiter::channelHopped(int c)
124 if ( c > 1 ) left.fill( '.', c-1 ); 126 if ( c > 1 ) left.fill( '.', c-1 );
125 title.append( left ); 127 title.append( left );
126 title.append( '|' ); 128 title.append( '|' );
127 if ( c < iface->channels() ) 129 if ( c < iface->channels() )
128 { 130 {
129 QString right; 131 QString right;
130 right.fill( '.', iface->channels()-c ); 132 right.fill( '.', iface->channels()-c );
131 title.append( right ); 133 title.append( right );
132 } 134 }
133 title.append( "]" ); 135 title.append( "]" );
134 //title.append( QString().sprintf( " %02d", c ) ); 136 //title.append( QString().sprintf( " %02d", c ) );
135 assert( parent() ); 137 assert( parent() );
136 ( (QMainWindow*) parent() )->setCaption( title ); 138 ( (QMainWindow*) parent() )->setCaption( title );
137} 139}
138 140
139 141
142void Wellenreiter::handleNotification( OPacket* p )
143{
144 QObjectList* l = p->queryList();
145 QObjectListIt it( *l );
146 QObject* o;
147
148 while ( (o = it.current()) != 0 )
149 {
150 QString name = it.current()->name();
151 if ( configwindow->parsePackets->isProtocolChecked( name ) )
152 {
153 QString action = configwindow->parsePackets->protocolAction( name );
154 qDebug( "action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
155 doAction( action, name, p );
156 }
157 else
158 {
159 qDebug( "protocol '%s' not checked.", (const char*) name );
160 }
161 ++it;
162 }
163}
164
165
140void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 166void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
141{ 167{
142 QString type; 168 QString type;
143 if ( beacon->canIBSS() ) 169 if ( beacon->canIBSS() )
144 { 170 {
145 type = "adhoc"; 171 type = "adhoc";
146 } 172 }
147 else if ( beacon->canESS() ) 173 else if ( beacon->canESS() )
148 { 174 {
149 type = "managed"; 175 type = "managed";
150 } 176 }
151 else 177 else
152 { 178 {
153 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 179 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
154 return; 180 return;
155 } 181 }
@@ -232,36 +258,44 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
232 } 258 }
233 else if ( arp->type() == "REPLY" ) 259 else if ( arp->type() == "REPLY" )
234 { 260 {
235 netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() ); 261 netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() );
236 netView()->identify( arp->targetMacAddress().toString(), arp->targetIPV4Address().toString() ); 262 netView()->identify( arp->targetMacAddress().toString(), arp->targetIPV4Address().toString() );
237 } 263 }
238 } 264 }
239 265
240 OIPPacket* ip = (OIPPacket*) p->child( "IP" ); 266 OIPPacket* ip = (OIPPacket*) p->child( "IP" );
241 if ( ip ) 267 if ( ip )
242 { 268 {
243 qDebug( "Received IP packet." ); 269 qDebug( "Received IP packet." );
244 } 270 }
245} 271}
246 272
247 273
274QObject* childIfToParse( OPacket* p, const QString& protocol )
275{
276 //FIXME: Implement
277}
278
279
248void Wellenreiter::receivePacket( OPacket* p ) 280void Wellenreiter::receivePacket( OPacket* p )
249{ 281{
250 hexWindow()->log( p->dump( 8 ) ); 282 hexWindow()->log( p->dump( 8 ) );
251 283
284 handleNotification( p );
285
252 // check if we received a beacon frame 286 // check if we received a beacon frame
253 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 287 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
254 if ( beacon && beacon->managementType() == "Beacon" ) 288 if ( beacon && beacon->managementType() == "Beacon" )
255 { 289 {
256 handleBeacon( p, beacon ); 290 handleBeacon( p, beacon );
257 return; 291 return;
258 } 292 }
259 293
260 //TODO: WEP check here 294 //TODO: WEP check here
261 295
262 // check for a data frame 296 // check for a data frame
263 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); 297 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) );
264 if ( data ) 298 if ( data )
265 { 299 {
266 handleData( p, data ); 300 handleData( p, data );
267 } 301 }
@@ -418,16 +452,35 @@ void Wellenreiter::startClicked()
418 452
419void Wellenreiter::timerEvent( QTimerEvent* ) 453void Wellenreiter::timerEvent( QTimerEvent* )
420{ 454{
421 qDebug( "Wellenreiter::timerEvent()" ); 455 qDebug( "Wellenreiter::timerEvent()" );
422 OPacket* p = pcap->next(); 456 OPacket* p = pcap->next();
423 if ( !p ) // no more packets available 457 if ( !p ) // no more packets available
424 { 458 {
425 stopClicked(); 459 stopClicked();
426 } 460 }
427 else 461 else
428 { 462 {
429 receivePacket( p ); 463 receivePacket( p );
430 delete p; 464 delete p;
431 } 465 }
432} 466}
433 467
468
469void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
470{
471 if ( action == "TouchSound" )
472 ODevice::inst()->touchSound();
473 else if ( action == "AlarmSound" )
474 ODevice::inst()->alarmSound();
475 else if ( action == "KeySound" )
476 ODevice::inst()->keySound();
477 else if ( action == "LedOn" )
478 ODevice::inst()->setLedState( Led_Mail, Led_On );
479 else if ( action == "LedOff" )
480 ODevice::inst()->setLedState( Led_Mail, Led_Off );
481 else if ( action == "LogMessage" )
482 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
483 else if ( action == "MessageBox" )
484 QMessageBox::information ( this, "Notification!",
485 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
486}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index ea8a692..e227a24 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -53,32 +53,35 @@ class Wellenreiter : public WellenreiterBase {
53 protected: 53 protected:
54 virtual void timerEvent( QTimerEvent* ); 54 virtual void timerEvent( QTimerEvent* );
55 55
56 public slots: 56 public slots:
57 void channelHopped(int); 57 void channelHopped(int);
58 void receivePacket(OPacket*); 58 void receivePacket(OPacket*);
59 void startClicked(); 59 void startClicked();
60 void stopClicked(); 60 void stopClicked();
61 61
62 signals: 62 signals:
63 void startedSniffing(); 63 void startedSniffing();
64 void stoppedSniffing(); 64 void stoppedSniffing();
65 65
66 private: 66 private:
67 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 67 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
68 void handleData( OPacket* p, OWaveLanDataPacket* data ); 68 void handleData( OPacket* p, OWaveLanDataPacket* data );
69 void handleNotification( OPacket* p );
70 void doAction( const QString& action, const QString& protocol, OPacket* p );
71 QObject* childIfToParse( OPacket* p, const QString& protocol );
69 72
70 private: 73 private:
71 #ifdef QWS 74 #ifdef QWS
72 OSystem _system; // Opie Operating System identifier 75 OSystem _system; // Opie Operating System identifier
73 #endif 76 #endif
74 77
75 OWirelessNetworkInterface* iface; 78 OWirelessNetworkInterface* iface;
76 OPacketCapturer* pcap; 79 OPacketCapturer* pcap;
77 ManufacturerDB* manufacturerdb; 80 ManufacturerDB* manufacturerdb;
78 WellenreiterConfigWindow* configwindow; 81 WellenreiterConfigWindow* configwindow;
79 82
80 //void readConfig(); 83 //void readConfig();
81 //void writeConfig(); 84 //void writeConfig();
82}; 85};
83 86
84 87