summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 4b82c9a..c061319 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -13,96 +13,97 @@
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Opie 16// Opie
17 17
18#ifdef QWS 18#ifdef QWS
19#include <opie/odevice.h> 19#include <opie/odevice.h>
20using namespace Opie; 20using namespace Opie;
21#endif 21#endif
22 22
23#ifdef QWS 23#ifdef QWS
24#include <opie2/oapplication.h> 24#include <opie2/oapplication.h>
25#else 25#else
26#include <qapplication.h> 26#include <qapplication.h>
27#endif 27#endif
28#include <opie2/onetwork.h> 28#include <opie2/onetwork.h>
29#include <opie2/opcap.h> 29#include <opie2/opcap.h>
30 30
31// Qt 31// Qt
32 32
33#include <qcheckbox.h> 33#include <qcheckbox.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qtoolbutton.h> 41#include <qtoolbutton.h>
42#include <qmainwindow.h> 42#include <qmainwindow.h>
43 43
44// Standard 44// Standard
45 45
46#include <assert.h> 46#include <assert.h>
47#include <errno.h> 47#include <errno.h>
48#include <unistd.h> 48#include <unistd.h>
49#include <string.h> 49#include <string.h>
50#include <sys/types.h> 50#include <sys/types.h>
51#include <stdlib.h> 51#include <stdlib.h>
52 52
53// Local 53// Local
54 54
55#include "wellenreiter.h" 55#include "wellenreiter.h"
56#include "scanlist.h" 56#include "scanlist.h"
57#include "logwindow.h" 57#include "logwindow.h"
58#include "hexwindow.h" 58#include "hexwindow.h"
59#include "configwindow.h" 59#include "configwindow.h"
60#include "statwindow.h" 60#include "statwindow.h"
61#include "graphwindow.h"
61#include "manufacturers.h" 62#include "manufacturers.h"
62 63
63Wellenreiter::Wellenreiter( QWidget* parent ) 64Wellenreiter::Wellenreiter( QWidget* parent )
64 : WellenreiterBase( parent, 0, 0 ), 65 : WellenreiterBase( parent, 0, 0 ),
65 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) 66 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 )
66{ 67{
67 68
68 // 69 //
69 // construct manufacturer database 70 // construct manufacturer database
70 // 71 //
71 72
72 QString manufile; 73 QString manufile;
73 #ifdef QWS 74 #ifdef QWS
74 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); 75 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
75 #else 76 #else
76 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); 77 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" );
77 #endif 78 #endif
78 manufacturerdb = new ManufacturerDB( manufile ); 79 manufacturerdb = new ManufacturerDB( manufile );
79 80
80 logwindow->log( "(i) Wellenreiter has been started." ); 81 logwindow->log( "(i) Wellenreiter has been started." );
81 82
82 // 83 //
83 // detect operating system 84 // detect operating system
84 // 85 //
85 86
86 #ifdef QWS 87 #ifdef QWS
87 QString sys; 88 QString sys;
88 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 89 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
89 _system = ODevice::inst()->system(); 90 _system = ODevice::inst()->system();
90 logwindow->log( sys ); 91 logwindow->log( sys );
91 #endif 92 #endif
92 93
93 // setup GUI 94 // setup GUI
94 netview->setColumnWidthMode( 1, QListView::Manual ); 95 netview->setColumnWidthMode( 1, QListView::Manual );
95 96
96 if ( manufacturerdb ) 97 if ( manufacturerdb )
97 netview->setManufacturerDB( manufacturerdb ); 98 netview->setManufacturerDB( manufacturerdb );
98 99
99 pcap = new OPacketCapturer(); 100 pcap = new OPacketCapturer();
100 101
101} 102}
102 103
103 104
104Wellenreiter::~Wellenreiter() 105Wellenreiter::~Wellenreiter()
105{ 106{
106 // no need to delete child widgets, Qt does it all for us 107 // no need to delete child widgets, Qt does it all for us
107 108
108 delete manufacturerdb; 109 delete manufacturerdb;
@@ -121,96 +122,102 @@ void Wellenreiter::channelHopped(int c)
121 QString title = "Wellenreiter II -scan- ["; 122 QString title = "Wellenreiter II -scan- [";
122 QString left; 123 QString left;
123 if ( c > 1 ) left.fill( '.', c-1 ); 124 if ( c > 1 ) left.fill( '.', c-1 );
124 title.append( left ); 125 title.append( left );
125 title.append( '|' ); 126 title.append( '|' );
126 if ( c < iface->channels() ) 127 if ( c < iface->channels() )
127 { 128 {
128 QString right; 129 QString right;
129 right.fill( '.', iface->channels()-c ); 130 right.fill( '.', iface->channels()-c );
130 title.append( right ); 131 title.append( right );
131 } 132 }
132 title.append( "]" ); 133 title.append( "]" );
133 //title.append( QString().sprintf( " %02d", c ) ); 134 //title.append( QString().sprintf( " %02d", c ) );
134 assert( parent() ); 135 assert( parent() );
135 ( (QMainWindow*) parent() )->setCaption( title ); 136 ( (QMainWindow*) parent() )->setCaption( title );
136} 137}
137 138
138 139
139void Wellenreiter::receivePacket(OPacket* p) 140void Wellenreiter::receivePacket(OPacket* p)
140{ 141{
141 hexWindow()->log( p->dump( 8 ) ); 142 hexWindow()->log( p->dump( 8 ) );
142 143
143 // check if we received a beacon frame 144 // check if we received a beacon frame
144 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 145 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
145 if ( beacon && beacon->managementType() == "Beacon" ) 146 if ( beacon && beacon->managementType() == "Beacon" )
146 { 147 {
147 QString type; 148 QString type;
148 if ( beacon->canIBSS() ) 149 if ( beacon->canIBSS() )
149 { 150 {
150 type = "adhoc"; 151 type = "adhoc";
151 } 152 }
152 else if ( beacon->canESS() ) 153 else if ( beacon->canESS() )
153 { 154 {
154 type = "managed"; 155 type = "managed";
155 } 156 }
156 else 157 else
157 { 158 {
158 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); 159 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) );
159 return; 160 return;
160 } 161 }
161 162
162 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 163 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
163 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 164 QString essid = ssid ? ssid->ID() : QString("<unknown>");
164 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 165 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
165 int channel = ds ? ds->channel() : -1; 166 int channel = ds ? ds->channel() : -1;
166 167
167 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 168 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
168 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); 169 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 );
170
171 // do we have a prism header?
172 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
173 if ( ds && prism )
174 graphwindow->traffic( ds->channel(), prism->signalStrength() );
175
169 return; 176 return;
170 } 177 }
171 178
172 // check for a data frame 179 // check for a data frame
173 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); 180 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) );
174 if ( data ) 181 if ( data )
175 { 182 {
176 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 183 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
177 if ( wlan->fromDS() && !wlan->toDS() ) 184 if ( wlan->fromDS() && !wlan->toDS() )
178 { 185 {
179 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", 186 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'",
180 (const char*) wlan->macAddress3().toString(true), 187 (const char*) wlan->macAddress3().toString(true),
181 (const char*) wlan->macAddress1().toString(true), 188 (const char*) wlan->macAddress1().toString(true),
182 (const char*) wlan->macAddress2().toString(true) ); 189 (const char*) wlan->macAddress2().toString(true) );
183 netView()->fromDStraffic( wlan->macAddress3().toString(), 190 netView()->fromDStraffic( wlan->macAddress3().toString(),
184 wlan->macAddress1().toString(), 191 wlan->macAddress1().toString(),
185 wlan->macAddress2().toString() ); 192 wlan->macAddress2().toString() );
186 } 193 }
187 else 194 else
188 if ( !wlan->fromDS() && wlan->toDS() ) 195 if ( !wlan->fromDS() && wlan->toDS() )
189 { 196 {
190 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", 197 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'",
191 (const char*) wlan->macAddress2().toString(true), 198 (const char*) wlan->macAddress2().toString(true),
192 (const char*) wlan->macAddress3().toString(true), 199 (const char*) wlan->macAddress3().toString(true),
193 (const char*) wlan->macAddress1().toString(true) ); 200 (const char*) wlan->macAddress1().toString(true) );
194 netView()->toDStraffic( wlan->macAddress2().toString(), 201 netView()->toDStraffic( wlan->macAddress2().toString(),
195 wlan->macAddress3().toString(), 202 wlan->macAddress3().toString(),
196 wlan->macAddress1().toString() ); 203 wlan->macAddress1().toString() );
197 } 204 }
198 else 205 else
199 if ( wlan->fromDS() && wlan->toDS() ) 206 if ( wlan->fromDS() && wlan->toDS() )
200 { 207 {
201 qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", 208 qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
202 (const char*) wlan->macAddress4().toString(true), 209 (const char*) wlan->macAddress4().toString(true),
203 (const char*) wlan->macAddress3().toString(true), 210 (const char*) wlan->macAddress3().toString(true),
204 (const char*) wlan->macAddress1().toString(true), 211 (const char*) wlan->macAddress1().toString(true),
205 (const char*) wlan->macAddress2().toString(true) ); 212 (const char*) wlan->macAddress2().toString(true) );
206 netView()->WDStraffic( wlan->macAddress4().toString(), 213 netView()->WDStraffic( wlan->macAddress4().toString(),
207 wlan->macAddress3().toString(), 214 wlan->macAddress3().toString(),
208 wlan->macAddress1().toString(), 215 wlan->macAddress1().toString(),
209 wlan->macAddress2().toString() ); 216 wlan->macAddress2().toString() );
210 } 217 }
211 else 218 else
212 { 219 {
213 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", 220 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
214 (const char*) wlan->macAddress2().toString(true), 221 (const char*) wlan->macAddress2().toString(true),
215 (const char*) wlan->macAddress1().toString(true), 222 (const char*) wlan->macAddress1().toString(true),
216 (const char*) wlan->macAddress3().toString(true) ); 223 (const char*) wlan->macAddress3().toString(true) );