Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 50 |
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 @@ -219,16 +219,24 @@ QString ONetworkInterface::ipV4Address() const //FIXME: Use QHostAddress here return QString( inet_ntoa( sa->sin_addr ) ); } else return "<unknown>"; } +void ONetworkInterface::setMacAddress( const OMacAddress& addr ) +{ + _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; + memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); + ioctl( SIOCSIFHWADDR ); +} + + OMacAddress ONetworkInterface::macAddress() const { if ( ioctl( SIOCGIFHWADDR ) ) { return OMacAddress( _ifr ); } else { @@ -642,16 +650,23 @@ void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, .. } va_end( argp ); priv->invoke(); } void OWirelessNetworkInterface::getPrivate( const QString& call ) { + qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); +} + + +bool OWirelessNetworkInterface::hasPrivate( const QString& call ) +{ + return child( (const char*) call ); } QString OWirelessNetworkInterface::SSID() const { char str[IW_ESSID_MAX_SIZE]; _iwr.u.essid.pointer = &str[0]; _iwr.u.essid.length = IW_ESSID_MAX_SIZE; @@ -829,39 +844,26 @@ OHostAPMonitoringInterface::~OHostAPMonitoringInterface() { } void OHostAPMonitoringInterface::setEnabled( bool b ) { // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring + //TODO: check wireless extensions version on runtime and use + //TODO: SIOCSIWMODE( IW_MODE_MONITOR ) if running on WE >= 15 + if ( b ) { - #if WIRELESS_EXT > 14 - _if->_iwr.u.mode = IW_MODE_MONITOR; - _if->wioctl( SIOCSIWMODE ); - #else - int* args = (int*) &_if->_iwr.u.name; - args[0] = 2; - args[1] = 0; - _if->wioctl( SIOCDEVPRIVATE ); - #endif + _if->setPrivate( "monitor", 1, 2 ); } else { - #if WIRELESS_EXT > 14 - _if->_iwr.u.mode = IW_MODE_INFRA; - _if->wioctl( SIOCSIWMODE ); - #else - int* args = (int*) &_if->_iwr.u.name; - args[0] = 0; - args[1] = 0; - _if->wioctl( SIOCDEVPRIVATE ); - #endif + _if->setPrivate( "monitor", 1, 0 ); } } QString OHostAPMonitoringInterface::name() const { return "hostap"; } @@ -880,37 +882,29 @@ OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* ifa OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() { } void OOrinocoMonitoringInterface::setChannel( int c ) { - // call iwpriv <device> monitor 2 <channel> - int* args = (int*) &_if->_iwr.u.name; - args[0] = 2; - args[1] = c; - _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); + _if->setPrivate( "monitor", 2, 2, c ); } void OOrinocoMonitoringInterface::setEnabled( bool b ) { if ( b ) { setChannel( 1 ); } else { - // call iwpriv <device> monitor 0 0 - int* args = (int*) &_if->_iwr.u.name; - args[0] = 0; - args[1] = 0; - _if->wioctl( SIOCIWFIRSTPRIV + 0x8 ); + _if->setPrivate( "monitor", 2, 0, 0 ); } } QString OOrinocoMonitoringInterface::name() const { return "orinoco"; } |