summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 6cef5cf..751d841 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -58,24 +58,25 @@
58 58
59using namespace std; 59using namespace std;
60 60
61/*====================================================================================== 61/*======================================================================================
62 * ONetwork 62 * ONetwork
63 *======================================================================================*/ 63 *======================================================================================*/
64 64
65ONetwork* ONetwork::_instance = 0; 65ONetwork* ONetwork::_instance = 0;
66 66
67ONetwork::ONetwork() 67ONetwork::ONetwork()
68{ 68{
69 qDebug( "ONetwork::ONetwork()" ); 69 qDebug( "ONetwork::ONetwork()" );
70 qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT );
70 synchronize(); 71 synchronize();
71} 72}
72 73
73void ONetwork::synchronize() 74void ONetwork::synchronize()
74{ 75{
75 // gather available interfaces by inspecting /proc/net/dev 76 // gather available interfaces by inspecting /proc/net/dev
76 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 77 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
77 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 78 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
78 79
79 _interfaces.clear(); 80 _interfaces.clear();
80 QString str; 81 QString str;
81 QFile f( "/proc/net/dev" ); 82 QFile f( "/proc/net/dev" );
@@ -100,24 +101,30 @@ void ONetwork::synchronize()
100 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 101 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
101 } 102 }
102 else 103 else
103 { 104 {
104 iface = new ONetworkInterface( this, (const char*) str ); 105 iface = new ONetworkInterface( this, (const char*) str );
105 } 106 }
106 _interfaces.insert( str, iface ); 107 _interfaces.insert( str, iface );
107 s.readLine(); 108 s.readLine();
108 } 109 }
109} 110}
110 111
111 112
113short ONetwork::wirelessExtensionVersion()
114{
115 return WIRELESS_EXT;
116}
117
118
112int ONetwork::count() const 119int ONetwork::count() const
113{ 120{
114 return _interfaces.count(); 121 return _interfaces.count();
115} 122}
116 123
117 124
118ONetworkInterface* ONetwork::interface( const QString& iface ) const 125ONetworkInterface* ONetwork::interface( const QString& iface ) const
119{ 126{
120 return _interfaces[iface]; 127 return _interfaces[iface];
121} 128}
122 129
123 130
@@ -940,37 +947,40 @@ OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface
940 iface->setMonitoring( this ); 947 iface->setMonitoring( this );
941} 948}
942 949
943OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 950OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
944{ 951{
945} 952}
946 953
947void OHostAPMonitoringInterface::setEnabled( bool b ) 954void OHostAPMonitoringInterface::setEnabled( bool b )
948{ 955{
949 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 956 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
950 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 957 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
951 958
952 //TODO: check wireless extensions version on runtime and use 959 #if WIRELESS_EXT > 14
953 //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 960 if ( b )
954 961 _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header
962 else
963 _if->setMode( "managed" );
964 #else
955 int monitorCode = _prismHeader ? 1 : 2; 965 int monitorCode = _prismHeader ? 1 : 2;
956
957 if ( b ) 966 if ( b )
958 { 967 {
959 _if->setPrivate( "monitor", 1, monitorCode ); 968 _if->setPrivate( "monitor", 1, monitorCode );
960 } 969 }
961 else 970 else
962 { 971 {
963 _if->setPrivate( "monitor", 1, 0 ); 972 _if->setPrivate( "monitor", 1, 0 );
964 } 973 }
974 #endif
965} 975}
966 976
967 977
968QString OHostAPMonitoringInterface::name() const 978QString OHostAPMonitoringInterface::name() const
969{ 979{
970 return "hostap"; 980 return "hostap";
971} 981}
972 982
973 983
974/*====================================================================================== 984/*======================================================================================
975 * OOrinocoNetworkInterface 985 * OOrinocoNetworkInterface
976 *======================================================================================*/ 986 *======================================================================================*/
@@ -987,27 +997,37 @@ OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
987} 997}
988 998
989 999
990void OOrinocoMonitoringInterface::setChannel( int c ) 1000void OOrinocoMonitoringInterface::setChannel( int c )
991{ 1001{
992 int monitorCode = _prismHeader ? 1 : 2; 1002 int monitorCode = _prismHeader ? 1 : 2;
993 _if->setPrivate( "monitor", 2, monitorCode, c ); 1003 _if->setPrivate( "monitor", 2, monitorCode, c );
994} 1004}
995 1005
996 1006
997void OOrinocoMonitoringInterface::setEnabled( bool b ) 1007void OOrinocoMonitoringInterface::setEnabled( bool b )
998{ 1008{
1009 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
1010 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
1011
1012 #if WIRELESS_EXT > 14
1013 if ( b )
1014 _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header
1015 else
1016 _if->setMode( "managed" );
1017 #else
999 if ( b ) 1018 if ( b )
1000 { 1019 {
1001 setChannel( 1 ); 1020 setChannel( 1 );
1002 } 1021 }
1003 else 1022 else
1004 { 1023 {
1005 _if->setPrivate( "monitor", 2, 0, 0 ); 1024 _if->setPrivate( "monitor", 2, 0, 0 );
1006 } 1025 }
1026 #endif
1007} 1027}
1008 1028
1009 1029
1010QString OOrinocoMonitoringInterface::name() const 1030QString OOrinocoMonitoringInterface::name() const
1011{ 1031{
1012 return "orinoco"; 1032 return "orinoco";
1013} 1033}