summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/ChangeLog5
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp20
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h7
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp39
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h5
5 files changed, 60 insertions, 16 deletions
diff --git a/noncore/net/wellenreiter/ChangeLog b/noncore/net/wellenreiter/ChangeLog
index d4dca9f..f183d80 100644
--- a/noncore/net/wellenreiter/ChangeLog
+++ b/noncore/net/wellenreiter/ChangeLog
@@ -1,79 +1,80 @@
1 2004-??-?? Michael Lauer <mickey@Vanille.de> 1 2004-??-?? Michael Lauer <mickey@Vanille.de>
2 2
3 * Added parsing of named ProbeRequests. Display only-probed-yet SSIDs in a different network color.
3 * Rewrote the simple actions on new {Network, Client, Station}. Besides playing a sound or 4 * Rewrote the simple actions on new {Network, Client, Station}. Besides playing a sound or
4 blinking a LED, a user customizable script can now be executed, if something has been 5 blinking a LED, a user customizable script can now be executed, if something has been
5 detected. This opens up many possibilities, i.e. a qcop to qpegps or exec'ing Flite. 6 detected. This opens up many possibilities, i.e. a qcop to qpegps or exec'ing flite (speech).
6 * Added decloaking of cloaked ESSIDs (length != 0, but essid[0] == \0) 7 * Added decloaking of cloaked ESSIDs (length != 0, but essid[0] == \0)
7 * Hided the 'Parse' Tab in the configuration window. Not functional now and may come later 8 * Hided the 'Parse' Tab in the configuration window. Not functional now and may come later
8 * Added parsing of control frames. Display stations sending them SSID "???" for now. 9 * Added parsing of control frames. Display stations sending them SSID "<unknown>" for now.
9 * Added command line option "-nocheck" to skip non-root and dhcp tests 10 * Added command line option "-nocheck" to skip non-root and dhcp tests
10 * Improved the speed reading the manufacturer list 11 * Improved the speed reading the manufacturer list
11 * GPS coordinates are now presented in the DMS (as opposed to decimal) format 12 * GPS coordinates are now presented in the DMS (as opposed to decimal) format
12 13
13 2003-12-18 Michael Lauer <mickey@Vanille.de> 14 2003-12-18 Michael Lauer <mickey@Vanille.de>
14 15
15 * Released as Version 1.0.2 (Development Snapshot) 16 * Released as Version 1.0.2 (Development Snapshot)
16 * Added automatic uploading of capture files to "The Capture Dump" site at 17 * Added automatic uploading of capture files to "The Capture Dump" site at
17 http://www.Vanille.de/projects/capturedump.spy 18 http://www.Vanille.de/projects/capturedump.spy
18 * Initial reading of the manufacturer database happens now in background 19 * Initial reading of the manufacturer database happens now in background
19 * Removed deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now. 20 * Removed deprecated setMonitorMode() API ==> Use setMode( "monitor" ) now.
20 The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that 21 The monitor mode now tries to use the standard IW_MODE_MONITOR first. If that
21 doesn't work, it falls back to using the proprietary iwpriv commands 22 doesn't work, it falls back to using the proprietary iwpriv commands
22 23
23 2003-11-30 Michael Lauer <mickey@Vanille.de> 24 2003-11-30 Michael Lauer <mickey@Vanille.de>
24 25
25 * Released as Version 1.0.1 (Development Snapshot) 26 * Released as Version 1.0.1 (Development Snapshot)
26 * Fixed ARP decoding for wired networks. 27 * Fixed ARP decoding for wired networks.
27 Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol. 28 Interestingly, 802.11 encapsulates these in IP packets, while wired ethernet just tags the type_of_protocol.
28 * Added reading GPS data from a gps daemon. 29 * Added reading GPS data from a gps daemon.
29 * Started preparations for utilizing Wellenreiter II in wired networks. 30 * Started preparations for utilizing Wellenreiter II in wired networks.
30 * Implemented persistant configuration interface and retriggerable auto detection. 31 * Implemented persistant configuration interface and retriggerable auto detection.
31 * Added QCOP interface for talking to opie-networksettings. 32 * Added QCOP interface for talking to opie-networksettings.
32 * Added parsing of DHCP packets and detecting DHCP servers. 33 * Added parsing of DHCP packets and detecting DHCP servers.
33 * Overhauled the configuration window and started with the customizable event system. 34 * Overhauled the configuration window and started with the customizable event system.
34 * Added disabling the screensaver. 35 * Added disabling the screensaver.
35 * Added automatic opening and scrolling to the network tree if a new station appears. 36 * Added automatic opening and scrolling to the network tree if a new station appears.
36 37
37 2003-05-10 Michael Lauer <mickey@Vanille.de> 38 2003-05-10 Michael Lauer <mickey@Vanille.de>
38 39
39 * Released as Version 1.0 (Stable) 40 * Released as Version 1.0 (Stable)
40 * Added restarting the dhcp client if having killed it before. 41 * Added restarting the dhcp client if having killed it before.
41 * Decouple dump files from live capture to shift control over 'what' is dumped to applications. 42 * Decouple dump files from live capture to shift control over 'what' is dumped to applications.
42 43
43 2003-05-05 Michael Lauer <mickey@Vanille.de> 44 2003-05-05 Michael Lauer <mickey@Vanille.de>
44 45
45 * Released as Version 1.0-RC1 (Release Candidate) 46 * Released as Version 1.0-RC1 (Release Candidate)
46 * Fixed rare segfaults while sniffing and operating the GUI simultaenously. 47 * Fixed rare segfaults while sniffing and operating the GUI simultaenously.
47 * Parse more data packets and detect more participating stations. 48 * Parse more data packets and detect more participating stations.
48 * Added live graph window showing the signal strength on all channels. 49 * Added live graph window showing the signal strength on all channels.
49 * Added parsing ARP packets and identifying IP addresses of participating stations. 50 * Added parsing ARP packets and identifying IP addresses of participating stations.
50 * Added parsing with optionally enabled PRISM headers (signal strength). 51 * Added parsing with optionally enabled PRISM headers (signal strength).
51 52
52 2003-04-12 Michael Lauer <mickey@Vanille.de> 53 2003-04-12 Michael Lauer <mickey@Vanille.de>
53 54
54 * Released as Version 1.0 (Beta) 55 * Released as Version 1.0 (Beta)
55 * GUI enhancements in the Menubar and the Toolbar. 56 * GUI enhancements in the Menubar and the Toolbar.
56 * Improved keyboard handling. 57 * Improved keyboard handling.
57 * Added sanity checks for running Wellenreiter II as non-root or with dhcp clients in the background. 58 * Added sanity checks for running Wellenreiter II as non-root or with dhcp clients in the background.
58 * Add writing and replaying of libpcap compatible capture files. 59 * Add writing and replaying of libpcap compatible capture files.
59 60
60 2003-04-08 Michael Lauer <mickey@Vanille.de> 61 2003-04-08 Michael Lauer <mickey@Vanille.de>
61 62
62 * Released as Version 0.2 (Alpha) 63 * Released as Version 0.2 (Alpha)
63 * Closed memory leak in packet capturer. 64 * Closed memory leak in packet capturer.
64 * Fixed client stations appearing under essid as access points. 65 * Fixed client stations appearing under essid as access points.
65 * Fixed false WEP reporting in some cases. 66 * Fixed false WEP reporting in some cases.
66 * Started with inspecting data packages. 67 * Started with inspecting data packages.
67 * Add detecting associated client stations in infrastructural networks (if they transmit data). 68 * Add detecting associated client stations in infrastructural networks (if they transmit data).
68 * Worked around buggy hostap drivers writing past fixed-length-structures on arm. 69 * Worked around buggy hostap drivers writing past fixed-length-structures on arm.
69 * Added dynamic checking of available private ioctls. 70 * Added dynamic checking of available private ioctls.
70 * Added a saveable hex window for packet dissection. 71 * Added a saveable hex window for packet dissection.
71 72
72 2003-03-30 Michael Lauer <mickey@Vanille.de> 73 2003-03-30 Michael Lauer <mickey@Vanille.de>
73 74
74 * Released as Version 0.1 (Alpha) 75 * Released as Version 0.1 (Alpha)
75 76
76 2003-03-25 Michael Lauer <mickey@Vanille.de> 77 2003-03-25 Michael Lauer <mickey@Vanille.de>
77 78
78 * Rewrote Wellenreiter II from scratch - including the sniffing engine. 79 * Rewrote Wellenreiter II from scratch - including the sniffing engine.
79 * Beacon inspection works and finds ad-hoc networks and managed networks. 80 * Beacon inspection works and finds ad-hoc networks and managed networks.
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index aea7eb6..fd88b63 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,554 +1,560 @@
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#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#include <assert.h> 20#include <assert.h>
21#include <qcursor.h> 21#include <qcursor.h>
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qtextstream.h> 23#include <qtextstream.h>
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26 26
27#ifdef QWS 27#ifdef QWS
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#endif 29#endif
30 30
31#ifdef QWS 31#ifdef QWS
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33#else 33#else
34#include "resource.h" 34#include "resource.h"
35#endif 35#endif
36 36
37const int col_type = 0; 37const int col_type = 0;
38const int col_essid = 0; 38const int col_essid = 0;
39const int col_sig = 1; 39const int col_sig = 1;
40const int col_ap = 2; 40const int col_ap = 2;
41const int col_channel = 3; 41const int col_channel = 3;
42const int col_wep = 4; 42const int col_wep = 4;
43const int col_traffic = 5; 43const int col_traffic = 5;
44const int col_ip = 6; 44const int col_ip = 6;
45const int col_manuf = 7; 45const int col_manuf = 7;
46const int col_firstseen = 8; 46const int col_firstseen = 8;
47const int col_lastseen = 9; 47const int col_lastseen = 9;
48const int col_location = 10; 48const int col_location = 10;
49 49
50MScanListView::MScanListView( QWidget* parent, const char* name ) 50MScanListView::MScanListView( QWidget* parent, const char* name )
51 :OListView( parent, name ) 51 :OListView( parent, name )
52{ 52{
53 53
54 setFrameShape( QListView::StyledPanel ); 54 setFrameShape( QListView::StyledPanel );
55 setFrameShadow( QListView::Sunken ); 55 setFrameShadow( QListView::Sunken );
56 56
57 addColumn( tr( "Net/Station" ) ); 57 addColumn( tr( "Net/Station" ) );
58 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 58 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
59 addColumn( tr( "#" ) ); 59 addColumn( tr( "#" ) );
60 setColumnAlignment( col_sig, AlignCenter ); 60 setColumnAlignment( col_sig, AlignCenter );
61 addColumn( tr( "MAC" ) ); 61 addColumn( tr( "MAC" ) );
62 setColumnAlignment( col_ap, AlignCenter ); 62 setColumnAlignment( col_ap, AlignCenter );
63 addColumn( tr( "Chn" ) ); 63 addColumn( tr( "Chn" ) );
64 setColumnAlignment( col_channel, AlignCenter ); 64 setColumnAlignment( col_channel, AlignCenter );
65 addColumn( tr( "W" ) ); 65 addColumn( tr( "W" ) );
66 setColumnAlignment( col_wep, AlignCenter ); 66 setColumnAlignment( col_wep, AlignCenter );
67 addColumn( tr( "T" ) ); 67 addColumn( tr( "T" ) );
68 setColumnAlignment( col_traffic, AlignCenter ); 68 setColumnAlignment( col_traffic, AlignCenter );
69 addColumn( tr( "IP" ) ); 69 addColumn( tr( "IP" ) );
70 setColumnAlignment( col_ip, AlignCenter ); 70 setColumnAlignment( col_ip, AlignCenter );
71 addColumn( tr( "Manufacturer" ) ); 71 addColumn( tr( "Manufacturer" ) );
72 setColumnAlignment( col_manuf, AlignCenter ); 72 setColumnAlignment( col_manuf, AlignCenter );
73 addColumn( tr( "First Seen" ) ); 73 addColumn( tr( "First Seen" ) );
74 setColumnAlignment( col_firstseen, AlignCenter ); 74 setColumnAlignment( col_firstseen, AlignCenter );
75 addColumn( tr( "Last Seen" ) ); 75 addColumn( tr( "Last Seen" ) );
76 setColumnAlignment( col_lastseen, AlignCenter ); 76 setColumnAlignment( col_lastseen, AlignCenter );
77 addColumn( tr( "Location" ) ); 77 addColumn( tr( "Location" ) );
78 setColumnAlignment( col_location, AlignCenter ); 78 setColumnAlignment( col_location, AlignCenter );
79 setRootIsDecorated( true ); 79 setRootIsDecorated( true );
80 setAllColumnsShowFocus( true ); 80 setAllColumnsShowFocus( true );
81 81
82 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 82 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
83 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 83 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
84 84
85 #ifdef QWS 85 #ifdef QWS
86 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 86 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
87 #endif 87 #endif
88 88
89}; 89};
90 90
91 91
92MScanListView::~MScanListView() 92MScanListView::~MScanListView()
93{ 93{
94}; 94};
95 95
96 96
97OListViewItem* MScanListView::childFactory() 97OListViewItem* MScanListView::childFactory()
98{ 98{
99 return new MScanListItem( this ); 99 return new MScanListItem( this );
100} 100}
101 101
102 102
103void MScanListView::serializeTo( QDataStream& s) const 103void MScanListView::serializeTo( QDataStream& s) const
104{ 104{
105 qDebug( "serializing MScanListView" ); 105 qDebug( "serializing MScanListView" );
106 OListView::serializeTo( s ); 106 OListView::serializeTo( s );
107} 107}
108 108
109 109
110void MScanListView::serializeFrom( QDataStream& s) 110void MScanListView::serializeFrom( QDataStream& s)
111{ 111{
112 qDebug( "serializing MScanListView" ); 112 qDebug( "serializing MScanListView" );
113 OListView::serializeFrom( s ); 113 OListView::serializeFrom( s );
114} 114}
115 115
116 116
117void MScanListView::addNewItem( const QString& type, 117void MScanListView::addNewItem( const QString& type,
118 const QString& essid, 118 const QString& essid,
119 const OMacAddress& mac, 119 const OMacAddress& mac,
120 bool wep, 120 bool wep,
121 int channel, 121 int channel,
122 int signal, 122 int signal,
123 const GpsLocation& loc ) 123 const GpsLocation& loc,
124 bool probe )
124{ 125{
125 QString macaddr = mac.toString(true); 126 QString macaddr = mac.toString(true);
126 127
127 #ifdef DEBUG 128 #ifdef DEBUG
128 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 129 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
129 (const char*) essid, (const char*) macaddr, channel ); 130 (const char*) essid, (const char*) macaddr, channel );
130 #endif 131 #endif
131 132
132 // search, if we already have seen this net 133 // search, if we already have seen this net
133 134
134 QString s; 135 QString s;
135 MScanListItem* network; 136 MScanListItem* network;
136 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 137 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
137 138
138 while ( item && ( item->text( col_essid ) != essid ) ) 139 while ( item && ( item->text( col_essid ) != essid ) )
139 { 140 {
140 #ifdef DEBUG 141 #ifdef DEBUG
141 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); 142 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
142 #endif 143 #endif
143 item = static_cast<MScanListItem*> ( item->nextSibling() ); 144 item = static_cast<MScanListItem*> ( item->nextSibling() );
144 } 145 }
145 if ( item ) 146 if ( item )
146 { 147 {
147 // we have already seen this net, check all childs if MAC exists 148 // we have already seen this net, check all childs if MAC exists
148 149
149 network = item; 150 network = item;
150 151
151 item = static_cast<MScanListItem*> ( item->firstChild() ); 152 item = static_cast<MScanListItem*> ( item->firstChild() );
152 assert( item ); // this shouldn't fail 153 assert( item ); // this shouldn't fail
153 154
154 while ( item && ( item->text( col_ap ) != macaddr ) ) 155 while ( item && ( item->text( col_ap ) != macaddr ) )
155 { 156 {
156 #ifdef DEBUG 157 #ifdef DEBUG
157 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); 158 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) );
158 #endif 159 #endif
159 item = static_cast<MScanListItem*> ( item->nextSibling() ); 160 item = static_cast<MScanListItem*> ( item->nextSibling() );
160 } 161 }
161 162
162 if ( item ) 163 if ( item )
163 { 164 {
164 // we have already seen this item, it's a dupe 165 // we have already seen this item, it's a dupe
165 #ifdef DEBUG 166 #ifdef DEBUG
166 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 167 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
167 #endif 168 #endif
168 item->receivedBeacon(); 169 item->receivedBeacon();
169 return; 170 return;
170 } 171 }
171 } 172 }
172 else 173 else
173 { 174 {
174 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 175 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
175 MLogWindow::logwindow()->log( s ); 176 MLogWindow::logwindow()->log( s );
176 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); 177 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe );
177 } 178 }
178 179
179 180
180 // insert new station as child from network 181 // insert new station as child from network
181 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 182 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
182 183
183 #ifdef DEBUG 184 #ifdef DEBUG
184 qDebug( "inserting new station %s", (const char*) macaddr ); 185 qDebug( "inserting new station %s", (const char*) macaddr );
185 #endif 186 #endif
186 187
187 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 188 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
188 station->setManufacturer( mac.manufacturer() ); 189 station->setManufacturer( mac.manufacturer() );
189 station->setLocation( loc.dmsPosition() ); 190 station->setLocation( loc.dmsPosition() );
190 191
191 if ( type == "managed" ) 192 if ( type == "managed" )
192 { 193 {
193 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 194 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
194 } 195 }
195 else 196 else
196 { 197 {
197 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 198 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
198 } 199 }
199 MLogWindow::logwindow()->log( s ); 200 MLogWindow::logwindow()->log( s );
200
201} 201}
202 202
203 203
204void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 204void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
205{ 205{
206 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 206 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
207 207
208 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 208 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
209 { 209 {
210 #ifdef DEBUG 210 #ifdef DEBUG
211 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 211 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
212 #endif 212 #endif
213 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 213 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
214 } 214 }
215 215
216 if ( subitem ) 216 if ( subitem )
217 { 217 {
218 // we have already seen this item, it's a dupe 218 // we have already seen this item, it's a dupe
219 #ifdef DEBUG 219 #ifdef DEBUG
220 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); 220 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) );
221 #endif 221 #endif
222 subitem->receivedBeacon(); //FIXME: sent data bit 222 subitem->receivedBeacon(); //FIXME: sent data bit
223 return; 223 return;
224 } 224 }
225 225
226 // Hey, it seems to be a new item :-D 226 // Hey, it seems to be a new item :-D
227 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 227 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
228 station->setManufacturer( addr.manufacturer() ); 228 station->setManufacturer( addr.manufacturer() );
229 229
230 QString s; 230 QString s;
231 if ( type == "station" ) 231 if ( type == "station" )
232 { 232 {
233 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 233 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
234 } 234 }
235 else 235 else
236 { 236 {
237 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 237 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
238 } 238 }
239 MLogWindow::logwindow()->log( s ); 239 MLogWindow::logwindow()->log( s );
240} 240}
241 241
242 242
243void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) 243void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
244{ 244{
245 QString s; 245 QString s;
246 MScanListItem* network; 246 MScanListItem* network;
247 247
248 QListViewItemIterator it( this ); 248 QListViewItemIterator it( this );
249 while ( it.current() && 249 while ( it.current() &&
250 it.current()->text( col_ap ) != viaFrom.toString(true) && 250 it.current()->text( col_ap ) != viaFrom.toString(true) &&
251 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; 251 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it;
252 252
253 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 253 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
254 254
255 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations 255 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations
256 { 256 {
257 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); 257 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
258 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); 258 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to );
259 } 259 }
260 else 260 else
261 { 261 {
262 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); 262 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" );
263 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); 263 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" );
264 } 264 }
265} 265}
266 266
267 267
268void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 268void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
269{ 269{
270 QString s; 270 QString s;
271 MScanListItem* network; 271 MScanListItem* network;
272 272
273 QListViewItemIterator it( this ); 273 QListViewItemIterator it( this );
274 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 274 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
275 275
276 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 276 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
277 277
278 if ( item ) // AP has shown up yet, so just add our new "from" - station 278 if ( item ) // AP has shown up yet, so just add our new "from" - station
279 { 279 {
280 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); 280 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" );
281 } 281 }
282 else 282 else
283 { 283 {
284 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); 284 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
285 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); 285 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
286 286
287 } 287 }
288} 288}
289 289
290 290
291void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 291void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
292{ 292{
293 QString s; 293 QString s;
294 MScanListItem* network; 294 MScanListItem* network;
295 295
296 QListViewItemIterator it( this ); 296 QListViewItemIterator it( this );
297 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 297 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
298 298
299 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 299 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
300 300
301 if ( item ) // AP has shown up yet, so just add our new "from" - station 301 if ( item ) // AP has shown up yet, so just add our new "from" - station
302 { 302 {
303 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); 303 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" );
304 } 304 }
305 else 305 else
306 { 306 {
307 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); 307 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
308 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); 308 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" );
309 } 309 }
310} 310}
311 311
312 312
313void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 313void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
314{ 314{
315 qWarning( "D'oh! Not yet implemented..." ); 315 qWarning( "D'oh! Not yet implemented..." );
316 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); 316 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
317} 317}
318 318
319 319
320void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) 320void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
321{ 321{
322 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); 322 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip );
323 323
324 QListViewItemIterator it( this ); 324 QListViewItemIterator it( this );
325 for ( ; it.current(); ++it ) 325 for ( ; it.current(); ++it )
326 { 326 {
327 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 327 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
328 { 328 {
329 it.current()->setText( col_ip, ip ); 329 it.current()->setText( col_ip, ip );
330 return; 330 return;
331 } 331 }
332 } 332 }
333 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 333 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
334 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 334 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
335 (const char*) macaddr.toString(), (const char*) ip ) ); 335 (const char*) macaddr.toString(), (const char*) ip ) );
336} 336}
337 337
338 338
339void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) 339void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
340{ 340{
341 qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); 341 qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip );
342 342
343 //TODO: Refactor that out, we need it all over the place. 343 //TODO: Refactor that out, we need it all over the place.
344 // Best to do it in a more comfortable abstraction in OListView 344 // Best to do it in a more comfortable abstraction in OListView
345 // (Hmm, didn't I already start something in this direction?) 345 // (Hmm, didn't I already start something in this direction?)
346 346
347 QListViewItemIterator it( this ); 347 QListViewItemIterator it( this );
348 for ( ; it.current(); ++it ) 348 for ( ; it.current(); ++it )
349 { 349 {
350 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 350 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
351 { 351 {
352 352
353 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); 353 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
354 354
355 while ( subitem && ( subitem->text( col_essid ) != name ) ) 355 while ( subitem && ( subitem->text( col_essid ) != name ) )
356 { 356 {
357 #ifdef DEBUG 357 #ifdef DEBUG
358 qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); 358 qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) );
359 #endif 359 #endif
360 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 360 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
361 } 361 }
362 362
363 if ( subitem ) 363 if ( subitem )
364 { 364 {
365 // we have already seen this item, it's a dupe 365 // we have already seen this item, it's a dupe
366 #ifdef DEBUG 366 #ifdef DEBUG
367 qDebug( "%s is a dupe - ignoring...", (const char*) name ); 367 qDebug( "%s is a dupe - ignoring...", (const char*) name );
368 #endif 368 #endif
369 subitem->receivedBeacon(); //FIXME: sent data bit 369 subitem->receivedBeacon(); //FIXME: sent data bit
370 return; 370 return;
371 } 371 }
372 372
373 // never seen that - add new item 373 // never seen that - add new item
374 374
375 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); 375 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 );
376 item->setText( col_essid, name ); 376 item->setText( col_essid, name );
377 377
378 return; 378 return;
379 } 379 }
380 } 380 }
381 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 381 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
382 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", 382 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
383 (const char*) macaddr.toString(), (const char*) ip ) ); 383 (const char*) macaddr.toString(), (const char*) ip ) );
384} 384}
385 385
386 386
387void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) 387void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
388{ 388{
389 if ( !item ) return; 389 if ( !item ) return;
390 390
391 MScanListItem* itm = static_cast<MScanListItem*>( item ); 391 MScanListItem* itm = static_cast<MScanListItem*>( item );
392 392
393 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", 393 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
394 (const char*) itm->text(0), (const char*) itm->type, col ); 394 (const char*) itm->text(0), (const char*) itm->type, col );
395 395
396 if ( itm->type == "adhoc" || itm->type == "managed" ) 396 if ( itm->type == "adhoc" || itm->type == "managed" )
397 { 397 {
398 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); 398 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
399 399
400 QPopupMenu m( this ); 400 QPopupMenu m( this );
401 m.insertItem( entry, 37773, 0 ); 401 m.insertItem( entry, 37773, 0 );
402 int result = m.exec( QCursor::pos() ); 402 int result = m.exec( QCursor::pos() );
403 if ( result == 37773 ) 403 if ( result == 37773 )
404 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); 404 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
405 } 405 }
406} 406}
407 407
408//============================================================ 408//============================================================
409// MScanListItem 409// MScanListItem
410//============================================================ 410//============================================================
411 411
412MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, 412MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr,
413 bool wep, int channel, int signal ) 413 bool wep, int channel, int signal, bool probed )
414 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 414 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
415 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 415 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
416 _channel( channel ), _signal( signal ), _beacons( 1 ) 416 _channel( channel ), _signal( signal ), _beacons( 1 )
417{ 417{
418 #ifdef DEBUG 418 #ifdef DEBUG
419 qDebug( "creating scanlist item" ); 419 qDebug( "creating scanlist item" );
420 #endif 420 #endif
421 421
422 if ( WellenreiterConfigWindow::instance() ) 422 if ( WellenreiterConfigWindow::instance() )
423 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here 423 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
424 424
425 decorateItem( type, essid, macaddr, wep, channel, signal ); 425 decorateItem( type, essid, macaddr, wep, channel, signal, probed );
426} 426}
427 427
428MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, 428MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr,
429 bool wep, int channel, int signal ) 429 bool wep, int channel, int signal )
430 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 430 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
431{ 431{
432 #ifdef DEBUG 432 #ifdef DEBUG
433 qDebug( "creating scanlist item" ); 433 qDebug( "creating scanlist item" );
434 #endif 434 #endif
435 decorateItem( type, essid, macaddr, wep, channel, signal ); 435 decorateItem( type, essid, macaddr, wep, channel, signal, false );
436} 436}
437 437
438const QString& MScanListItem::essid() const 438const QString& MScanListItem::essid() const
439{ 439{
440 if ( type == "network" ) 440 if ( type == "network" )
441 return _essid; 441 return _essid;
442 else 442 else
443 return ( (MScanListItem*) parent() )->essid(); 443 return ( (MScanListItem*) parent() )->essid();
444} 444}
445 445
446OListViewItem* MScanListItem::childFactory() 446OListViewItem* MScanListItem::childFactory()
447{ 447{
448 return new MScanListItem( this ); 448 return new MScanListItem( this );
449} 449}
450 450
451void MScanListItem::serializeTo( QDataStream& s ) const 451void MScanListItem::serializeTo( QDataStream& s ) const
452{ 452{
453 #ifdef DEBUG 453 #ifdef DEBUG
454 qDebug( "serializing MScanListItem" ); 454 qDebug( "serializing MScanListItem" );
455 #endif 455 #endif
456 OListViewItem::serializeTo( s ); 456 OListViewItem::serializeTo( s );
457 457
458 s << _type; 458 s << _type;
459 s << (Q_UINT8) ( _wep ? 'y' : 'n' ); 459 s << (Q_UINT8) ( _wep ? 'y' : 'n' );
460} 460}
461 461
462void MScanListItem::serializeFrom( QDataStream& s ) 462void MScanListItem::serializeFrom( QDataStream& s )
463{ 463{
464 #ifdef DEBUG 464 #ifdef DEBUG
465 qDebug( "serializing MScanListItem" ); 465 qDebug( "serializing MScanListItem" );
466 #endif 466 #endif
467 OListViewItem::serializeFrom( s ); 467 OListViewItem::serializeFrom( s );
468 468
469 char wep; 469 char wep;
470 s >> _type; 470 s >> _type;
471 s >> (Q_UINT8) wep; 471 s >> (Q_UINT8) wep;
472 _wep = (wep == 'y'); 472 _wep = (wep == 'y');
473 473
474 QString name; 474 QString name;
475 name.sprintf( "wellenreiter/%s", (const char*) _type ); 475 name.sprintf( "wellenreiter/%s", (const char*) _type );
476 setPixmap( col_type, Resource::loadPixmap( name ) ); 476 setPixmap( col_type, Resource::loadPixmap( name ) );
477 if ( _wep ) 477 if ( _wep )
478 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 478 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
479 listView()->triggerUpdate(); 479 listView()->triggerUpdate();
480} 480}
481 481
482void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 482void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed )
483{ 483{
484 #ifdef DEBUG 484 #ifdef DEBUG
485 qDebug( "decorating scanlist item %s / %s / %s [%d]", 485 qDebug( "decorating scanlist item %s / %s / %s [%d]",
486 (const char*) type, 486 (const char*) type,
487 (const char*) essid, 487 (const char*) essid,
488 (const char*) macaddr, 488 (const char*) macaddr,
489 channel ); 489 channel );
490 #endif 490 #endif
491 491
492 // set icon for managed or adhoc mode 492 // set icon for managed or adhoc mode
493 QString name; 493 QString name;
494 name.sprintf( "wellenreiter/%s", (const char*) type ); 494 name.sprintf( "wellenreiter/%s", (const char*) type );
495 setPixmap( col_type, Resource::loadPixmap( name ) ); 495 setPixmap( col_type, Resource::loadPixmap( name ) );
496 496
497 // special case for probed networks FIXME: This is ugly at present
498 if ( type == "network" && probed )
499 {
500 setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) );
501 }
502
497 // set icon for wep (wireless encryption protocol) 503 // set icon for wep (wireless encryption protocol)
498 if ( wep ) 504 if ( wep )
499 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 505 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
500 506
501 // set channel and signal text 507 // set channel and signal text
502 508
503 if ( signal != -1 ) 509 if ( signal != -1 )
504 setText( col_sig, QString::number( signal ) ); 510 setText( col_sig, QString::number( signal ) );
505 if ( channel != -1 ) 511 if ( channel != -1 )
506 setText( col_channel, QString::number( channel ) ); 512 setText( col_channel, QString::number( channel ) );
507 513
508 setText( col_firstseen, QTime::currentTime().toString() ); 514 setText( col_firstseen, QTime::currentTime().toString() );
509 //setText( col_lastseen, QTime::currentTime().toString() ); 515 //setText( col_lastseen, QTime::currentTime().toString() );
510 516
511 listView()->triggerUpdate(); 517 listView()->triggerUpdate();
512 518
513 this->type = type; 519 this->type = type;
514 _type = type; 520 _type = type;
515 _essid = essid; 521 _essid = essid;
516 _macaddr = macaddr; 522 _macaddr = macaddr;
517 _channel = channel; 523 _channel = channel;
518 _beacons = 1; 524 _beacons = 1;
519 _signal = 0; 525 _signal = 0;
520 526
521 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) 527 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() )
522 { 528 {
523 listView()->ensureItemVisible( this ); 529 listView()->ensureItemVisible( this );
524 } 530 }
525 531
526} 532}
527 533
528 534
529void MScanListItem::setManufacturer( const QString& manufacturer ) 535void MScanListItem::setManufacturer( const QString& manufacturer )
530{ 536{
531 setText( col_manuf, manufacturer ); 537 setText( col_manuf, manufacturer );
532} 538}
533 539
534 540
535void MScanListItem::setLocation( const QString& location ) 541void MScanListItem::setLocation( const QString& location )
536{ 542{
537 setText( col_location, location ); 543 setText( col_location, location );
538} 544}
539 545
540 546
541void MScanListItem::receivedBeacon() 547void MScanListItem::receivedBeacon()
542{ 548{
543 _beacons++; 549 _beacons++;
544 #ifdef DEBUG 550 #ifdef DEBUG
545 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 551 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
546 #endif 552 #endif
547 setText( col_sig, QString::number( _beacons ) ); 553 setText( col_sig, QString::number( _beacons ) );
548 setText( col_lastseen, QTime::currentTime().toString() ); 554 setText( col_lastseen, QTime::currentTime().toString() );
549 555
550 MScanListItem* p = (MScanListItem*) parent(); 556 MScanListItem* p = (MScanListItem*) parent();
551 if ( p ) p->receivedBeacon(); 557 if ( p ) p->receivedBeacon();
552 558
553} 559}
554 560
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index e8d48c3..cbacdee 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -1,139 +1,140 @@
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 "gps.h" 19#include "gps.h"
20 20
21/* OPIE */ 21/* OPIE */
22#include <opie2/olistview.h> 22#include <opie2/olistview.h>
23#include <opie2/onetutils.h> 23#include <opie2/onetutils.h>
24 24
25/* QT */ 25/* QT */
26#include <qtextstream.h> 26#include <qtextstream.h>
27 27
28class QString; 28class QString;
29class MScanListItem; 29class MScanListItem;
30 30
31class MScanListView: public OListView 31class MScanListView: public OListView
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35 public: 35 public:
36 MScanListView( QWidget* parent = 0, const char* name = 0 ); 36 MScanListView( QWidget* parent = 0, const char* name = 0 );
37 virtual ~MScanListView(); 37 virtual ~MScanListView();
38 38
39 virtual OListViewItem* childFactory(); 39 virtual OListViewItem* childFactory();
40 virtual void serializeTo( QDataStream& s ) const; 40 virtual void serializeTo( QDataStream& s ) const;
41 virtual void serializeFrom( QDataStream& s ); 41 virtual void serializeFrom( QDataStream& s );
42 42
43 public slots: 43 public slots:
44 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal, const GpsLocation& location ); 44 void addNewItem( const QString& type, const QString&, const OMacAddress&, bool, int, int, const GpsLocation&, bool = false );
45 void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); 45 void addService( const QString& name, const OMacAddress& macaddr, const QString& ip );
46 46
47 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 47 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
48 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 48 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
49 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); 49 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo );
50 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 50 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
51 51
52 void identify( const OMacAddress&, const QString& ipaddr ); 52 void identify( const OMacAddress&, const QString& ipaddr );
53 53
54 void contextMenuRequested( QListViewItem* item, const QPoint&, int ); 54 void contextMenuRequested( QListViewItem* item, const QPoint&, int );
55 55
56 signals: 56 signals:
57 void rightButtonClicked(QListViewItem*,const QPoint&,int); 57 void rightButtonClicked(QListViewItem*,const QPoint&,int);
58 void joinNetwork( const QString&, const QString&, int, const QString& ); 58 void joinNetwork( const QString&, const QString&, int, const QString& );
59 59
60 protected: 60 protected:
61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); 61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" );
62 62
63}; 63};
64 64
65//****************************** MScanListItem **************************************************************** 65//****************************** MScanListItem ****************************************************************
66 66
67class MScanListItem: public OListViewItem 67class MScanListItem: public OListViewItem
68{ 68{
69 public: 69 public:
70 MScanListItem::MScanListItem( QListView* parent, 70 MScanListItem::MScanListItem( QListView* parent,
71 const QString& type = "unknown", 71 const QString& type = "unknown",
72 const QString& essid = "unknown", 72 const QString& essid = "unknown",
73 const QString& macaddr = "unknown", 73 const QString& macaddr = "unknown",
74 bool wep = false, 74 bool wep = false,
75 int channel = 0, 75 int channel = 0,
76 int signal = 0 ); 76 int signal = 0,
77 bool probed = false );
77 78
78 MScanListItem::MScanListItem( QListViewItem* parent, 79 MScanListItem::MScanListItem( QListViewItem* parent,
79 const QString& type = "unknown", 80 const QString& type = "unknown",
80 const QString& essid = "unknown", 81 const QString& essid = "unknown",
81 const QString& macaddr = "unknown", 82 const QString& macaddr = "unknown",
82 bool wep = false, 83 bool wep = false,
83 int channel = 0, 84 int channel = 0,
84 int signal = 0 ); 85 int signal = 0 );
85 86
86 87
87 protected: 88 protected:
88 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 89 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed );
89 90
90 public: 91 public:
91 QString type; 92 QString type;
92 93
93 public: 94 public:
94 //const QString& type() { return _type; }; 95 //const QString& type() { return _type; };
95 const QString& essid() const; 96 const QString& essid() const;
96 const QString& macaddr() { return _macaddr; }; 97 const QString& macaddr() { return _macaddr; };
97 bool wep() { return _wep; }; 98 bool wep() { return _wep; };
98 int channel() { return _channel; }; 99 int channel() { return _channel; };
99 int signal() { return _signal; }; 100 int signal() { return _signal; };
100 int beacons() { return _beacons; }; 101 int beacons() { return _beacons; };
101 102
102 void setSignal( int signal ) { /* TODO */ }; 103 void setSignal( int signal ) { /* TODO */ };
103 void receivedBeacon(); 104 void receivedBeacon();
104 105
105 void setManufacturer( const QString& manufacturer ); 106 void setManufacturer( const QString& manufacturer );
106 void setLocation( const QString& location ); 107 void setLocation( const QString& location );
107 108
108 virtual OListViewItem* childFactory(); 109 virtual OListViewItem* childFactory();
109 virtual void serializeTo( QDataStream& s ) const; 110 virtual void serializeTo( QDataStream& s ) const;
110 virtual void serializeFrom( QDataStream& s ); 111 virtual void serializeFrom( QDataStream& s );
111 112
112 private: 113 private:
113 QString _type; 114 QString _type;
114 QString _essid; 115 QString _essid;
115 QString _macaddr; 116 QString _macaddr;
116 bool _wep; 117 bool _wep;
117 int _channel; 118 int _channel;
118 int _signal; 119 int _signal;
119 int _beacons; 120 int _beacons;
120 121
121}; 122};
122 123
123//****************************** MScanListViewFactory **************************************************************** 124//****************************** MScanListViewFactory ****************************************************************
124 125
125/* 126/*
126 127
127class MScanListViewFactory : public OListViewFactory 128class MScanListViewFactory : public OListViewFactory
128{ 129{
129public: 130public:
130 virtual QListView* listViewFactory(); 131 virtual QListView* listViewFactory();
131 virtual QListViewItem* listViewItemFactory( QListView* lv ); 132 virtual QListViewItem* listViewItemFactory( QListView* lv );
132 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 133 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
133 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 134 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
134 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 135 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
135} 136}
136*/ 137*/
137 138
138#endif 139#endif
139 140
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 25632f3..cd74bed 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,603 +1,636 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Local 16// Local
17 17
18#include "gps.h" 18#include "gps.h"
19#include "wellenreiter.h" 19#include "wellenreiter.h"
20#include "scanlist.h" 20#include "scanlist.h"
21#include "logwindow.h" 21#include "logwindow.h"
22#include "hexwindow.h" 22#include "hexwindow.h"
23#include "configwindow.h" 23#include "configwindow.h"
24#include "statwindow.h" 24#include "statwindow.h"
25#include "graphwindow.h" 25#include "graphwindow.h"
26#include "protolistview.h" 26#include "protolistview.h"
27 27
28// Opie 28// Opie
29 29
30#ifdef QWS 30#ifdef QWS
31#include <opie/odevice.h> 31#include <opie/odevice.h>
32#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
33using namespace Opie; 33using namespace Opie;
34#endif 34#endif
35 35
36#ifdef QWS 36#ifdef QWS
37#include <opie2/oapplication.h> 37#include <opie2/oapplication.h>
38#else 38#else
39#include <qapplication.h> 39#include <qapplication.h>
40#endif 40#endif
41#include <opie2/omanufacturerdb.h> 41#include <opie2/omanufacturerdb.h>
42#include <opie2/onetwork.h> 42#include <opie2/onetwork.h>
43#include <opie2/opcap.h> 43#include <opie2/opcap.h>
44 44
45// Qt 45// Qt
46 46
47#include <qcheckbox.h> 47#include <qcheckbox.h>
48#include <qcombobox.h> 48#include <qcombobox.h>
49#include <qdatetime.h> 49#include <qdatetime.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qlineedit.h> 51#include <qlineedit.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qobjectlist.h> 53#include <qobjectlist.h>
54#include <qregexp.h> 54#include <qregexp.h>
55#include <qspinbox.h> 55#include <qspinbox.h>
56#include <qtimer.h> 56#include <qtimer.h>
57#include <qtoolbutton.h> 57#include <qtoolbutton.h>
58#include <qmainwindow.h> 58#include <qmainwindow.h>
59 59
60// Standard 60// Standard
61 61
62#include <assert.h> 62#include <assert.h>
63#include <errno.h> 63#include <errno.h>
64#include <unistd.h> 64#include <unistd.h>
65#include <string.h> 65#include <string.h>
66#include <sys/types.h> 66#include <sys/types.h>
67#include <stdlib.h> 67#include <stdlib.h>
68 68
69Wellenreiter::Wellenreiter( QWidget* parent ) 69Wellenreiter::Wellenreiter( QWidget* parent )
70 : WellenreiterBase( parent, 0, 0 ), 70 : WellenreiterBase( parent, 0, 0 ),
71 sniffing( false ), iface( 0 ), configwindow( 0 ) 71 sniffing( false ), iface( 0 ), configwindow( 0 )
72{ 72{
73 73
74 logwindow->log( "(i) Wellenreiter has been started." ); 74 logwindow->log( "(i) Wellenreiter has been started." );
75 75
76 // 76 //
77 // detect operating system 77 // detect operating system
78 // 78 //
79 79
80 #ifdef QWS 80 #ifdef QWS
81 QString sys; 81 QString sys;
82 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 82 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
83 _system = ODevice::inst()->system(); 83 _system = ODevice::inst()->system();
84 logwindow->log( sys ); 84 logwindow->log( sys );
85 #endif 85 #endif
86 86
87 netview->setColumnWidthMode( 1, QListView::Manual ); 87 netview->setColumnWidthMode( 1, QListView::Manual );
88 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 88 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
89 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 89 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
90 pcap = new OPacketCapturer(); 90 pcap = new OPacketCapturer();
91 91
92 gps = new GPS( this ); 92 gps = new GPS( this );
93 93
94 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); 94 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
95 95
96} 96}
97 97
98 98
99Wellenreiter::~Wellenreiter() 99Wellenreiter::~Wellenreiter()
100{ 100{
101 delete pcap; 101 delete pcap;
102} 102}
103 103
104 104
105void Wellenreiter::initialTimer() 105void Wellenreiter::initialTimer()
106{ 106{
107 qDebug( "Wellenreiter::preloading manufacturer database..." ); 107 qDebug( "Wellenreiter::preloading manufacturer database..." );
108 OManufacturerDB::instance(); 108 OManufacturerDB::instance();
109} 109}
110 110
111 111
112void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 112void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
113{ 113{
114 configwindow = cw; 114 configwindow = cw;
115} 115}
116 116
117 117
118void Wellenreiter::channelHopped(int c) 118void Wellenreiter::channelHopped(int c)
119{ 119{
120 QString title = "Wellenreiter II -scan- ["; 120 QString title = "Wellenreiter II -scan- [";
121 QString left; 121 QString left;
122 if ( c > 1 ) left.fill( '.', c-1 ); 122 if ( c > 1 ) left.fill( '.', c-1 );
123 title.append( left ); 123 title.append( left );
124 title.append( '|' ); 124 title.append( '|' );
125 if ( c < iface->channels() ) 125 if ( c < iface->channels() )
126 { 126 {
127 QString right; 127 QString right;
128 right.fill( '.', iface->channels()-c ); 128 right.fill( '.', iface->channels()-c );
129 title.append( right ); 129 title.append( right );
130 } 130 }
131 title.append( "]" ); 131 title.append( "]" );
132 //title.append( QString().sprintf( " %02d", c ) ); 132 //title.append( QString().sprintf( " %02d", c ) );
133 assert( parent() ); 133 assert( parent() );
134 ( (QMainWindow*) parent() )->setCaption( title ); 134 ( (QMainWindow*) parent() )->setCaption( title );
135} 135}
136 136
137 137
138void Wellenreiter::handleNotification( OPacket* p ) 138void Wellenreiter::handleNotification( OPacket* p )
139{ 139{
140 QObjectList* l = p->queryList(); 140 QObjectList* l = p->queryList();
141 QObjectListIt it( *l ); 141 QObjectListIt it( *l );
142 QObject* o; 142 QObject* o;
143 143
144 while ( (o = it.current()) != 0 ) 144 while ( (o = it.current()) != 0 )
145 { 145 {
146 QString name = it.current()->name(); 146 QString name = it.current()->name();
147 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 147 if ( configwindow->parsePackets->isProtocolChecked( name ) )
148 { 148 {
149 QString action = configwindow->parsePackets->protocolAction( name ); 149 QString action = configwindow->parsePackets->protocolAction( name );
150 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 150 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
151 doAction( action, name, p ); 151 doAction( action, name, p );
152 } 152 }
153 else 153 else
154 { 154 {
155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 155 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
156 } 156 }
157 ++it; 157 ++it;
158 } 158 }
159} 159}
160 160
161 161
162void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 162void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
163{ 163{
164 if ( manage->managementType() != "Beacon" ) return; // only handling beacons at that time 164 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
165 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
166 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
167 else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() );
168}
165 169
166 OWaveLanManagementPacket* beacon = manage;
167 170
171void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request )
172{
173 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
174 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
175 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
176 int channel = ds ? ds->channel() : -1;
177 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
178
179 GpsLocation loc( -111, -111 );
180 if ( configwindow->enableGPS->isChecked() )
181 {
182 // TODO: add check if GPS is working!?
183 qDebug( "Wellenreiter::gathering GPS data..." );
184 loc = gps->position();
185 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
186 }
187
188 if ( essid.length() )
189 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
190 qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" );
191}
192
193
194void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response )
195{
196}
197
198
199void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
200{
168 QString type; 201 QString type;
169 if ( beacon->canIBSS() ) 202 if ( beacon->canIBSS() )
170 { 203 {
171 type = "adhoc"; 204 type = "adhoc";
172 } 205 }
173 else if ( beacon->canESS() ) 206 else if ( beacon->canESS() )
174 { 207 {
175 type = "managed"; 208 type = "managed";
176 } 209 }
177 else 210 else
178 { 211 {
179 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 212 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
180 return; 213 return;
181 } 214 }
182 215
183 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 216 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
184 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 217 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
185 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 218 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
186 int channel = ds ? ds->channel() : -1; 219 int channel = ds ? ds->channel() : -1;
187 220
188 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 221 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
189 222
190 GpsLocation loc( -111, -111 ); 223 GpsLocation loc( -111, -111 );
191 if ( configwindow->enableGPS->isChecked() ) 224 if ( configwindow->enableGPS->isChecked() )
192 { 225 {
193 // TODO: add check if GPS is working!? 226 // TODO: add check if GPS is working!?
194 qDebug( "Wellenreiter::gathering GPS data..." ); 227 qDebug( "Wellenreiter::gathering GPS data..." );
195 loc = gps->position(); 228 loc = gps->position();
196 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); 229 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
197 } 230 }
198 231
199 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 232 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
200 233
201 // update graph window 234 // update graph window
202 if ( ds ) 235 if ( ds )
203 { 236 {
204 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 237 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
205 if ( prism ) 238 if ( prism )
206 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 239 graphwindow->traffic( ds->channel(), prism->signalStrength() );
207 else 240 else
208 graphwindow->traffic( ds->channel(), 95 ); 241 graphwindow->traffic( ds->channel(), 95 );
209 } 242 }
210} 243}
211 244
212 245
213void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) 246void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
214{ 247{
215 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 248 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
216 249
217 if ( control->controlType() == "Acknowledge" ) 250 if ( control->controlType() == "Acknowledge" )
218 { 251 {
219 netView()->addNewItem( "adhoc", "???", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 252 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
220 } 253 }
221 else 254 else
222 { 255 {
223 qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); 256 qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() );
224 } 257 }
225} 258}
226 259
227 260
228void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 261void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
229{ 262{
230 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 263 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
231 if ( wlan->fromDS() && !wlan->toDS() ) 264 if ( wlan->fromDS() && !wlan->toDS() )
232 { 265 {
233 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 266 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
234 from = wlan->macAddress3(); 267 from = wlan->macAddress3();
235 to = wlan->macAddress2(); 268 to = wlan->macAddress2();
236 } 269 }
237 else if ( !wlan->fromDS() && wlan->toDS() ) 270 else if ( !wlan->fromDS() && wlan->toDS() )
238 { 271 {
239 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 272 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
240 from = wlan->macAddress2(); 273 from = wlan->macAddress2();
241 to = wlan->macAddress3(); 274 to = wlan->macAddress3();
242 } 275 }
243 else if ( wlan->fromDS() && wlan->toDS() ) 276 else if ( wlan->fromDS() && wlan->toDS() )
244 { 277 {
245 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 278 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
246 from = wlan->macAddress4(); 279 from = wlan->macAddress4();
247 to = wlan->macAddress3(); 280 to = wlan->macAddress3();
248 } 281 }
249 else 282 else
250 { 283 {
251 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 284 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
252 from = wlan->macAddress2(); 285 from = wlan->macAddress2();
253 to = wlan->macAddress1(); 286 to = wlan->macAddress1();
254 } 287 }
255} 288}
256 289
257 290
258void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 291void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
259{ 292{
260 from = data->sourceAddress(); 293 from = data->sourceAddress();
261 to = data->destinationAddress(); 294 to = data->destinationAddress();
262 295
263 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 296 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
264} 297}
265 298
266 299
267void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 300void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
268{ 301{
269 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 302 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
270 if ( arp ) 303 if ( arp )
271 { 304 {
272 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 305 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
273 if ( arp->type() == "REQUEST" ) 306 if ( arp->type() == "REQUEST" )
274 { 307 {
275 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 308 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
276 } 309 }
277 else if ( arp->type() == "REPLY" ) 310 else if ( arp->type() == "REPLY" )
278 { 311 {
279 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 312 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
280 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 313 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
281 } 314 }
282 } 315 }
283} 316}
284 317
285 318
286void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 319void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
287{ 320{
288 //TODO: Implement more IP based protocols 321 //TODO: Implement more IP based protocols
289 322
290 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 323 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
291 if ( dhcp ) 324 if ( dhcp )
292 { 325 {
293 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 326 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
294 if ( dhcp->type() == "OFFER" ) 327 if ( dhcp->type() == "OFFER" )
295 { 328 {
296 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 329 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
297 netView()->identify( source, dhcp->serverAddress().toString() ); 330 netView()->identify( source, dhcp->serverAddress().toString() );
298 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 331 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
299 } 332 }
300 else if ( dhcp->type() == "ACK" ) 333 else if ( dhcp->type() == "ACK" )
301 { 334 {
302 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 335 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
303 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 336 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
304 } 337 }
305 } 338 }
306} 339}
307 340
308 341
309QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 342QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
310{ 343{
311 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 344 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
312 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 345 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
313 return 0; 346 return 0;
314 347
315 return p->child( protocol ); 348 return p->child( protocol );
316} 349}
317 350
318 351
319bool Wellenreiter::checkDumpPacket( OPacket* p ) 352bool Wellenreiter::checkDumpPacket( OPacket* p )
320{ 353{
321 // go through all child packets and see if one is inside the child hierarchy for p 354 // go through all child packets and see if one is inside the child hierarchy for p
322 // if so, do what the user requested (protocolAction), e.g. pass or discard 355 // if so, do what the user requested (protocolAction), e.g. pass or discard
323 if ( !configwindow->writeCaptureFile->isChecked() ) 356 if ( !configwindow->writeCaptureFile->isChecked() )
324 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 357 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
325 358
326 QObjectList* l = p->queryList(); 359 QObjectList* l = p->queryList();
327 QObjectListIt it( *l ); 360 QObjectListIt it( *l );
328 QObject* o; 361 QObject* o;
329 362
330 while ( (o = it.current()) != 0 ) 363 while ( (o = it.current()) != 0 )
331 { 364 {
332 QString name = it.current()->name(); 365 QString name = it.current()->name();
333 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 366 if ( configwindow->capturePackets->isProtocolChecked( name ) )
334 { 367 {
335 QString action = configwindow->capturePackets->protocolAction( name ); 368 QString action = configwindow->capturePackets->protocolAction( name );
336 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 369 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
337 if ( action == "Discard" ) 370 if ( action == "Discard" )
338 { 371 {
339 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 372 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
340 return false; 373 return false;
341 } 374 }
342 } 375 }
343 else 376 else
344 { 377 {
345 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 378 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
346 } 379 }
347 ++it; 380 ++it;
348 } 381 }
349 return true; 382 return true;
350} 383}
351 384
352 385
353void Wellenreiter::receivePacket( OPacket* p ) 386void Wellenreiter::receivePacket( OPacket* p )
354{ 387{
355 hexWindow()->log( p->dump( 8 ) ); 388 hexWindow()->log( p->dump( 8 ) );
356 389
357 if ( checkDumpPacket( p ) ) 390 if ( checkDumpPacket( p ) )
358 { 391 {
359 pcap->dump( p ); 392 pcap->dump( p );
360 } 393 }
361 394
362 // check for a management frame 395 // check for a management frame
363 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 396 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
364 if ( manage ) 397 if ( manage )
365 { 398 {
366 handleManagementFrame( p, manage ); 399 handleManagementFrame( p, manage );
367 return; 400 return;
368 } 401 }
369 402
370 // check for a control frame 403 // check for a control frame
371 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 404 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
372 if ( control ) 405 if ( control )
373 { 406 {
374 handleControlFrame( p, control ); 407 handleControlFrame( p, control );
375 return; 408 return;
376 } 409 }
377 410
378 OMacAddress source; 411 OMacAddress source;
379 OMacAddress dest; 412 OMacAddress dest;
380 413
381 //TODO: WEP check here 414 //TODO: WEP check here
382 415
383 // check for a wireless data frame 416 // check for a wireless data frame
384 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 417 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
385 if ( wlan ) 418 if ( wlan )
386 { 419 {
387 handleWlanData( p, wlan, source, dest ); 420 handleWlanData( p, wlan, source, dest );
388 } 421 }
389 422
390 // check for a wired data frame 423 // check for a wired data frame
391 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 424 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
392 if ( eth ) 425 if ( eth )
393 { 426 {
394 handleEthernetData( p, eth, source, dest ); 427 handleEthernetData( p, eth, source, dest );
395 } 428 }
396 429
397 // check for an arp frame since arp frames come in two flavours: 430 // check for an arp frame since arp frames come in two flavours:
398 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 431 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
399 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 432 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
400 if ( arp ) 433 if ( arp )
401 { 434 {
402 handleARPData( p, arp, source, dest ); 435 handleARPData( p, arp, source, dest );
403 } 436 }
404 437
405 // check for a ip frame 438 // check for a ip frame
406 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 439 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
407 if ( ip ) 440 if ( ip )
408 { 441 {
409 handleIPData( p, ip, source, dest ); 442 handleIPData( p, ip, source, dest );
410 } 443 }
411 444
412 //handleNotification( p ); 445 //handleNotification( p );
413 446
414} 447}
415 448
416 449
417void Wellenreiter::stopClicked() 450void Wellenreiter::stopClicked()
418{ 451{
419 if ( iface ) 452 if ( iface )
420 { 453 {
421 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 454 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
422 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 455 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
423 iface->setChannelHopping(); // stop hopping channels 456 iface->setChannelHopping(); // stop hopping channels
424 } 457 }
425 else 458 else
426 killTimers(); 459 killTimers();
427 460
428 pcap->close(); 461 pcap->close();
429 sniffing = false; 462 sniffing = false;
430 463
431 if ( iface ) 464 if ( iface )
432 { 465 {
433 // switch off monitor mode 466 // switch off monitor mode
434 iface->setMode( "managed" ); 467 iface->setMode( "managed" );
435 // switch off promisc flag 468 // switch off promisc flag
436 iface->setPromiscuousMode( false ); 469 iface->setPromiscuousMode( false );
437 470
438 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 471 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
439 } 472 }
440 473
441 logwindow->log( "(i) Stopped Scanning." ); 474 logwindow->log( "(i) Stopped Scanning." );
442 assert( parent() ); 475 assert( parent() );
443 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 476 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
444 477
445 // message the user 478 // message the user
446 QMessageBox::information( this, "Wellenreiter II", 479 QMessageBox::information( this, "Wellenreiter II",
447 tr( "Your wireless card\nshould now be usable again." ) ); 480 tr( "Your wireless card\nshould now be usable again." ) );
448 481
449 sniffing = false; 482 sniffing = false;
450 emit( stoppedSniffing() ); 483 emit( stoppedSniffing() );
451 484
452 #ifdef QWS 485 #ifdef QWS
453 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 486 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
454 { 487 {
455 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 488 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
456 } 489 }
457 #else 490 #else
458 #warning FIXME: setScreenSaverMode is not operational on the X11 build 491 #warning FIXME: setScreenSaverMode is not operational on the X11 build
459 #endif 492 #endif
460 493
461 // print out statistics 494 // print out statistics
462 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 495 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
463 statwindow->updateCounter( it.key(), it.data() ); 496 statwindow->updateCounter( it.key(), it.data() );
464} 497}
465 498
466 499
467void Wellenreiter::startClicked() 500void Wellenreiter::startClicked()
468{ 501{
469 // get configuration from config window 502 // get configuration from config window
470 503
471 const QString& interface = configwindow->interfaceName->currentText(); 504 const QString& interface = configwindow->interfaceName->currentText();
472 const int cardtype = configwindow->driverType(); 505 const int cardtype = configwindow->driverType();
473 const int interval = configwindow->hoppingInterval(); 506 const int interval = configwindow->hoppingInterval();
474 507
475 if ( ( interface == "" ) || ( cardtype == 0 ) ) 508 if ( ( interface == "" ) || ( cardtype == 0 ) )
476 { 509 {
477 QMessageBox::information( this, "Wellenreiter II", 510 QMessageBox::information( this, "Wellenreiter II",
478 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 511 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
479 return; 512 return;
480 } 513 }
481 514
482 // configure device 515 // configure device
483 ONetwork* net = ONetwork::instance(); 516 ONetwork* net = ONetwork::instance();
484 517
485 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 518 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
486 519
487 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 520 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
488 521
489 // bring device UP 522 // bring device UP
490 if ( cardtype != DEVTYPE_FILE ) 523 if ( cardtype != DEVTYPE_FILE )
491 { 524 {
492 iface->setUp( true ); 525 iface->setUp( true );
493 if ( !iface->isUp() ) 526 if ( !iface->isUp() )
494 { 527 {
495 QMessageBox::warning( this, "Wellenreiter II", 528 QMessageBox::warning( this, "Wellenreiter II",
496 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 529 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
497 return; 530 return;
498 } 531 }
499 } 532 }
500 // set monitor mode 533 // set monitor mode
501 bool usePrism = configwindow->usePrismHeader(); 534 bool usePrism = configwindow->usePrismHeader();
502 535
503 switch ( cardtype ) 536 switch ( cardtype )
504 { 537 {
505 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 538 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
506 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 539 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
507 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 540 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
508 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 541 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
509 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 542 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
510 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 543 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
511 default: assert( 0 ); // shouldn't reach this 544 default: assert( 0 ); // shouldn't reach this
512 } 545 }
513 546
514 // switch device into monitor mode 547 // switch device into monitor mode
515 if ( cardtype < DEVTYPE_FILE ) 548 if ( cardtype < DEVTYPE_FILE )
516 { 549 {
517 if ( cardtype != DEVTYPE_MANUAL ) 550 if ( cardtype != DEVTYPE_MANUAL )
518 iface->setMode( "monitor" ); 551 iface->setMode( "monitor" );
519 if ( iface->mode() != "monitor" ) 552 if ( iface->mode() != "monitor" )
520 { 553 {
521 if ( QMessageBox::warning( this, "Wellenreiter II", 554 if ( QMessageBox::warning( this, "Wellenreiter II",
522 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 555 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
523 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 556 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
524 return; 557 return;
525 } 558 }
526 } 559 }
527 560
528 // open GPS device 561 // open GPS device
529 if ( configwindow->enableGPS->isChecked() ) 562 if ( configwindow->enableGPS->isChecked() )
530 { 563 {
531 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 564 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
532 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 565 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
533 } 566 }
534 567
535 // open pcap and start sniffing 568 // open pcap and start sniffing
536 569
537 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 570 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
538 { 571 {
539 dumpname = configwindow->captureFileName->text(); 572 dumpname = configwindow->captureFileName->text();
540 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 573 if ( dumpname.isEmpty() ) dumpname = "captureFile";
541 dumpname.append( '-' ); 574 dumpname.append( '-' );
542 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 575 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
543 dumpname.append( ".wellenreiter" ); 576 dumpname.append( ".wellenreiter" );
544 } 577 }
545 else // write it anyway ;) 578 else // write it anyway ;)
546 { 579 {
547 dumpname = "/var/log/dump.wellenreiter"; 580 dumpname = "/var/log/dump.wellenreiter";
548 } 581 }
549 582
550 if ( cardtype != DEVTYPE_FILE ) 583 if ( cardtype != DEVTYPE_FILE )
551 pcap->open( interface ); 584 pcap->open( interface );
552 else 585 else
553 pcap->open( QFile( interface ) ); 586 pcap->open( QFile( interface ) );
554 587
555 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); 588 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
556 pcap->openDumpFile( dumpname ); 589 pcap->openDumpFile( dumpname );
557 590
558 if ( !pcap->isOpen() ) 591 if ( !pcap->isOpen() )
559 { 592 {
560 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 593 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
561 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 594 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
562 return; 595 return;
563 } 596 }
564 597
565 // set capturer to non-blocking mode 598 // set capturer to non-blocking mode
566 pcap->setBlocking( false ); 599 pcap->setBlocking( false );
567 600
568 // start channel hopper 601 // start channel hopper
569 if ( cardtype != DEVTYPE_FILE ) 602 if ( cardtype != DEVTYPE_FILE )
570 { 603 {
571 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 604 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
572 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 605 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
573 } 606 }
574 607
575 if ( cardtype != DEVTYPE_FILE ) 608 if ( cardtype != DEVTYPE_FILE )
576 { 609 {
577 // connect socket notifier and start channel hopper 610 // connect socket notifier and start channel hopper
578 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 611 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
579 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 612 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
580 } 613 }
581 else 614 else
582 { 615 {
583 // start timer for reading packets 616 // start timer for reading packets
584 startTimer( 100 ); 617 startTimer( 100 );
585 } 618 }
586 619
587 logwindow->log( "(i) Started Scanning." ); 620 logwindow->log( "(i) Started Scanning." );
588 sniffing = true; 621 sniffing = true;
589 622
590 #ifdef QWS 623 #ifdef QWS
591 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 624 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
592 { 625 {
593 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 626 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
594 } 627 }
595 #else 628 #else
596 #warning FIXME: setScreenSaverMode is not operational on the X11 build 629 #warning FIXME: setScreenSaverMode is not operational on the X11 build
597 #endif 630 #endif
598 631
599 emit( startedSniffing() ); 632 emit( startedSniffing() );
600 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 633 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
601 else 634 else
602 { 635 {
603 assert( parent() ); 636 assert( parent() );
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 5414fda..a28740b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,106 +1,109 @@
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 WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26class QTimerEvent; 26class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OWaveLanManagementPacket; 29class OWaveLanManagementPacket;
30class OWaveLanControlPacket; 30class OWaveLanControlPacket;
31class OWaveLanDataPacket; 31class OWaveLanDataPacket;
32class OEthernetPacket; 32class OEthernetPacket;
33class OARPPacket; 33class OARPPacket;
34class OMacAddress; 34class OMacAddress;
35class OIPPacket; 35class OIPPacket;
36class OPacketCapturer; 36class OPacketCapturer;
37class OWirelessNetworkInterface; 37class OWirelessNetworkInterface;
38class WellenreiterConfigWindow; 38class WellenreiterConfigWindow;
39class MLogWindow; 39class MLogWindow;
40class MHexWindow; 40class MHexWindow;
41class GPS; 41class GPS;
42 42
43class Wellenreiter : public WellenreiterBase { 43class Wellenreiter : public WellenreiterBase {
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 Wellenreiter( QWidget* parent = 0 ); 47 Wellenreiter( QWidget* parent = 0 );
48 ~Wellenreiter(); 48 ~Wellenreiter();
49 49
50 void setConfigWindow( WellenreiterConfigWindow* cw ); 50 void setConfigWindow( WellenreiterConfigWindow* cw );
51 MScanListView* netView() const { return netview; }; 51 MScanListView* netView() const { return netview; };
52 MLogWindow* logWindow() const { return logwindow; }; 52 MLogWindow* logWindow() const { return logwindow; };
53 MHexWindow* hexWindow() const { return hexwindow; }; 53 MHexWindow* hexWindow() const { return hexwindow; };
54 bool isDaemonRunning() const { return sniffing; }; 54 bool isDaemonRunning() const { return sniffing; };
55 QString captureFileName() const { return dumpname; }; 55 QString captureFileName() const { return dumpname; };
56 56
57 public: 57 public:
58 bool sniffing; 58 bool sniffing;
59 59
60 protected: 60 protected:
61 virtual void timerEvent( QTimerEvent* ); 61 virtual void timerEvent( QTimerEvent* );
62 62
63 public slots: 63 public slots:
64 void initialTimer(); 64 void initialTimer();
65 65
66 void channelHopped(int); 66 void channelHopped(int);
67 void receivePacket(OPacket*); 67 void receivePacket(OPacket*);
68 void startClicked(); 68 void startClicked();
69 void stopClicked(); 69 void stopClicked();
70 70
71 void joinNetwork(const QString&,const QString&,int,const QString&); 71 void joinNetwork(const QString&,const QString&,int,const QString&);
72 72
73 signals: 73 signals:
74 void startedSniffing(); 74 void startedSniffing();
75 void stoppedSniffing(); 75 void stoppedSniffing();
76 76
77 private: 77 private:
78 void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ); 78 void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* );
79 void handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* );
80 void handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* );
81 void handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* );
79 void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); 82 void handleControlFrame( OPacket* p, OWaveLanControlPacket* control );
80 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); 83 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to );
81 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); 84 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to );
82 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); 85 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to );
83 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); 86 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to );
84 void handleNotification( OPacket* p ); 87 void handleNotification( OPacket* p );
85 void doAction( const QString& action, const QString& protocol, OPacket* p ); 88 void doAction( const QString& action, const QString& protocol, OPacket* p );
86 QObject* childIfToParse( OPacket* p, const QString& protocol ); 89 QObject* childIfToParse( OPacket* p, const QString& protocol );
87 bool checkDumpPacket( OPacket* p ); 90 bool checkDumpPacket( OPacket* p );
88 91
89 private: 92 private:
90 #ifdef QWS 93 #ifdef QWS
91 OSystem _system; // Opie Operating System identifier 94 OSystem _system; // Opie Operating System identifier
92 #endif 95 #endif
93 96
94 QString dumpname; 97 QString dumpname;
95 OWirelessNetworkInterface* iface; 98 OWirelessNetworkInterface* iface;
96 OPacketCapturer* pcap; 99 OPacketCapturer* pcap;
97 WellenreiterConfigWindow* configwindow; 100 WellenreiterConfigWindow* configwindow;
98 GPS* gps; 101 GPS* gps;
99 102
100 //void readConfig(); 103 //void readConfig();
101 //void writeConfig(); 104 //void writeConfig();
102}; 105};
103 106
104 107
105 108
106#endif 109#endif