summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 751d841..1f529d2 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -745,289 +745,290 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
745 return; 745 return;
746 } 746 }
747 747
748 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); 748 qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() );
749 memset( &_iwr, 0, sizeof _iwr ); 749 memset( &_iwr, 0, sizeof _iwr );
750 va_list argp; 750 va_list argp;
751 va_start( argp, numargs ); 751 va_start( argp, numargs );
752 for ( int i = 0; i < numargs; ++i ) 752 for ( int i = 0; i < numargs; ++i )
753 { 753 {
754 priv->setParameter( i, va_arg( argp, int ) ); 754 priv->setParameter( i, va_arg( argp, int ) );
755 } 755 }
756 va_end( argp ); 756 va_end( argp );
757 priv->invoke(); 757 priv->invoke();
758} 758}
759 759
760 760
761void OWirelessNetworkInterface::getPrivate( const QString& call ) 761void OWirelessNetworkInterface::getPrivate( const QString& call )
762{ 762{
763 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); 763 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
764} 764}
765 765
766 766
767bool OWirelessNetworkInterface::hasPrivate( const QString& call ) 767bool OWirelessNetworkInterface::hasPrivate( const QString& call )
768{ 768{
769 return child( (const char*) call ); 769 return child( (const char*) call );
770} 770}
771 771
772 772
773QString OWirelessNetworkInterface::SSID() const 773QString OWirelessNetworkInterface::SSID() const
774{ 774{
775 char str[IW_ESSID_MAX_SIZE]; 775 char str[IW_ESSID_MAX_SIZE];
776 _iwr.u.essid.pointer = &str[0]; 776 _iwr.u.essid.pointer = &str[0];
777 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 777 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
778 if ( !wioctl( SIOCGIWESSID ) ) 778 if ( !wioctl( SIOCGIWESSID ) )
779 { 779 {
780 return "<unknown>"; 780 return "<unknown>";
781 } 781 }
782 else 782 else
783 { 783 {
784 return str; 784 return str;
785 } 785 }
786} 786}
787 787
788 788
789void OWirelessNetworkInterface::setSSID( const QString& ssid ) 789void OWirelessNetworkInterface::setSSID( const QString& ssid )
790{ 790{
791 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); 791 _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid );
792 _iwr.u.essid.length = ssid.length(); 792 _iwr.u.essid.length = ssid.length();
793 wioctl( SIOCSIWESSID ); 793 wioctl( SIOCSIWESSID );
794} 794}
795 795
796 796
797bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const 797bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
798{ 798{
799 int result = ::ioctl( _sfd, call, &iwreq ); 799 int result = ::ioctl( _sfd, call, &iwreq );
800 if ( result == -1 ) 800 if ( result == -1 )
801 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) ); 801 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Failed: %d (%s)", name(), call, result, strerror( errno ) );
802 else 802 else
803 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call ); 803 qDebug( "ONetworkInterface::wioctl (%s) call %d - Status: Ok.", name(), call );
804 return ( result != -1 ); 804 return ( result != -1 );
805} 805}
806 806
807 807
808bool OWirelessNetworkInterface::wioctl( int call ) const 808bool OWirelessNetworkInterface::wioctl( int call ) const
809{ 809{
810 strcpy( _iwr.ifr_name, name() ); 810 strcpy( _iwr.ifr_name, name() );
811 return wioctl( call, _iwr ); 811 return wioctl( call, _iwr );
812} 812}
813 813
814 814
815/*====================================================================================== 815/*======================================================================================
816 * OMonitoringInterface 816 * OMonitoringInterface
817 *======================================================================================*/ 817 *======================================================================================*/
818 818
819OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 819OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
820 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) 820 :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader )
821{ 821{
822} 822}
823 823
824 824
825OMonitoringInterface::~OMonitoringInterface() 825OMonitoringInterface::~OMonitoringInterface()
826{ 826{
827} 827}
828 828
829 829
830void OMonitoringInterface::setChannel( int c ) 830void OMonitoringInterface::setChannel( int c )
831{ 831{
832 // use standard WE channel switching protocol 832 // use standard WE channel switching protocol
833 memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); 833 memset( &_if->_iwr, 0, sizeof( struct iwreq ) );
834 _if->_iwr.u.freq.m = c; 834 _if->_iwr.u.freq.m = c;
835 _if->_iwr.u.freq.e = 0; 835 _if->_iwr.u.freq.e = 0;
836 _if->wioctl( SIOCSIWFREQ ); 836 _if->wioctl( SIOCSIWFREQ );
837} 837}
838 838
839 839
840bool OMonitoringInterface::enabled() const 840bool OMonitoringInterface::enabled() const
841{ 841{
842 return _if->monitorMode(); 842 return _if->monitorMode();
843} 843}
844 844
845 845
846void OMonitoringInterface::setEnabled( bool b ) 846void OMonitoringInterface::setEnabled( bool b )
847{ 847{
848} 848}
849 849
850 850
851/*====================================================================================== 851/*======================================================================================
852 * OCiscoMonitoringInterface 852 * OCiscoMonitoringInterface
853 *======================================================================================*/ 853 *======================================================================================*/
854 854
855OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 855OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
856 :OMonitoringInterface( iface, prismHeader ) 856 :OMonitoringInterface( iface, prismHeader )
857{ 857{
858 iface->setMonitoring( this ); 858 iface->setMonitoring( this );
859} 859}
860 860
861 861
862OCiscoMonitoringInterface::~OCiscoMonitoringInterface() 862OCiscoMonitoringInterface::~OCiscoMonitoringInterface()
863{ 863{
864} 864}
865 865
866 866
867void OCiscoMonitoringInterface::setEnabled( bool b ) 867void OCiscoMonitoringInterface::setEnabled( bool b )
868{ 868{
869 QString fname; 869 QString fname;
870 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); 870 fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() );
871 QFile f( fname ); 871 QFile f( fname );
872 if ( !f.exists() ) return; 872 if ( !f.exists() ) return;
873 873
874 if ( f.open( IO_WriteOnly ) ) 874 if ( f.open( IO_WriteOnly ) )
875 { 875 {
876 QTextStream s( &f ); 876 QTextStream s( &f );
877 s << "Mode: r"; 877 s << "Mode: r";
878 s << "Mode: y"; 878 s << "Mode: y";
879 s << "XmitPower: 1"; 879 s << "XmitPower: 1";
880 } 880 }
881 881
882 // flushing and closing will be done automatically when f goes out of scope 882 // flushing and closing will be done automatically when f goes out of scope
883} 883}
884 884
885 885
886QString OCiscoMonitoringInterface::name() const 886QString OCiscoMonitoringInterface::name() const
887{ 887{
888 return "cisco"; 888 return "cisco";
889} 889}
890 890
891 891
892void OCiscoMonitoringInterface::setChannel( int ) 892void OCiscoMonitoringInterface::setChannel( int )
893{ 893{
894 // cisco devices automatically switch channels when in monitor mode 894 // cisco devices automatically switch channels when in monitor mode
895} 895}
896 896
897 897
898/*====================================================================================== 898/*======================================================================================
899 * OWlanNGMonitoringInterface 899 * OWlanNGMonitoringInterface
900 *======================================================================================*/ 900 *======================================================================================*/
901 901
902 902
903OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 903OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
904 :OMonitoringInterface( iface, prismHeader ) 904 :OMonitoringInterface( iface, prismHeader )
905{ 905{
906 iface->setMonitoring( this ); 906 iface->setMonitoring( this );
907} 907}
908 908
909 909
910OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() 910OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface()
911{ 911{
912} 912}
913 913
914 914
915void OWlanNGMonitoringInterface::setEnabled( bool b ) 915void OWlanNGMonitoringInterface::setEnabled( bool b )
916{ 916{
917 //FIXME: do nothing if its already in the same mode 917 //FIXME: do nothing if its already in the same mode
918 918
919 QString enable = b ? "true" : "false"; 919 QString enable = b ? "true" : "false";
920 QString prism = _prismHeader ? "true" : "false"; 920 QString prism = _prismHeader ? "true" : "false";
921 QString cmd; 921 QString cmd;
922 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", 922 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
923 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); 923 (const char*) _if->name(), 1, (const char*) enable, (const char*) prism );
924 system( cmd ); 924 system( cmd );
925} 925}
926 926
927 927
928QString OWlanNGMonitoringInterface::name() const 928QString OWlanNGMonitoringInterface::name() const
929{ 929{
930 return "wlan-ng"; 930 return "wlan-ng";
931} 931}
932 932
933 933
934void OWlanNGMonitoringInterface::setChannel( int ) 934void OWlanNGMonitoringInterface::setChannel( int )
935{ 935{
936 // wlan-ng devices automatically switch channels when in monitor mode 936 // wlan-ng devices automatically switch channels when in monitor mode
937 // NOTE: The above note no longer seems to be true for recent driver versions!
937} 938}
938 939
939 940
940/*====================================================================================== 941/*======================================================================================
941 * OHostAPMonitoringInterface 942 * OHostAPMonitoringInterface
942 *======================================================================================*/ 943 *======================================================================================*/
943 944
944OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 945OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
945 :OMonitoringInterface( iface, prismHeader ) 946 :OMonitoringInterface( iface, prismHeader )
946{ 947{
947 iface->setMonitoring( this ); 948 iface->setMonitoring( this );
948} 949}
949 950
950OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 951OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
951{ 952{
952} 953}
953 954
954void OHostAPMonitoringInterface::setEnabled( bool b ) 955void OHostAPMonitoringInterface::setEnabled( bool b )
955{ 956{
956 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 957 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
957 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 958 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
958 959
959 #if WIRELESS_EXT > 14 960 #if WIRELESS_EXT > 14
960 if ( b ) 961 if ( b )
961 _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header 962 _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header
962 else 963 else
963 _if->setMode( "managed" ); 964 _if->setMode( "managed" );
964 #else 965 #else
965 int monitorCode = _prismHeader ? 1 : 2; 966 int monitorCode = _prismHeader ? 1 : 2;
966 if ( b ) 967 if ( b )
967 { 968 {
968 _if->setPrivate( "monitor", 1, monitorCode ); 969 _if->setPrivate( "monitor", 1, monitorCode );
969 } 970 }
970 else 971 else
971 { 972 {
972 _if->setPrivate( "monitor", 1, 0 ); 973 _if->setPrivate( "monitor", 1, 0 );
973 } 974 }
974 #endif 975 #endif
975} 976}
976 977
977 978
978QString OHostAPMonitoringInterface::name() const 979QString OHostAPMonitoringInterface::name() const
979{ 980{
980 return "hostap"; 981 return "hostap";
981} 982}
982 983
983 984
984/*====================================================================================== 985/*======================================================================================
985 * OOrinocoNetworkInterface 986 * OOrinocoNetworkInterface
986 *======================================================================================*/ 987 *======================================================================================*/
987 988
988OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) 989OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader )
989 :OMonitoringInterface( iface, prismHeader ) 990 :OMonitoringInterface( iface, prismHeader )
990{ 991{
991 iface->setMonitoring( this ); 992 iface->setMonitoring( this );
992} 993}
993 994
994 995
995OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 996OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
996{ 997{
997} 998}
998 999
999 1000
1000void OOrinocoMonitoringInterface::setChannel( int c ) 1001void OOrinocoMonitoringInterface::setChannel( int c )
1001{ 1002{
1002 int monitorCode = _prismHeader ? 1 : 2; 1003 int monitorCode = _prismHeader ? 1 : 2;
1003 _if->setPrivate( "monitor", 2, monitorCode, c ); 1004 _if->setPrivate( "monitor", 2, monitorCode, c );
1004} 1005}
1005 1006
1006 1007
1007void OOrinocoMonitoringInterface::setEnabled( bool b ) 1008void OOrinocoMonitoringInterface::setEnabled( bool b )
1008{ 1009{
1009 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 1010 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
1010 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 1011 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
1011 1012
1012 #if WIRELESS_EXT > 14 1013 #if WIRELESS_EXT > 14
1013 if ( b ) 1014 if ( b )
1014 _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header 1015 _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header
1015 else 1016 else
1016 _if->setMode( "managed" ); 1017 _if->setMode( "managed" );
1017 #else 1018 #else
1018 if ( b ) 1019 if ( b )
1019 { 1020 {
1020 setChannel( 1 ); 1021 setChannel( 1 );
1021 } 1022 }
1022 else 1023 else
1023 { 1024 {
1024 _if->setPrivate( "monitor", 2, 0, 0 ); 1025 _if->setPrivate( "monitor", 2, 0, 0 );
1025 } 1026 }
1026 #endif 1027 #endif
1027} 1028}
1028 1029
1029 1030
1030QString OOrinocoMonitoringInterface::name() const 1031QString OOrinocoMonitoringInterface::name() const
1031{ 1032{
1032 return "orinoco"; 1033 return "orinoco";
1033} 1034}