author | tille <tille> | 2003-06-21 15:36:59 (UTC) |
---|---|---|
committer | tille <tille> | 2003-06-21 15:36:59 (UTC) |
commit | e1e6c04dfb5d2ac785b4b5b0ed21648eb4e4d03b (patch) (unidiff) | |
tree | 1d95c13bf5def759982a73ea5f11637f0715097e | |
parent | 5f5accf337a109371296c6a78175734454165406 (diff) | |
download | opie-e1e6c04dfb5d2ac785b4b5b0ed21648eb4e4d03b.zip opie-e1e6c04dfb5d2ac785b4b5b0ed21648eb4e4d03b.tar.gz opie-e1e6c04dfb5d2ac785b4b5b0ed21648eb4e4d03b.tar.bz2 |
send message cound to networksettings
it's working now on the Z
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 79773b3..dcf796f 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,522 +1,530 @@ | |||
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 | // Local | 16 | // Local |
17 | 17 | ||
18 | #include "wellenreiter.h" | 18 | #include "wellenreiter.h" |
19 | #include "scanlist.h" | 19 | #include "scanlist.h" |
20 | #include "logwindow.h" | 20 | #include "logwindow.h" |
21 | #include "hexwindow.h" | 21 | #include "hexwindow.h" |
22 | #include "configwindow.h" | 22 | #include "configwindow.h" |
23 | #include "statwindow.h" | 23 | #include "statwindow.h" |
24 | #include "graphwindow.h" | 24 | #include "graphwindow.h" |
25 | #include "protolistview.h" | 25 | #include "protolistview.h" |
26 | 26 | ||
27 | // Opie | 27 | // Opie |
28 | 28 | ||
29 | #ifdef QWS | 29 | #ifdef QWS |
30 | #include <opie/odevice.h> | 30 | #include <opie/odevice.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | using namespace Opie; | 32 | using namespace Opie; |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | #ifdef QWS | 35 | #ifdef QWS |
36 | #include <opie2/oapplication.h> | 36 | #include <opie2/oapplication.h> |
37 | #else | 37 | #else |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #endif | 39 | #endif |
40 | #include <opie2/onetwork.h> | 40 | #include <opie2/onetwork.h> |
41 | #include <opie2/opcap.h> | 41 | #include <opie2/opcap.h> |
42 | 42 | ||
43 | // Qt | 43 | // Qt |
44 | 44 | ||
45 | #include <qcheckbox.h> | 45 | #include <qcheckbox.h> |
46 | #include <qcombobox.h> | 46 | #include <qcombobox.h> |
47 | #include <qdatetime.h> | 47 | #include <qdatetime.h> |
48 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
49 | #include <qlineedit.h> | 49 | #include <qlineedit.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qobjectlist.h> | 51 | #include <qobjectlist.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qspinbox.h> | 53 | #include <qspinbox.h> |
54 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
55 | #include <qmainwindow.h> | 55 | #include <qmainwindow.h> |
56 | 56 | ||
57 | // Standard | 57 | // Standard |
58 | 58 | ||
59 | #include <assert.h> | 59 | #include <assert.h> |
60 | #include <errno.h> | 60 | #include <errno.h> |
61 | #include <unistd.h> | 61 | #include <unistd.h> |
62 | #include <string.h> | 62 | #include <string.h> |
63 | #include <sys/types.h> | 63 | #include <sys/types.h> |
64 | #include <stdlib.h> | 64 | #include <stdlib.h> |
65 | 65 | ||
66 | Wellenreiter::Wellenreiter( QWidget* parent ) | 66 | Wellenreiter::Wellenreiter( QWidget* parent ) |
67 | : WellenreiterBase( parent, 0, 0 ), | 67 | : WellenreiterBase( parent, 0, 0 ), |
68 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 68 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
69 | { | 69 | { |
70 | 70 | ||
71 | logwindow->log( "(i) Wellenreiter has been started." ); | 71 | logwindow->log( "(i) Wellenreiter has been started." ); |
72 | 72 | ||
73 | // | 73 | // |
74 | // detect operating system | 74 | // detect operating system |
75 | // | 75 | // |
76 | 76 | ||
77 | #ifdef QWS | 77 | #ifdef QWS |
78 | QString sys; | 78 | QString sys; |
79 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 79 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
80 | _system = ODevice::inst()->system(); | 80 | _system = ODevice::inst()->system(); |
81 | logwindow->log( sys ); | 81 | logwindow->log( sys ); |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | netview->setColumnWidthMode( 1, QListView::Manual ); | 84 | netview->setColumnWidthMode( 1, QListView::Manual ); |
85 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 85 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
86 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 86 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
87 | pcap = new OPacketCapturer(); | 87 | pcap = new OPacketCapturer(); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | Wellenreiter::~Wellenreiter() | 91 | Wellenreiter::~Wellenreiter() |
92 | { | 92 | { |
93 | delete pcap; | 93 | delete pcap; |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 97 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
98 | { | 98 | { |
99 | configwindow = cw; | 99 | configwindow = cw; |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | void Wellenreiter::channelHopped(int c) | 103 | void Wellenreiter::channelHopped(int c) |
104 | { | 104 | { |
105 | QString title = "Wellenreiter II -scan- ["; | 105 | QString title = "Wellenreiter II -scan- ["; |
106 | QString left; | 106 | QString left; |
107 | if ( c > 1 ) left.fill( '.', c-1 ); | 107 | if ( c > 1 ) left.fill( '.', c-1 ); |
108 | title.append( left ); | 108 | title.append( left ); |
109 | title.append( '|' ); | 109 | title.append( '|' ); |
110 | if ( c < iface->channels() ) | 110 | if ( c < iface->channels() ) |
111 | { | 111 | { |
112 | QString right; | 112 | QString right; |
113 | right.fill( '.', iface->channels()-c ); | 113 | right.fill( '.', iface->channels()-c ); |
114 | title.append( right ); | 114 | title.append( right ); |
115 | } | 115 | } |
116 | title.append( "]" ); | 116 | title.append( "]" ); |
117 | //title.append( QString().sprintf( " %02d", c ) ); | 117 | //title.append( QString().sprintf( " %02d", c ) ); |
118 | assert( parent() ); | 118 | assert( parent() ); |
119 | ( (QMainWindow*) parent() )->setCaption( title ); | 119 | ( (QMainWindow*) parent() )->setCaption( title ); |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | void Wellenreiter::handleNotification( OPacket* p ) | 123 | void Wellenreiter::handleNotification( OPacket* p ) |
124 | { | 124 | { |
125 | QObjectList* l = p->queryList(); | 125 | QObjectList* l = p->queryList(); |
126 | QObjectListIt it( *l ); | 126 | QObjectListIt it( *l ); |
127 | QObject* o; | 127 | QObject* o; |
128 | 128 | ||
129 | while ( (o = it.current()) != 0 ) | 129 | while ( (o = it.current()) != 0 ) |
130 | { | 130 | { |
131 | QString name = it.current()->name(); | 131 | QString name = it.current()->name(); |
132 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 132 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
133 | { | 133 | { |
134 | QString action = configwindow->parsePackets->protocolAction( name ); | 134 | QString action = configwindow->parsePackets->protocolAction( name ); |
135 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 135 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
136 | doAction( action, name, p ); | 136 | doAction( action, name, p ); |
137 | } | 137 | } |
138 | else | 138 | else |
139 | { | 139 | { |
140 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 140 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
141 | } | 141 | } |
142 | ++it; | 142 | ++it; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 147 | void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
148 | { | 148 | { |
149 | QString type; | 149 | QString type; |
150 | if ( beacon->canIBSS() ) | 150 | if ( beacon->canIBSS() ) |
151 | { | 151 | { |
152 | type = "adhoc"; | 152 | type = "adhoc"; |
153 | } | 153 | } |
154 | else if ( beacon->canESS() ) | 154 | else if ( beacon->canESS() ) |
155 | { | 155 | { |
156 | type = "managed"; | 156 | type = "managed"; |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 160 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | 163 | ||
164 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 164 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
165 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 165 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
166 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 166 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
167 | int channel = ds ? ds->channel() : -1; | 167 | int channel = ds ? ds->channel() : -1; |
168 | 168 | ||
169 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 169 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
170 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); | 170 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); |
171 | 171 | ||
172 | // update graph window | 172 | // update graph window |
173 | if ( ds ) | 173 | if ( ds ) |
174 | { | 174 | { |
175 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 175 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
176 | if ( prism ) | 176 | if ( prism ) |
177 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 177 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
178 | else | 178 | else |
179 | graphwindow->traffic( ds->channel(), 95 ); | 179 | graphwindow->traffic( ds->channel(), 95 ); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) | 184 | void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) |
185 | { | 185 | { |
186 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 186 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
187 | if ( wlan->fromDS() && !wlan->toDS() ) | 187 | if ( wlan->fromDS() && !wlan->toDS() ) |
188 | { | 188 | { |
189 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 189 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
190 | } | 190 | } |
191 | else if ( !wlan->fromDS() && wlan->toDS() ) | 191 | else if ( !wlan->fromDS() && wlan->toDS() ) |
192 | { | 192 | { |
193 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 193 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
194 | } | 194 | } |
195 | else if ( wlan->fromDS() && wlan->toDS() ) | 195 | else if ( wlan->fromDS() && wlan->toDS() ) |
196 | { | 196 | { |
197 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 197 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
198 | } | 198 | } |
199 | else | 199 | else |
200 | { | 200 | { |
201 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); | 201 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); |
202 | } | 202 | } |
203 | 203 | ||
204 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 204 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
205 | if ( arp ) | 205 | if ( arp ) |
206 | { | 206 | { |
207 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 207 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); |
208 | if ( arp->type() == "REQUEST" ) | 208 | if ( arp->type() == "REQUEST" ) |
209 | { | 209 | { |
210 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 210 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
211 | } | 211 | } |
212 | else if ( arp->type() == "REPLY" ) | 212 | else if ( arp->type() == "REPLY" ) |
213 | { | 213 | { |
214 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 214 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
215 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 215 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | OIPPacket* ip = (OIPPacket*) p->child( "IP" ); | 219 | OIPPacket* ip = (OIPPacket*) p->child( "IP" ); |
220 | if ( ip ) | 220 | if ( ip ) |
221 | { | 221 | { |
222 | qDebug( "Received IP packet." ); | 222 | qDebug( "Received IP packet." ); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 227 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
228 | { | 228 | { |
229 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 229 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
230 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 230 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
231 | return 0; | 231 | return 0; |
232 | 232 | ||
233 | return p->child( protocol ); | 233 | return p->child( protocol ); |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 237 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
238 | { | 238 | { |
239 | // go through all child packets and see if one is inside the child hierarchy for p | 239 | // go through all child packets and see if one is inside the child hierarchy for p |
240 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 240 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
241 | if ( !configwindow->writeCaptureFile->isOn() ) | 241 | if ( !configwindow->writeCaptureFile->isOn() ) |
242 | return false; | 242 | return false; |
243 | 243 | ||
244 | QObjectList* l = p->queryList(); | 244 | QObjectList* l = p->queryList(); |
245 | QObjectListIt it( *l ); | 245 | QObjectListIt it( *l ); |
246 | QObject* o; | 246 | QObject* o; |
247 | 247 | ||
248 | while ( (o = it.current()) != 0 ) | 248 | while ( (o = it.current()) != 0 ) |
249 | { | 249 | { |
250 | QString name = it.current()->name(); | 250 | QString name = it.current()->name(); |
251 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 251 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
252 | { | 252 | { |
253 | QString action = configwindow->capturePackets->protocolAction( name ); | 253 | QString action = configwindow->capturePackets->protocolAction( name ); |
254 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 254 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
255 | if ( action == "Discard" ) | 255 | if ( action == "Discard" ) |
256 | { | 256 | { |
257 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 257 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 263 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
264 | } | 264 | } |
265 | ++it; | 265 | ++it; |
266 | } | 266 | } |
267 | return true; | 267 | return true; |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | void Wellenreiter::receivePacket( OPacket* p ) | 271 | void Wellenreiter::receivePacket( OPacket* p ) |
272 | { | 272 | { |
273 | hexWindow()->log( p->dump( 8 ) ); | 273 | hexWindow()->log( p->dump( 8 ) ); |
274 | 274 | ||
275 | if ( checkDumpPacket( p ) ) | 275 | if ( checkDumpPacket( p ) ) |
276 | { | 276 | { |
277 | pcap->dump( p ); | 277 | pcap->dump( p ); |
278 | } | 278 | } |
279 | 279 | ||
280 | // check if we received a beacon frame | 280 | // check if we received a beacon frame |
281 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 281 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
282 | if ( beacon && beacon->managementType() == "Beacon" ) | 282 | if ( beacon && beacon->managementType() == "Beacon" ) |
283 | { | 283 | { |
284 | handleBeacon( p, beacon ); | 284 | handleBeacon( p, beacon ); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | 287 | ||
288 | //TODO: WEP check here | 288 | //TODO: WEP check here |
289 | 289 | ||
290 | // check for a data frame | 290 | // check for a data frame |
291 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 291 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
292 | if ( data ) | 292 | if ( data ) |
293 | { | 293 | { |
294 | handleData( p, data ); | 294 | handleData( p, data ); |
295 | } | 295 | } |
296 | 296 | ||
297 | handleNotification( p ); | 297 | handleNotification( p ); |
298 | 298 | ||
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | void Wellenreiter::stopClicked() | 302 | void Wellenreiter::stopClicked() |
303 | { | 303 | { |
304 | if ( iface ) | 304 | if ( iface ) |
305 | { | 305 | { |
306 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 306 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
307 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 307 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
308 | iface->setChannelHopping(); // stop hopping channels | 308 | iface->setChannelHopping(); // stop hopping channels |
309 | } | 309 | } |
310 | else | 310 | else |
311 | killTimers(); | 311 | killTimers(); |
312 | 312 | ||
313 | pcap->close(); | 313 | pcap->close(); |
314 | sniffing = false; | 314 | sniffing = false; |
315 | 315 | ||
316 | if ( iface ) | 316 | if ( iface ) |
317 | { | 317 | { |
318 | // switch off monitor mode | 318 | // switch off monitor mode |
319 | iface->setMonitorMode( false ); | 319 | iface->setMonitorMode( false ); |
320 | // switch off promisc flag | 320 | // switch off promisc flag |
321 | iface->setPromiscuousMode( false ); | 321 | iface->setPromiscuousMode( false ); |
322 | 322 | ||
323 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 323 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
324 | } | 324 | } |
325 | 325 | ||
326 | logwindow->log( "(i) Stopped Scanning." ); | 326 | logwindow->log( "(i) Stopped Scanning." ); |
327 | assert( parent() ); | 327 | assert( parent() ); |
328 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 328 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
329 | 329 | ||
330 | // message the user | 330 | // message the user |
331 | QMessageBox::information( this, "Wellenreiter II", | 331 | QMessageBox::information( this, "Wellenreiter II", |
332 | tr( "Your wireless card\nshould now be usable again." ) ); | 332 | tr( "Your wireless card\nshould now be usable again." ) ); |
333 | 333 | ||
334 | sniffing = false; | 334 | sniffing = false; |
335 | emit( stoppedSniffing() ); | 335 | emit( stoppedSniffing() ); |
336 | 336 | ||
337 | // print out statistics | 337 | // print out statistics |
338 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 338 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
339 | statwindow->updateCounter( it.key(), it.data() ); | 339 | statwindow->updateCounter( it.key(), it.data() ); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void Wellenreiter::startClicked() | 343 | void Wellenreiter::startClicked() |
344 | { | 344 | { |
345 | // get configuration from config window | 345 | // get configuration from config window |
346 | 346 | ||
347 | const QString& interface = configwindow->interfaceName->currentText(); | 347 | const QString& interface = configwindow->interfaceName->currentText(); |
348 | const int cardtype = configwindow->driverType(); | 348 | const int cardtype = configwindow->driverType(); |
349 | const int interval = configwindow->hoppingInterval(); | 349 | const int interval = configwindow->hoppingInterval(); |
350 | 350 | ||
351 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 351 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
352 | { | 352 | { |
353 | QMessageBox::information( this, "Wellenreiter II", | 353 | QMessageBox::information( this, "Wellenreiter II", |
354 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 354 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
355 | return; | 355 | return; |
356 | } | 356 | } |
357 | 357 | ||
358 | // configure device | 358 | // configure device |
359 | ONetwork* net = ONetwork::instance(); | 359 | ONetwork* net = ONetwork::instance(); |
360 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 360 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
361 | 361 | ||
362 | // bring device UP | 362 | // bring device UP |
363 | iface->setUp( true ); | 363 | iface->setUp( true ); |
364 | if ( !iface->isUp() ) | 364 | if ( !iface->isUp() ) |
365 | { | 365 | { |
366 | QMessageBox::warning( this, "Wellenreiter II", | 366 | QMessageBox::warning( this, "Wellenreiter II", |
367 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 367 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
368 | return; | 368 | return; |
369 | } | 369 | } |
370 | 370 | ||
371 | // set monitor mode | 371 | // set monitor mode |
372 | bool usePrism = configwindow->usePrismHeader(); | 372 | bool usePrism = configwindow->usePrismHeader(); |
373 | 373 | ||
374 | switch ( cardtype ) | 374 | switch ( cardtype ) |
375 | { | 375 | { |
376 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 376 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
377 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 377 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
378 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 378 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
379 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 379 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
380 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 380 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
381 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 381 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
382 | default: assert( 0 ); // shouldn't reach this | 382 | default: assert( 0 ); // shouldn't reach this |
383 | } | 383 | } |
384 | 384 | ||
385 | // switch device into monitor mode | 385 | // switch device into monitor mode |
386 | if ( cardtype < DEVTYPE_FILE ) | 386 | if ( cardtype < DEVTYPE_FILE ) |
387 | { | 387 | { |
388 | if ( cardtype != DEVTYPE_MANUAL ) | 388 | if ( cardtype != DEVTYPE_MANUAL ) |
389 | iface->setMonitorMode( true ); | 389 | iface->setMonitorMode( true ); |
390 | if ( !iface->monitorMode() ) | 390 | if ( !iface->monitorMode() ) |
391 | { | 391 | { |
392 | QMessageBox::warning( this, "Wellenreiter II", | 392 | QMessageBox::warning( this, "Wellenreiter II", |
393 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); | 393 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // open pcap and start sniffing | 398 | // open pcap and start sniffing |
399 | if ( cardtype != DEVTYPE_FILE ) | 399 | if ( cardtype != DEVTYPE_FILE ) |
400 | { | 400 | { |
401 | pcap->open( interface ); | 401 | pcap->open( interface ); |
402 | 402 | ||
403 | if ( configwindow->writeCaptureFile->isOn() ) | 403 | if ( configwindow->writeCaptureFile->isOn() ) |
404 | { | 404 | { |
405 | QString dumpname( configwindow->captureFileName->text() ); | 405 | QString dumpname( configwindow->captureFileName->text() ); |
406 | dumpname.append( '-' ); | 406 | dumpname.append( '-' ); |
407 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 407 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
408 | dumpname.append( ".wellenreiter" ); | 408 | dumpname.append( ".wellenreiter" ); |
409 | pcap->openDumpFile( dumpname ); | 409 | pcap->openDumpFile( dumpname ); |
410 | } | 410 | } |
411 | else | 411 | else |
412 | { | 412 | { |
413 | pcap->open( interface ); | 413 | pcap->open( interface ); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | else | 416 | else |
417 | { | 417 | { |
418 | pcap->open( QFile( interface ) ); | 418 | pcap->open( QFile( interface ) ); |
419 | } | 419 | } |
420 | 420 | ||
421 | if ( !pcap->isOpen() ) | 421 | if ( !pcap->isOpen() ) |
422 | { | 422 | { |
423 | QMessageBox::warning( this, "Wellenreiter II", | 423 | QMessageBox::warning( this, "Wellenreiter II", |
424 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); | 424 | tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | 427 | ||
428 | // set capturer to non-blocking mode | 428 | // set capturer to non-blocking mode |
429 | pcap->setBlocking( false ); | 429 | pcap->setBlocking( false ); |
430 | 430 | ||
431 | // start channel hopper | 431 | // start channel hopper |
432 | if ( cardtype != DEVTYPE_FILE ) | 432 | if ( cardtype != DEVTYPE_FILE ) |
433 | iface->setChannelHopping( 1000 ); //use interval from config window | 433 | iface->setChannelHopping( 1000 ); //use interval from config window |
434 | 434 | ||
435 | if ( cardtype != DEVTYPE_FILE ) | 435 | if ( cardtype != DEVTYPE_FILE ) |
436 | { | 436 | { |
437 | // connect socket notifier and start channel hopper | 437 | // connect socket notifier and start channel hopper |
438 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 438 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
439 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 439 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | // start timer for reading packets | 443 | // start timer for reading packets |
444 | startTimer( 100 ); | 444 | startTimer( 100 ); |
445 | } | 445 | } |
446 | 446 | ||
447 | logwindow->log( "(i) Started Scanning." ); | 447 | logwindow->log( "(i) Started Scanning." ); |
448 | sniffing = true; | 448 | sniffing = true; |
449 | emit( startedSniffing() ); | 449 | emit( startedSniffing() ); |
450 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 450 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
451 | else | 451 | else |
452 | { | 452 | { |
453 | assert( parent() ); | 453 | assert( parent() ); |
454 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 454 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void Wellenreiter::timerEvent( QTimerEvent* ) | 459 | void Wellenreiter::timerEvent( QTimerEvent* ) |
460 | { | 460 | { |
461 | qDebug( "Wellenreiter::timerEvent()" ); | 461 | qDebug( "Wellenreiter::timerEvent()" ); |
462 | OPacket* p = pcap->next(); | 462 | OPacket* p = pcap->next(); |
463 | if ( !p ) // no more packets available | 463 | if ( !p ) // no more packets available |
464 | { | 464 | { |
465 | stopClicked(); | 465 | stopClicked(); |
466 | } | 466 | } |
467 | else | 467 | else |
468 | { | 468 | { |
469 | receivePacket( p ); | 469 | receivePacket( p ); |
470 | delete p; | 470 | delete p; |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 475 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
476 | { | 476 | { |
477 | if ( action == "TouchSound" ) | 477 | if ( action == "TouchSound" ) |
478 | ODevice::inst()->touchSound(); | 478 | ODevice::inst()->touchSound(); |
479 | else if ( action == "AlarmSound" ) | 479 | else if ( action == "AlarmSound" ) |
480 | ODevice::inst()->alarmSound(); | 480 | ODevice::inst()->alarmSound(); |
481 | else if ( action == "KeySound" ) | 481 | else if ( action == "KeySound" ) |
482 | ODevice::inst()->keySound(); | 482 | ODevice::inst()->keySound(); |
483 | else if ( action == "LedOn" ) | 483 | else if ( action == "LedOn" ) |
484 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 484 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
485 | else if ( action == "LedOff" ) | 485 | else if ( action == "LedOff" ) |
486 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 486 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
487 | else if ( action == "LogMessage" ) | 487 | else if ( action == "LogMessage" ) |
488 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 488 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
489 | else if ( action == "MessageBox" ) | 489 | else if ( action == "MessageBox" ) |
490 | QMessageBox::information( this, "Notification!", | 490 | QMessageBox::information( this, "Notification!", |
491 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 491 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
492 | } | 492 | } |
493 | 493 | ||
494 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) | 494 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) |
495 | { | 495 | { |
496 | if ( !iface ) | 496 | if ( !iface ) |
497 | { | 497 | { |
498 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); | 498 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); |
499 | return; | 499 | return; |
500 | } | 500 | } |
501 | 501 | ||
502 | if ( sniffing ) | 502 | if ( sniffing ) |
503 | { | 503 | { |
504 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); | 504 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); |
505 | return; | 505 | return; |
506 | } | 506 | } |
507 | 507 | ||
508 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 508 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
509 | (const char*) iface->name(), | 509 | (const char*) iface->name(), |
510 | (const char*) type, | 510 | (const char*) type, |
511 | (const char*) essid, | 511 | (const char*) essid, |
512 | channel, | 512 | channel, |
513 | (const char*) macaddr ); | 513 | (const char*) macaddr ); |
514 | 514 | ||
515 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 515 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
516 | int count = 3; | ||
517 | qDebug("sending %d messages",count); | ||
518 | msg << QString("count") << QString::number(count); | ||
519 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | ||
516 | msg << QString(iface->name()) << QString("Mode") << type; | 520 | msg << QString(iface->name()) << QString("Mode") << type; |
521 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | ||
517 | msg << QString(iface->name()) << QString("ESSID") << essid; | 522 | msg << QString(iface->name()) << QString("ESSID") << essid; |
523 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | ||
518 | msg << QString(iface->name()) << QString("Channel") << channel; | 524 | msg << QString(iface->name()) << QString("Channel") << channel; |
519 | msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 525 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); |
526 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | ||
527 | |||
520 | 528 | ||
521 | } | 529 | } |
522 | 530 | ||