Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 40cd105..12b3978 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -58,6 +58,9 @@ using namespace Opie::Ui; | |||
58 | #include <string.h> | 58 | #include <string.h> |
59 | #include <sys/types.h> | 59 | #include <sys/types.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <signal.h> | ||
62 | |||
63 | Wellenreiter* Wellenreiter::instance = 0; | ||
61 | 64 | ||
62 | Wellenreiter::Wellenreiter( QWidget* parent ) | 65 | Wellenreiter::Wellenreiter( QWidget* parent ) |
63 | : WellenreiterBase( parent, 0, 0 ), | 66 | : WellenreiterBase( parent, 0, 0 ), |
@@ -87,22 +90,53 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
87 | 90 | ||
88 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); | 91 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); |
89 | 92 | ||
93 | registerSignalHandler(); | ||
90 | } | 94 | } |
91 | 95 | ||
92 | 96 | ||
93 | Wellenreiter::~Wellenreiter() | 97 | Wellenreiter::~Wellenreiter() |
94 | { | 98 | { |
95 | delete pcap; | 99 | delete pcap; |
100 | //unregisterSignalHandler(); | ||
96 | } | 101 | } |
97 | 102 | ||
98 | 103 | ||
99 | void Wellenreiter::initialTimer() | 104 | void Wellenreiter::initialTimer() |
100 | { | 105 | { |
101 | odebug << "Wellenreiter::preloading manufacturer database..." << oendl; | 106 | odebug << "preloading manufacturer database..." << oendl; |
102 | OManufacturerDB::instance(); | 107 | OManufacturerDB::instance(); |
103 | } | 108 | } |
104 | 109 | ||
105 | 110 | ||
111 | void Wellenreiter::signalHandler( int sig ) | ||
112 | { | ||
113 | oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl; | ||
114 | if ( Wellenreiter::instance->sniffing ) | ||
115 | { | ||
116 | Wellenreiter::instance->pcap->close(); | ||
117 | Wellenreiter::instance->stopClicked(); | ||
118 | } | ||
119 | oerr << "Phew. Seemed to work." << oendl; | ||
120 | ::exit( -1 ); | ||
121 | } | ||
122 | |||
123 | |||
124 | void Wellenreiter::registerSignalHandler() | ||
125 | { | ||
126 | Wellenreiter::instance = this; | ||
127 | struct sigaction action; | ||
128 | |||
129 | action.sa_handler = Wellenreiter::signalHandler; | ||
130 | if (sigemptyset(&action.sa_mask)) | ||
131 | oerr << "sigemptyset() failure:" << strerror( errno ) << oendl; | ||
132 | if (sigaction(SIGSEGV, &action, NULL)) | ||
133 | oerr << "can't set up a signal handler for SIGSEGV:" << strerror( errno ) << oendl; | ||
134 | if (sigaction(SIGBUS, &action, NULL)) | ||
135 | oerr << "can't set up a signal handler for SIGBUS:" << strerror( errno ) << oendl; | ||
136 | odebug << "signal handlers setup." << oendl; | ||
137 | } | ||
138 | |||
139 | |||
106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 140 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
107 | { | 141 | { |
108 | configwindow = cw; | 142 | configwindow = cw; |
@@ -502,7 +536,7 @@ void Wellenreiter::startClicked() | |||
502 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 536 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
503 | { | 537 | { |
504 | QMessageBox::information( this, "Wellenreiter II", | 538 | QMessageBox::information( this, "Wellenreiter II", |
505 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 539 | tr( "No device configured.\nPlease reconfigure!" ) ); |
506 | return; | 540 | return; |
507 | } | 541 | } |
508 | 542 | ||
@@ -532,6 +566,16 @@ void Wellenreiter::startClicked() | |||
532 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 566 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
533 | return; | 567 | return; |
534 | } | 568 | } |
569 | |||
570 | // check if wireless extension version matches | ||
571 | if ( ONetwork::wirelessExtensionCompileVersion() != iface->wirelessExtensionDriverVersion() ) | ||
572 | { | ||
573 | QMessageBox::critical( this, "Wellenreiter II", tr( "<p>The Wireless Extension Versions<br>are not matching!<p>" | ||
574 | " Wellenreiter II : WE V%1<br>Interface driver: WE V%2" ) | ||
575 | .arg( QString::number( ONetwork::wirelessExtensionCompileVersion() ) ) | ||
576 | .arg( QString::number( iface->wirelessExtensionDriverVersion() ) ) ); | ||
577 | return; | ||
578 | } | ||
535 | } | 579 | } |
536 | // set monitor mode | 580 | // set monitor mode |
537 | bool usePrism = configwindow->usePrismHeader(); | 581 | bool usePrism = configwindow->usePrismHeader(); |