author | mickeyl <mickeyl> | 2003-03-31 15:00:44 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-31 15:00:44 (UTC) |
commit | f3b37f3dd4ae27e809415af67dd4df052d72d076 (patch) (unidiff) | |
tree | 36216a0e3543b11499da3ea56e2e0695c188c49d | |
parent | 13e8e8cbaede72948d3901a1a903eba43854d770 (diff) | |
download | opie-f3b37f3dd4ae27e809415af67dd4df052d72d076.zip opie-f3b37f3dd4ae27e809415af67dd4df052d72d076.tar.gz opie-f3b37f3dd4ae27e809415af67dd4df052d72d076.tar.bz2 |
only cardctl reset after sniffing. maybe later make calling dhcp client a configurable option.
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index d1dd73a..e294eb8 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,228 +1,228 @@ | |||
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 | // Opie | 16 | // Opie |
17 | 17 | ||
18 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <opie/odevice.h> | 19 | #include <opie/odevice.h> |
20 | using namespace Opie; | 20 | using 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 <qsocketnotifier.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 | ||
58 | Wellenreiter::Wellenreiter( QWidget* parent ) | 58 | Wellenreiter::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 | { |
62 | 62 | ||
63 | // | 63 | // |
64 | // construct manufacturer database | 64 | // construct manufacturer database |
65 | // | 65 | // |
66 | 66 | ||
67 | QString manufile; | 67 | QString manufile; |
68 | #ifdef QWS | 68 | #ifdef QWS |
69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
70 | #else | 70 | #else |
71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
72 | #endif | 72 | #endif |
73 | manufacturerdb = new ManufacturerDB( manufile ); | 73 | manufacturerdb = new ManufacturerDB( manufile ); |
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 | Wellenreiter::~Wellenreiter() | 98 | Wellenreiter::~Wellenreiter() |
99 | { | 99 | { |
100 | // no need to delete child widgets, Qt does it all for us | 100 | // no need to delete child widgets, Qt does it all for us |
101 | 101 | ||
102 | delete manufacturerdb; | 102 | delete manufacturerdb; |
103 | delete pcap; | 103 | delete pcap; |
104 | } | 104 | } |
105 | 105 | ||
106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
107 | { | 107 | { |
108 | configwindow = cw; | 108 | configwindow = cw; |
109 | } | 109 | } |
110 | 110 | ||
111 | void Wellenreiter::receivePacket(OPacket* p) | 111 | void Wellenreiter::receivePacket(OPacket* p) |
112 | { | 112 | { |
113 | // check if we received a beacon frame | 113 | // check if we received a beacon frame |
114 | // static_cast is justified here | 114 | // static_cast is justified here |
115 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 115 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
116 | if ( !beacon ) return; | 116 | if ( !beacon ) return; |
117 | QString type; | 117 | QString type; |
118 | 118 | ||
119 | //FIXME: Can stations in ESS mode can be distinguished from APs? | 119 | //FIXME: Can stations in ESS mode can be distinguished from APs? |
120 | //FIXME: Apparently yes, but not by listening to beacons, because | 120 | //FIXME: Apparently yes, but not by listening to beacons, because |
121 | //FIXME: they simply don't send beacons in infrastructure mode. | 121 | //FIXME: they simply don't send beacons in infrastructure mode. |
122 | //FIXME: so we also have to listen to data packets | 122 | //FIXME: so we also have to listen to data packets |
123 | 123 | ||
124 | if ( beacon->canIBSS() ) | 124 | if ( beacon->canIBSS() ) |
125 | type = "adhoc"; | 125 | type = "adhoc"; |
126 | else | 126 | else |
127 | type = "managed"; | 127 | type = "managed"; |
128 | 128 | ||
129 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 129 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
130 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 130 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
131 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 131 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
132 | int channel = ds ? ds->channel() : -1; | 132 | int channel = ds ? ds->channel() : -1; |
133 | 133 | ||
134 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 134 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
135 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); | 135 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); |
136 | } | 136 | } |
137 | 137 | ||
138 | void Wellenreiter::startStopClicked() | 138 | void Wellenreiter::startStopClicked() |
139 | { | 139 | { |
140 | if ( sniffing ) | 140 | if ( sniffing ) |
141 | { | 141 | { |
142 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 142 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
143 | 143 | ||
144 | iface->setChannelHopping(); // stop hopping channels | 144 | iface->setChannelHopping(); // stop hopping channels |
145 | pcap->close(); | 145 | pcap->close(); |
146 | sniffing = false; | 146 | sniffing = false; |
147 | #ifdef QWS | 147 | #ifdef QWS |
148 | oApp->setTitle(); | 148 | oApp->setTitle(); |
149 | #else | 149 | #else |
150 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | 150 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | // get interface name from config window | 153 | // get interface name from config window |
154 | const QString& interface = configwindow->interfaceName->currentText(); | 154 | const QString& interface = configwindow->interfaceName->currentText(); |
155 | ONetwork* net = ONetwork::instance(); | 155 | ONetwork* net = ONetwork::instance(); |
156 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 156 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
157 | 157 | ||
158 | // switch off monitor mode | 158 | // switch off monitor mode |
159 | iface->setMonitorMode( false ); | 159 | iface->setMonitorMode( false ); |
160 | // switch off promisc flag | 160 | // switch off promisc flag |
161 | iface->setPromiscuousMode( false ); | 161 | iface->setPromiscuousMode( false ); |
162 | 162 | ||
163 | system( "cardctl reset; sleep 1; dhclient; udhcpc" ); //FIXME: Use OProcess | 163 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
164 | 164 | ||
165 | // message the user | 165 | // message the user |
166 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | 166 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
167 | } | 167 | } |
168 | 168 | ||
169 | else | 169 | else |
170 | { | 170 | { |
171 | // get configuration from config window | 171 | // get configuration from config window |
172 | 172 | ||
173 | const QString& interface = configwindow->interfaceName->currentText(); | 173 | const QString& interface = configwindow->interfaceName->currentText(); |
174 | const int cardtype = configwindow->daemonDeviceType(); | 174 | const int cardtype = configwindow->daemonDeviceType(); |
175 | const int interval = configwindow->daemonHopInterval(); | 175 | const int interval = configwindow->daemonHopInterval(); |
176 | 176 | ||
177 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 177 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
178 | { | 178 | { |
179 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 179 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
180 | return; | 180 | return; |
181 | } | 181 | } |
182 | 182 | ||
183 | // configure device | 183 | // configure device |
184 | 184 | ||
185 | ONetwork* net = ONetwork::instance(); | 185 | ONetwork* net = ONetwork::instance(); |
186 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 186 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
187 | 187 | ||
188 | // set monitor mode | 188 | // set monitor mode |
189 | 189 | ||
190 | switch ( cardtype ) | 190 | switch ( cardtype ) |
191 | { | 191 | { |
192 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | 192 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
193 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | 193 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
194 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | 194 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
195 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | 195 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; |
196 | default: assert( 0 ); // shouldn't happen | 196 | default: assert( 0 ); // shouldn't happen |
197 | } | 197 | } |
198 | 198 | ||
199 | iface->setMonitorMode( true ); | 199 | iface->setMonitorMode( true ); |
200 | 200 | ||
201 | // open pcap and start sniffing | 201 | // open pcap and start sniffing |
202 | pcap->open( interface ); | 202 | pcap->open( interface ); |
203 | 203 | ||
204 | if ( !pcap->isOpen() ) | 204 | if ( !pcap->isOpen() ) |
205 | { | 205 | { |
206 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 206 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | // set capturer to non-blocking mode | 210 | // set capturer to non-blocking mode |
211 | pcap->setBlocking( false ); | 211 | pcap->setBlocking( false ); |
212 | 212 | ||
213 | // start channel hopper | 213 | // start channel hopper |
214 | iface->setChannelHopping( 1000 ); //use interval from config window | 214 | iface->setChannelHopping( 1000 ); //use interval from config window |
215 | 215 | ||
216 | // connect | 216 | // connect |
217 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 217 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
218 | 218 | ||
219 | logwindow->log( "(i) Daemon has been started." ); | 219 | logwindow->log( "(i) Daemon has been started." ); |
220 | #ifdef QWS | 220 | #ifdef QWS |
221 | oApp->setTitle( "Scanning ..." ); | 221 | oApp->setTitle( "Scanning ..." ); |
222 | #else | 222 | #else |
223 | qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); | 223 | qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); |
224 | #endif | 224 | #endif |
225 | sniffing = true; | 225 | sniffing = true; |
226 | 226 | ||
227 | } | 227 | } |
228 | } | 228 | } |