summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-08 13:37:06 (UTC)
committer mickeyl <mickeyl>2003-05-08 13:37:06 (UTC)
commit78c60031b506b85dc20bd555d83486aeb831bf38 (patch) (unidiff)
tree8bd0af604c911309162560fcac7bc2dcd9855d51
parent08f9d5965b127b0b889b96cf16b7d34b5a9a6928 (diff)
downloadopie-78c60031b506b85dc20bd555d83486aeb831bf38.zip
opie-78c60031b506b85dc20bd555d83486aeb831bf38.tar.gz
opie-78c60031b506b85dc20bd555d83486aeb831bf38.tar.bz2
- add more sanity checks and verbose error messages
- try to restart dhcp client after having killed it before
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui8
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp17
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp9
-rw-r--r--noncore/net/wellenreiter/gui/protolistview.cpp2
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp16
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h1
6 files changed, 45 insertions, 8 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
index 422826a..590ca92 100644
--- a/noncore/net/wellenreiter/gui/configbase.ui
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -108,16 +108,20 @@
108 </widget> 108 </widget>
109 <widget row="6" column="0" rowspan="1" colspan="4" > 109 <widget row="6" column="0" rowspan="1" colspan="4" >
110 <class>QGroupBox</class> 110 <class>QGroupBox</class>
111 <property stdset="1"> 111 <property stdset="1">
112 <name>name</name> 112 <name>name</name>
113 <cstring>GroupBox1</cstring> 113 <cstring>GroupBox1</cstring>
114 </property> 114 </property>
115 <property stdset="1"> 115 <property stdset="1">
116 <name>enabled</name>
117 <bool>false</bool>
118 </property>
119 <property stdset="1">
116 <name>title</name> 120 <name>title</name>
117 <string>Scan on channel</string> 121 <string>Scan on channel</string>
118 </property> 122 </property>
119 <property> 123 <property>
120 <name>layoutMargin</name> 124 <name>layoutMargin</name>
121 </property> 125 </property>
122 <property> 126 <property>
123 <name>layoutSpacing</name> 127 <name>layoutSpacing</name>
@@ -454,16 +458,20 @@
454 </widget> 458 </widget>
455 <widget row="5" column="0" rowspan="1" colspan="4" > 459 <widget row="5" column="0" rowspan="1" colspan="4" >
456 <class>QCheckBox</class> 460 <class>QCheckBox</class>
457 <property stdset="1"> 461 <property stdset="1">
458 <name>name</name> 462 <name>name</name>
459 <cstring>adaptiveHopping</cstring> 463 <cstring>adaptiveHopping</cstring>
460 </property> 464 </property>
461 <property stdset="1"> 465 <property stdset="1">
466 <name>enabled</name>
467 <bool>false</bool>
468 </property>
469 <property stdset="1">
462 <name>text</name> 470 <name>text</name>
463 <string>Use Adaptive(TM) Hop Scheme</string> 471 <string>Use Adaptive(TM) Hop Scheme</string>
464 </property> 472 </property>
465 </widget> 473 </widget>
466 </grid> 474 </grid>
467 </widget> 475 </widget>
468 <widget> 476 <widget>
469 <class>QWidget</class> 477 <class>QWidget</class>
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 96ebb3f..55a5260 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -41,16 +41,17 @@ int main( int argc, char **argv )
41 #else 41 #else
42 QApplication a( argc, argv ); 42 QApplication a( argc, argv );
43 #endif 43 #endif
44 WellenreiterMainWindow* w = new WellenreiterMainWindow(); 44 WellenreiterMainWindow* w = new WellenreiterMainWindow();
45 #ifdef QWS 45 #ifdef QWS
46 a.showMainWidget( w ); 46 a.showMainWidget( w );
47 #else 47 #else
48 a.setMainWidget( w ); 48 a.setMainWidget( w );
49 w->setCaption( "Wellenreiter II" );
49 w->show(); 50 w->show();
50 #endif 51 #endif
51 52
52 a.processEvents(); // show the window before doing the safety checks 53 a.processEvents(); // show the window before doing the safety checks
53 int result = -1; 54 int result = -1;
54 55
55 // root check 56 // root check
56 if ( getuid() ) 57 if ( getuid() )
@@ -60,16 +61,18 @@ int main( int argc, char **argv )
60 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), 61 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ),
61 QMessageBox::Yes, QMessageBox::No ); 62 QMessageBox::Yes, QMessageBox::No );
62 if ( result == QMessageBox::No ) return -1; 63 if ( result == QMessageBox::No ) return -1;
63 } 64 }
64 65
65 // dhcp check - NOT HERE! This really belongs as a static member to OProcess 66 // dhcp check - NOT HERE! This really belongs as a static member to OProcess
66 // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... 67 // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ...
67 68
69 static int killed = false;
70
68 QString line; 71 QString line;
69 QDir d = QDir( "/proc" ); 72 QDir d = QDir( "/proc" );
70 QStringList dirs = d.entryList( QDir::Dirs ); 73 QStringList dirs = d.entryList( QDir::Dirs );
71 QStringList::Iterator it; 74 QStringList::Iterator it;
72 for ( it = dirs.begin(); it != dirs.end(); ++it ) 75 for ( it = dirs.begin(); it != dirs.end(); ++it )
73 { 76 {
74 //qDebug( "next entry: %s", (const char*) *it ); 77 //qDebug( "next entry: %s", (const char*) *it );
75 QFile file( "/proc/"+*it+"/cmdline" ); 78 QFile file( "/proc/"+*it+"/cmdline" );
@@ -84,16 +87,28 @@ int main( int argc, char **argv )
84 { 87 {
85 qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() ); 88 qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() );
86 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" 89 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n"
87 "This can severly limit scanning!\nShould I kill it for you?" ), 90 "This can severly limit scanning!\nShould I kill it for you?" ),
88 QMessageBox::Yes, QMessageBox::No ); 91 QMessageBox::Yes, QMessageBox::No );
89 if ( result == QMessageBox::Yes ) 92 if ( result == QMessageBox::Yes )
90 { 93 {
91 if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) 94 if ( -1 == ::kill( (*it).toInt(), SIGTERM ) )
92 qWarning( "Wellenreiter: can't kill process (%s)", result, strerror( errno ) ); 95 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) );
96 else
97 killed = true;
93 } 98 }
94 } 99 }
95 100
96 a.exec(); 101 a.exec();
102
103 if ( killed )
104 {
105 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No );
106 if ( result == QMessageBox::Yes )
107 {
108 system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) );
109 }
110 }
111
97 delete w; 112 delete w;
98 return 0; 113 return 0;
99} 114}
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 7241f7a..3e36f5b 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -130,18 +130,19 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
130 130
131 QPopupMenu* demo = new QPopupMenu( mb ); 131 QPopupMenu* demo = new QPopupMenu( mb );
132 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); 132 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) );
133 133
134 id = mb->insertItem( tr( "&File" ), file ); 134 id = mb->insertItem( tr( "&File" ), file );
135 //id = mb->insertItem( tr( "&View" ), view ); 135 //id = mb->insertItem( tr( "&View" ), view );
136 //mb->setItemEnabled( id, false ); 136 //mb->setItemEnabled( id, false );
137 id = mb->insertItem( tr( "&Sniffer" ), sniffer ); 137 id = mb->insertItem( tr( "&Sniffer" ), sniffer );
138 //id = mb->insertItem( tr( "&Demo" ), demo ); 138
139 //mb->setItemEnabled( id, true ); 139 id = mb->insertItem( tr( "&Demo" ), demo );
140 mb->setItemEnabled( id, true );
140 141
141 #ifdef QWS 142 #ifdef QWS
142 mb->insertItem( startButton ); 143 mb->insertItem( startButton );
143 mb->insertItem( stopButton ); 144 mb->insertItem( stopButton );
144 mb->insertItem( c ); 145 mb->insertItem( c );
145 mb->insertItem( d ); 146 mb->insertItem( d );
146 #else // Qt3 changed the insertion order. It's now totally random :( 147 #else // Qt3 changed the insertion order. It's now totally random :(
147 mb->insertItem( d ); 148 mb->insertItem( d );
@@ -210,16 +211,18 @@ WellenreiterMainWindow::~WellenreiterMainWindow()
210 delete infoIconSet; 211 delete infoIconSet;
211 delete settingsIconSet; 212 delete settingsIconSet;
212 delete startIconSet; 213 delete startIconSet;
213 delete stopIconSet; 214 delete stopIconSet;
214}; 215};
215 216
216void WellenreiterMainWindow::demoAddStations() 217void WellenreiterMainWindow::demoAddStations()
217{ 218{
219 mw = 0;
220
218 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 221 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
219 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); 222 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
220 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 223 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
221 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 224 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
222 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 225 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
223} 226}
224 227
225 228
@@ -354,8 +357,10 @@ void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
354 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); 357 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) );
355 e->ignore(); 358 e->ignore();
356 } 359 }
357 else 360 else
358 { 361 {
359 QMainWindow::closeEvent( e ); 362 QMainWindow::closeEvent( e );
360 } 363 }
361} 364}
365
366
diff --git a/noncore/net/wellenreiter/gui/protolistview.cpp b/noncore/net/wellenreiter/gui/protolistview.cpp
index f4b45d0..daca095 100644
--- a/noncore/net/wellenreiter/gui/protolistview.cpp
+++ b/noncore/net/wellenreiter/gui/protolistview.cpp
@@ -79,17 +79,17 @@ void ProtocolListView::addProtocol( const QString& name )
79 new QCheckBox( name, hbox, (const char*) name ); 79 new QCheckBox( name, hbox, (const char*) name );
80 80
81 if ( parse ) 81 if ( parse )
82 { 82 {
83 QComboBox* combo = new QComboBox( hbox, (const char*) name ); 83 QComboBox* combo = new QComboBox( hbox, (const char*) name );
84 #ifdef QWS 84 #ifdef QWS
85 combo->setFixedWidth( 75 ); 85 combo->setFixedWidth( 75 );
86 #endif 86 #endif
87 combo->insertItem( "Ignore" ); 87 combo->insertItem( "Pass" );
88 combo->insertItem( "Discard!" ); 88 combo->insertItem( "Discard!" );
89 combo->insertItem( "TouchSound" ); 89 combo->insertItem( "TouchSound" );
90 combo->insertItem( "AlarmSound" ); 90 combo->insertItem( "AlarmSound" );
91 combo->insertItem( "KeySound" ); 91 combo->insertItem( "KeySound" );
92 combo->insertItem( "LedOn" ); 92 combo->insertItem( "LedOn" );
93 combo->insertItem( "LedOff" ); 93 combo->insertItem( "LedOff" );
94 combo->insertItem( "LogMessage" ); 94 combo->insertItem( "LogMessage" );
95 combo->insertItem( "MessageBox" ); 95 combo->insertItem( "MessageBox" );
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 965f6b0..4257be1 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -398,22 +398,29 @@ void Wellenreiter::startClicked()
398 if ( ( interface == "" ) || ( cardtype == 0 ) ) 398 if ( ( interface == "" ) || ( cardtype == 0 ) )
399 { 399 {
400 QMessageBox::information( this, "Wellenreiter II", 400 QMessageBox::information( this, "Wellenreiter II",
401 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 401 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
402 return; 402 return;
403 } 403 }
404 404
405 // configure device 405 // configure device
406
407 ONetwork* net = ONetwork::instance(); 406 ONetwork* net = ONetwork::instance();
408 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 407 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
409 408
410 // set monitor mode 409 // bring device UP
410 iface->setUp( true );
411 if ( !iface->isUp() )
412 {
413 QMessageBox::warning( this, "Wellenreiter II",
414 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
415 return;
416 }
411 417
418 // set monitor mode
412 bool usePrism = configwindow->usePrismHeader(); 419 bool usePrism = configwindow->usePrismHeader();
413 420
414 switch ( cardtype ) 421 switch ( cardtype )
415 { 422 {
416 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 423 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
417 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 424 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
418 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 425 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
419 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 426 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
@@ -425,17 +432,17 @@ void Wellenreiter::startClicked()
425 // switch device into monitor mode 432 // switch device into monitor mode
426 if ( cardtype < DEVTYPE_FILE ) 433 if ( cardtype < DEVTYPE_FILE )
427 { 434 {
428 if ( cardtype != DEVTYPE_MANUAL ) 435 if ( cardtype != DEVTYPE_MANUAL )
429 iface->setMonitorMode( true ); 436 iface->setMonitorMode( true );
430 if ( !iface->monitorMode() ) 437 if ( !iface->monitorMode() )
431 { 438 {
432 QMessageBox::warning( this, "Wellenreiter II", 439 QMessageBox::warning( this, "Wellenreiter II",
433 tr( "Can't set device into monitor mode." ) ); 440 tr( "Can't set interface '%1' into monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) );
434 return; 441 return;
435 } 442 }
436 } 443 }
437 444
438 // open pcap and start sniffing 445 // open pcap and start sniffing
439 if ( cardtype != DEVTYPE_FILE ) 446 if ( cardtype != DEVTYPE_FILE )
440 { 447 {
441 pcap->open( interface ); 448 pcap->open( interface );
@@ -456,17 +463,17 @@ void Wellenreiter::startClicked()
456 else 463 else
457 { 464 {
458 pcap->open( QFile( interface ) ); 465 pcap->open( QFile( interface ) );
459 } 466 }
460 467
461 if ( !pcap->isOpen() ) 468 if ( !pcap->isOpen() )
462 { 469 {
463 QMessageBox::warning( this, "Wellenreiter II", 470 QMessageBox::warning( this, "Wellenreiter II",
464 tr( "Can't open packet capturer:\n" ) + QString(strerror( errno ) )); 471 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) ));
465 return; 472 return;
466 } 473 }
467 474
468 // set capturer to non-blocking mode 475 // set capturer to non-blocking mode
469 pcap->setBlocking( false ); 476 pcap->setBlocking( false );
470 477
471 // start channel hopper 478 // start channel hopper
472 if ( cardtype != DEVTYPE_FILE ) 479 if ( cardtype != DEVTYPE_FILE )
@@ -525,8 +532,9 @@ void Wellenreiter::doAction( const QString& action, const QString& protocol, OPa
525 else if ( action == "LedOff" ) 532 else if ( action == "LedOff" )
526 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 533 ODevice::inst()->setLedState( Led_Mail, Led_Off );
527 else if ( action == "LogMessage" ) 534 else if ( action == "LogMessage" )
528 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 535 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
529 else if ( action == "MessageBox" ) 536 else if ( action == "MessageBox" )
530 QMessageBox::information ( this, "Notification!", 537 QMessageBox::information ( this, "Notification!",
531 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 538 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
532} 539}
540
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 37e692c..d776492 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -43,16 +43,17 @@ class Wellenreiter : public WellenreiterBase {
43 ~Wellenreiter(); 43 ~Wellenreiter();
44 44
45 void setConfigWindow( WellenreiterConfigWindow* cw ); 45 void setConfigWindow( WellenreiterConfigWindow* cw );
46 MScanListView* netView() const { return netview; }; 46 MScanListView* netView() const { return netview; };
47 MLogWindow* logWindow() const { return logwindow; }; 47 MLogWindow* logWindow() const { return logwindow; };
48 MHexWindow* hexWindow() const { return hexwindow; }; 48 MHexWindow* hexWindow() const { return hexwindow; };
49 bool isDaemonRunning() const { return sniffing; }; 49 bool isDaemonRunning() const { return sniffing; };
50 50
51 public:
51 bool sniffing; 52 bool sniffing;
52 53
53 protected: 54 protected:
54 virtual void timerEvent( QTimerEvent* ); 55 virtual void timerEvent( QTimerEvent* );
55 56
56 public slots: 57 public slots:
57 void channelHopped(int); 58 void channelHopped(int);
58 void receivePacket(OPacket*); 59 void receivePacket(OPacket*);