summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp85
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h1
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp88
3 files changed, 138 insertions, 36 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 34c69f5..1525934 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -17,24 +17,42 @@
17#include "configwindow.h" 17#include "configwindow.h"
18 18
19#include <assert.h> 19#include <assert.h>
20#include "manufacturers.h" 20#include "manufacturers.h"
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qtextstream.h> 22#include <qtextstream.h>
23 23
24#ifdef QWS 24#ifdef QWS
25#include <opie/odevice.h> 25#include <opie/odevice.h>
26using namespace Opie; 26using namespace Opie;
27#endif 27#endif
28 28
29
30#ifdef QWS
31#include <qpe/resource.h>
32#else
33#include "resource.h"
34#endif
35
36const int col_type = 0;
37const int col_essid = 0;
38const int col_sig = 1;
39const int col_ap = 2;
40const int col_channel = 3;
41const int col_wep = 4;
42const int col_traffic = 5;
43const int col_manuf = 6;
44const int col_firstseen = 7;
45const int col_lastseen = 8;
46
29MScanListView::MScanListView( QWidget* parent, const char* name ) 47MScanListView::MScanListView( QWidget* parent, const char* name )
30 :OListView( parent, name ), _manufacturerdb( 0 ) 48 :OListView( parent, name ), _manufacturerdb( 0 )
31{ 49{
32 50
33 setFrameShape( QListView::StyledPanel ); 51 setFrameShape( QListView::StyledPanel );
34 setFrameShadow( QListView::Sunken ); 52 setFrameShadow( QListView::Sunken );
35 53
36 addColumn( tr( "Net/Station" ) ); 54 addColumn( tr( "Net/Station" ) );
37 setColumnAlignment( 0, AlignLeft || AlignVCenter ); 55 setColumnAlignment( 0, AlignLeft || AlignVCenter );
38 addColumn( tr( "B" ) ); 56 addColumn( tr( "B" ) );
39 setColumnAlignment( 1, AlignCenter ); 57 setColumnAlignment( 1, AlignCenter );
40 addColumn( tr( "AP" ) ); 58 addColumn( tr( "AP" ) );
@@ -96,25 +114,25 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
96 QString s; 114 QString s;
97 MScanListItem* network; 115 MScanListItem* network;
98 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 116 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
99 117
100 while ( item && ( item->text( 0 ) != essid ) ) 118 while ( item && ( item->text( 0 ) != essid ) )
101 { 119 {
102 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 120 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
103 item = static_cast<MScanListItem*> ( item->itemBelow() ); 121 item = static_cast<MScanListItem*> ( item->itemBelow() );
104 } 122 }
105 if ( item ) 123 if ( item )
106 { 124 {
107 // animate the item 125 // animate the item
108 126
109 /* 127 /*
110 128
111 const QPixmap* pixmap = item->pixmap( 0 ); 129 const QPixmap* pixmap = item->pixmap( 0 );
112 const QPixmap* nextpixmap = ani2; 130 const QPixmap* nextpixmap = ani2;
113 if ( pixmap == ani1 ) 131 if ( pixmap == ani1 )
114 nextpixmap = ani2; 132 nextpixmap = ani2;
115 else if ( pixmap == ani2 ) 133 else if ( pixmap == ani2 )
116 nextpixmap = ani3; 134 nextpixmap = ani3;
117 else if ( pixmap == ani3 ) 135 else if ( pixmap == ani3 )
118 nextpixmap = ani4; 136 nextpixmap = ani4;
119 else if ( pixmap == ani4 ) 137 else if ( pixmap == ani4 )
120 nextpixmap = ani1; 138 nextpixmap = ani1;
@@ -164,40 +182,75 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
164 182
165 if ( type == "managed" ) 183 if ( type == "managed" )
166 { 184 {
167 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 185 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
168 } 186 }
169 else 187 else
170 { 188 {
171 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 189 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
172 } 190 }
173 191
174} 192}
175 193
176#ifdef QWS 194void MScanListView::traffic( QString type, QString from, QString to, QString via, QString additional )
177#include <qpe/resource.h> 195{
178#else 196 if ( type != "toDS" ) return;
179#include "resource.h"
180#endif
181 197
182const int col_type = 0; 198 qDebug( "MScanList::traffic( [%s] | %s -> %s (via %s)",
183const int col_essid = 0; 199 (const char*) type, (const char*) from,
184const int col_sig = 1; 200 (const char*) to, (const char*) via );
185const int col_ap = 2; 201
186const int col_channel = 3; 202 QString s;
187const int col_wep = 4; 203 MScanListItem* network;
188const int col_traffic = 5; 204
189const int col_manuf = 6; 205 QListViewItemIterator it( this );
190const int col_firstseen = 7; 206 while ( it.current() && it.current()->text( col_ap ) != via ) ++it;
191const int col_lastseen = 8; 207
208 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
209
210 if ( item ) // AP has been shown up, so just add our new "from" - station
211 {
212 network = static_cast<MScanListItem*>( item->parent() );
213 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
214
215 while ( subitem && ( subitem->text( col_ap ) != from ) )
216 {
217 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
218 subitem = static_cast<MScanListItem*> ( subitem->itemBelow() );
219 }
220
221 if ( subitem )
222 {
223 // we have already seen this item, it's a dupe
224 #ifdef DEBUG
225 qDebug( "%s is a dupe - ignoring...", (const char*) from );
226 #endif
227 subitem->receivedBeacon(); //FIXME: sent data bit
228 return;
229 }
230
231 // Hey, it seems to be a new item :-D
232 MScanListItem* station = new MScanListItem( item->parent(), "adhoc", /* network->text( col_essid ) */ "", from, false, -1, -1 );
233 if ( _manufacturerdb )
234 station->setManufacturer( _manufacturerdb->lookup( from ) );
235 }
236 else
237 {
238 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" );
239 }
240}
241
242//============================================================
243// MScanListItem
244//============================================================
192 245
193MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 246MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
194 bool wep, int channel, int signal ) 247 bool wep, int channel, int signal )
195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 248 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
196 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 249 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
197 _channel( channel ), _signal( signal ), _beacons( 1 ) 250 _channel( channel ), _signal( signal ), _beacons( 1 )
198{ 251{
199 qDebug( "creating scanlist item" ); 252 qDebug( "creating scanlist item" );
200 if ( WellenreiterConfigWindow::instance() && type == "networks" ) 253 if ( WellenreiterConfigWindow::instance() && type == "networks" )
201 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); 254 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() );
202 decorateItem( type, essid, macaddr, wep, channel, signal ); 255 decorateItem( type, essid, macaddr, wep, channel, signal );
203} 256}
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 01db172..bed69f1 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -30,24 +30,25 @@ class MScanListView: public OListView
30 public: 30 public:
31 MScanListView( QWidget* parent = 0, const char* name = 0 ); 31 MScanListView( QWidget* parent = 0, const char* name = 0 );
32 virtual ~MScanListView(); 32 virtual ~MScanListView();
33 33
34 void setManufacturerDB( ManufacturerDB* manufacturerdb ); 34 void setManufacturerDB( ManufacturerDB* manufacturerdb );
35 35
36 virtual OListViewItem* childFactory(); 36 virtual OListViewItem* childFactory();
37 virtual void serializeTo( QDataStream& s ) const; 37 virtual void serializeTo( QDataStream& s ) const;
38 virtual void serializeFrom( QDataStream& s ); 38 virtual void serializeFrom( QDataStream& s );
39 39
40 public slots: 40 public slots:
41 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 41 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
42 void traffic( QString type, QString from, QString to, QString via, QString additional = QString::null );
42 43
43 private: 44 private:
44 ManufacturerDB* _manufacturerdb; 45 ManufacturerDB* _manufacturerdb;
45 46
46}; 47};
47 48
48//****************************** MScanListItem **************************************************************** 49//****************************** MScanListItem ****************************************************************
49 50
50class MScanListItem: public OListViewItem 51class MScanListItem: public OListViewItem
51{ 52{
52 public: 53 public:
53 MScanListItem::MScanListItem( QListView* parent, 54 MScanListItem::MScanListItem( QListView* parent,
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index aa33158..8d18f73 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -104,46 +104,94 @@ Wellenreiter::~Wellenreiter()
104} 104}
105 105
106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
107{ 107{
108 configwindow = cw; 108 configwindow = cw;
109} 109}
110 110
111void Wellenreiter::receivePacket(OPacket* p) 111void Wellenreiter::receivePacket(OPacket* p)
112{ 112{
113 hexWindow()->log( p->dump( 8 ) ); 113 hexWindow()->log( p->dump( 8 ) );
114 114
115 // check if we received a beacon frame 115 // check if we received a beacon frame
116 // static_cast is justified here
117 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 116 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
118 if ( !beacon ) return; 117 if ( beacon )
119 QString type; 118 {
120 119 QString type;
121 //FIXME: Can stations in ESS mode can be distinguished from APs? 120 if ( beacon->canIBSS() )
122 //FIXME: Apparently yes, but not by listening to beacons, because 121 type = "adhoc";
123 //FIXME: they simply don't send beacons in infrastructure mode. 122 else
124 //FIXME: so we also have to listen to data packets 123 type = "managed";
125 124
126 if ( beacon->canIBSS() ) 125 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
127 type = "adhoc"; 126 QString essid = ssid ? ssid->ID() : QString("<unknown>");
128 else 127 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
129 type = "managed"; 128 int channel = ds ? ds->channel() : -1;
130 129
131 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 130 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
132 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 131 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 );
133 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 132 return;
134 int channel = ds ? ds->channel() : -1; 133 }
135 134
136 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 135 // check for a data frame
137 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); 136 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) );
137 if ( data )
138 {
139 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
140 if ( wlan->fromDS() && !wlan->toDS() )
141 {
142 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'",
143 (const char*) wlan->macAddress3().toString(true),
144 (const char*) wlan->macAddress1().toString(true),
145 (const char*) wlan->macAddress2().toString(true) );
146 netView()->traffic( "fromDS", wlan->macAddress3().toString(),
147 wlan->macAddress1().toString(),
148 wlan->macAddress2().toString() );
149 }
150 else
151 if ( !wlan->fromDS() && wlan->toDS() )
152 {
153 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'",
154 (const char*) wlan->macAddress2().toString(true),
155 (const char*) wlan->macAddress3().toString(true),
156 (const char*) wlan->macAddress1().toString(true) );
157 netView()->traffic( "toDS", wlan->macAddress2().toString(),
158 wlan->macAddress3().toString(),
159 wlan->macAddress1().toString() );
160 }
161 else
162 if ( wlan->fromDS() && wlan->toDS() )
163 {
164 qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
165 (const char*) wlan->macAddress4().toString(true),
166 (const char*) wlan->macAddress3().toString(true),
167 (const char*) wlan->macAddress1().toString(true),
168 (const char*) wlan->macAddress2().toString(true) );
169 netView()->traffic( "WSD", wlan->macAddress4().toString(),
170 wlan->macAddress3().toString(),
171 wlan->macAddress1().toString(),
172 wlan->macAddress2().toString() );
173 }
174 else
175 {
176 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
177 (const char*) wlan->macAddress2().toString(true),
178 (const char*) wlan->macAddress1().toString(true),
179 (const char*) wlan->macAddress3().toString(true) );
180 netView()->traffic( "fromDS", wlan->macAddress2().toString(),
181 wlan->macAddress1().toString(),
182 wlan->macAddress3().toString() );
183 }
184 return;
185 }
138} 186}
139 187
140void Wellenreiter::startStopClicked() 188void Wellenreiter::startStopClicked()
141{ 189{
142 if ( sniffing ) 190 if ( sniffing )
143 { 191 {
144 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 192 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
145 193
146 iface->setChannelHopping(); // stop hopping channels 194 iface->setChannelHopping(); // stop hopping channels
147 pcap->close(); 195 pcap->close();
148 sniffing = false; 196 sniffing = false;
149 #ifdef QWS 197 #ifdef QWS