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
@@ -25,25 +25,25 @@ using namespace Opie;
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
@@ -86,37 +86,60 @@ Wellenreiter::Wellenreiter( QWidget* parent )
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";
@@ -177,59 +200,61 @@ void Wellenreiter::receivePacket(OPacket* p)
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();
@@ -272,23 +297,19 @@ void Wellenreiter::startStopClicked()
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
@@ -39,24 +39,25 @@ class Wellenreiter : public WellenreiterBase {
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;