summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-04-23 14:44:25 (UTC)
committer mickeyl <mickeyl>2004-04-23 14:44:25 (UTC)
commite4433b86449dab80f1a5303f9f5c86d3b9d138c7 (patch) (unidiff)
tree5c15ddef0188d2240c7580346ee7c4028f3b01fa
parentd8a8c7bf9559dd1ad6a72c9e5582d72a176c97f6 (diff)
downloadopie-e4433b86449dab80f1a5303f9f5c86d3b9d138c7.zip
opie-e4433b86449dab80f1a5303f9f5c86d3b9d138c7.tar.gz
opie-e4433b86449dab80f1a5303f9f5c86d3b9d138c7.tar.bz2
gcc 3.4 fixlets
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp52
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp2
2 files changed, 27 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index ed9ec14..c605111 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,567 +1,567 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
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#include "scanlist.h" 16#include "scanlist.h"
17#include "configwindow.h" 17#include "configwindow.h"
18#include "logwindow.h" 18#include "logwindow.h"
19 19
20/* OPIE */ 20/* OPIE */
21#ifdef QWS 21#ifdef QWS
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#else 25#else
26#include "resource.h" 26#include "resource.h"
27#endif 27#endif
28using namespace Opie::Core; 28using namespace Opie::Core;
29using namespace Opie::Ui; 29using namespace Opie::Ui;
30using namespace Opie::Net; 30using namespace Opie::Net;
31 31
32/* QT */ 32/* QT */
33#include <qcursor.h> 33#include <qcursor.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37 37
38/* STD */ 38/* STD */
39#include <assert.h> 39#include <assert.h>
40 40
41const int col_type = 0; 41const int col_type = 0;
42const int col_essid = 0; 42const int col_essid = 0;
43const int col_sig = 1; 43const int col_sig = 1;
44const int col_ap = 2; 44const int col_ap = 2;
45const int col_channel = 3; 45const int col_channel = 3;
46const int col_wep = 4; 46const int col_wep = 4;
47const int col_traffic = 5; 47const int col_traffic = 5;
48const int col_ip = 6; 48const int col_ip = 6;
49const int col_manuf = 7; 49const int col_manuf = 7;
50const int col_firstseen = 8; 50const int col_firstseen = 8;
51const int col_lastseen = 9; 51const int col_lastseen = 9;
52const int col_location = 10; 52const int col_location = 10;
53 53
54MScanListView::MScanListView( QWidget* parent, const char* name ) 54MScanListView::MScanListView( QWidget* parent, const char* name )
55 :OListView( parent, name ) 55 :OListView( parent, name )
56{ 56{
57 setFrameShape( QListView::StyledPanel ); 57 setFrameShape( QListView::StyledPanel );
58 setFrameShadow( QListView::Sunken ); 58 setFrameShadow( QListView::Sunken );
59 59
60 addColumn( tr( "Net/Station" ) ); 60 addColumn( tr( "Net/Station" ) );
61 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 61 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
62 addColumn( tr( "#" ) ); 62 addColumn( tr( "#" ) );
63 setColumnAlignment( col_sig, AlignCenter ); 63 setColumnAlignment( col_sig, AlignCenter );
64 addColumn( tr( "MAC" ) ); 64 addColumn( tr( "MAC" ) );
65 setColumnAlignment( col_ap, AlignCenter ); 65 setColumnAlignment( col_ap, AlignCenter );
66 addColumn( tr( "Chn" ) ); 66 addColumn( tr( "Chn" ) );
67 setColumnAlignment( col_channel, AlignCenter ); 67 setColumnAlignment( col_channel, AlignCenter );
68 addColumn( tr( "W" ) ); 68 addColumn( tr( "W" ) );
69 setColumnAlignment( col_wep, AlignCenter ); 69 setColumnAlignment( col_wep, AlignCenter );
70 addColumn( tr( "T" ) ); 70 addColumn( tr( "T" ) );
71 setColumnAlignment( col_traffic, AlignCenter ); 71 setColumnAlignment( col_traffic, AlignCenter );
72 addColumn( tr( "IP" ) ); 72 addColumn( tr( "IP" ) );
73 setColumnAlignment( col_ip, AlignCenter ); 73 setColumnAlignment( col_ip, AlignCenter );
74 addColumn( tr( "Manufacturer" ) ); 74 addColumn( tr( "Manufacturer" ) );
75 setColumnAlignment( col_manuf, AlignCenter ); 75 setColumnAlignment( col_manuf, AlignCenter );
76 addColumn( tr( "First Seen" ) ); 76 addColumn( tr( "First Seen" ) );
77 setColumnAlignment( col_firstseen, AlignCenter ); 77 setColumnAlignment( col_firstseen, AlignCenter );
78 addColumn( tr( "Last Seen" ) ); 78 addColumn( tr( "Last Seen" ) );
79 setColumnAlignment( col_lastseen, AlignCenter ); 79 setColumnAlignment( col_lastseen, AlignCenter );
80 addColumn( tr( "Location" ) ); 80 addColumn( tr( "Location" ) );
81 setColumnAlignment( col_location, AlignCenter ); 81 setColumnAlignment( col_location, AlignCenter );
82 setRootIsDecorated( true ); 82 setRootIsDecorated( true );
83 setAllColumnsShowFocus( true ); 83 setAllColumnsShowFocus( true );
84 84
85 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 85 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
86 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 86 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
87 87
88 #ifdef QWS 88 #ifdef QWS
89 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 89 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
90 #endif 90 #endif
91 91
92}; 92};
93 93
94 94
95MScanListView::~MScanListView() 95MScanListView::~MScanListView()
96{ 96{
97}; 97};
98 98
99 99
100OListViewItem* MScanListView::childFactory() 100OListViewItem* MScanListView::childFactory()
101{ 101{
102 return new MScanListItem( this ); 102 return new MScanListItem( this );
103} 103}
104 104
105 105
106void MScanListView::serializeTo( QDataStream& s) const 106void MScanListView::serializeTo( QDataStream& s) const
107{ 107{
108 odebug << "serializing MScanListView" << oendl; 108 odebug << "serializing MScanListView" << oendl;
109 OListView::serializeTo( s ); 109 OListView::serializeTo( s );
110} 110}
111 111
112 112
113void MScanListView::serializeFrom( QDataStream& s) 113void MScanListView::serializeFrom( QDataStream& s)
114{ 114{
115 odebug << "serializing MScanListView" << oendl; 115 odebug << "serializing MScanListView" << oendl;
116 OListView::serializeFrom( s ); 116 OListView::serializeFrom( s );
117} 117}
118 118
119 119
120void MScanListView::addNewItem( const QString& type, 120void MScanListView::addNewItem( const QString& type,
121 const QString& essid, 121 const QString& essid,
122 const OMacAddress& mac, 122 const OMacAddress& mac,
123 bool wep, 123 bool wep,
124 int channel, 124 int channel,
125 int signal, 125 int signal,
126 const GpsLocation& loc, 126 const GpsLocation& loc,
127 bool probe ) 127 bool probe )
128{ 128{
129 QString macaddr = mac.toString(true); 129 QString macaddr = mac.toString(true);
130 130
131 #ifdef DEBUG 131 #ifdef DEBUG
132 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 132 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
133 (const char*) essid, (const char*) macaddr, channel ); 133 (const char*) essid, (const char*) macaddr, channel );
134 #endif 134 #endif
135 135
136 // search, if we already have seen this net 136 // search, if we already have seen this net
137 137
138 QString s; 138 QString s;
139 MScanListItem* network; 139 MScanListItem* network;
140 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 140 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
141 141
142 while ( item && ( item->text( col_essid ) != essid ) ) 142 while ( item && ( item->text( col_essid ) != essid ) )
143 { 143 {
144 #ifdef DEBUG 144 #ifdef DEBUG
145 odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; 145 odebug << "itemtext: " << item->text( col_essid ) << "" << oendl;
146 #endif 146 #endif
147 item = static_cast<MScanListItem*> ( item->nextSibling() ); 147 item = static_cast<MScanListItem*> ( item->nextSibling() );
148 } 148 }
149 if ( item ) 149 if ( item )
150 { 150 {
151 // we have already seen this net, check all childs if MAC exists 151 // we have already seen this net, check all childs if MAC exists
152 152
153 network = item; 153 network = item;
154 154
155 item = static_cast<MScanListItem*> ( item->firstChild() ); 155 item = static_cast<MScanListItem*> ( item->firstChild() );
156 assert( item ); // this shouldn't fail 156 assert( item ); // this shouldn't fail
157 157
158 while ( item && ( item->text( col_ap ) != macaddr ) ) 158 while ( item && ( item->text( col_ap ) != macaddr ) )
159 { 159 {
160 #ifdef DEBUG 160 #ifdef DEBUG
161 odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; 161 odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl;
162 #endif 162 #endif
163 item = static_cast<MScanListItem*> ( item->nextSibling() ); 163 item = static_cast<MScanListItem*> ( item->nextSibling() );
164 } 164 }
165 165
166 if ( item ) 166 if ( item )
167 { 167 {
168 // we have already seen this item, it's a dupe 168 // we have already seen this item, it's a dupe
169 #ifdef DEBUG 169 #ifdef DEBUG
170 odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; 170 odebug << "" << macaddr << " is a dupe - ignoring..." << oendl;
171 #endif 171 #endif
172 item->receivedBeacon(); 172 item->receivedBeacon();
173 return; 173 return;
174 } 174 }
175 } 175 }
176 else 176 else
177 { 177 {
178 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 178 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
179 MLogWindow::logwindow()->log( s ); 179 MLogWindow::logwindow()->log( s );
180 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); 180 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe );
181 } 181 }
182 182
183 183
184 // insert new station as child from network 184 // insert new station as child from network
185 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 185 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
186 186
187 #ifdef DEBUG 187 #ifdef DEBUG
188 odebug << "inserting new station " << macaddr << "" << oendl; 188 odebug << "inserting new station " << macaddr << "" << oendl;
189 #endif 189 #endif
190 190
191 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 191 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
192 station->setManufacturer( mac.manufacturer() ); 192 station->setManufacturer( mac.manufacturer() );
193 station->setLocation( loc.dmsPosition() ); 193 station->setLocation( loc.dmsPosition() );
194 194
195 if ( type == "managed" ) 195 if ( type == "managed" )
196 { 196 {
197 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 197 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
198 } 198 }
199 else 199 else
200 { 200 {
201 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 201 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
202 } 202 }
203 MLogWindow::logwindow()->log( s ); 203 MLogWindow::logwindow()->log( s );
204} 204}
205 205
206 206
207void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 207void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
208{ 208{
209 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 209 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
210 210
211 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 211 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
212 { 212 {
213 #ifdef DEBUG 213 #ifdef DEBUG
214 odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl; 214 odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl;
215 #endif 215 #endif
216 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 216 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
217 } 217 }
218 218
219 if ( subitem ) 219 if ( subitem )
220 { 220 {
221 // we have already seen this item, it's a dupe 221 // we have already seen this item, it's a dupe
222 #ifdef DEBUG 222 #ifdef DEBUG
223 odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl; 223 odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl;
224 #endif 224 #endif
225 subitem->receivedBeacon(); //FIXME: sent data bit 225 subitem->receivedBeacon(); //FIXME: sent data bit
226 return; 226 return;
227 } 227 }
228 228
229 // Hey, it seems to be a new item :-D 229 // Hey, it seems to be a new item :-D
230 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 230 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
231 station->setManufacturer( addr.manufacturer() ); 231 station->setManufacturer( addr.manufacturer() );
232 232
233 QString s; 233 QString s;
234 if ( type == "station" ) 234 if ( type == "station" )
235 { 235 {
236 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 236 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
237 } 237 }
238 else 238 else
239 { 239 {
240 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 240 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
241 } 241 }
242 MLogWindow::logwindow()->log( s ); 242 MLogWindow::logwindow()->log( s );
243} 243}
244 244
245 245
246void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) 246void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
247{ 247{
248 odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; 248 odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl;
249 QString s; 249 QString s;
250 MScanListItem* network; 250 MScanListItem* network;
251 251
252 QListViewItemIterator it( this ); 252 QListViewItemIterator it( this );
253 while ( it.current() && 253 while ( it.current() &&
254 it.current()->text( col_ap ) != viaFrom.toString(true) && 254 it.current()->text( col_ap ) != viaFrom.toString(true) &&
255 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; 255 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it;
256 256
257 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 257 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
258 258
259 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations 259 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations
260 { 260 {
261 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); 261 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
262 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); 262 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to );
263 } 263 }
264 else 264 else
265 { 265 {
266 odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; 266 odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl;
267 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); 267 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" );
268 } 268 }
269} 269}
270 270
271 271
272void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 272void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
273{ 273{
274 QString s; 274 QString s;
275 MScanListItem* network; 275 MScanListItem* network;
276 276
277 QListViewItemIterator it( this ); 277 QListViewItemIterator it( this );
278 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 278 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
279 279
280 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 280 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
281 281
282 if ( item ) // AP has shown up yet, so just add our new "from" - station 282 if ( item ) // AP has shown up yet, so just add our new "from" - station
283 { 283 {
284 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); 284 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" );
285 } 285 }
286 else 286 else
287 { 287 {
288 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; 288 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl;
289 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); 289 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
290 290
291 } 291 }
292} 292}
293 293
294 294
295void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 295void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
296{ 296{
297 QString s; 297 QString s;
298 MScanListItem* network; 298 MScanListItem* network;
299 299
300 QListViewItemIterator it( this ); 300 QListViewItemIterator it( this );
301 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 301 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
302 302
303 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 303 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
304 304
305 if ( item ) // AP has shown up yet, so just add our new "from" - station 305 if ( item ) // AP has shown up yet, so just add our new "from" - station
306 { 306 {
307 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); 307 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" );
308 } 308 }
309 else 309 else
310 { 310 {
311 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; 311 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl;
312 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); 312 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" );
313 } 313 }
314} 314}
315 315
316 316
317void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 317void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
318{ 318{
319 owarn << "D'oh! Not yet implemented..." << oendl; 319 owarn << "D'oh! Not yet implemented..." << oendl;
320 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); 320 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
321} 321}
322 322
323 323
324void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) 324void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
325{ 325{
326 odebug << "identify " << (const char*) macaddr.toString() << " = " << ip << "" << oendl; 326 odebug << "identify " << (const char*) macaddr.toString() << " = " << ip << "" << oendl;
327 327
328 QListViewItemIterator it( this ); 328 QListViewItemIterator it( this );
329 for ( ; it.current(); ++it ) 329 for ( ; it.current(); ++it )
330 { 330 {
331 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 331 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
332 { 332 {
333 it.current()->setText( col_ip, ip ); 333 it.current()->setText( col_ip, ip );
334 return; 334 return;
335 } 335 }
336 } 336 }
337 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; 337 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl;
338 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 338 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
339 (const char*) macaddr.toString(), (const char*) ip ) ); 339 (const char*) macaddr.toString(), (const char*) ip ) );
340} 340}
341 341
342 342
343void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) 343void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
344{ 344{
345 odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << ip << "" << oendl; 345 odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << ip << "" << oendl;
346 346
347 //TODO: Refactor that out, we need it all over the place. 347 //TODO: Refactor that out, we need it all over the place.
348 // Best to do it in a more comfortable abstraction in OListView 348 // Best to do it in a more comfortable abstraction in OListView
349 // (Hmm, didn't I already start something in this direction?) 349 // (Hmm, didn't I already start something in this direction?)
350 350
351 QListViewItemIterator it( this ); 351 QListViewItemIterator it( this );
352 for ( ; it.current(); ++it ) 352 for ( ; it.current(); ++it )
353 { 353 {
354 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 354 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
355 { 355 {
356 356
357 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); 357 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
358 358
359 while ( subitem && ( subitem->text( col_essid ) != name ) ) 359 while ( subitem && ( subitem->text( col_essid ) != name ) )
360 { 360 {
361 #ifdef DEBUG 361 #ifdef DEBUG
362 odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl; 362 odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl;
363 #endif 363 #endif
364 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 364 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
365 } 365 }
366 366
367 if ( subitem ) 367 if ( subitem )
368 { 368 {
369 // we have already seen this item, it's a dupe 369 // we have already seen this item, it's a dupe
370 #ifdef DEBUG 370 #ifdef DEBUG
371 odebug << "" << name << " is a dupe - ignoring..." << oendl; 371 odebug << "" << name << " is a dupe - ignoring..." << oendl;
372 #endif 372 #endif
373 subitem->receivedBeacon(); //FIXME: sent data bit 373 subitem->receivedBeacon(); //FIXME: sent data bit
374 return; 374 return;
375 } 375 }
376 376
377 // never seen that - add new item 377 // never seen that - add new item
378 378
379 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); 379 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 );
380 item->setText( col_essid, name ); 380 item->setText( col_essid, name );
381 381
382 return; 382 return;
383 } 383 }
384 } 384 }
385 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; 385 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl;
386 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", 386 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
387 (const char*) macaddr.toString(), (const char*) ip ) ); 387 (const char*) macaddr.toString(), (const char*) ip ) );
388} 388}
389 389
390 390
391void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) 391void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
392{ 392{
393 if ( !item ) return; 393 if ( !item ) return;
394 394
395 MScanListItem* itm = static_cast<MScanListItem*>( item ); 395 MScanListItem* itm = static_cast<MScanListItem*>( item );
396 396
397 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", 397 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
398 (const char*) itm->text(0), (const char*) itm->type, col ); 398 (const char*) itm->text(0), (const char*) itm->type, col );
399 399
400 if ( itm->type == "adhoc" || itm->type == "managed" ) 400 if ( itm->type == "adhoc" || itm->type == "managed" )
401 { 401 {
402 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); 402 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
403 403
404 QPopupMenu m( this ); 404 QPopupMenu m( this );
405 m.insertItem( entry, 37773, 0 ); 405 m.insertItem( entry, 37773, 0 );
406 int result = m.exec( QCursor::pos() ); 406 int result = m.exec( QCursor::pos() );
407 if ( result == 37773 ) 407 if ( result == 37773 )
408 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); 408 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
409 } 409 }
410} 410}
411 411
412//============================================================ 412//============================================================
413// MScanListItem 413// MScanListItem
414//============================================================ 414//============================================================
415 415
416MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, 416MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr,
417 bool wep, int channel, int signal, bool probed ) 417 bool wep, int channel, int signal, bool probed )
418 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 418 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
419 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 419 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
420 _channel( channel ), _signal( signal ), _beacons( 1 ) 420 _channel( channel ), _signal( signal ), _beacons( 1 )
421{ 421{
422 #ifdef DEBUG 422 #ifdef DEBUG
423 odebug << "creating scanlist item" << oendl; 423 odebug << "creating scanlist item" << oendl;
424 #endif 424 #endif
425 425
426 if ( WellenreiterConfigWindow::instance() ) 426 if ( WellenreiterConfigWindow::instance() )
427 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here 427 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
428 428
429 decorateItem( type, essid, macaddr, wep, channel, signal, probed ); 429 decorateItem( type, essid, macaddr, wep, channel, signal, probed );
430} 430}
431 431
432MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, 432MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr,
433 bool wep, int channel, int signal ) 433 bool wep, int channel, int signal )
434 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 434 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
435{ 435{
436 #ifdef DEBUG 436 #ifdef DEBUG
437 odebug << "creating scanlist item" << oendl; 437 odebug << "creating scanlist item" << oendl;
438 #endif 438 #endif
439 if ( WellenreiterConfigWindow::instance() ) 439 if ( WellenreiterConfigWindow::instance() )
440 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here 440 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
441 441
442 decorateItem( type, essid, macaddr, wep, channel, signal, false ); 442 decorateItem( type, essid, macaddr, wep, channel, signal, false );
443} 443}
444 444
445const QString& MScanListItem::essid() const 445const QString& MScanListItem::essid() const
446{ 446{
447 if ( type == "network" ) 447 if ( type == "network" )
448 return _essid; 448 return _essid;
449 else 449 else
450 return ( (MScanListItem*) parent() )->essid(); 450 return ( (MScanListItem*) parent() )->essid();
451} 451}
452 452
453OListViewItem* MScanListItem::childFactory() 453OListViewItem* MScanListItem::childFactory()
454{ 454{
455 return new MScanListItem( this ); 455 return new MScanListItem( this );
456} 456}
457 457
458void MScanListItem::serializeTo( QDataStream& s ) const 458void MScanListItem::serializeTo( QDataStream& s ) const
459{ 459{
460 #ifdef DEBUG 460 #ifdef DEBUG
461 odebug << "serializing MScanListItem" << oendl; 461 odebug << "serializing MScanListItem" << oendl;
462 #endif 462 #endif
463 OListViewItem::serializeTo( s ); 463 OListViewItem::serializeTo( s );
464 464
465 s << _type; 465 s << _type;
466 s << (Q_UINT8) ( _wep ? 'y' : 'n' ); 466 s << (Q_UINT8) ( _wep ? 'y' : 'n' );
467} 467}
468 468
469void MScanListItem::serializeFrom( QDataStream& s ) 469void MScanListItem::serializeFrom( QDataStream& s )
470{ 470{
471 #ifdef DEBUG 471 #ifdef DEBUG
472 odebug << "serializing MScanListItem" << oendl; 472 odebug << "serializing MScanListItem" << oendl;
473 #endif 473 #endif
474 OListViewItem::serializeFrom( s ); 474 OListViewItem::serializeFrom( s );
475 475
476 char wep; 476 Q_UINT8 wep;
477 s >> _type; 477 s >> _type;
478 s >> (Q_UINT8) wep; 478 s >> wep;
479 _wep = (wep == 'y'); 479 _wep = (wep == 'y');
480 480
481 QString name; 481 QString name;
482 name.sprintf( "wellenreiter/%s", (const char*) _type ); 482 name.sprintf( "wellenreiter/%s", (const char*) _type );
483 setPixmap( col_type, Resource::loadPixmap( name ) ); 483 setPixmap( col_type, Resource::loadPixmap( name ) );
484 if ( _wep ) 484 if ( _wep )
485 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 485 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
486 listView()->triggerUpdate(); 486 listView()->triggerUpdate();
487} 487}
488 488
489void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) 489void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed )
490{ 490{
491 #ifdef DEBUG 491 #ifdef DEBUG
492 qDebug( "decorating scanlist item %s / %s / %s [%d]", 492 qDebug( "decorating scanlist item %s / %s / %s [%d]",
493 (const char*) type, 493 (const char*) type,
494 (const char*) essid, 494 (const char*) essid,
495 (const char*) macaddr, 495 (const char*) macaddr,
496 channel ); 496 channel );
497 #endif 497 #endif
498 498
499 // set icon for managed or adhoc mode 499 // set icon for managed or adhoc mode
500 QString name; 500 QString name;
501 name.sprintf( "wellenreiter/%s", (const char*) type ); 501 name.sprintf( "wellenreiter/%s", (const char*) type );
502 setPixmap( col_type, Resource::loadPixmap( name ) ); 502 setPixmap( col_type, Resource::loadPixmap( name ) );
503 503
504 // special case for probed networks FIXME: This is ugly at present 504 // special case for probed networks FIXME: This is ugly at present
505 if ( type == "network" && probed ) 505 if ( type == "network" && probed )
506 { 506 {
507 setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); 507 setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) );
508 } 508 }
509 509
510 // set icon for wep (wireless encryption protocol) 510 // set icon for wep (wireless encryption protocol)
511 if ( wep ) 511 if ( wep )
512 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 512 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
513 513
514 // set channel and signal text 514 // set channel and signal text
515 515
516 if ( signal != -1 ) 516 if ( signal != -1 )
517 setText( col_sig, QString::number( signal ) ); 517 setText( col_sig, QString::number( signal ) );
518 if ( channel != -1 ) 518 if ( channel != -1 )
519 setText( col_channel, QString::number( channel ) ); 519 setText( col_channel, QString::number( channel ) );
520 520
521 setText( col_firstseen, QTime::currentTime().toString() ); 521 setText( col_firstseen, QTime::currentTime().toString() );
522 //setText( col_lastseen, QTime::currentTime().toString() ); 522 //setText( col_lastseen, QTime::currentTime().toString() );
523 523
524 listView()->triggerUpdate(); 524 listView()->triggerUpdate();
525 525
526 this->type = type; 526 this->type = type;
527 _type = type; 527 _type = type;
528 _essid = essid; 528 _essid = essid;
529 _macaddr = macaddr; 529 _macaddr = macaddr;
530 _channel = channel; 530 _channel = channel;
531 _beacons = 1; 531 _beacons = 1;
532 _signal = 0; 532 _signal = 0;
533 533
534 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) 534 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() )
535 { 535 {
536 listView()->ensureItemVisible( this ); 536 listView()->ensureItemVisible( this );
537 } 537 }
538 538
539} 539}
540 540
541 541
542void MScanListItem::setManufacturer( const QString& manufacturer ) 542void MScanListItem::setManufacturer( const QString& manufacturer )
543{ 543{
544 setText( col_manuf, manufacturer ); 544 setText( col_manuf, manufacturer );
545} 545}
546 546
547 547
548void MScanListItem::setLocation( const QString& location ) 548void MScanListItem::setLocation( const QString& location )
549{ 549{
550 setText( col_location, location ); 550 setText( col_location, location );
551} 551}
552 552
553 553
554void MScanListItem::receivedBeacon() 554void MScanListItem::receivedBeacon()
555{ 555{
556 _beacons++; 556 _beacons++;
557 #ifdef DEBUG 557 #ifdef DEBUG
558 odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl; 558 odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl;
559 #endif 559 #endif
560 setText( col_sig, QString::number( _beacons ) ); 560 setText( col_sig, QString::number( _beacons ) );
561 setText( col_lastseen, QTime::currentTime().toString() ); 561 setText( col_lastseen, QTime::currentTime().toString() );
562 562
563 MScanListItem* p = (MScanListItem*) parent(); 563 MScanListItem* p = (MScanListItem*) parent();
564 if ( p ) p->receivedBeacon(); 564 if ( p ) p->receivedBeacon();
565 565
566} 566}
567 567
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 822bde8..40cd105 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,725 +1,725 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12***********************************************************************/ 12***********************************************************************/
13 13
14#include "gps.h" 14#include "gps.h"
15#include "wellenreiter.h" 15#include "wellenreiter.h"
16#include "scanlist.h" 16#include "scanlist.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "packetview.h" 18#include "packetview.h"
19#include "configwindow.h" 19#include "configwindow.h"
20#include "statwindow.h" 20#include "statwindow.h"
21#include "graphwindow.h" 21#include "graphwindow.h"
22#include "protolistview.h" 22#include "protolistview.h"
23 23
24/* OPIE */ 24/* OPIE */
25#ifdef QWS 25#ifdef QWS
26#include <opie2/oapplication.h> 26#include <opie2/oapplication.h>
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/odevice.h> 28#include <opie2/odevice.h>
29#else 29#else
30#include <qapplication.h> 30#include <qapplication.h>
31#endif 31#endif
32#include <opie2/omanufacturerdb.h> 32#include <opie2/omanufacturerdb.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/opcap.h> 34#include <opie2/opcap.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36using namespace Opie::Core; 36using namespace Opie::Core;
37using namespace Opie::Net; 37using namespace Opie::Net;
38using namespace Opie::Ui; 38using namespace Opie::Ui;
39 39
40/* QT */ 40/* QT */
41#include <qcheckbox.h> 41#include <qcheckbox.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qdatetime.h> 43#include <qdatetime.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qobjectlist.h> 47#include <qobjectlist.h>
48#include <qregexp.h> 48#include <qregexp.h>
49#include <qspinbox.h> 49#include <qspinbox.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qtoolbutton.h> 51#include <qtoolbutton.h>
52#include <qmainwindow.h> 52#include <qmainwindow.h>
53 53
54/* STD */ 54/* STD */
55#include <assert.h> 55#include <assert.h>
56#include <errno.h> 56#include <errno.h>
57#include <unistd.h> 57#include <unistd.h>
58#include <string.h> 58#include <string.h>
59#include <sys/types.h> 59#include <sys/types.h>
60#include <stdlib.h> 60#include <stdlib.h>
61 61
62Wellenreiter::Wellenreiter( QWidget* parent ) 62Wellenreiter::Wellenreiter( QWidget* parent )
63 : WellenreiterBase( parent, 0, 0 ), 63 : WellenreiterBase( parent, 0, 0 ),
64 sniffing( false ), iface( 0 ), configwindow( 0 ) 64 sniffing( false ), iface( 0 ), configwindow( 0 )
65{ 65{
66 66
67 logwindow->log( "(i) Wellenreiter has been started." ); 67 logwindow->log( "(i) Wellenreiter has been started." );
68 68
69 // 69 //
70 // detect operating system 70 // detect operating system
71 // 71 //
72 72
73 #ifdef QWS 73 #ifdef QWS
74 QString sys; 74 QString sys;
75 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 75 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
76 _system = ODevice::inst()->system(); 76 _system = ODevice::inst()->system();
77 logwindow->log( sys ); 77 logwindow->log( sys );
78 #endif 78 #endif
79 79
80 netview->setColumnWidthMode( 1, QListView::Manual ); 80 netview->setColumnWidthMode( 1, QListView::Manual );
81 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 81 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
82 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 82 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
83 pcap = new OPacketCapturer(); 83 pcap = new OPacketCapturer();
84 pcap->setAutoDelete( false ); 84 pcap->setAutoDelete( false );
85 85
86 gps = new GPS( this ); 86 gps = new GPS( this );
87 87
88 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); 88 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
89 89
90} 90}
91 91
92 92
93Wellenreiter::~Wellenreiter() 93Wellenreiter::~Wellenreiter()
94{ 94{
95 delete pcap; 95 delete pcap;
96} 96}
97 97
98 98
99void Wellenreiter::initialTimer() 99void Wellenreiter::initialTimer()
100{ 100{
101 odebug << "Wellenreiter::preloading manufacturer database..." << oendl; 101 odebug << "Wellenreiter::preloading manufacturer database..." << oendl;
102 OManufacturerDB::instance(); 102 OManufacturerDB::instance();
103} 103}
104 104
105 105
106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
107{ 107{
108 configwindow = cw; 108 configwindow = cw;
109} 109}
110 110
111 111
112void Wellenreiter::channelHopped(int c) 112void Wellenreiter::channelHopped(int c)
113{ 113{
114 QString title = "Wellenreiter II -scan- ["; 114 QString title = "Wellenreiter II -scan- [";
115 QString left; 115 QString left;
116 if ( c > 1 ) left.fill( '.', c-1 ); 116 if ( c > 1 ) left.fill( '.', c-1 );
117 title.append( left ); 117 title.append( left );
118 title.append( '|' ); 118 title.append( '|' );
119 if ( c < iface->channels() ) 119 if ( c < iface->channels() )
120 { 120 {
121 QString right; 121 QString right;
122 right.fill( '.', iface->channels()-c ); 122 right.fill( '.', iface->channels()-c );
123 title.append( right ); 123 title.append( right );
124 } 124 }
125 title.append( "]" ); 125 title.append( "]" );
126 //title.append( QString().sprintf( " %02d", c ) ); 126 //title.append( QString().sprintf( " %02d", c ) );
127 assert( parent() ); 127 assert( parent() );
128 ( (QMainWindow*) parent() )->setCaption( title ); 128 ( (QMainWindow*) parent() )->setCaption( title );
129} 129}
130 130
131 131
132void Wellenreiter::handleNotification( OPacket* p ) 132void Wellenreiter::handleNotification( OPacket* p )
133{ 133{
134 QObjectList* l = p->queryList(); 134 QObjectList* l = p->queryList();
135 QObjectListIt it( *l ); 135 QObjectListIt it( *l );
136 QObject* o; 136 QObject* o;
137 137
138 while ( (o = it.current()) != 0 ) 138 while ( (o = it.current()) != 0 )
139 { 139 {
140 QString name = it.current()->name(); 140 QString name = it.current()->name();
141 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 141 if ( configwindow->parsePackets->isProtocolChecked( name ) )
142 { 142 {
143 QString action = configwindow->parsePackets->protocolAction( name ); 143 QString action = configwindow->parsePackets->protocolAction( name );
144 odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 144 odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl;
145 doAction( action, name, p ); 145 doAction( action, name, p );
146 } 146 }
147 else 147 else
148 { 148 {
149 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; 149 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl;
150 } 150 }
151 ++it; 151 ++it;
152 } 152 }
153} 153}
154 154
155 155
156void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 156void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
157{ 157{
158 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); 158 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
159 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); 159 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
160 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); 160 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
161 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl; 161 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl;
162} 162}
163 163
164 164
165void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) 165void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request )
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( true /* decloak */ ) : QString("<unknown>"); 168 QString essid = ssid ? ssid->ID( true /* decloak */ ) : 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 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 171 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
172 172
173 GpsLocation loc( -111, -111 ); 173 GpsLocation loc( -111, -111 );
174 if ( configwindow->enableGPS->isChecked() ) 174 if ( configwindow->enableGPS->isChecked() )
175 { 175 {
176 // TODO: add check if GPS is working!? 176 // TODO: add check if GPS is working!?
177 odebug << "Wellenreiter::gathering GPS data..." << oendl; 177 odebug << "Wellenreiter::gathering GPS data..." << oendl;
178 loc = gps->position(); 178 loc = gps->position();
179 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 179 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
180 } 180 }
181 181
182 if ( essid.length() ) 182 if ( essid.length() )
183 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); 183 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
184 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 184 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
185} 185}
186 186
187 187
188void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) 188void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response )
189{ 189{
190} 190}
191 191
192 192
193void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 193void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
194{ 194{
195 QString type; 195 QString type;
196 if ( beacon->canIBSS() ) 196 if ( beacon->canIBSS() )
197 { 197 {
198 type = "adhoc"; 198 type = "adhoc";
199 } 199 }
200 else if ( beacon->canESS() ) 200 else if ( beacon->canESS() )
201 { 201 {
202 type = "managed"; 202 type = "managed";
203 } 203 }
204 else 204 else
205 { 205 {
206 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 206 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
207 return; 207 return;
208 } 208 }
209 209
210 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 210 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
211 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 211 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
212 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 212 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
213 int channel = ds ? ds->channel() : -1; 213 int channel = ds ? ds->channel() : -1;
214 214
215 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 215 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
216 216
217 GpsLocation loc( -111, -111 ); 217 GpsLocation loc( -111, -111 );
218 if ( configwindow->enableGPS->isChecked() ) 218 if ( configwindow->enableGPS->isChecked() )
219 { 219 {
220 // TODO: add check if GPS is working!? 220 // TODO: add check if GPS is working!?
221 odebug << "Wellenreiter::gathering GPS data..." << oendl; 221 odebug << "Wellenreiter::gathering GPS data..." << oendl;
222 loc = gps->position(); 222 loc = gps->position();
223 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 223 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
224 } 224 }
225 225
226 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 226 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
227 227
228 // update graph window 228 // update graph window
229 if ( ds ) 229 if ( ds )
230 { 230 {
231 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 231 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
232 if ( prism ) 232 if ( prism )
233 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 233 graphwindow->traffic( ds->channel(), prism->signalStrength() );
234 else 234 else
235 graphwindow->traffic( ds->channel(), 95 ); 235 graphwindow->traffic( ds->channel(), 95 );
236 } 236 }
237} 237}
238 238
239 239
240void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) 240void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
241{ 241{
242 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 242 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
243 243
244 if ( control->controlType() == "Acknowledge" ) 244 if ( control->controlType() == "Acknowledge" )
245 { 245 {
246 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 246 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
247 } 247 }
248 else 248 else
249 { 249 {
250 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl; 250 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl;
251 } 251 }
252} 252}
253 253
254 254
255void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 255void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
256{ 256{
257 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 257 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
258 if ( wlan->fromDS() && !wlan->toDS() ) 258 if ( wlan->fromDS() && !wlan->toDS() )
259 { 259 {
260 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 260 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
261 from = wlan->macAddress3(); 261 from = wlan->macAddress3();
262 to = wlan->macAddress2(); 262 to = wlan->macAddress2();
263 } 263 }
264 else if ( !wlan->fromDS() && wlan->toDS() ) 264 else if ( !wlan->fromDS() && wlan->toDS() )
265 { 265 {
266 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 266 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
267 from = wlan->macAddress2(); 267 from = wlan->macAddress2();
268 to = wlan->macAddress3(); 268 to = wlan->macAddress3();
269 } 269 }
270 else if ( wlan->fromDS() && wlan->toDS() ) 270 else if ( wlan->fromDS() && wlan->toDS() )
271 { 271 {
272 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 272 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
273 from = wlan->macAddress4(); 273 from = wlan->macAddress4();
274 to = wlan->macAddress3(); 274 to = wlan->macAddress3();
275 } 275 }
276 else 276 else
277 { 277 {
278 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 278 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
279 from = wlan->macAddress2(); 279 from = wlan->macAddress2();
280 to = wlan->macAddress1(); 280 to = wlan->macAddress1();
281 } 281 }
282} 282}
283 283
284 284
285void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 285void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
286{ 286{
287 from = data->sourceAddress(); 287 from = data->sourceAddress();
288 to = data->destinationAddress(); 288 to = data->destinationAddress();
289 289
290 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 290 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
291} 291}
292 292
293 293
294void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 294void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
295{ 295{
296 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 296 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
297 if ( arp ) 297 if ( arp )
298 { 298 {
299 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl; 299 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl;
300 if ( arp->type() == "REQUEST" ) 300 if ( arp->type() == "REQUEST" )
301 { 301 {
302 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 302 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
303 } 303 }
304 else if ( arp->type() == "REPLY" ) 304 else if ( arp->type() == "REPLY" )
305 { 305 {
306 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 306 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
307 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 307 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
308 } 308 }
309 } 309 }
310} 310}
311 311
312 312
313void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 313void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
314{ 314{
315 //TODO: Implement more IP based protocols 315 //TODO: Implement more IP based protocols
316 316
317 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 317 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
318 if ( dhcp ) 318 if ( dhcp )
319 { 319 {
320 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl; 320 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl;
321 if ( dhcp->type() == "OFFER" ) 321 if ( dhcp->type() == "OFFER" )
322 { 322 {
323 odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; 323 odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl;
324 netView()->identify( source, dhcp->serverAddress().toString() ); 324 netView()->identify( source, dhcp->serverAddress().toString() );
325 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 325 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
326 } 326 }
327 else if ( dhcp->type() == "ACK" ) 327 else if ( dhcp->type() == "ACK" )
328 { 328 {
329 odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; 329 odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl;
330 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 330 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
331 } 331 }
332 } 332 }
333} 333}
334 334
335 335
336QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 336QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
337{ 337{
338 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 338 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
339 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 339 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
340 return 0; 340 return 0;
341 341
342 return p->child( protocol ); 342 return p->child( protocol );
343} 343}
344 344
345 345
346bool Wellenreiter::checkDumpPacket( OPacket* p ) 346bool Wellenreiter::checkDumpPacket( OPacket* p )
347{ 347{
348 // go through all child packets and see if one is inside the child hierarchy for p 348 // go through all child packets and see if one is inside the child hierarchy for p
349 // if so, do what the user requested (protocolAction), e.g. pass or discard 349 // if so, do what the user requested (protocolAction), e.g. pass or discard
350 if ( !configwindow->writeCaptureFile->isChecked() ) 350 if ( !configwindow->writeCaptureFile->isChecked() )
351 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 351 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
352 352
353 QObjectList* l = p->queryList(); 353 QObjectList* l = p->queryList();
354 QObjectListIt it( *l ); 354 QObjectListIt it( *l );
355 QObject* o; 355 QObject* o;
356 356
357 while ( (o = it.current()) != 0 ) 357 while ( (o = it.current()) != 0 )
358 { 358 {
359 QString name = it.current()->name(); 359 QString name = it.current()->name();
360 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 360 if ( configwindow->capturePackets->isProtocolChecked( name ) )
361 { 361 {
362 QString action = configwindow->capturePackets->protocolAction( name ); 362 QString action = configwindow->capturePackets->protocolAction( name );
363 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 363 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl;
364 if ( action == "Discard" ) 364 if ( action == "Discard" )
365 { 365 {
366 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 366 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
367 return false; 367 return false;
368 } 368 }
369 } 369 }
370 else 370 else
371 { 371 {
372 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; 372 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl;
373 } 373 }
374 ++it; 374 ++it;
375 } 375 }
376 return true; 376 return true;
377} 377}
378 378
379 379
380void Wellenreiter::receivePacket( OPacket* p ) 380void Wellenreiter::receivePacket( OPacket* p )
381{ 381{
382 hexWindow()->add( p ); 382 hexWindow()->add( p );
383 383
384 if ( checkDumpPacket( p ) ) 384 if ( checkDumpPacket( p ) )
385 { 385 {
386 pcap->dump( p ); 386 pcap->dump( p );
387 } 387 }
388 388
389 // check for a management frame 389 // check for a management frame
390 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 390 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
391 if ( manage ) 391 if ( manage )
392 { 392 {
393 handleManagementFrame( p, manage ); 393 handleManagementFrame( p, manage );
394 return; 394 return;
395 } 395 }
396 396
397 // check for a control frame 397 // check for a control frame
398 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 398 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
399 if ( control ) 399 if ( control )
400 { 400 {
401 handleControlFrame( p, control ); 401 handleControlFrame( p, control );
402 return; 402 return;
403 } 403 }
404 404
405 OMacAddress source; 405 OMacAddress source;
406 OMacAddress dest; 406 OMacAddress dest;
407 407
408 //TODO: WEP check here 408 //TODO: WEP check here
409 409
410 // check for a wireless data frame 410 // check for a wireless data frame
411 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 411 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
412 if ( wlan ) 412 if ( wlan )
413 { 413 {
414 handleWlanData( p, wlan, source, dest ); 414 handleWlanData( p, wlan, source, dest );
415 } 415 }
416 416
417 // check for a wired data frame 417 // check for a wired data frame
418 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 418 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
419 if ( eth ) 419 if ( eth )
420 { 420 {
421 handleEthernetData( p, eth, source, dest ); 421 handleEthernetData( p, eth, source, dest );
422 } 422 }
423 423
424 // check for an arp frame since arp frames come in two flavours: 424 // check for an arp frame since arp frames come in two flavours:
425 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 425 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
426 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 426 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
427 if ( arp ) 427 if ( arp )
428 { 428 {
429 handleARPData( p, arp, source, dest ); 429 handleARPData( p, arp, source, dest );
430 } 430 }
431 431
432 // check for a ip frame 432 // check for a ip frame
433 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 433 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
434 if ( ip ) 434 if ( ip )
435 { 435 {
436 handleIPData( p, ip, source, dest ); 436 handleIPData( p, ip, source, dest );
437 } 437 }
438 438
439 //handleNotification( p ); 439 //handleNotification( p );
440 440
441} 441}
442 442
443 443
444void Wellenreiter::stopClicked() 444void Wellenreiter::stopClicked()
445{ 445{
446 if ( iface ) 446 if ( iface )
447 { 447 {
448 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 448 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
449 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 449 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
450 iface->setChannelHopping(); // stop hopping channels 450 iface->setChannelHopping(); // stop hopping channels
451 } 451 }
452 else 452 else
453 killTimers(); 453 killTimers();
454 454
455 pcap->close(); 455 pcap->close();
456 sniffing = false; 456 sniffing = false;
457 457
458 if ( iface ) 458 if ( iface )
459 { 459 {
460 // switch off monitor mode 460 // switch off monitor mode
461 iface->setMode( "managed" ); 461 iface->setMode( "managed" );
462 // switch off promisc flag 462 // switch off promisc flag
463 iface->setPromiscuousMode( false ); 463 iface->setPromiscuousMode( false );
464 464
465 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 465 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
466 } 466 }
467 467
468 logwindow->log( "(i) Stopped Scanning." ); 468 logwindow->log( "(i) Stopped Scanning." );
469 assert( parent() ); 469 assert( parent() );
470 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 470 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
471 471
472 // message the user 472 // message the user
473 QMessageBox::information( this, "Wellenreiter II", 473 QMessageBox::information( this, "Wellenreiter II",
474 tr( "Your wireless card\nshould now be usable again." ) ); 474 tr( "Your wireless card\nshould now be usable again." ) );
475 475
476 sniffing = false; 476 sniffing = false;
477 emit( stoppedSniffing() ); 477 emit( stoppedSniffing() );
478 478
479 #ifdef QWS 479 #ifdef QWS
480 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 480 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
481 { 481 {
482 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 482 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
483 } 483 }
484 #else 484 #else
485 #warning FIXME: setScreenSaverMode is not operational on the X11 build 485 #warning FIXME: setScreenSaverMode is not operational on the X11 build
486 #endif 486 #endif
487 487
488 // print out statistics 488 // print out statistics
489 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 489 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
490 statwindow->updateCounter( it.key(), it.data() ); 490 statwindow->updateCounter( it.key(), it.data() );
491} 491}
492 492
493 493
494void Wellenreiter::startClicked() 494void Wellenreiter::startClicked()
495{ 495{
496 // get configuration from config window 496 // get configuration from config window
497 497
498 const QString& interface = configwindow->interfaceName->currentText(); 498 const QString& interface = configwindow->interfaceName->currentText();
499 const int cardtype = configwindow->driverType(); 499 const int cardtype = configwindow->driverType();
500 const int interval = configwindow->hoppingInterval(); 500 const int interval = configwindow->hoppingInterval();
501 501
502 if ( ( interface == "" ) || ( cardtype == 0 ) ) 502 if ( ( interface == "" ) || ( cardtype == 0 ) )
503 { 503 {
504 QMessageBox::information( this, "Wellenreiter II", 504 QMessageBox::information( this, "Wellenreiter II",
505 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 505 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
506 return; 506 return;
507 } 507 }
508 508
509 // configure device 509 // configure device
510 ONetwork* net = ONetwork::instance(); 510 ONetwork* net = ONetwork::instance();
511 511
512 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 512 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
513 513
514 if ( cardtype != DEVTYPE_FILE ) 514 if ( cardtype != DEVTYPE_FILE )
515 { 515 {
516 516
517 if ( !net->isPresent( interface ) ) 517 if ( !net->isPresent( interface ) )
518 { 518 {
519 QMessageBox::information( this, "Wellenreiter II", 519 QMessageBox::information( this, "Wellenreiter II",
520 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); 520 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
521 return; 521 return;
522 } 522 }
523 523
524 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 524 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
525 assert( iface ); 525 assert( iface );
526 526
527 // bring device UP 527 // bring device UP
528 iface->setUp( true ); 528 iface->setUp( true );
529 if ( !iface->isUp() ) 529 if ( !iface->isUp() )
530 { 530 {
531 QMessageBox::warning( this, "Wellenreiter II", 531 QMessageBox::warning( this, "Wellenreiter II",
532 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 532 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
533 return; 533 return;
534 } 534 }
535 } 535 }
536 // set monitor mode 536 // set monitor mode
537 bool usePrism = configwindow->usePrismHeader(); 537 bool usePrism = configwindow->usePrismHeader();
538 538
539 switch ( cardtype ) 539 switch ( cardtype )
540 { 540 {
541 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 541 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
542 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 542 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
543 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 543 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
544 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 544 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
545 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 545 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
546 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break; 546 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break;
547 default: assert( 0 ); // shouldn't reach this 547 default: assert( 0 ); // shouldn't reach this
548 } 548 }
549 549
550 // switch device into monitor mode 550 // switch device into monitor mode
551 if ( cardtype < DEVTYPE_FILE ) 551 if ( cardtype < DEVTYPE_FILE )
552 { 552 {
553 if ( cardtype != DEVTYPE_MANUAL ) 553 if ( cardtype != DEVTYPE_MANUAL )
554 iface->setMode( "monitor" ); 554 iface->setMode( "monitor" );
555 if ( iface->mode() != "monitor" ) 555 if ( iface->mode() != "monitor" )
556 { 556 {
557 if ( QMessageBox::warning( this, "Wellenreiter II", 557 if ( QMessageBox::warning( this, "Wellenreiter II",
558 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 558 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
559 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 559 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
560 return; 560 return;
561 } 561 }
562 } 562 }
563 563
564 // open GPS device 564 // open GPS device
565 if ( configwindow->enableGPS->isChecked() ) 565 if ( configwindow->enableGPS->isChecked() )
566 { 566 {
567 odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; 567 odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl;
568 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 568 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
569 } 569 }
570 570
571 // open pcap and start sniffing 571 // open pcap and start sniffing
572 572
573 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 573 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
574 { 574 {
575 dumpname = configwindow->captureFileName->text(); 575 dumpname = configwindow->captureFileName->text();
576 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 576 if ( dumpname.isEmpty() ) dumpname = "captureFile";
577 dumpname.append( '-' ); 577 dumpname.append( '-' );
578 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 578 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
579 dumpname.append( ".wellenreiter" ); 579 dumpname.append( ".wellenreiter" );
580 } 580 }
581 else // write it anyway ;) 581 else // write it anyway ;)
582 { 582 {
583 dumpname = "/var/log/dump.wellenreiter"; 583 dumpname = "/var/log/dump.wellenreiter";
584 } 584 }
585 585
586 if ( cardtype != DEVTYPE_FILE ) 586 if ( cardtype != DEVTYPE_FILE )
587 pcap->open( interface ); 587 pcap->open( interface );
588 else 588 else
589 pcap->open( QFile( interface ) ); 589 pcap->openCaptureFile( interface );
590 590
591 odebug << "Wellenreiter:: dumping to " << dumpname << "" << oendl; 591 odebug << "Wellenreiter:: dumping to " << dumpname << "" << oendl;
592 pcap->openDumpFile( dumpname ); 592 pcap->openDumpFile( dumpname );
593 593
594 if ( !pcap->isOpen() ) 594 if ( !pcap->isOpen() )
595 { 595 {
596 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 596 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
597 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 597 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
598 return; 598 return;
599 } 599 }
600 600
601 // set capturer to non-blocking mode 601 // set capturer to non-blocking mode
602 pcap->setBlocking( false ); 602 pcap->setBlocking( false );
603 603
604 // start channel hopper 604 // start channel hopper
605 if ( cardtype != DEVTYPE_FILE ) 605 if ( cardtype != DEVTYPE_FILE )
606 { 606 {
607 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 607 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
608 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 608 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
609 } 609 }
610 610
611 if ( cardtype != DEVTYPE_FILE ) 611 if ( cardtype != DEVTYPE_FILE )
612 { 612 {
613 // connect socket notifier and start channel hopper 613 // connect socket notifier and start channel hopper
614 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 614 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
615 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 615 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
616 } 616 }
617 else 617 else
618 { 618 {
619 // start timer for reading packets 619 // start timer for reading packets
620 startTimer( 100 ); 620 startTimer( 100 );
621 } 621 }
622 622
623 logwindow->log( "(i) Started Scanning." ); 623 logwindow->log( "(i) Started Scanning." );
624 sniffing = true; 624 sniffing = true;
625 625
626 #ifdef QWS 626 #ifdef QWS
627 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 627 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
628 { 628 {
629 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 629 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
630 } 630 }
631 #else 631 #else
632 #warning FIXME: setScreenSaverMode is not operational on the X11 build 632 #warning FIXME: setScreenSaverMode is not operational on the X11 build
633 #endif 633 #endif
634 634
635 emit( startedSniffing() ); 635 emit( startedSniffing() );
636 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 636 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
637 else 637 else
638 { 638 {
639 assert( parent() ); 639 assert( parent() );
640 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 640 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
641 } 641 }
642} 642}
643 643
644 644
645void Wellenreiter::timerEvent( QTimerEvent* ) 645void Wellenreiter::timerEvent( QTimerEvent* )
646{ 646{
647 odebug << "Wellenreiter::timerEvent()" << oendl; 647 odebug << "Wellenreiter::timerEvent()" << oendl;
648 OPacket* p = pcap->next(); 648 OPacket* p = pcap->next();
649 if ( !p ) // no more packets available 649 if ( !p ) // no more packets available
650 { 650 {
651 stopClicked(); 651 stopClicked();
652 } 652 }
653 else 653 else
654 { 654 {
655 receivePacket( p ); 655 receivePacket( p );
656 // We no longer delete packets here. Ownership of the packets is 656 // We no longer delete packets here. Ownership of the packets is
657 // transferred to the PacketView. 657 // transferred to the PacketView.
658 //delete p; 658 //delete p;
659 } 659 }
660} 660}
661 661
662 662
663void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 663void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
664{ 664{
665 #ifdef QWS 665 #ifdef QWS
666 if ( action == "TouchSound" ) 666 if ( action == "TouchSound" )
667 ODevice::inst()->playTouchSound(); 667 ODevice::inst()->playTouchSound();
668 else if ( action == "AlarmSound" ) 668 else if ( action == "AlarmSound" )
669 ODevice::inst()->playAlarmSound(); 669 ODevice::inst()->playAlarmSound();
670 else if ( action == "KeySound" ) 670 else if ( action == "KeySound" )
671 ODevice::inst()->playKeySound(); 671 ODevice::inst()->playKeySound();
672 else if ( action == "LedOn" ) 672 else if ( action == "LedOn" )
673 ODevice::inst()->setLedState( Led_Mail, Led_On ); 673 ODevice::inst()->setLedState( Led_Mail, Led_On );
674 else if ( action == "LedOff" ) 674 else if ( action == "LedOff" )
675 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 675 ODevice::inst()->setLedState( Led_Mail, Led_Off );
676 else if ( action == "LogMessage" ) 676 else if ( action == "LogMessage" )
677 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 677 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
678 else if ( action == "MessageBox" ) 678 else if ( action == "MessageBox" )
679 QMessageBox::information( this, "Notification!", 679 QMessageBox::information( this, "Notification!",
680 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 680 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
681 #else 681 #else
682 #warning Actions do not work with Qt/X11 yet 682 #warning Actions do not work with Qt/X11 yet
683 #endif 683 #endif
684} 684}
685 685
686void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 686void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
687{ 687{
688 #ifdef QWS 688 #ifdef QWS
689 if ( !iface ) 689 if ( !iface )
690 { 690 {
691 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 691 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
692 return; 692 return;
693 } 693 }
694 694
695 if ( sniffing ) 695 if ( sniffing )
696 { 696 {
697 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 697 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
698 return; 698 return;
699 } 699 }
700 700
701 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 701 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
702 (const char*) iface->name(), 702 (const char*) iface->name(),
703 (const char*) type, 703 (const char*) type,
704 (const char*) essid, 704 (const char*) essid,
705 channel, 705 channel,
706 (const char*) macaddr ); 706 (const char*) macaddr );
707 707
708 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 708 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
709 int count = 3; 709 int count = 3;
710 odebug << "sending " << count << " messages" << oendl; 710 odebug << "sending " << count << " messages" << oendl;
711 msg << QString("count") << QString::number(count); 711 msg << QString("count") << QString::number(count);
712 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; 712 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl;
713 msg << QString(iface->name()) << QString("Mode") << type; 713 msg << QString(iface->name()) << QString("Mode") << type;
714 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; 714 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl;
715 msg << QString(iface->name()) << QString("ESSID") << essid; 715 msg << QString(iface->name()) << QString("ESSID") << essid;
716 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; 716 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl;
717 msg << QString(iface->name()) << QString("Channel") << channel; 717 msg << QString(iface->name()) << QString("Channel") << channel;
718// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; 718// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl;
719// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 719// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
720 #else 720 #else
721 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 721 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
722 #endif 722 #endif
723 723
724} 724}
725 725