summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 36f409b..915814d 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1008,218 +1008,221 @@ bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
1008 return ( result != -1 ); 1008 return ( result != -1 );
1009 #else 1009 #else
1010 return ::ioctl( _sfd, call, &iwreq ) != -1; 1010 return ::ioctl( _sfd, call, &iwreq ) != -1;
1011 #endif 1011 #endif
1012} 1012}
1013 1013
1014 1014
1015bool OWirelessNetworkInterface::wioctl( int call ) const 1015bool OWirelessNetworkInterface::wioctl( int call ) const
1016{ 1016{
1017 strcpy( _iwr.ifr_name, name() ); 1017 strcpy( _iwr.ifr_name, name() );
1018 return wioctl( call, _iwr ); 1018 return wioctl( call, _iwr );
1019} 1019}
1020 1020
1021 1021
1022/*====================================================================================== 1022/*======================================================================================
1023 * OMonitoringInterface 1023 * OMonitoringInterface
1024 *======================================================================================*/ 1024 *======================================================================================*/
1025 1025
1026OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1026OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1027 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 1027 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
1028{ 1028{
1029} 1029}
1030 1030
1031 1031
1032OMonitoringInterface::~OMonitoringInterface() 1032OMonitoringInterface::~OMonitoringInterface()
1033{ 1033{
1034} 1034}
1035 1035
1036 1036
1037void OMonitoringInterface::setChannel( int c ) 1037void OMonitoringInterface::setChannel( int c )
1038{ 1038{
1039 // use standard WE channel switching protocol 1039 // use standard WE channel switching protocol
1040 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 1040 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
1041 _if->_iwr.u.freq.m = c; 1041 _if->_iwr.u.freq.m = c;
1042 _if->_iwr.u.freq.e = 0; 1042 _if->_iwr.u.freq.e = 0;
1043 _if->wioctl( SIOCSIWFREQ ); 1043 _if->wioctl( SIOCSIWFREQ );
1044} 1044}
1045 1045
1046 1046
1047void OMonitoringInterface::setEnabled( bool b ) 1047void OMonitoringInterface::setEnabled( bool b )
1048{ 1048{
1049} 1049}
1050 1050
1051 1051
1052/*====================================================================================== 1052/*======================================================================================
1053 * OCiscoMonitoringInterface 1053 * OCiscoMonitoringInterface
1054 *======================================================================================*/ 1054 *======================================================================================*/
1055 1055
1056OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1056OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1057 :OMonitoringInterface( iface, prismHeader ) 1057 :OMonitoringInterface( iface, prismHeader )
1058{ 1058{
1059 iface->setMonitoring( this ); 1059 iface->setMonitoring( this );
1060} 1060}
1061 1061
1062 1062
1063OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 1063OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
1064{ 1064{
1065} 1065}
1066 1066
1067 1067
1068void OCiscoMonitoringInterface::setEnabled( bool b ) 1068void OCiscoMonitoringInterface::setEnabled( bool b )
1069{ 1069{
1070 QString fname; 1070 QString fname;
1071 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 1071 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
1072 QFile f( fname ); 1072 QFile f( fname );
1073 if ( !f.exists() ) return; 1073 if ( !f.exists() ) return;
1074 1074
1075 if ( f.open( IO_WriteOnly ) ) 1075 if ( f.open( IO_WriteOnly ) )
1076 { 1076 {
1077 QTextStream s( &f ); 1077 QTextStream s( &f );
1078 s << "Mode: r"; 1078 s << "Mode: r";
1079 s << "Mode: y"; 1079 s << "Mode: y";
1080 s << "XmitPower: 1"; 1080 s << "XmitPower: 1";
1081 } 1081 }
1082 1082
1083 // flushing and closing will be done automatically when f goes out of scope 1083 // flushing and closing will be done automatically when f goes out of scope
1084} 1084}
1085 1085
1086 1086
1087QString OCiscoMonitoringInterface::name() const 1087QString OCiscoMonitoringInterface::name() const
1088{ 1088{
1089 return "cisco"; 1089 return "cisco";
1090} 1090}
1091 1091
1092 1092
1093void OCiscoMonitoringInterface::setChannel( int ) 1093void OCiscoMonitoringInterface::setChannel( int )
1094{ 1094{
1095 // cisco devices automatically switch channels when in monitor mode 1095 // cisco devices automatically switch channels when in monitor mode
1096} 1096}
1097 1097
1098 1098
1099/*====================================================================================== 1099/*======================================================================================
1100 * OWlanNGMonitoringInterface 1100 * OWlanNGMonitoringInterface
1101 *======================================================================================*/ 1101 *======================================================================================*/
1102 1102
1103 1103
1104OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1104OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1105 :OMonitoringInterface( iface, prismHeader ) 1105 :OMonitoringInterface( iface, prismHeader )
1106{ 1106{
1107 iface->setMonitoring( this ); 1107 iface->setMonitoring( this );
1108} 1108}
1109 1109
1110 1110
1111OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 1111OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
1112{ 1112{
1113} 1113}
1114 1114
1115 1115
1116void OWlanNGMonitoringInterface::setEnabled( bool b ) 1116void OWlanNGMonitoringInterface::setEnabled( bool b )
1117{ 1117{
1118 //FIXME: do nothing if its already in the same mode 1118 //FIXME: do nothing if its already in the same mode
1119 1119
1120 QString enable = b ? "true" : "false"; 1120 QString enable = b ? "true" : "false";
1121 QString prism = _prismHeader ? "true" : "false"; 1121 QString prism = _prismHeader ? "true" : "false";
1122 QString cmd; 1122 QString cmd;
1123 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1123 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1124 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); 1124 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism );
1125 system( cmd ); 1125 system( cmd );
1126} 1126}
1127 1127
1128 1128
1129QString OWlanNGMonitoringInterface::name() const 1129QString OWlanNGMonitoringInterface::name() const
1130{ 1130{
1131 return "wlan-ng"; 1131 return "wlan-ng";
1132} 1132}
1133 1133
1134 1134
1135void OWlanNGMonitoringInterface::setChannel( int c ) 1135void OWlanNGMonitoringInterface::setChannel( int c )
1136{ 1136{
1137 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. 1137 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
1138 1138
1139 QString enable = "true"; //_if->monitorMode() ? "true" : "false"; 1139 QString enable = "true"; //_if->monitorMode() ? "true" : "false";
1140 QString prism = _prismHeader ? "true" : "false"; 1140 QString prism = _prismHeader ? "true" : "false";
1141 QString cmd; 1141 QString cmd;
1142 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 1142 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
1143 (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); 1143 (const char*) _if->name(), c, (const char*) enable, (const char*) prism );
1144 system( cmd ); 1144 system( cmd );
1145} 1145}
1146 1146
1147 1147
1148/*====================================================================================== 1148/*======================================================================================
1149 * OHostAPMonitoringInterface 1149 * OHostAPMonitoringInterface
1150 *======================================================================================*/ 1150 *======================================================================================*/
1151 1151
1152OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1152OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1153 :OMonitoringInterface( iface, prismHeader ) 1153 :OMonitoringInterface( iface, prismHeader )
1154{ 1154{
1155 iface->setMonitoring( this ); 1155 iface->setMonitoring( this );
1156} 1156}
1157 1157
1158OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 1158OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
1159{ 1159{
1160} 1160}
1161 1161
1162void OHostAPMonitoringInterface::setEnabled( bool b ) 1162void OHostAPMonitoringInterface::setEnabled( bool b )
1163{ 1163{
1164 int monitorCode = _prismHeader ? 1 : 2; 1164 int monitorCode = _prismHeader ? 1 : 2;
1165 if ( b ) 1165 if ( b )
1166 { 1166 {
1167 _if->setPrivate( "monitor", 1, monitorCode ); 1167 _if->setPrivate( "monitor", 1, monitorCode );
1168 } 1168 }
1169 else 1169 else
1170 { 1170 {
1171 _if->setPrivate( "monitor", 1, 0 ); 1171 _if->setPrivate( "monitor", 1, 0 );
1172 } 1172 }
1173} 1173}
1174 1174
1175 1175
1176QString OHostAPMonitoringInterface::name() const 1176QString OHostAPMonitoringInterface::name() const
1177{ 1177{
1178 return "hostap"; 1178 return "hostap";
1179} 1179}
1180 1180
1181 1181
1182/*====================================================================================== 1182/*======================================================================================
1183 * OOrinocoNetworkInterface 1183 * OOrinocoNetworkInterface
1184 *======================================================================================*/ 1184 *======================================================================================*/
1185 1185
1186OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 1186OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
1187 :OMonitoringInterface( iface, prismHeader ) 1187 :OMonitoringInterface( iface, prismHeader )
1188{ 1188{
1189 iface->setMonitoring( this ); 1189 iface->setMonitoring( this );
1190} 1190}
1191 1191
1192 1192
1193OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 1193OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
1194{ 1194{
1195} 1195}
1196 1196
1197 1197
1198void OOrinocoMonitoringInterface::setChannel( int c ) 1198void OOrinocoMonitoringInterface::setChannel( int c )
1199{ 1199{
1200 int monitorCode = _prismHeader ? 1 : 2; 1200 if ( !_if->hasPrivate( "monitor" ) )
1201 _if->setPrivate( "monitor", 2, monitorCode, c ); 1201 {
1202 this->OMonitoringInterface::setChannel( c );
1203 }
1204 else
1205 {
1206 int monitorCode = _prismHeader ? 1 : 2;
1207 _if->setPrivate( "monitor", 2, monitorCode, c );
1208 }
1202} 1209}
1203 1210
1204 1211
1205void OOrinocoMonitoringInterface::setEnabled( bool b ) 1212void OOrinocoMonitoringInterface::setEnabled( bool b )
1206{ 1213{
1207 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
1208 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
1209 // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported
1210
1211 if ( b ) 1214 if ( b )
1212 { 1215 {
1213 setChannel( 1 ); 1216 setChannel( 1 );
1214 } 1217 }
1215 else 1218 else
1216 { 1219 {
1217 _if->setPrivate( "monitor", 2, 0, 0 ); 1220 _if->setPrivate( "monitor", 2, 0, 0 );
1218 } 1221 }
1219} 1222}
1220 1223
1221 1224
1222QString OOrinocoMonitoringInterface::name() const 1225QString OOrinocoMonitoringInterface::name() const
1223{ 1226{
1224 return "orinoco"; 1227 return "orinoco";
1225} 1228}