summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp90
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h10
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp28
3 files changed, 85 insertions, 43 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index a8cadd8..7733934 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -2,364 +2,398 @@
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#include "scanlist.h" 16#include "scanlist.h"
17#include "configwindow.h" 17#include "configwindow.h"
18 18
19#include <assert.h> 19#include <assert.h>
20#include "manufacturers.h" 20#include "manufacturers.h"
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qtextstream.h> 22#include <qtextstream.h>
23 23
24#ifdef QWS 24#ifdef QWS
25#include <opie/odevice.h> 25#include <opie/odevice.h>
26using namespace Opie; 26using namespace Opie;
27#endif 27#endif
28 28
29 29
30#ifdef QWS 30#ifdef QWS
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#else 32#else
33#include "resource.h" 33#include "resource.h"
34#endif 34#endif
35 35
36const int col_type = 0; 36const int col_type = 0;
37const int col_essid = 0; 37const int col_essid = 0;
38const int col_sig = 1; 38const int col_sig = 1;
39const int col_ap = 2; 39const int col_ap = 2;
40const int col_channel = 3; 40const int col_channel = 3;
41const int col_wep = 4; 41const int col_wep = 4;
42const int col_traffic = 5; 42const int col_traffic = 5;
43const int col_manuf = 6; 43const int col_manuf = 6;
44const int col_firstseen = 7; 44const int col_firstseen = 7;
45const int col_lastseen = 8; 45const int col_lastseen = 8;
46 46
47MScanListView::MScanListView( QWidget* parent, const char* name ) 47MScanListView::MScanListView( QWidget* parent, const char* name )
48 :OListView( parent, name ), _manufacturerdb( 0 ) 48 :OListView( parent, name ), _manufacturerdb( 0 )
49{ 49{
50 50
51 setFrameShape( QListView::StyledPanel ); 51 setFrameShape( QListView::StyledPanel );
52 setFrameShadow( QListView::Sunken ); 52 setFrameShadow( QListView::Sunken );
53 53
54 addColumn( tr( "Net/Station" ) ); 54 addColumn( tr( "Net/Station" ) );
55 setColumnAlignment( 0, AlignLeft || AlignVCenter ); 55 setColumnAlignment( 0, AlignLeft || AlignVCenter );
56 addColumn( tr( "B" ) ); 56 addColumn( tr( "B" ) );
57 setColumnAlignment( 1, AlignCenter ); 57 setColumnAlignment( 1, AlignCenter );
58 addColumn( tr( "AP" ) ); 58 addColumn( tr( "AP" ) );
59 setColumnAlignment( 2, AlignCenter ); 59 setColumnAlignment( 2, AlignCenter );
60 addColumn( tr( "Chn" ) ); 60 addColumn( tr( "Chn" ) );
61 setColumnAlignment( 3, AlignCenter ); 61 setColumnAlignment( 3, AlignCenter );
62 addColumn( tr( "W" ) ); 62 addColumn( tr( "W" ) );
63 setColumnAlignment( 4, AlignCenter ); 63 setColumnAlignment( 4, AlignCenter );
64 addColumn( tr( "T" ) ); 64 addColumn( tr( "T" ) );
65 setColumnAlignment( 5, AlignCenter ); 65 setColumnAlignment( 5, AlignCenter );
66 addColumn( tr( "Manufacturer" ) ); 66 addColumn( tr( "Manufacturer" ) );
67 setColumnAlignment( 6, AlignCenter ); 67 setColumnAlignment( 6, AlignCenter );
68 addColumn( tr( "First Seen" ) ); 68 addColumn( tr( "First Seen" ) );
69 setColumnAlignment( 7, AlignCenter ); 69 setColumnAlignment( 7, AlignCenter );
70 addColumn( tr( "Last Seen" ) ); 70 addColumn( tr( "Last Seen" ) );
71 setColumnAlignment( 8, AlignCenter ); 71 setColumnAlignment( 8, AlignCenter );
72 setRootIsDecorated( true ); 72 setRootIsDecorated( true );
73 setAllColumnsShowFocus( true ); 73 setAllColumnsShowFocus( true );
74}; 74};
75 75
76MScanListView::~MScanListView() 76MScanListView::~MScanListView()
77{ 77{
78}; 78};
79 79
80OListViewItem* MScanListView::childFactory() 80OListViewItem* MScanListView::childFactory()
81{ 81{
82 return new MScanListItem( this ); 82 return new MScanListItem( this );
83} 83}
84 84
85void MScanListView::serializeTo( QDataStream& s) const 85void MScanListView::serializeTo( QDataStream& s) const
86{ 86{
87 qDebug( "serializing MScanListView" ); 87 qDebug( "serializing MScanListView" );
88 OListView::serializeTo( s ); 88 OListView::serializeTo( s );
89} 89}
90 90
91void MScanListView::serializeFrom( QDataStream& s) 91void MScanListView::serializeFrom( QDataStream& s)
92{ 92{
93 qDebug( "serializing MScanListView" ); 93 qDebug( "serializing MScanListView" );
94 OListView::serializeFrom( s ); 94 OListView::serializeFrom( s );
95} 95}
96 96
97void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) 97void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
98{ 98{
99 _manufacturerdb = manufacturerdb; 99 _manufacturerdb = manufacturerdb;
100} 100}
101 101
102void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 102void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
103{ 103{
104 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 104 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
105 105
106 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", 106 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]",
107 (const char*) type, 107 (const char*) type,
108 (const char*) essid, 108 (const char*) essid,
109 (const char*) macaddr, 109 (const char*) macaddr,
110 channel ); 110 channel );
111 111
112 // search, if we already have seen this net 112 // search, if we already have seen this net
113 113
114 QString s; 114 QString s;
115 MScanListItem* network; 115 MScanListItem* network;
116 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 116 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
117 117
118 while ( item && ( item->text( 0 ) != essid ) ) 118 while ( item && ( item->text( 0 ) != essid ) )
119 { 119 {
120 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 120 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
121 item = static_cast<MScanListItem*> ( item->itemBelow() ); 121 item = static_cast<MScanListItem*> ( item->itemBelow() );
122 } 122 }
123 if ( item ) 123 if ( item )
124 { 124 {
125 // animate the item 125 // animate the item
126 126
127 /* 127 /*
128 128
129 const QPixmap* pixmap = item->pixmap( 0 ); 129 const QPixmap* pixmap = item->pixmap( 0 );
130 const QPixmap* nextpixmap = ani2; 130 const QPixmap* nextpixmap = ani2;
131 if ( pixmap == ani1 ) 131 if ( pixmap == ani1 )
132 nextpixmap = ani2; 132 nextpixmap = ani2;
133 else if ( pixmap == ani2 ) 133 else if ( pixmap == ani2 )
134 nextpixmap = ani3; 134 nextpixmap = ani3;
135 else if ( pixmap == ani3 ) 135 else if ( pixmap == ani3 )
136 nextpixmap = ani4; 136 nextpixmap = ani4;
137 else if ( pixmap == ani4 ) 137 else if ( pixmap == ani4 )
138 nextpixmap = ani1; 138 nextpixmap = ani1;
139 item->setPixmap( 0, *nextpixmap ); */ 139 item->setPixmap( 0, *nextpixmap ); */
140 140
141 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); 141 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
142 142
143 // we have already seen this net, check all childs if MAC exists 143 // we have already seen this net, check all childs if MAC exists
144 144
145 network = item; 145 network = item;
146 146
147 item = static_cast<MScanListItem*> ( item->firstChild() ); 147 item = static_cast<MScanListItem*> ( item->firstChild() );
148 assert( item ); // this shouldn't fail 148 assert( item ); // this shouldn't fail
149 149
150 while ( item && ( item->text( 2 ) != macaddr ) ) 150 while ( item && ( item->text( 2 ) != macaddr ) )
151 { 151 {
152 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 152 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
153 item = static_cast<MScanListItem*> ( item->itemBelow() ); 153 item = static_cast<MScanListItem*> ( item->itemBelow() );
154 } 154 }
155 155
156 if ( item ) 156 if ( item )
157 { 157 {
158 // we have already seen this item, it's a dupe 158 // we have already seen this item, it's a dupe
159 #ifdef DEBUG 159 #ifdef DEBUG
160 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 160 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
161 #endif 161 #endif
162 item->receivedBeacon(); 162 item->receivedBeacon();
163 return; 163 return;
164 } 164 }
165 } 165 }
166 else 166 else
167 { 167 {
168 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 168 s.sprintf( "(i) new network: '%s'", (const char*) essid );
169 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); 169 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 );
170 } 170 }
171 171
172 172
173 // insert new station as child from network 173 // insert new station as child from network
174 174
175 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 175 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
176 176
177 qDebug( "inserting new station %s", (const char*) macaddr ); 177 qDebug( "inserting new station %s", (const char*) macaddr );
178 178
179 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 179 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
180 if ( _manufacturerdb ) 180 if ( _manufacturerdb )
181 station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); 181 station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
182 182
183 if ( type == "managed" ) 183 if ( type == "managed" )
184 { 184 {
185 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 185 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
186 } 186 }
187 else 187 else
188 { 188 {
189 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 189 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
190 } 190 }
191 191
192} 192}
193 193
194void MScanListView::traffic( QString type, QString from, QString to, QString via, QString additional ) 194
195void MScanListView::addIfNotExisting( MScanListItem* network, QString addr )
195{ 196{
196 if ( type != "toDS" ) return; 197 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
198
199 while ( subitem && ( subitem->text( col_ap ) != addr ) )
200 {
201 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
202 subitem = static_cast<MScanListItem*> ( subitem->itemBelow() );
203 }
204
205 if ( subitem )
206 {
207 // we have already seen this item, it's a dupe
208 #ifdef DEBUG
209 qDebug( "%s is a dupe - ignoring...", (const char*) addr );
210 #endif
211 subitem->receivedBeacon(); //FIXME: sent data bit
212 return;
213 }
214
215 // Hey, it seems to be a new item :-D
216 MScanListItem* station = new MScanListItem( network, "station", /* network->text( col_essid ) */ "", addr, false, -1, -1 );
217 if ( _manufacturerdb )
218 station->setManufacturer( _manufacturerdb->lookup( addr ) );
219}
197 220
198 qDebug( "MScanList::traffic( [%s] | %s -> %s (via %s)",
199 (const char*) type, (const char*) from,
200 (const char*) to, (const char*) via );
201 221
222void MScanListView::WDStraffic( QString from, QString to, QString viaFrom, QString viaTo )
223{
202 QString s; 224 QString s;
203 MScanListItem* network; 225 MScanListItem* network;
204 226
205 QListViewItemIterator it( this ); 227 QListViewItemIterator it( this );
206 while ( it.current() && it.current()->text( col_ap ) != via ) ++it; 228 while ( it.current() &&
229 it.current()->text( col_ap ) != viaFrom &&
230 it.current()->text( col_ap ) != viaTo ) ++it;
207 231
208 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 232 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
209 233
210 if ( item ) // AP has been shown up, so just add our new "from" - station 234 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations
235 {
236 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
237 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to );
238 }
239 else
211 { 240 {
212 network = static_cast<MScanListItem*>( item->parent() ); 241 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" );
213 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 242 }
243}
214 244
215 while ( subitem && ( subitem->text( col_ap ) != from ) )
216 {
217 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
218 subitem = static_cast<MScanListItem*> ( subitem->itemBelow() );
219 }
220 245
221 if ( subitem ) 246void MScanListView::toDStraffic( QString from, QString to, QString via )
222 { 247{
223 // we have already seen this item, it's a dupe 248 QString s;
224 #ifdef DEBUG 249 MScanListItem* network;
225 qDebug( "%s is a dupe - ignoring...", (const char*) from ); 250
226 #endif 251 QListViewItemIterator it( this );
227 subitem->receivedBeacon(); //FIXME: sent data bit 252 while ( it.current() && it.current()->text( col_ap ) != via ) ++it;
228 return; 253
229 } 254 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
230 255
231 // Hey, it seems to be a new item :-D 256 if ( item ) // AP has shown up yet, so just add our new "from" - station
232 MScanListItem* station = new MScanListItem( item->parent(), "adhoc", /* network->text( col_essid ) */ "", from, false, -1, -1 ); 257 {
233 if ( _manufacturerdb ) 258 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
234 station->setManufacturer( _manufacturerdb->lookup( from ) );
235 } 259 }
236 else 260 else
237 { 261 {
238 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" ); 262 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
239 } 263 }
240} 264}
241 265
266void MScanListView::fromDStraffic( QString from, QString to, QString via )
267{
268 qWarning( "D'oh! Not yet implemented..." );
269}
270
271void MScanListView::IBSStraffic( QString from, QString to, QString via )
272{
273 qWarning( "D'oh! Not yet implemented..." );
274}
275
242//============================================================ 276//============================================================
243// MScanListItem 277// MScanListItem
244//============================================================ 278//============================================================
245 279
246MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 280MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
247 bool wep, int channel, int signal ) 281 bool wep, int channel, int signal )
248 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 282 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
249 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 283 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
250 _channel( channel ), _signal( signal ), _beacons( 1 ) 284 _channel( channel ), _signal( signal ), _beacons( 1 )
251{ 285{
252 qDebug( "creating scanlist item" ); 286 qDebug( "creating scanlist item" );
253 if ( WellenreiterConfigWindow::instance() && type == "network" ) 287 if ( WellenreiterConfigWindow::instance() && type == "network" )
254 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); 288 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() );
255 decorateItem( type, essid, macaddr, wep, channel, signal ); 289 decorateItem( type, essid, macaddr, wep, channel, signal );
256} 290}
257 291
258MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 292MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
259 bool wep, int channel, int signal ) 293 bool wep, int channel, int signal )
260 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 294 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
261{ 295{
262 qDebug( "creating scanlist item" ); 296 qDebug( "creating scanlist item" );
263 decorateItem( type, essid, macaddr, wep, channel, signal ); 297 decorateItem( type, essid, macaddr, wep, channel, signal );
264} 298}
265 299
266OListViewItem* MScanListItem::childFactory() 300OListViewItem* MScanListItem::childFactory()
267{ 301{
268 return new MScanListItem( this ); 302 return new MScanListItem( this );
269} 303}
270 304
271void MScanListItem::serializeTo( QDataStream& s ) const 305void MScanListItem::serializeTo( QDataStream& s ) const
272{ 306{
273 qDebug( "serializing MScanListItem" ); 307 qDebug( "serializing MScanListItem" );
274 OListViewItem::serializeTo( s ); 308 OListViewItem::serializeTo( s );
275 309
276 s << _type; 310 s << _type;
277 s << (Q_UINT8) ( _wep ? 'y' : 'n' ); 311 s << (Q_UINT8) ( _wep ? 'y' : 'n' );
278} 312}
279 313
280void MScanListItem::serializeFrom( QDataStream& s ) 314void MScanListItem::serializeFrom( QDataStream& s )
281{ 315{
282 qDebug( "serializing MScanListItem" ); 316 qDebug( "serializing MScanListItem" );
283 OListViewItem::serializeFrom( s ); 317 OListViewItem::serializeFrom( s );
284 318
285 char wep; 319 char wep;
286 s >> _type; 320 s >> _type;
287 s >> (Q_UINT8) wep; 321 s >> (Q_UINT8) wep;
288 _wep = (wep == 'y'); 322 _wep = (wep == 'y');
289 323
290 QString name; 324 QString name;
291 name.sprintf( "wellenreiter/%s", (const char*) _type ); 325 name.sprintf( "wellenreiter/%s", (const char*) _type );
292 setPixmap( col_type, Resource::loadPixmap( name ) ); 326 setPixmap( col_type, Resource::loadPixmap( name ) );
293 if ( _wep ) 327 if ( _wep )
294 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 328 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
295 listView()->triggerUpdate(); 329 listView()->triggerUpdate();
296} 330}
297 331
298void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 332void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
299{ 333{
300 qDebug( "decorating scanlist item %s / %s / %s [%d]", 334 qDebug( "decorating scanlist item %s / %s / %s [%d]",
301 (const char*) type, 335 (const char*) type,
302 (const char*) essid, 336 (const char*) essid,
303 (const char*) macaddr, 337 (const char*) macaddr,
304 channel ); 338 channel );
305 339
306 // set icon for managed or adhoc mode 340 // set icon for managed or adhoc mode
307 QString name; 341 QString name;
308 name.sprintf( "wellenreiter/%s", (const char*) type ); 342 name.sprintf( "wellenreiter/%s", (const char*) type );
309 setPixmap( col_type, Resource::loadPixmap( name ) ); 343 setPixmap( col_type, Resource::loadPixmap( name ) );
310 344
311 // set icon for wep (wireless encryption protocol) 345 // set icon for wep (wireless encryption protocol)
312 if ( wep ) 346 if ( wep )
313 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 347 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
314 348
315 // set channel and signal text 349 // set channel and signal text
316 350
317 if ( signal != -1 ) 351 if ( signal != -1 )
318 setText( col_sig, QString::number( signal ) ); 352 setText( col_sig, QString::number( signal ) );
319 if ( channel != -1 ) 353 if ( channel != -1 )
320 setText( col_channel, QString::number( channel ) ); 354 setText( col_channel, QString::number( channel ) );
321 355
322 setText( col_firstseen, QTime::currentTime().toString() ); 356 setText( col_firstseen, QTime::currentTime().toString() );
323 //setText( col_lastseen, QTime::currentTime().toString() ); 357 //setText( col_lastseen, QTime::currentTime().toString() );
324 358
325 listView()->triggerUpdate(); 359 listView()->triggerUpdate();
326 360
327 this->type = type; 361 this->type = type;
328 _type = type; 362 _type = type;
329 _essid = essid; 363 _essid = essid;
330 _macaddr = macaddr; 364 _macaddr = macaddr;
331 _channel = channel; 365 _channel = channel;
332 _beacons = 1; 366 _beacons = 1;
333 _signal = 0; 367 _signal = 0;
334} 368}
335 369
336 370
337void MScanListItem::setManufacturer( const QString& manufacturer ) 371void MScanListItem::setManufacturer( const QString& manufacturer )
338{ 372{
339 setText( col_manuf, manufacturer ); 373 setText( col_manuf, manufacturer );
340} 374}
341 375
342 376
343void MScanListItem::playSound( const QString& sound ) const 377void MScanListItem::playSound( const QString& sound ) const
344{ 378{
345 #ifdef QWS 379 #ifdef QWS
346 if ( sound == "Ignore" ) return; 380 if ( sound == "Ignore" ) return;
347 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 381 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
348 else if ( sound == "Key" ) ODevice::inst()->keySound(); 382 else if ( sound == "Key" ) ODevice::inst()->keySound();
349 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 383 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
350 #endif 384 #endif
351} 385}
352 386
353 387
354void MScanListItem::receivedBeacon() 388void MScanListItem::receivedBeacon()
355{ 389{
356 _beacons++; 390 _beacons++;
357 #ifdef DEBUG 391 #ifdef DEBUG
358 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 392 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
359 #endif 393 #endif
360 setText( col_sig, QString::number( _beacons ) ); 394 setText( col_sig, QString::number( _beacons ) );
361 setText( col_lastseen, QTime::currentTime().toString() ); 395 setText( col_lastseen, QTime::currentTime().toString() );
362 if ( WellenreiterConfigWindow::instance() ) 396 if ( WellenreiterConfigWindow::instance() )
363 playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() ); 397 playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() );
364} 398}
365 399
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index bed69f1..a14d426 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -1,125 +1,133 @@
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#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include <opie2/olistview.h> 19#include <opie2/olistview.h>
20 20
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
23class QString; 23class QString;
24class ManufacturerDB; 24class ManufacturerDB;
25 25
26class MScanListItem;
27
26class MScanListView: public OListView 28class MScanListView: public OListView
27{ 29{
28 Q_OBJECT 30 Q_OBJECT
29 31
30 public: 32 public:
31 MScanListView( QWidget* parent = 0, const char* name = 0 ); 33 MScanListView( QWidget* parent = 0, const char* name = 0 );
32 virtual ~MScanListView(); 34 virtual ~MScanListView();
33 35
34 void setManufacturerDB( ManufacturerDB* manufacturerdb ); 36 void setManufacturerDB( ManufacturerDB* manufacturerdb );
35 37
36 virtual OListViewItem* childFactory(); 38 virtual OListViewItem* childFactory();
37 virtual void serializeTo( QDataStream& s ) const; 39 virtual void serializeTo( QDataStream& s ) const;
38 virtual void serializeFrom( QDataStream& s ); 40 virtual void serializeFrom( QDataStream& s );
39 41
40 public slots: 42 public slots:
41 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 43 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
42 void traffic( QString type, QString from, QString to, QString via, QString additional = QString::null ); 44 void fromDStraffic( QString from, QString to, QString via ); // NYI
45 void toDStraffic( QString from, QString to, QString via );
46 void WDStraffic( QString from, QString to, QString viaFrom, QString viaTo );
47 void IBSStraffic( QString from, QString to, QString via ); // NYI
48
49 protected:
50 void addIfNotExisting( MScanListItem* parent, QString addr );
43 51
44 private: 52 private:
45 ManufacturerDB* _manufacturerdb; 53 ManufacturerDB* _manufacturerdb;
46 54
47}; 55};
48 56
49//****************************** MScanListItem **************************************************************** 57//****************************** MScanListItem ****************************************************************
50 58
51class MScanListItem: public OListViewItem 59class MScanListItem: public OListViewItem
52{ 60{
53 public: 61 public:
54 MScanListItem::MScanListItem( QListView* parent, 62 MScanListItem::MScanListItem( QListView* parent,
55 QString type = "unknown", 63 QString type = "unknown",
56 QString essid = "unknown", 64 QString essid = "unknown",
57 QString macaddr = "unknown", 65 QString macaddr = "unknown",
58 bool wep = false, 66 bool wep = false,
59 int channel = 0, 67 int channel = 0,
60 int signal = 0 ); 68 int signal = 0 );
61 69
62 MScanListItem::MScanListItem( QListViewItem* parent, 70 MScanListItem::MScanListItem( QListViewItem* parent,
63 QString type = "unknown", 71 QString type = "unknown",
64 QString essid = "unknown", 72 QString essid = "unknown",
65 QString macaddr = "unknown", 73 QString macaddr = "unknown",
66 bool wep = false, 74 bool wep = false,
67 int channel = 0, 75 int channel = 0,
68 int signal = 0 ); 76 int signal = 0 );
69 77
70 78
71 protected: 79 protected:
72 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 80 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
73 81
74 public: 82 public:
75 QString type; 83 QString type;
76 84
77 public: 85 public:
78 //const QString& type() { return _type; }; 86 //const QString& type() { return _type; };
79 const QString& essid() { return _essid; }; 87 const QString& essid() { return _essid; };
80 const QString& macaddr() { return _macaddr; }; 88 const QString& macaddr() { return _macaddr; };
81 bool wep() { return _wep; }; 89 bool wep() { return _wep; };
82 int channel() { return _channel; }; 90 int channel() { return _channel; };
83 int signal() { return _signal; }; 91 int signal() { return _signal; };
84 int beacons() { return _beacons; }; 92 int beacons() { return _beacons; };
85 93
86 void setSignal( int signal ) { /* TODO */ }; 94 void setSignal( int signal ) { /* TODO */ };
87 void receivedBeacon(); 95 void receivedBeacon();
88 96
89 void setManufacturer( const QString& manufacturer ); 97 void setManufacturer( const QString& manufacturer );
90 98
91 virtual OListViewItem* childFactory(); 99 virtual OListViewItem* childFactory();
92 virtual void serializeTo( QDataStream& s ) const; 100 virtual void serializeTo( QDataStream& s ) const;
93 virtual void serializeFrom( QDataStream& s ); 101 virtual void serializeFrom( QDataStream& s );
94 102
95 protected: 103 protected:
96 void playSound( const QString& ) const; 104 void playSound( const QString& ) const;
97 105
98 private: 106 private:
99 QString _type; 107 QString _type;
100 QString _essid; 108 QString _essid;
101 QString _macaddr; 109 QString _macaddr;
102 bool _wep; 110 bool _wep;
103 int _channel; 111 int _channel;
104 int _signal; 112 int _signal;
105 int _beacons; 113 int _beacons;
106 114
107}; 115};
108 116
109//****************************** MScanListViewFactory **************************************************************** 117//****************************** MScanListViewFactory ****************************************************************
110 118
111/* 119/*
112 120
113class MScanListViewFactory : public OListViewFactory 121class MScanListViewFactory : public OListViewFactory
114{ 122{
115public: 123public:
116 virtual QListView* listViewFactory(); 124 virtual QListView* listViewFactory();
117 virtual QListViewItem* listViewItemFactory( QListView* lv ); 125 virtual QListViewItem* listViewItemFactory( QListView* lv );
118 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 126 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
119 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 127 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
120 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 128 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
121} 129}
122*/ 130*/
123 131
124#endif 132#endif
125 133
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 5ec9ee4..4b82c9a 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,382 +1,382 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Opie 16// Opie
17 17
18#ifdef QWS 18#ifdef QWS
19#include <opie/odevice.h> 19#include <opie/odevice.h>
20using namespace Opie; 20using namespace Opie;
21#endif 21#endif
22 22
23#ifdef QWS 23#ifdef QWS
24#include <opie2/oapplication.h> 24#include <opie2/oapplication.h>
25#else 25#else
26#include <qapplication.h> 26#include <qapplication.h>
27#endif 27#endif
28#include <opie2/onetwork.h> 28#include <opie2/onetwork.h>
29#include <opie2/opcap.h> 29#include <opie2/opcap.h>
30 30
31// Qt 31// Qt
32 32
33#include <qcheckbox.h> 33#include <qcheckbox.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qtoolbutton.h> 41#include <qtoolbutton.h>
42#include <qmainwindow.h> 42#include <qmainwindow.h>
43 43
44// Standard 44// Standard
45 45
46#include <assert.h> 46#include <assert.h>
47#include <errno.h> 47#include <errno.h>
48#include <unistd.h> 48#include <unistd.h>
49#include <string.h> 49#include <string.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <stdlib.h> 51#include <stdlib.h>
52 52
53// Local 53// Local
54 54
55#include "wellenreiter.h" 55#include "wellenreiter.h"
56#include "scanlist.h" 56#include "scanlist.h"
57#include "logwindow.h" 57#include "logwindow.h"
58#include "hexwindow.h" 58#include "hexwindow.h"
59#include "configwindow.h" 59#include "configwindow.h"
60#include "statwindow.h" 60#include "statwindow.h"
61#include "manufacturers.h" 61#include "manufacturers.h"
62 62
63Wellenreiter::Wellenreiter( QWidget* parent ) 63Wellenreiter::Wellenreiter( QWidget* parent )
64 : WellenreiterBase( parent, 0, 0 ), 64 : WellenreiterBase( parent, 0, 0 ),
65 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) 65 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 )
66{ 66{
67 67
68 // 68 //
69 // construct manufacturer database 69 // construct manufacturer database
70 // 70 //
71 71
72 QString manufile; 72 QString manufile;
73 #ifdef QWS 73 #ifdef QWS
74 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); 74 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
75 #else 75 #else
76 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); 76 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" );
77 #endif 77 #endif
78 manufacturerdb = new ManufacturerDB( manufile ); 78 manufacturerdb = new ManufacturerDB( manufile );
79 79
80 logwindow->log( "(i) Wellenreiter has been started." ); 80 logwindow->log( "(i) Wellenreiter has been started." );
81 81
82 // 82 //
83 // detect operating system 83 // detect operating system
84 // 84 //
85 85
86 #ifdef QWS 86 #ifdef QWS
87 QString sys; 87 QString sys;
88 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 88 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
89 _system = ODevice::inst()->system(); 89 _system = ODevice::inst()->system();
90 logwindow->log( sys ); 90 logwindow->log( sys );
91 #endif 91 #endif
92 92
93 // setup GUI 93 // setup GUI
94 netview->setColumnWidthMode( 1, QListView::Manual ); 94 netview->setColumnWidthMode( 1, QListView::Manual );
95 95
96 if ( manufacturerdb ) 96 if ( manufacturerdb )
97 netview->setManufacturerDB( manufacturerdb ); 97 netview->setManufacturerDB( manufacturerdb );
98 98
99 pcap = new OPacketCapturer(); 99 pcap = new OPacketCapturer();
100 100
101} 101}
102 102
103 103
104Wellenreiter::~Wellenreiter() 104Wellenreiter::~Wellenreiter()
105{ 105{
106 // no need to delete child widgets, Qt does it all for us 106 // no need to delete child widgets, Qt does it all for us
107 107
108 delete manufacturerdb; 108 delete manufacturerdb;
109 delete pcap; 109 delete pcap;
110} 110}
111 111
112 112
113void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 113void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
114{ 114{
115 configwindow = cw; 115 configwindow = cw;
116} 116}
117 117
118 118
119void Wellenreiter::channelHopped(int c) 119void Wellenreiter::channelHopped(int c)
120{ 120{
121 QString title = "Wellenreiter II -scan- ["; 121 QString title = "Wellenreiter II -scan- [";
122 QString left; 122 QString left;
123 if ( c > 1 ) left.fill( '.', c-1 ); 123 if ( c > 1 ) left.fill( '.', c-1 );
124 title.append( left ); 124 title.append( left );
125 title.append( '|' ); 125 title.append( '|' );
126 if ( c < iface->channels() ) 126 if ( c < iface->channels() )
127 { 127 {
128 QString right; 128 QString right;
129 right.fill( '.', iface->channels()-c ); 129 right.fill( '.', iface->channels()-c );
130 title.append( right ); 130 title.append( right );
131 } 131 }
132 title.append( "]" ); 132 title.append( "]" );
133 //title.append( QString().sprintf( " %02d", c ) ); 133 //title.append( QString().sprintf( " %02d", c ) );
134 assert( parent() ); 134 assert( parent() );
135 ( (QMainWindow*) parent() )->setCaption( title ); 135 ( (QMainWindow*) parent() )->setCaption( title );
136} 136}
137 137
138 138
139void Wellenreiter::receivePacket(OPacket* p) 139void Wellenreiter::receivePacket(OPacket* p)
140{ 140{
141 hexWindow()->log( p->dump( 8 ) ); 141 hexWindow()->log( p->dump( 8 ) );
142 142
143 // check if we received a beacon frame 143 // check if we received a beacon frame
144 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 144 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
145 if ( beacon && beacon->managementType() == "Beacon" ) 145 if ( beacon && beacon->managementType() == "Beacon" )
146 { 146 {
147 QString type; 147 QString type;
148 if ( beacon->canIBSS() ) 148 if ( beacon->canIBSS() )
149 { 149 {
150 type = "adhoc"; 150 type = "adhoc";
151 } 151 }
152 else if ( beacon->canESS() ) 152 else if ( beacon->canESS() )
153 { 153 {
154 type = "managed"; 154 type = "managed";
155 } 155 }
156 else 156 else
157 { 157 {
158 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); 158 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) );
159 return; 159 return;
160 } 160 }
161 161
162 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 162 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
163 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 163 QString essid = ssid ? ssid->ID() : QString("<unknown>");
164 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 164 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
165 int channel = ds ? ds->channel() : -1; 165 int channel = ds ? ds->channel() : -1;
166 166
167 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 167 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
168 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); 168 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 );
169 return; 169 return;
170 } 170 }
171 171
172 // check for a data frame 172 // check for a data frame
173 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); 173 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) );
174 if ( data ) 174 if ( data )
175 { 175 {
176 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 176 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
177 if ( wlan->fromDS() && !wlan->toDS() ) 177 if ( wlan->fromDS() && !wlan->toDS() )
178 { 178 {
179 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", 179 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'",
180 (const char*) wlan->macAddress3().toString(true), 180 (const char*) wlan->macAddress3().toString(true),
181 (const char*) wlan->macAddress1().toString(true), 181 (const char*) wlan->macAddress1().toString(true),
182 (const char*) wlan->macAddress2().toString(true) ); 182 (const char*) wlan->macAddress2().toString(true) );
183 netView()->traffic( "fromDS", wlan->macAddress3().toString(), 183 netView()->fromDStraffic( wlan->macAddress3().toString(),
184 wlan->macAddress1().toString(), 184 wlan->macAddress1().toString(),
185 wlan->macAddress2().toString() ); 185 wlan->macAddress2().toString() );
186 } 186 }
187 else 187 else
188 if ( !wlan->fromDS() && wlan->toDS() ) 188 if ( !wlan->fromDS() && wlan->toDS() )
189 { 189 {
190 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", 190 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'",
191 (const char*) wlan->macAddress2().toString(true), 191 (const char*) wlan->macAddress2().toString(true),
192 (const char*) wlan->macAddress3().toString(true), 192 (const char*) wlan->macAddress3().toString(true),
193 (const char*) wlan->macAddress1().toString(true) ); 193 (const char*) wlan->macAddress1().toString(true) );
194 netView()->traffic( "toDS", wlan->macAddress2().toString(), 194 netView()->toDStraffic( wlan->macAddress2().toString(),
195 wlan->macAddress3().toString(), 195 wlan->macAddress3().toString(),
196 wlan->macAddress1().toString() ); 196 wlan->macAddress1().toString() );
197 } 197 }
198 else 198 else
199 if ( wlan->fromDS() && wlan->toDS() ) 199 if ( wlan->fromDS() && wlan->toDS() )
200 { 200 {
201 qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", 201 qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
202 (const char*) wlan->macAddress4().toString(true), 202 (const char*) wlan->macAddress4().toString(true),
203 (const char*) wlan->macAddress3().toString(true), 203 (const char*) wlan->macAddress3().toString(true),
204 (const char*) wlan->macAddress1().toString(true), 204 (const char*) wlan->macAddress1().toString(true),
205 (const char*) wlan->macAddress2().toString(true) ); 205 (const char*) wlan->macAddress2().toString(true) );
206 netView()->traffic( "WSD", wlan->macAddress4().toString(), 206 netView()->WDStraffic( wlan->macAddress4().toString(),
207 wlan->macAddress3().toString(), 207 wlan->macAddress3().toString(),
208 wlan->macAddress1().toString(), 208 wlan->macAddress1().toString(),
209 wlan->macAddress2().toString() ); 209 wlan->macAddress2().toString() );
210 } 210 }
211 else 211 else
212 { 212 {
213 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", 213 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
214 (const char*) wlan->macAddress2().toString(true), 214 (const char*) wlan->macAddress2().toString(true),
215 (const char*) wlan->macAddress1().toString(true), 215 (const char*) wlan->macAddress1().toString(true),
216 (const char*) wlan->macAddress3().toString(true) ); 216 (const char*) wlan->macAddress3().toString(true) );
217 netView()->traffic( "IBSS", wlan->macAddress2().toString(), 217 netView()->IBSStraffic( wlan->macAddress2().toString(),
218 wlan->macAddress1().toString(), 218 wlan->macAddress1().toString(),
219 wlan->macAddress3().toString() ); 219 wlan->macAddress3().toString() );
220 } 220 }
221 return; 221 return;
222 } 222 }
223} 223}
224 224
225 225
226void Wellenreiter::stopClicked() 226void Wellenreiter::stopClicked()
227{ 227{
228 if ( iface ) 228 if ( iface )
229 { 229 {
230 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 230 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
231 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 231 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
232 iface->setChannelHopping(); // stop hopping channels 232 iface->setChannelHopping(); // stop hopping channels
233 } 233 }
234 else 234 else
235 killTimers(); 235 killTimers();
236 236
237 pcap->close(); 237 pcap->close();
238 sniffing = false; 238 sniffing = false;
239 239
240 if ( iface ) 240 if ( iface )
241 { 241 {
242 // switch off monitor mode 242 // switch off monitor mode
243 iface->setMonitorMode( false ); 243 iface->setMonitorMode( false );
244 // switch off promisc flag 244 // switch off promisc flag
245 iface->setPromiscuousMode( false ); 245 iface->setPromiscuousMode( false );
246 246
247 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 247 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
248 } 248 }
249 249
250 logwindow->log( "(i) Stopped Scanning." ); 250 logwindow->log( "(i) Stopped Scanning." );
251 assert( parent() ); 251 assert( parent() );
252 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 252 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
253 253
254 // message the user 254 // message the user
255 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); 255 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
256 256
257 sniffing = false; 257 sniffing = false;
258 emit( stoppedSniffing() ); 258 emit( stoppedSniffing() );
259 259
260 // print out statistics 260 // print out statistics
261 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 261 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
262 statwindow->updateCounter( it.key(), it.data() ); 262 statwindow->updateCounter( it.key(), it.data() );
263} 263}
264 264
265 265
266void Wellenreiter::startClicked() 266void Wellenreiter::startClicked()
267{ 267{
268 // get configuration from config window 268 // get configuration from config window
269 269
270 const QString& interface = configwindow->interfaceName->currentText(); 270 const QString& interface = configwindow->interfaceName->currentText();
271 const int cardtype = configwindow->daemonDeviceType(); 271 const int cardtype = configwindow->daemonDeviceType();
272 const int interval = configwindow->daemonHopInterval(); 272 const int interval = configwindow->daemonHopInterval();
273 273
274 if ( ( interface == "" ) || ( cardtype == 0 ) ) 274 if ( ( interface == "" ) || ( cardtype == 0 ) )
275 { 275 {
276 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); 276 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
277 return; 277 return;
278 } 278 }
279 279
280 // configure device 280 // configure device
281 281
282 ONetwork* net = ONetwork::instance(); 282 ONetwork* net = ONetwork::instance();
283 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 283 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
284 284
285 // set monitor mode 285 // set monitor mode
286 286
287 switch ( cardtype ) 287 switch ( cardtype )
288 { 288 {
289 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; 289 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
290 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; 290 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
291 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; 291 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
292 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; 292 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
293 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break; 293 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break;
294 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 294 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
295 default: assert( 0 ); // shouldn't reach this 295 default: assert( 0 ); // shouldn't reach this
296 } 296 }
297 297
298 // switch device into monitor mode 298 // switch device into monitor mode
299 if ( cardtype < DEVTYPE_FILE ) 299 if ( cardtype < DEVTYPE_FILE )
300 { 300 {
301 if ( cardtype != DEVTYPE_MANUAL ) 301 if ( cardtype != DEVTYPE_MANUAL )
302 iface->setMonitorMode( true ); 302 iface->setMonitorMode( true );
303 if ( !iface->monitorMode() ) 303 if ( !iface->monitorMode() )
304 { 304 {
305 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); 305 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
306 return; 306 return;
307 } 307 }
308 } 308 }
309 309
310 // open pcap and start sniffing 310 // open pcap and start sniffing
311 if ( cardtype != DEVTYPE_FILE ) 311 if ( cardtype != DEVTYPE_FILE )
312 { 312 {
313 if ( configwindow->writeCaptureFile->isEnabled() ) 313 if ( configwindow->writeCaptureFile->isEnabled() )
314 { 314 {
315 QString dumpname( configwindow->captureFileName->text() ); 315 QString dumpname( configwindow->captureFileName->text() );
316 dumpname.append( '-' ); 316 dumpname.append( '-' );
317 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 317 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
318 dumpname.append( ".wellenreiter" ); 318 dumpname.append( ".wellenreiter" );
319 pcap->open( interface, dumpname ); 319 pcap->open( interface, dumpname );
320 } 320 }
321 else 321 else
322 { 322 {
323 pcap->open( interface ); 323 pcap->open( interface );
324 } 324 }
325 } 325 }
326 else 326 else
327 { 327 {
328 pcap->open( QFile( interface ) ); 328 pcap->open( QFile( interface ) );
329 } 329 }
330 330
331 if ( !pcap->isOpen() ) 331 if ( !pcap->isOpen() )
332 { 332 {
333 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); 333 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
334 return; 334 return;
335 } 335 }
336 336
337 // set capturer to non-blocking mode 337 // set capturer to non-blocking mode
338 pcap->setBlocking( false ); 338 pcap->setBlocking( false );
339 339
340 // start channel hopper 340 // start channel hopper
341 if ( cardtype != DEVTYPE_FILE ) 341 if ( cardtype != DEVTYPE_FILE )
342 iface->setChannelHopping( 1000 ); //use interval from config window 342 iface->setChannelHopping( 1000 ); //use interval from config window
343 343
344 if ( cardtype != DEVTYPE_FILE ) 344 if ( cardtype != DEVTYPE_FILE )
345 { 345 {
346 // connect socket notifier and start channel hopper 346 // connect socket notifier and start channel hopper
347 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 347 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
348 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 348 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
349 } 349 }
350 else 350 else
351 { 351 {
352 // start timer for reading packets 352 // start timer for reading packets
353 startTimer( 100 ); 353 startTimer( 100 );
354 } 354 }
355 355
356 logwindow->log( "(i) Started Scanning." ); 356 logwindow->log( "(i) Started Scanning." );
357 sniffing = true; 357 sniffing = true;
358 emit( startedSniffing() ); 358 emit( startedSniffing() );
359 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 359 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
360 else 360 else
361 { 361 {
362 assert( parent() ); 362 assert( parent() );
363 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II - replaying capture file..." ); 363 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II - replaying capture file..." );
364 } 364 }
365} 365}
366 366
367 367
368void Wellenreiter::timerEvent( QTimerEvent* ) 368void Wellenreiter::timerEvent( QTimerEvent* )
369{ 369{
370 qDebug( "Wellenreiter::timerEvent()" ); 370 qDebug( "Wellenreiter::timerEvent()" );
371 OPacket* p = pcap->next(); 371 OPacket* p = pcap->next();
372 if ( !p ) // no more packets available 372 if ( !p ) // no more packets available
373 { 373 {
374 stopClicked(); 374 stopClicked();
375 } 375 }
376 else 376 else
377 { 377 {
378 receivePacket( p ); 378 receivePacket( p );
379 delete p; 379 delete p;
380 } 380 }
381} 381}
382 382