summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-09 10:37:19 (UTC)
committer mickeyl <mickeyl>2003-04-09 10:37:19 (UTC)
commit73f4014f0175c77b9bff8dd06f1c034eb80442f9 (patch) (unidiff)
treee402a7229190e3af5a090b7fdeadf43b78164061
parent5cb59a3e8abdbb05fe4bbc9e549f264153168232 (diff)
downloadopie-73f4014f0175c77b9bff8dd06f1c034eb80442f9.zip
opie-73f4014f0175c77b9bff8dd06f1c034eb80442f9.tar.gz
opie-73f4014f0175c77b9bff8dd06f1c034eb80442f9.tar.bz2
display a fancy ascii-animation in the titlebar while scanning...
... no really, it's actually pretty useful, because you can see which channel we are currently monitoring :-D
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp37
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h1
2 files changed, 30 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 8c2c315..0bfc8e9 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -13,49 +13,49 @@
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Opie 16// Opie
17 17
18#ifdef QWS 18#ifdef QWS
19#include <opie/odevice.h> 19#include <opie/odevice.h>
20using namespace Opie; 20using namespace Opie;
21#endif 21#endif
22 22
23#ifdef QWS 23#ifdef QWS
24#include <opie2/oapplication.h> 24#include <opie2/oapplication.h>
25#else 25#else
26#include <qapplication.h> 26#include <qapplication.h>
27#endif 27#endif
28#include <opie2/onetwork.h> 28#include <opie2/onetwork.h>
29#include <opie2/opcap.h> 29#include <opie2/opcap.h>
30 30
31// Qt 31// Qt
32 32
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qmessagebox.h> 34#include <qmessagebox.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37#include <qsocketnotifier.h> 37#include <qmainwindow.h>
38 38
39// Standard 39// Standard
40 40
41#include <assert.h> 41#include <assert.h>
42#include <errno.h> 42#include <errno.h>
43#include <unistd.h> 43#include <unistd.h>
44#include <string.h> 44#include <string.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <stdlib.h> 46#include <stdlib.h>
47 47
48// Local 48// Local
49 49
50#include "wellenreiter.h" 50#include "wellenreiter.h"
51#include "scanlist.h" 51#include "scanlist.h"
52#include "logwindow.h" 52#include "logwindow.h"
53#include "hexwindow.h" 53#include "hexwindow.h"
54#include "configwindow.h" 54#include "configwindow.h"
55 55
56#include "manufacturers.h" 56#include "manufacturers.h"
57 57
58Wellenreiter::Wellenreiter( QWidget* parent ) 58Wellenreiter::Wellenreiter( QWidget* parent )
59 : WellenreiterBase( parent, 0, 0 ), 59 : WellenreiterBase( parent, 0, 0 ),
60 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) 60 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 )
61{ 61{
@@ -74,61 +74,84 @@ Wellenreiter::Wellenreiter( QWidget* parent )
74 74
75 logwindow->log( "(i) Wellenreiter has been started." ); 75 logwindow->log( "(i) Wellenreiter has been started." );
76 76
77 // 77 //
78 // detect operating system 78 // detect operating system
79 // 79 //
80 80
81 #ifdef QWS 81 #ifdef QWS
82 QString sys; 82 QString sys;
83 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 83 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
84 _system = ODevice::inst()->system(); 84 _system = ODevice::inst()->system();
85 logwindow->log( sys ); 85 logwindow->log( sys );
86 #endif 86 #endif
87 87
88 // setup GUI 88 // setup GUI
89 netview->setColumnWidthMode( 1, QListView::Manual ); 89 netview->setColumnWidthMode( 1, QListView::Manual );
90 90
91 if ( manufacturerdb ) 91 if ( manufacturerdb )
92 netview->setManufacturerDB( manufacturerdb ); 92 netview->setManufacturerDB( manufacturerdb );
93 93
94 pcap = new OPacketCapturer(); 94 pcap = new OPacketCapturer();
95 95
96} 96}
97 97
98
98Wellenreiter::~Wellenreiter() 99Wellenreiter::~Wellenreiter()
99{ 100{
100 // no need to delete child widgets, Qt does it all for us 101 // no need to delete child widgets, Qt does it all for us
101 102
102 delete manufacturerdb; 103 delete manufacturerdb;
103 delete pcap; 104 delete pcap;
104} 105}
105 106
107
106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 108void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
107{ 109{
108 configwindow = cw; 110 configwindow = cw;
109} 111}
110 112
113
114void Wellenreiter::channelHopped(int c)
115{
116 QString title = "Wellenreiter II -scan- [";
117 QString left;
118 if ( c > 1 ) left.fill( '.', c-1 );
119 title.append( left );
120 title.append( '|' );
121 if ( c < iface->channels() )
122 {
123 QString right;
124 right.fill( '.', iface->channels()-c );
125 title.append( right );
126 }
127 title.append( "]" );
128 //title.append( QString().sprintf( " %02d", c ) );
129 assert( parent() );
130 ( (QMainWindow*) parent() )->setCaption( title );
131}
132
133
111void Wellenreiter::receivePacket(OPacket* p) 134void Wellenreiter::receivePacket(OPacket* p)
112{ 135{
113 hexWindow()->log( p->dump( 8 ) ); 136 hexWindow()->log( p->dump( 8 ) );
114 137
115 // check if we received a beacon frame 138 // check if we received a beacon frame
116 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 139 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
117 if ( beacon && beacon->managementType() == "Beacon" ) 140 if ( beacon && beacon->managementType() == "Beacon" )
118 { 141 {
119 QString type; 142 QString type;
120 if ( beacon->canIBSS() ) 143 if ( beacon->canIBSS() )
121 { 144 {
122 type = "adhoc"; 145 type = "adhoc";
123 } 146 }
124 else if ( beacon->canESS() ) 147 else if ( beacon->canESS() )
125 { 148 {
126 type = "managed"; 149 type = "managed";
127 } 150 }
128 else 151 else
129 { 152 {
130 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); 153 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) );
131 return; 154 return;
132 } 155 }
133 156
134 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 157 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
@@ -165,83 +188,85 @@ void Wellenreiter::receivePacket(OPacket* p)
165 (const char*) wlan->macAddress1().toString(true) ); 188 (const char*) wlan->macAddress1().toString(true) );
166 netView()->traffic( "toDS", wlan->macAddress2().toString(), 189 netView()->traffic( "toDS", wlan->macAddress2().toString(),
167 wlan->macAddress3().toString(), 190 wlan->macAddress3().toString(),
168 wlan->macAddress1().toString() ); 191 wlan->macAddress1().toString() );
169 } 192 }
170 else 193 else
171 if ( wlan->fromDS() && wlan->toDS() ) 194 if ( wlan->fromDS() && wlan->toDS() )
172 { 195 {
173 qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", 196 qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
174 (const char*) wlan->macAddress4().toString(true), 197 (const char*) wlan->macAddress4().toString(true),
175 (const char*) wlan->macAddress3().toString(true), 198 (const char*) wlan->macAddress3().toString(true),
176 (const char*) wlan->macAddress1().toString(true), 199 (const char*) wlan->macAddress1().toString(true),
177 (const char*) wlan->macAddress2().toString(true) ); 200 (const char*) wlan->macAddress2().toString(true) );
178 netView()->traffic( "WSD", wlan->macAddress4().toString(), 201 netView()->traffic( "WSD", wlan->macAddress4().toString(),
179 wlan->macAddress3().toString(), 202 wlan->macAddress3().toString(),
180 wlan->macAddress1().toString(), 203 wlan->macAddress1().toString(),
181 wlan->macAddress2().toString() ); 204 wlan->macAddress2().toString() );
182 } 205 }
183 else 206 else
184 { 207 {
185 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", 208 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
186 (const char*) wlan->macAddress2().toString(true), 209 (const char*) wlan->macAddress2().toString(true),
187 (const char*) wlan->macAddress1().toString(true), 210 (const char*) wlan->macAddress1().toString(true),
188 (const char*) wlan->macAddress3().toString(true) ); 211 (const char*) wlan->macAddress3().toString(true) );
189 netView()->traffic( "fromDS", wlan->macAddress2().toString(), 212 netView()->traffic( "IBSS", wlan->macAddress2().toString(),
190 wlan->macAddress1().toString(), 213 wlan->macAddress1().toString(),
191 wlan->macAddress3().toString() ); 214 wlan->macAddress3().toString() );
192 } 215 }
193 return; 216 return;
194 } 217 }
195} 218}
196 219
197void Wellenreiter::startStopClicked() 220void Wellenreiter::startStopClicked()
198{ 221{
199 if ( sniffing ) 222 if ( sniffing )
200 { 223 {
201 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 224 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
202 225 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
203 iface->setChannelHopping(); // stop hopping channels 226 iface->setChannelHopping(); // stop hopping channels
204 pcap->close(); 227 pcap->close();
205 sniffing = false; 228 sniffing = false;
206 #ifdef QWS 229 #ifdef QWS
207 oApp->setTitle(); 230 oApp->setTitle();
208 #else 231 #else
209 qApp->mainWidget()->setCaption( "Wellenreiter II" ); 232 qApp->mainWidget()->setCaption( "Wellenreiter II" );
210 #endif 233 #endif
211 234
212 // get interface name from config window 235 // get interface name from config window
213 const QString& interface = configwindow->interfaceName->currentText(); 236 const QString& interface = configwindow->interfaceName->currentText();
214 ONetwork* net = ONetwork::instance(); 237 ONetwork* net = ONetwork::instance();
215 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 238 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
216 239
217 // switch off monitor mode 240 // switch off monitor mode
218 iface->setMonitorMode( false ); 241 iface->setMonitorMode( false );
219 // switch off promisc flag 242 // switch off promisc flag
220 iface->setPromiscuousMode( false ); 243 iface->setPromiscuousMode( false );
221 244
222 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 245 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
223 logwindow->log( "(i) Stopped Scanning." ); 246 logwindow->log( "(i) Stopped Scanning." );
247 assert( parent() );
248 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
224 249
225 // message the user 250 // message the user
226 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); 251 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
227 } 252 }
228 253
229 else 254 else
230 { 255 {
231 // get configuration from config window 256 // get configuration from config window
232 257
233 const QString& interface = configwindow->interfaceName->currentText(); 258 const QString& interface = configwindow->interfaceName->currentText();
234 const int cardtype = configwindow->daemonDeviceType(); 259 const int cardtype = configwindow->daemonDeviceType();
235 const int interval = configwindow->daemonHopInterval(); 260 const int interval = configwindow->daemonHopInterval();
236 261
237 if ( ( interface == "" ) || ( cardtype == 0 ) ) 262 if ( ( interface == "" ) || ( cardtype == 0 ) )
238 { 263 {
239 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); 264 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
240 return; 265 return;
241 } 266 }
242 267
243 // configure device 268 // configure device
244 269
245 ONetwork* net = ONetwork::instance(); 270 ONetwork* net = ONetwork::instance();
246 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 271 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
247 272
@@ -260,35 +285,31 @@ void Wellenreiter::startStopClicked()
260 285
261 if ( !iface->monitorMode() ) 286 if ( !iface->monitorMode() )
262 { 287 {
263 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); 288 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
264 return; 289 return;
265 } 290 }
266 291
267 // open pcap and start sniffing 292 // open pcap and start sniffing
268 pcap->open( interface ); 293 pcap->open( interface );
269 294
270 if ( !pcap->isOpen() ) 295 if ( !pcap->isOpen() )
271 { 296 {
272 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); 297 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
273 return; 298 return;
274 } 299 }
275 300
276 // set capturer to non-blocking mode 301 // set capturer to non-blocking mode
277 pcap->setBlocking( false ); 302 pcap->setBlocking( false );
278 303
279 // start channel hopper 304 // start channel hopper
280 iface->setChannelHopping( 1000 ); //use interval from config window 305 iface->setChannelHopping( 1000 ); //use interval from config window
281 306
282 // connect 307 // connect
283 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 308 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
309 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
284 310
285 logwindow->log( "(i) Started Scanning." ); 311 logwindow->log( "(i) Started Scanning." );
286 #ifdef QWS
287 oApp->setTitle( "Scanning ..." );
288 #else
289 qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." );
290 #endif
291 sniffing = true; 312 sniffing = true;
292 313
293 } 314 }
294} 315}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index ff73dd4..85f889b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -27,45 +27,46 @@ class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OPacketCapturer; 29class OPacketCapturer;
30class OWirelessNetworkInterface; 30class OWirelessNetworkInterface;
31 31
32class ManufacturerDB; 32class ManufacturerDB;
33class WellenreiterConfigWindow; 33class WellenreiterConfigWindow;
34class MLogWindow; 34class MLogWindow;
35class MHexWindow; 35class MHexWindow;
36 36
37class Wellenreiter : public WellenreiterBase { 37class Wellenreiter : public WellenreiterBase {
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 Wellenreiter( QWidget* parent = 0 ); 41 Wellenreiter( QWidget* parent = 0 );
42 ~Wellenreiter(); 42 ~Wellenreiter();
43 43
44 void setConfigWindow( WellenreiterConfigWindow* cw ); 44 void setConfigWindow( WellenreiterConfigWindow* cw );
45 MScanListView* netView() const { return netview; }; 45 MScanListView* netView() const { return netview; };
46 MLogWindow* logWindow() const { return logwindow; }; 46 MLogWindow* logWindow() const { return logwindow; };
47 MHexWindow* hexWindow() const { return hexwindow; }; 47 MHexWindow* hexWindow() const { return hexwindow; };
48 bool isDaemonRunning() const { return sniffing; }; 48 bool isDaemonRunning() const { return sniffing; };
49 49
50 public slots: 50 public slots:
51 void channelHopped(int);
51 void receivePacket(OPacket*); 52 void receivePacket(OPacket*);
52 void startStopClicked(); 53 void startStopClicked();
53 54
54 private: 55 private:
55 #ifdef QWS 56 #ifdef QWS
56 OSystem _system; // Opie Operating System identifier 57 OSystem _system; // Opie Operating System identifier
57 #endif 58 #endif
58 59
59 bool sniffing; 60 bool sniffing;
60 OWirelessNetworkInterface* iface; 61 OWirelessNetworkInterface* iface;
61 OPacketCapturer* pcap; 62 OPacketCapturer* pcap;
62 ManufacturerDB* manufacturerdb; 63 ManufacturerDB* manufacturerdb;
63 WellenreiterConfigWindow* configwindow; 64 WellenreiterConfigWindow* configwindow;
64 65
65 //void readConfig(); 66 //void readConfig();
66 //void writeConfig(); 67 //void writeConfig();
67}; 68};
68 69
69 70
70 71
71#endif 72#endif