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.cpp50
1 files changed, 22 insertions, 28 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index f52279a..e916c44 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -215,24 +215,32 @@ QString ONetworkInterface::ipV4Address() const
215{ 215{
216 if ( ioctl( SIOCGIFADDR ) ) 216 if ( ioctl( SIOCGIFADDR ) )
217 { 217 {
218 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; 218 struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr;
219 //FIXME: Use QHostAddress here 219 //FIXME: Use QHostAddress here
220 return QString( inet_ntoa( sa->sin_addr ) ); 220 return QString( inet_ntoa( sa->sin_addr ) );
221 } 221 }
222 else 222 else
223 return "<unknown>"; 223 return "<unknown>";
224} 224}
225 225
226 226
227void ONetworkInterface::setMacAddress( const OMacAddress& addr )
228{
229 _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
230 memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 );
231 ioctl( SIOCSIFHWADDR );
232}
233
234
227OMacAddress ONetworkInterface::macAddress() const 235OMacAddress ONetworkInterface::macAddress() const
228{ 236{
229 if ( ioctl( SIOCGIFHWADDR ) ) 237 if ( ioctl( SIOCGIFHWADDR ) )
230 { 238 {
231 return OMacAddress( _ifr ); 239 return OMacAddress( _ifr );
232 } 240 }
233 else 241 else
234 { 242 {
235 return OMacAddress::unknown; 243 return OMacAddress::unknown;
236 } 244 }
237} 245}
238 246
@@ -638,24 +646,31 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ..
638 va_start( argp, numargs ); 646 va_start( argp, numargs );
639 for ( int i = 0; i < numargs; ++i ) 647 for ( int i = 0; i < numargs; ++i )
640 { 648 {
641 priv->setParameter( i, va_arg( argp, int ) ); 649 priv->setParameter( i, va_arg( argp, int ) );
642 } 650 }
643 va_end( argp ); 651 va_end( argp );
644 priv->invoke(); 652 priv->invoke();
645} 653}
646 654
647 655
648void OWirelessNetworkInterface::getPrivate( const QString& call ) 656void OWirelessNetworkInterface::getPrivate( const QString& call )
649{ 657{
658 qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." );
659}
660
661
662bool OWirelessNetworkInterface::hasPrivate( const QString& call )
663{
664 return child( (const char*) call );
650} 665}
651 666
652 667
653QString OWirelessNetworkInterface::SSID() const 668QString OWirelessNetworkInterface::SSID() const
654{ 669{
655 char str[IW_ESSID_MAX_SIZE]; 670 char str[IW_ESSID_MAX_SIZE];
656 _iwr.u.essid.pointer = &str[0]; 671 _iwr.u.essid.pointer = &str[0];
657 _iwr.u.essid.length = IW_ESSID_MAX_SIZE; 672 _iwr.u.essid.length = IW_ESSID_MAX_SIZE;
658 if ( !wioctl( SIOCGIWESSID ) ) 673 if ( !wioctl( SIOCGIWESSID ) )
659 { 674 {
660 return "<unknown>"; 675 return "<unknown>";
661 } 676 }
@@ -825,47 +840,34 @@ OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface
825 iface->setMonitoring( this ); 840 iface->setMonitoring( this );
826} 841}
827 842
828OHostAPMonitoringInterface::~OHostAPMonitoringInterface() 843OHostAPMonitoringInterface::~OHostAPMonitoringInterface()
829{ 844{
830} 845}
831 846
832void OHostAPMonitoringInterface::setEnabled( bool b ) 847void OHostAPMonitoringInterface::setEnabled( bool b )
833{ 848{
834 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 849 // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15
835 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 850 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
836 851
852 //TODO: check wireless extensions version on runtime and use
853 //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15
854
837 if ( b ) 855 if ( b )
838 { 856 {
839 #if WIRELESS_EXT > 14 857 _if->setPrivate( "monitor", 1, 2 );
840 _if->_iwr.u.mode = IW_MODE_MONITOR;
841 _if->wioctl( SIOCSIWMODE );
842 #else
843 int* args = (int*) &_if->_iwr.u.name;
844 args[0] = 2;
845 args[1] = 0;
846 _if->wioctl( SIOCDEVPRIVATE );
847 #endif
848 } 858 }
849 else 859 else
850 { 860 {
851 #if WIRELESS_EXT > 14 861 _if->setPrivate( "monitor", 1, 0 );
852 _if->_iwr.u.mode = IW_MODE_INFRA;
853 _if->wioctl( SIOCSIWMODE );
854 #else
855 int* args = (int*) &_if->_iwr.u.name;
856 args[0] = 0;
857 args[1] = 0;
858 _if->wioctl( SIOCDEVPRIVATE );
859 #endif
860 } 862 }
861} 863}
862 864
863 865
864QString OHostAPMonitoringInterface::name() const 866QString OHostAPMonitoringInterface::name() const
865{ 867{
866 return "hostap"; 868 return "hostap";
867} 869}
868 870
869 871
870/*====================================================================================== 872/*======================================================================================
871 * OOrinocoNetworkInterface 873 * OOrinocoNetworkInterface
@@ -876,41 +878,33 @@ OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* ifa
876{ 878{
877 iface->setMonitoring( this ); 879 iface->setMonitoring( this );
878} 880}
879 881
880 882
881OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() 883OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface()
882{ 884{
883} 885}
884 886
885 887
886void OOrinocoMonitoringInterface::setChannel( int c ) 888void OOrinocoMonitoringInterface::setChannel( int c )
887{ 889{
888 // call iwpriv <device> monitor 2 <channel> 890 _if->setPrivate( "monitor", 2, 2, c );
889 int* args = (int*) &_if->_iwr.u.name;
890 args[0] = 2;
891 args[1] = c;
892 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
893} 891}
894 892
895 893
896void OOrinocoMonitoringInterface::setEnabled( bool b ) 894void OOrinocoMonitoringInterface::setEnabled( bool b )
897{ 895{
898 if ( b ) 896 if ( b )
899 { 897 {
900 setChannel( 1 ); 898 setChannel( 1 );
901 } 899 }
902 else 900 else
903 { 901 {
904 // call iwpriv <device> monitor 0 0 902 _if->setPrivate( "monitor", 2, 0, 0 );
905 int* args = (int*) &_if->_iwr.u.name;
906 args[0] = 0;
907 args[1] = 0;
908 _if->wioctl( SIOCIWFIRSTPRIV + 0x8 );
909 } 903 }
910} 904}
911 905
912 906
913QString OOrinocoMonitoringInterface::name() const 907QString OOrinocoMonitoringInterface::name() const
914{ 908{
915 return "orinoco"; 909 return "orinoco";
916} 910}