author | mickeyl <mickeyl> | 2003-10-28 16:38:55 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-28 16:38:55 (UTC) |
commit | 877bc5c756d94db71a745596dd7e48104a2ec9a1 (patch) (unidiff) | |
tree | df4de5f085b55e812488b0db2be1d66f63b67945 /libopie2/opienet/onetwork.cpp | |
parent | 1fed961e25a6afd4070d8873b431aba8342406c3 (diff) | |
download | opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.zip opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.tar.gz opie-877bc5c756d94db71a745596dd7e48104a2ec9a1.tar.bz2 |
- remove deprecated setMonitorMode() API. Use setMode( "monitor" ) now.
- monitor mode now tries to use the standard IW_MODE_MONITOR first. If that
doesn't work, it falls back to using proprietary iwpriv commands
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 106 |
1 files changed, 62 insertions, 44 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 50c6679..c329e9a 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -674,38 +674,80 @@ OChannelHopper* OWirelessNetworkInterface::channelHopper() const | |||
674 | 674 | ||
675 | 675 | ||
676 | void OWirelessNetworkInterface::setMode( const QString& mode ) | 676 | void OWirelessNetworkInterface::commit() const |
677 | { | 677 | { |
678 | _iwr.u.mode = stringToMode( mode ); | 678 | wioctl( SIOCSIWCOMMIT ); |
679 | wioctl( SIOCSIWMODE ); | ||
680 | } | 679 | } |
681 | 680 | ||
682 | 681 | ||
683 | QString OWirelessNetworkInterface::mode() const | 682 | void OWirelessNetworkInterface::setMode( const QString& newMode ) |
684 | { | 683 | { |
685 | if ( !wioctl( SIOCGIWMODE ) ) | 684 | #ifdef FINALIZE |
685 | QString currentMode = mode(); | ||
686 | if ( currentMode == newMode ) return; | ||
687 | #endif | ||
688 | |||
689 | qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); | ||
690 | |||
691 | _iwr.u.mode = stringToMode( newMode ); | ||
692 | |||
693 | if ( _iwr.u.mode != IW_MODE_MONITOR ) | ||
686 | { | 694 | { |
687 | return "<unknown>"; | 695 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! |
696 | _iwr.u.mode = stringToMode( newMode ); | ||
697 | wioctl( SIOCSIWMODE ); | ||
698 | |||
699 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) | ||
700 | |||
701 | if ( mode() == "monitor" ) | ||
702 | { | ||
703 | qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); | ||
704 | if ( _mon ) | ||
705 | _mon->setEnabled( false ); | ||
706 | else | ||
707 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | ||
708 | } | ||
709 | |||
710 | } | ||
711 | else // special iwpriv fallback for monitor mode | ||
712 | { | ||
713 | if ( wioctl( SIOCSIWMODE ) ) | ||
714 | { | ||
715 | qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); | ||
716 | } | ||
717 | else | ||
718 | { | ||
719 | qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); | ||
720 | |||
721 | if ( _mon ) | ||
722 | _mon->setEnabled( true ); | ||
723 | else | ||
724 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | ||
725 | } | ||
688 | } | 726 | } |
689 | return modeToString( _iwr.u.mode ); | ||
690 | } | 727 | } |
691 | 728 | ||
692 | 729 | ||
693 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 730 | QString OWirelessNetworkInterface::mode() const |
694 | { | 731 | { |
695 | if ( _mon ) | 732 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
696 | _mon->setEnabled( b ); | 733 | |
697 | else | 734 | if ( !wioctl( SIOCGIWMODE ) ) |
698 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 735 | { |
699 | } | 736 | return "<unknown>"; |
737 | } | ||
700 | 738 | ||
739 | qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); | ||
701 | 740 | ||
702 | bool OWirelessNetworkInterface::monitorMode() const | 741 | // legacy compatible monitor mode check |
703 | { | ||
704 | qDebug( "dataLinkType = %d", dataLinkType() ); | ||
705 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); | ||
706 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... | ||
707 | //FIXME: What is 119, by the way? | ||
708 | } | ||
709 | 742 | ||
743 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) | ||
744 | { | ||
745 | return "monitor"; | ||
746 | } | ||
747 | else | ||
748 | { | ||
749 | return modeToString( _iwr.u.mode ); | ||
750 | } | ||
751 | } | ||
710 | 752 | ||
711 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 753 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
@@ -970,10 +1012,4 @@ void OMonitoringInterface::setChannel( int c ) | |||
970 | 1012 | ||
971 | 1013 | ||
972 | bool OMonitoringInterface::enabled() const | ||
973 | { | ||
974 | return _if->monitorMode(); | ||
975 | } | ||
976 | |||
977 | |||
978 | void OMonitoringInterface::setEnabled( bool b ) | 1014 | void OMonitoringInterface::setEnabled( bool b ) |
979 | { | 1015 | { |
@@ -1093,13 +1129,4 @@ OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | |||
1093 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 1129 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
1094 | { | 1130 | { |
1095 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | ||
1096 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | ||
1097 | |||
1098 | #if WIRELESS_EXT > 14 | ||
1099 | if ( b ) | ||
1100 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | ||
1101 | else | ||
1102 | _if->setMode( "managed" ); | ||
1103 | #else | ||
1104 | int monitorCode = _prismHeader ? 1 : 2; | 1131 | int monitorCode = _prismHeader ? 1 : 2; |
1105 | if ( b ) | 1132 | if ( b ) |
@@ -1111,5 +1138,4 @@ void OHostAPMonitoringInterface::setEnabled( bool b ) | |||
1111 | _if->setPrivate( "monitor", 1, 0 ); | 1138 | _if->setPrivate( "monitor", 1, 0 ); |
1112 | } | 1139 | } |
1113 | #endif | ||
1114 | } | 1140 | } |
1115 | 1141 | ||
@@ -1150,11 +1176,4 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) | |||
1150 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported | 1176 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported |
1151 | 1177 | ||
1152 | #if 0 | ||
1153 | //#if WIRELESS_EXT > 14 | ||
1154 | if ( b ) | ||
1155 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | ||
1156 | else | ||
1157 | _if->setMode( "managed" ); | ||
1158 | #else | ||
1159 | if ( b ) | 1178 | if ( b ) |
1160 | { | 1179 | { |
@@ -1165,5 +1184,4 @@ void OOrinocoMonitoringInterface::setEnabled( bool b ) | |||
1165 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1184 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1166 | } | 1185 | } |
1167 | #endif | ||
1168 | } | 1186 | } |
1169 | 1187 | ||