author | mickeyl <mickeyl> | 2003-03-30 01:41:56 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 01:41:56 (UTC) |
commit | 99899abc80a8aa05044eeecd8a061b0a8efaa713 (patch) (unidiff) | |
tree | 45db7a60f17d00ae72d0e8d6b986d5be10232c6c /libopie2/opienet/onetwork.cpp | |
parent | 340cb7e64fb898966996b00b93c03ca05a347aa5 (diff) | |
download | opie-99899abc80a8aa05044eeecd8a061b0a8efaa713.zip opie-99899abc80a8aa05044eeecd8a061b0a8efaa713.tar.gz opie-99899abc80a8aa05044eeecd8a061b0a8efaa713.tar.bz2 |
- add classes for 802.11 tagged values
- adjust miniwellenreiter accordingly
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 1d3b9fe..25c70e0 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -291,7 +291,8 @@ bool ONetworkInterface::isWireless() const | |||
291 | 291 | ||
292 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 292 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
293 | :QObject( 0, "Mickey's funky hopper" ), | 293 | :QObject( 0, "Mickey's funky hopper" ), |
294 | _iface( iface ), _interval( 0 ), _channel( 0 ), _tid( 0 ) | 294 | _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ), |
295 | _maxChannel( iface->channels()+1 ) | ||
295 | { | 296 | { |
296 | } | 297 | } |
297 | 298 | ||
@@ -301,10 +302,21 @@ OChannelHopper::~OChannelHopper() | |||
301 | } | 302 | } |
302 | 303 | ||
303 | 304 | ||
305 | bool OChannelHopper::isActive() const | ||
306 | { | ||
307 | return _tid; | ||
308 | } | ||
309 | |||
310 | |||
311 | int OChannelHopper::channel() const | ||
312 | { | ||
313 | return _channel; | ||
314 | } | ||
315 | |||
316 | |||
304 | void OChannelHopper::timerEvent( QTimerEvent* ) | 317 | void OChannelHopper::timerEvent( QTimerEvent* ) |
305 | { | 318 | { |
306 | //FIXME: Get available channels from OWirelessNetworkInterface | 319 | if ( !--_channel ) _channel = _maxChannel; |
307 | if ( --_channel < 0 ) _channel = 13; | ||
308 | _iface->setChannel( _channel ); | 320 | _iface->setChannel( _channel ); |
309 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", | 321 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", |
310 | _channel, (const char*) _iface->name() ); | 322 | _channel, (const char*) _iface->name() ); |
@@ -319,6 +331,7 @@ void OChannelHopper::setInterval( int interval ) | |||
319 | if ( _interval ) | 331 | if ( _interval ) |
320 | killTimer( _tid ); | 332 | killTimer( _tid ); |
321 | 333 | ||
334 | _tid = 0; | ||
322 | _interval = interval; | 335 | _interval = interval; |
323 | 336 | ||
324 | if ( _interval ) | 337 | if ( _interval ) |
@@ -339,7 +352,7 @@ int OChannelHopper::interval() const | |||
339 | *======================================================================================*/ | 352 | *======================================================================================*/ |
340 | 353 | ||
341 | OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) | 354 | OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) |
342 | :ONetworkInterface( name ), _hopper( this ) | 355 | :ONetworkInterface( name ), _hopper( 0 ) |
343 | { | 356 | { |
344 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 357 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); |
345 | init(); | 358 | init(); |
@@ -376,13 +389,10 @@ void OWirelessNetworkInterface::init() | |||
376 | return; | 389 | return; |
377 | } | 390 | } |
378 | 391 | ||
379 | //TODO: Find out what the difference between num_channel and | ||
380 | // num_frequency is about. | ||
381 | |||
382 | for ( int i = 0; i < range.num_frequency; ++i ) | 392 | for ( int i = 0; i < range.num_frequency; ++i ) |
383 | { | 393 | { |
384 | int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); | 394 | int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); |
385 | _channels.insert( freq, i ); | 395 | _channels.insert( freq, i+1 ); |
386 | } | 396 | } |
387 | } | 397 | } |
388 | 398 | ||
@@ -412,13 +422,18 @@ QString OWirelessNetworkInterface::associatedAP() const | |||
412 | 422 | ||
413 | int OWirelessNetworkInterface::channel() const | 423 | int OWirelessNetworkInterface::channel() const |
414 | { | 424 | { |
425 | //FIXME: When monitoring enabled, then use it | ||
426 | //FIXME: to gather the current RF channel | ||
427 | //FIXME: Until then, get active channel from hopper. | ||
428 | if ( _hopper && _hopper->isActive() ) | ||
429 | return _hopper->channel(); | ||
430 | |||
415 | if ( !wioctl( SIOCGIWFREQ ) ) | 431 | if ( !wioctl( SIOCGIWFREQ ) ) |
416 | { | 432 | { |
417 | return -1; | 433 | return -1; |
418 | } | 434 | } |
419 | else | 435 | else |
420 | { | 436 | { |
421 | //FIXME: This is off-by-one !? Why? | ||
422 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ]; | 437 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ]; |
423 | } | 438 | } |
424 | } | 439 | } |
@@ -461,13 +476,15 @@ int OWirelessNetworkInterface::channels() const | |||
461 | 476 | ||
462 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 477 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
463 | { | 478 | { |
464 | _hopper.setInterval( interval ); | 479 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
480 | _hopper->setInterval( interval ); | ||
481 | //FIXME: When and by whom will the channel hopper be deleted? | ||
465 | } | 482 | } |
466 | 483 | ||
467 | 484 | ||
468 | int OWirelessNetworkInterface::channelHopping() const | 485 | int OWirelessNetworkInterface::channelHopping() const |
469 | { | 486 | { |
470 | return _hopper.interval(); | 487 | return _hopper->interval(); |
471 | } | 488 | } |
472 | 489 | ||
473 | 490 | ||
@@ -479,6 +496,7 @@ void OWirelessNetworkInterface::setMonitorMode( bool b ) | |||
479 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 496 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
480 | } | 497 | } |
481 | 498 | ||
499 | |||
482 | bool OWirelessNetworkInterface::monitorMode() const | 500 | bool OWirelessNetworkInterface::monitorMode() const |
483 | { | 501 | { |
484 | return _mon ? _mon->enabled() : false; | 502 | return _mon ? _mon->enabled() : false; |