-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 15 |
2 files changed, 16 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 1525934..1ef24d2 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -229,106 +229,108 @@ void MScanListView::traffic( QString type, QString from, QString to, QString via | |||
229 | } | 229 | } |
230 | 230 | ||
231 | // Hey, it seems to be a new item :-D | 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 ); | 232 | MScanListItem* station = new MScanListItem( item->parent(), "adhoc", /* network->text( col_essid ) */ "", from, false, -1, -1 ); |
233 | if ( _manufacturerdb ) | 233 | if ( _manufacturerdb ) |
234 | station->setManufacturer( _manufacturerdb->lookup( from ) ); | 234 | station->setManufacturer( _manufacturerdb->lookup( from ) ); |
235 | } | 235 | } |
236 | else | 236 | else |
237 | { | 237 | { |
238 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" ); | 238 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in alpha-4 version :-D" ); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | //============================================================ | 242 | //============================================================ |
243 | // MScanListItem | 243 | // MScanListItem |
244 | //============================================================ | 244 | //============================================================ |
245 | 245 | ||
246 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 246 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
247 | bool wep, int channel, int signal ) | 247 | bool wep, int channel, int signal ) |
248 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 248 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
249 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 249 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
250 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 250 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
251 | { | 251 | { |
252 | qDebug( "creating scanlist item" ); | 252 | qDebug( "creating scanlist item" ); |
253 | if ( WellenreiterConfigWindow::instance() && type == "networks" ) | 253 | if ( WellenreiterConfigWindow::instance() && type == "networks" ) |
254 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 254 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
255 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 255 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
256 | } | 256 | } |
257 | 257 | ||
258 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 258 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
259 | bool wep, int channel, int signal ) | 259 | bool wep, int channel, int signal ) |
260 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 260 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
261 | { | 261 | { |
262 | qDebug( "creating scanlist item" ); | 262 | qDebug( "creating scanlist item" ); |
263 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 263 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
264 | } | 264 | } |
265 | 265 | ||
266 | OListViewItem* MScanListItem::childFactory() | 266 | OListViewItem* MScanListItem::childFactory() |
267 | { | 267 | { |
268 | return new MScanListItem( this ); | 268 | return new MScanListItem( this ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void MScanListItem::serializeTo( QDataStream& s ) const | 271 | void MScanListItem::serializeTo( QDataStream& s ) const |
272 | { | 272 | { |
273 | qDebug( "serializing MScanListItem" ); | 273 | qDebug( "serializing MScanListItem" ); |
274 | OListViewItem::serializeTo( s ); | 274 | OListViewItem::serializeTo( s ); |
275 | 275 | ||
276 | s << _type; | 276 | s << _type; |
277 | s << (Q_UINT8) _wep; | 277 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
278 | } | 278 | } |
279 | 279 | ||
280 | void MScanListItem::serializeFrom( QDataStream& s ) | 280 | void MScanListItem::serializeFrom( QDataStream& s ) |
281 | { | 281 | { |
282 | qDebug( "serializing MScanListItem" ); | 282 | qDebug( "serializing MScanListItem" ); |
283 | OListViewItem::serializeFrom( s ); | 283 | OListViewItem::serializeFrom( s ); |
284 | 284 | ||
285 | char wep; | ||
285 | s >> _type; | 286 | s >> _type; |
286 | s >> (Q_UINT8) _wep; | 287 | s >> (Q_UINT8) wep; |
288 | _wep = (wep == 'y'); | ||
287 | 289 | ||
288 | QString name; | 290 | QString name; |
289 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 291 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
290 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 292 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
291 | if ( _wep ) | 293 | if ( _wep ) |
292 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 294 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
293 | listView()->triggerUpdate(); | 295 | listView()->triggerUpdate(); |
294 | } | 296 | } |
295 | 297 | ||
296 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 298 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
297 | { | 299 | { |
298 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 300 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
299 | (const char*) type, | 301 | (const char*) type, |
300 | (const char*) essid, | 302 | (const char*) essid, |
301 | (const char*) macaddr, | 303 | (const char*) macaddr, |
302 | channel ); | 304 | channel ); |
303 | 305 | ||
304 | // set icon for managed or adhoc mode | 306 | // set icon for managed or adhoc mode |
305 | QString name; | 307 | QString name; |
306 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 308 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
307 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 309 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
308 | 310 | ||
309 | // set icon for wep (wireless encryption protocol) | 311 | // set icon for wep (wireless encryption protocol) |
310 | if ( wep ) | 312 | if ( wep ) |
311 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 313 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
312 | 314 | ||
313 | // set channel and signal text | 315 | // set channel and signal text |
314 | 316 | ||
315 | if ( signal != -1 ) | 317 | if ( signal != -1 ) |
316 | setText( col_sig, QString::number( signal ) ); | 318 | setText( col_sig, QString::number( signal ) ); |
317 | if ( channel != -1 ) | 319 | if ( channel != -1 ) |
318 | setText( col_channel, QString::number( channel ) ); | 320 | setText( col_channel, QString::number( channel ) ); |
319 | 321 | ||
320 | setText( col_firstseen, QTime::currentTime().toString() ); | 322 | setText( col_firstseen, QTime::currentTime().toString() ); |
321 | //setText( col_lastseen, QTime::currentTime().toString() ); | 323 | //setText( col_lastseen, QTime::currentTime().toString() ); |
322 | 324 | ||
323 | listView()->triggerUpdate(); | 325 | listView()->triggerUpdate(); |
324 | 326 | ||
325 | this->type = type; | 327 | this->type = type; |
326 | _type = type; | 328 | _type = type; |
327 | _essid = essid; | 329 | _essid = essid; |
328 | _macaddr = macaddr; | 330 | _macaddr = macaddr; |
329 | _channel = channel; | 331 | _channel = channel; |
330 | _beacons = 1; | 332 | _beacons = 1; |
331 | _signal = 0; | 333 | _signal = 0; |
332 | } | 334 | } |
333 | 335 | ||
334 | 336 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 8d18f73..8c2c315 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -69,111 +69,120 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
70 | #else | 70 | #else |
71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
72 | #endif | 72 | #endif |
73 | manufacturerdb = new ManufacturerDB( manufile ); | 73 | manufacturerdb = new ManufacturerDB( manufile ); |
74 | 74 | ||
75 | logwindow->log( "(i) Wellenreiter has been started." ); | 75 | logwindow->log( "(i) Wellenreiter has been started." ); |
76 | 76 | ||
77 | // | 77 | // |
78 | // detect operating system | 78 | // detect operating system |
79 | // | 79 | // |
80 | 80 | ||
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | QString sys; | 82 | QString sys; |
83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
84 | _system = ODevice::inst()->system(); | 84 | _system = ODevice::inst()->system(); |
85 | logwindow->log( sys ); | 85 | logwindow->log( sys ); |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | // setup GUI | 88 | // setup GUI |
89 | netview->setColumnWidthMode( 1, QListView::Manual ); | 89 | netview->setColumnWidthMode( 1, QListView::Manual ); |
90 | 90 | ||
91 | if ( manufacturerdb ) | 91 | if ( manufacturerdb ) |
92 | netview->setManufacturerDB( manufacturerdb ); | 92 | netview->setManufacturerDB( manufacturerdb ); |
93 | 93 | ||
94 | pcap = new OPacketCapturer(); | 94 | pcap = new OPacketCapturer(); |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | Wellenreiter::~Wellenreiter() | 98 | Wellenreiter::~Wellenreiter() |
99 | { | 99 | { |
100 | // no need to delete child widgets, Qt does it all for us | 100 | // no need to delete child widgets, Qt does it all for us |
101 | 101 | ||
102 | delete manufacturerdb; | 102 | delete manufacturerdb; |
103 | delete pcap; | 103 | delete pcap; |
104 | } | 104 | } |
105 | 105 | ||
106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
107 | { | 107 | { |
108 | configwindow = cw; | 108 | configwindow = cw; |
109 | } | 109 | } |
110 | 110 | ||
111 | void Wellenreiter::receivePacket(OPacket* p) | 111 | void 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 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 116 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
117 | if ( beacon ) | 117 | if ( beacon && beacon->managementType() == "Beacon" ) |
118 | { | 118 | { |
119 | QString type; | 119 | QString type; |
120 | if ( beacon->canIBSS() ) | 120 | if ( beacon->canIBSS() ) |
121 | { | ||
121 | type = "adhoc"; | 122 | type = "adhoc"; |
122 | else | 123 | } |
124 | else if ( beacon->canESS() ) | ||
125 | { | ||
123 | type = "managed"; | 126 | type = "managed"; |
127 | } | ||
128 | else | ||
129 | { | ||
130 | qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); | ||
131 | return; | ||
132 | } | ||
124 | 133 | ||
125 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 134 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
126 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 135 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
127 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 136 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
128 | int channel = ds ? ds->channel() : -1; | 137 | int channel = ds ? ds->channel() : -1; |
129 | 138 | ||
130 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 139 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
131 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); | 140 | netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); |
132 | return; | 141 | return; |
133 | } | 142 | } |
134 | 143 | ||
135 | // check for a data frame | 144 | // check for a data frame |
136 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); | 145 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); |
137 | if ( data ) | 146 | if ( data ) |
138 | { | 147 | { |
139 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 148 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
140 | if ( wlan->fromDS() && !wlan->toDS() ) | 149 | if ( wlan->fromDS() && !wlan->toDS() ) |
141 | { | 150 | { |
142 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", | 151 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", |
143 | (const char*) wlan->macAddress3().toString(true), | 152 | (const char*) wlan->macAddress3().toString(true), |
144 | (const char*) wlan->macAddress1().toString(true), | 153 | (const char*) wlan->macAddress1().toString(true), |
145 | (const char*) wlan->macAddress2().toString(true) ); | 154 | (const char*) wlan->macAddress2().toString(true) ); |
146 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), | 155 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), |
147 | wlan->macAddress1().toString(), | 156 | wlan->macAddress1().toString(), |
148 | wlan->macAddress2().toString() ); | 157 | wlan->macAddress2().toString() ); |
149 | } | 158 | } |
150 | else | 159 | else |
151 | if ( !wlan->fromDS() && wlan->toDS() ) | 160 | if ( !wlan->fromDS() && wlan->toDS() ) |
152 | { | 161 | { |
153 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", | 162 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", |
154 | (const char*) wlan->macAddress2().toString(true), | 163 | (const char*) wlan->macAddress2().toString(true), |
155 | (const char*) wlan->macAddress3().toString(true), | 164 | (const char*) wlan->macAddress3().toString(true), |
156 | (const char*) wlan->macAddress1().toString(true) ); | 165 | (const char*) wlan->macAddress1().toString(true) ); |
157 | netView()->traffic( "toDS", wlan->macAddress2().toString(), | 166 | netView()->traffic( "toDS", wlan->macAddress2().toString(), |
158 | wlan->macAddress3().toString(), | 167 | wlan->macAddress3().toString(), |
159 | wlan->macAddress1().toString() ); | 168 | wlan->macAddress1().toString() ); |
160 | } | 169 | } |
161 | else | 170 | else |
162 | if ( wlan->fromDS() && wlan->toDS() ) | 171 | if ( wlan->fromDS() && wlan->toDS() ) |
163 | { | 172 | { |
164 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", | 173 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", |
165 | (const char*) wlan->macAddress4().toString(true), | 174 | (const char*) wlan->macAddress4().toString(true), |
166 | (const char*) wlan->macAddress3().toString(true), | 175 | (const char*) wlan->macAddress3().toString(true), |
167 | (const char*) wlan->macAddress1().toString(true), | 176 | (const char*) wlan->macAddress1().toString(true), |
168 | (const char*) wlan->macAddress2().toString(true) ); | 177 | (const char*) wlan->macAddress2().toString(true) ); |
169 | netView()->traffic( "WSD", wlan->macAddress4().toString(), | 178 | netView()->traffic( "WSD", wlan->macAddress4().toString(), |
170 | wlan->macAddress3().toString(), | 179 | wlan->macAddress3().toString(), |
171 | wlan->macAddress1().toString(), | 180 | wlan->macAddress1().toString(), |
172 | wlan->macAddress2().toString() ); | 181 | wlan->macAddress2().toString() ); |
173 | } | 182 | } |
174 | else | 183 | else |
175 | { | 184 | { |
176 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", | 185 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", |
177 | (const char*) wlan->macAddress2().toString(true), | 186 | (const char*) wlan->macAddress2().toString(true), |
178 | (const char*) wlan->macAddress1().toString(true), | 187 | (const char*) wlan->macAddress1().toString(true), |
179 | (const char*) wlan->macAddress3().toString(true) ); | 188 | (const char*) wlan->macAddress3().toString(true) ); |