author | mickeyl <mickeyl> | 2003-10-09 16:01:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-09 16:01:08 (UTC) |
commit | 802c9ab6b89fd10f709aa012e8ff075e9b4a5d7f (patch) (unidiff) | |
tree | c6a33ab027752ca04d0d98a2e71a238aa954978d | |
parent | c5c5c9f9fc6cab574f35f8be21076ac81f8c0369 (diff) | |
download | opie-802c9ab6b89fd10f709aa012e8ff075e9b4a5d7f.zip opie-802c9ab6b89fd10f709aa012e8ff075e9b4a5d7f.tar.gz opie-802c9ab6b89fd10f709aa012e8ff075e9b4a5d7f.tar.bz2 |
- fix monitor mode on orinoco. Although WE > 14 define the standard mode
"MONITOR", the orinoco monitor patch for 0.13e still does not use that...
- add documentation, a warning, and a runtime check for setChannel(0)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 12 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 45ee4c0..767651e 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -580,32 +580,38 @@ int OWirelessNetworkInterface::channel() const | |||
580 | if ( _hopper && _hopper->isActive() ) | 580 | if ( _hopper && _hopper->isActive() ) |
581 | return _hopper->channel(); | 581 | return _hopper->channel(); |
582 | 582 | ||
583 | if ( !wioctl( SIOCGIWFREQ ) ) | 583 | if ( !wioctl( SIOCGIWFREQ ) ) |
584 | { | 584 | { |
585 | return -1; | 585 | return -1; |
586 | } | 586 | } |
587 | else | 587 | else |
588 | { | 588 | { |
589 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 589 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | 593 | ||
594 | void OWirelessNetworkInterface::setChannel( int c ) const | 594 | void OWirelessNetworkInterface::setChannel( int c ) const |
595 | { | 595 | { |
596 | if ( c ) | ||
597 | { | ||
598 | qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); | ||
599 | return; | ||
600 | } | ||
601 | |||
596 | if ( !_mon ) | 602 | if ( !_mon ) |
597 | { | 603 | { |
598 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 604 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
599 | _iwr.u.freq.m = c; | 605 | _iwr.u.freq.m = c; |
600 | _iwr.u.freq.e = 0; | 606 | _iwr.u.freq.e = 0; |
601 | wioctl( SIOCSIWFREQ ); | 607 | wioctl( SIOCSIWFREQ ); |
602 | } | 608 | } |
603 | else | 609 | else |
604 | { | 610 | { |
605 | _mon->setChannel( c ); | 611 | _mon->setChannel( c ); |
606 | } | 612 | } |
607 | } | 613 | } |
608 | 614 | ||
609 | 615 | ||
610 | double OWirelessNetworkInterface::frequency() const | 616 | double OWirelessNetworkInterface::frequency() const |
611 | { | 617 | { |
@@ -926,33 +932,33 @@ void OWlanNGMonitoringInterface::setEnabled( bool b ) | |||
926 | 932 | ||
927 | 933 | ||
928 | QString OWlanNGMonitoringInterface::name() const | 934 | QString OWlanNGMonitoringInterface::name() const |
929 | { | 935 | { |
930 | return "wlan-ng"; | 936 | return "wlan-ng"; |
931 | } | 937 | } |
932 | 938 | ||
933 | 939 | ||
934 | void OWlanNGMonitoringInterface::setChannel( int c ) | 940 | void OWlanNGMonitoringInterface::setChannel( int c ) |
935 | { | 941 | { |
936 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. | 942 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. |
937 | 943 | ||
938 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; | 944 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; |
939 | QString prism = _prismHeader ? "true" : "false"; | 945 | QString prism = _prismHeader ? "true" : "false"; |
940 | QString cmd; | 946 | QString cmd; |
941 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 947 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
942 | (const char*) _if->name(), c+1, (const char*) enable, (const char*) prism ); | 948 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); |
943 | system( cmd ); | 949 | system( cmd ); |
944 | } | 950 | } |
945 | 951 | ||
946 | 952 | ||
947 | /*====================================================================================== | 953 | /*====================================================================================== |
948 | * OHostAPMonitoringInterface | 954 | * OHostAPMonitoringInterface |
949 | *======================================================================================*/ | 955 | *======================================================================================*/ |
950 | 956 | ||
951 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 957 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
952 | :OMonitoringInterface( iface, prismHeader ) | 958 | :OMonitoringInterface( iface, prismHeader ) |
953 | { | 959 | { |
954 | iface->setMonitoring( this ); | 960 | iface->setMonitoring( this ); |
955 | } | 961 | } |
956 | 962 | ||
957 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 963 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
958 | { | 964 | { |
@@ -1002,34 +1008,36 @@ OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* ifa | |||
1002 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1008 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1003 | { | 1009 | { |
1004 | } | 1010 | } |
1005 | 1011 | ||
1006 | 1012 | ||
1007 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1013 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1008 | { | 1014 | { |
1009 | int monitorCode = _prismHeader ? 1 : 2; | 1015 | int monitorCode = _prismHeader ? 1 : 2; |
1010 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1016 | _if->setPrivate( "monitor", 2, monitorCode, c ); |
1011 | } | 1017 | } |
1012 | 1018 | ||
1013 | 1019 | ||
1014 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1020 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1015 | { | 1021 | { |
1016 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 1022 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
1017 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 1023 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
1024 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported | ||
1018 | 1025 | ||
1019 | #if WIRELESS_EXT > 14 | 1026 | #if 0 |
1027 | //#if WIRELESS_EXT > 14 | ||
1020 | if ( b ) | 1028 | if ( b ) |
1021 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | 1029 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header |
1022 | else | 1030 | else |
1023 | _if->setMode( "managed" ); | 1031 | _if->setMode( "managed" ); |
1024 | #else | 1032 | #else |
1025 | if ( b ) | 1033 | if ( b ) |
1026 | { | 1034 | { |
1027 | setChannel( 1 ); | 1035 | setChannel( 1 ); |
1028 | } | 1036 | } |
1029 | else | 1037 | else |
1030 | { | 1038 | { |
1031 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1039 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1032 | } | 1040 | } |
1033 | #endif | 1041 | #endif |
1034 | } | 1042 | } |
1035 | 1043 | ||
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 2553a61..00d1ebb 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -323,32 +323,34 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
323 | friend class OOrinocoMonitoringInterface; | 323 | friend class OOrinocoMonitoringInterface; |
324 | 324 | ||
325 | friend class OPrivateIOCTL; | 325 | friend class OPrivateIOCTL; |
326 | 326 | ||
327 | public: | 327 | public: |
328 | /** | 328 | /** |
329 | * Constructor. | 329 | * Constructor. |
330 | */ | 330 | */ |
331 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 331 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
332 | /** | 332 | /** |
333 | * Destructor. | 333 | * Destructor. |
334 | */ | 334 | */ |
335 | virtual ~OWirelessNetworkInterface(); | 335 | virtual ~OWirelessNetworkInterface(); |
336 | /** | 336 | /** |
337 | * Setting the @a channel of the interface changes the radio frequency (RF) | 337 | * Setting the @a channel of the interface changes the radio frequency (RF) |
338 | * of the corresponding wireless network device. | 338 | * of the corresponding wireless network device. |
339 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. | ||
340 | * @see channels() | ||
339 | */ | 341 | */ |
340 | virtual void setChannel( int channel ) const; | 342 | virtual void setChannel( int channel ) const; |
341 | /** | 343 | /** |
342 | * @returns the channel index of the current radio frequency. | 344 | * @returns the channel index of the current radio frequency. |
343 | */ | 345 | */ |
344 | virtual int channel() const; | 346 | virtual int channel() const; |
345 | /** | 347 | /** |
346 | * @returns the current radio frequency (in MHz). | 348 | * @returns the current radio frequency (in MHz). |
347 | */ | 349 | */ |
348 | virtual double frequency() const; | 350 | virtual double frequency() const; |
349 | /** | 351 | /** |
350 | * @returns the number of radio frequency channels for the | 352 | * @returns the number of radio frequency channels for the |
351 | * corresponding wireless network device. | 353 | * corresponding wireless network device. |
352 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 354 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
353 | */ | 355 | */ |
354 | virtual int channels() const; | 356 | virtual int channels() const; |