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