summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 21fa390..cd36f16 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -348,70 +348,72 @@ int OChannelHopper::interval() const
348 348
349 349
350/*====================================================================================== 350/*======================================================================================
351 * OWirelessNetworkInterface 351 * OWirelessNetworkInterface
352 *======================================================================================*/ 352 *======================================================================================*/
353 353
354OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name ) 354OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name )
355 :ONetworkInterface( name ), _hopper( 0 ) 355 :ONetworkInterface( name ), _hopper( 0 )
356{ 356{
357 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); 357 qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" );
358 init(); 358 init();
359} 359}
360 360
361 361
362OWirelessNetworkInterface::~OWirelessNetworkInterface() 362OWirelessNetworkInterface::~OWirelessNetworkInterface()
363{ 363{
364} 364}
365 365
366 366
367iwreqstruct& OWirelessNetworkInterface::iwr() const 367iwreqstruct& OWirelessNetworkInterface::iwr() const
368{ 368{
369 return _iwr; 369 return _iwr;
370} 370}
371 371
372 372
373void OWirelessNetworkInterface::init() 373void OWirelessNetworkInterface::init()
374{ 374{
375 qDebug( "OWirelessNetworkInterface::init()" ); 375 qDebug( "OWirelessNetworkInterface::init()" );
376 376
377 memset( &_iwr, 0, sizeof( struct iwreq ) ); 377 memset( &_iwr, 0, sizeof( struct iwreq ) );
378 378
379 // IEEE802.11(b) radio frequency channels 379 // IEEE802.11(b) radio frequency channels
380 //FIXME: get these directly from the interface
381 //FIXME: check if these channels are off-by-one
382 380
383 iwrangestruct range; 381 iwrangestruct range;
382 //ML: work around an ugly HostAP bug, which needs
383 //ML: extra space or will complain with "invalid argument length"... :-(
384 char __extraBufferForBuggyDrivers[sizeof range];
384 _iwr.u.data.pointer = (char*) ⦥ 385 _iwr.u.data.pointer = (char*) ⦥
385 _iwr.u.data.length = sizeof( iwrangestruct ); 386 _iwr.u.data.length = (sizeof range) * 2;
387 _iwr.u.data.flags = 0;
386 if ( !wioctl( SIOCGIWRANGE ) ) 388 if ( !wioctl( SIOCGIWRANGE ) )
387 { 389 {
388 qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) ); 390 qDebug( "OWirelessNetworkInterface::init(): SIOCGIWRANGE failed (%s)", strerror( errno ) );
389 return; 391 return;
390 } 392 }
391 393
392 for ( int i = 0; i < range.num_frequency; ++i ) 394 for ( int i = 0; i < range.num_frequency; ++i )
393 { 395 {
394 int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 ); 396 int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 );
395 _channels.insert( freq, i+1 ); 397 _channels.insert( freq, i+1 );
396 } 398 }
397} 399}
398 400
399 401
400QString OWirelessNetworkInterface::associatedAP() const 402QString OWirelessNetworkInterface::associatedAP() const
401{ 403{
402 //FIXME: use OMacAddress 404 //FIXME: use OMacAddress
403 QString mac; 405 QString mac;
404 406
405 if ( ioctl( SIOCGIWAP ) ) 407 if ( ioctl( SIOCGIWAP ) )
406 { 408 {
407 mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 409 mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
408 _ifr.ifr_hwaddr.sa_data[0]&0xff, 410 _ifr.ifr_hwaddr.sa_data[0]&0xff,
409 _ifr.ifr_hwaddr.sa_data[1]&0xff, 411 _ifr.ifr_hwaddr.sa_data[1]&0xff,
410 _ifr.ifr_hwaddr.sa_data[2]&0xff, 412 _ifr.ifr_hwaddr.sa_data[2]&0xff,
411 _ifr.ifr_hwaddr.sa_data[3]&0xff, 413 _ifr.ifr_hwaddr.sa_data[3]&0xff,
412 _ifr.ifr_hwaddr.sa_data[4]&0xff, 414 _ifr.ifr_hwaddr.sa_data[4]&0xff,
413 _ifr.ifr_hwaddr.sa_data[5]&0xff ); 415 _ifr.ifr_hwaddr.sa_data[5]&0xff );
414 } 416 }
415 else 417 else
416 { 418 {
417 mac = "<Unknown>"; 419 mac = "<Unknown>";
@@ -692,73 +694,88 @@ void OWlanNGMonitoringInterface::setEnabled( bool b )
692 694
693QString OWlanNGMonitoringInterface::name() const 695QString OWlanNGMonitoringInterface::name() const
694{ 696{
695 return "wlan-ng"; 697 return "wlan-ng";
696} 698}
697 699
698 700
699void OWlanNGMonitoringInterface::setChannel( int ) 701void OWlanNGMonitoringInterface::setChannel( int )
700{ 702{
701 // wlan-ng devices automatically switch channels when in monitor mode 703 // wlan-ng devices automatically switch channels when in monitor mode
702} 704}
703 705
704 706
705/*====================================================================================== 707/*======================================================================================
706 * OHostAPMonitoringInterface 708 * OHostAPMonitoringInterface
707 *======================================================================================*/ 709 *======================================================================================*/
708 710
709OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) 711OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface )
710 :OMonitoringInterface( iface ) 712 :OMonitoringInterface( iface )
711{ 713{
712 iface->setMonitoring( this ); 714 iface->setMonitoring( this );
713} 715}
714 716
715OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 717OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
716{ 718{
717} 719}
718 720
719void OHostAPMonitoringInterface::setEnabled( bool b ) 721void OHostAPMonitoringInterface::setEnabled( bool b )
720{ 722{
721 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 723 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
722 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 724 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
723 725
724 #if WIRELESS_EXT > 14 726 if ( b )
725 _if->_iwr.u.mode = IW_MODE_MONITOR; 727 {
726 _if->wioctl( SIOCSIWMODE ); 728 #if WIRELESS_EXT > 14
727 #else 729 _if->_iwr.u.mode = IW_MODE_MONITOR;
728 int* args = (int*) &_if->_iwr.u.name; 730 _if->wioctl( SIOCSIWMODE );
729 args[0] = 2; 731 #else
730 args[1] = 0; 732 int* args = (int*) &_if->_iwr.u.name;
731 _if->wioctl( SIOCDEVPRIVATE ); 733 args[0] = 2;
732 #endif 734 args[1] = 0;
735 _if->wioctl( SIOCDEVPRIVATE );
736 #endif
737 }
738 else
739 {
740 #if WIRELESS_EXT > 14
741 _if->_iwr.u.mode = IW_MODE_INFRA;
742 _if->wioctl( SIOCSIWMODE );
743 #else
744 int* args = (int*) &_if->_iwr.u.name;
745 args[0] = 0;
746 args[1] = 0;
747 _if->wioctl( SIOCDEVPRIVATE );
748 #endif
749 }
733 750
734 OMonitoringInterface::setEnabled( b ); 751 OMonitoringInterface::setEnabled( b );
735} 752}
736 753
737 754
738QString OHostAPMonitoringInterface::name() const 755QString OHostAPMonitoringInterface::name() const
739{ 756{
740 return "hostap"; 757 return "hostap";
741} 758}
742 759
743 760
744/*====================================================================================== 761/*======================================================================================
745 * OOrinocoNetworkInterface 762 * OOrinocoNetworkInterface
746 *======================================================================================*/ 763 *======================================================================================*/
747 764
748OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface ) 765OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface )
749 :OMonitoringInterface( iface ) 766 :OMonitoringInterface( iface )
750{ 767{
751 iface->setMonitoring( this ); 768 iface->setMonitoring( this );
752} 769}
753 770
754 771
755OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 772OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
756{ 773{
757} 774}
758 775
759 776
760void OOrinocoMonitoringInterface::setChannel( int c ) 777void OOrinocoMonitoringInterface::setChannel( int c )
761{ 778{
762 // call iwpriv <device> monitor 2 <channel> 779 // call iwpriv <device> monitor 2 <channel>
763 int* args = (int*) &_if->_iwr.u.name; 780 int* args = (int*) &_if->_iwr.u.name;
764 args[0] = 2; 781 args[0] = 2;