summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 1d3b9fe..25c70e0 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -293,3 +293,4 @@ OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
:QObject( 0, "Mickey's funky hopper" ),
- _iface( iface ), _interval( 0 ), _channel( 0 ), _tid( 0 )
+ _iface( iface ), _interval( 0 ), _channel( 1 ), _tid( 0 ),
+ _maxChannel( iface->channels()+1 )
{
@@ -303,6 +304,17 @@ OChannelHopper::~OChannelHopper()
+bool OChannelHopper::isActive() const
+{
+ return _tid;
+}
+
+
+int OChannelHopper::channel() const
+{
+ return _channel;
+}
+
+
void OChannelHopper::timerEvent( QTimerEvent* )
{
- //FIXME: Get available channels from OWirelessNetworkInterface
- if ( --_channel < 0 ) _channel = 13;
+ if ( !--_channel ) _channel = _maxChannel;
_iface->setChannel( _channel );
@@ -321,2 +333,3 @@ void OChannelHopper::setInterval( int interval )
+ _tid = 0;
_interval = interval;
@@ -341,3 +354,3 @@ int OChannelHopper::interval() const
OWirelessNetworkInterface::OWirelessNetworkInterface( const QString& name )
- :ONetworkInterface( name ), _hopper( this )
+ :ONetworkInterface( name ), _hopper( 0 )
{
@@ -378,5 +391,2 @@ void OWirelessNetworkInterface::init()
- //TODO: Find out what the difference between num_channel and
- // num_frequency is about.
-
for ( int i = 0; i < range.num_frequency; ++i )
@@ -384,3 +394,3 @@ void OWirelessNetworkInterface::init()
int freq = (int) ( double( range.freq[i].m ) * pow( 10, range.freq[i].e ) / 1000000.0 );
- _channels.insert( freq, i );
+ _channels.insert( freq, i+1 );
}
@@ -414,2 +424,8 @@ int OWirelessNetworkInterface::channel() const
{
+ //FIXME: When monitoring enabled, then use it
+ //FIXME: to gather the current RF channel
+ //FIXME: Until then, get active channel from hopper.
+ if ( _hopper && _hopper->isActive() )
+ return _hopper->channel();
+
if ( !wioctl( SIOCGIWFREQ ) )
@@ -420,3 +436,2 @@ int OWirelessNetworkInterface::channel() const
{
- //FIXME: This is off-by-one !? Why?
return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10, _iwr.u.freq.e ) / 1000000) ];
@@ -463,3 +478,5 @@ void OWirelessNetworkInterface::setChannelHopping( int interval )
{
- _hopper.setInterval( interval );
+ if ( !_hopper ) _hopper = new OChannelHopper( this );
+ _hopper->setInterval( interval );
+ //FIXME: When and by whom will the channel hopper be deleted?
}
@@ -469,3 +486,3 @@ int OWirelessNetworkInterface::channelHopping() const
{
- return _hopper.interval();
+ return _hopper->interval();
}
@@ -481,2 +498,3 @@ void OWirelessNetworkInterface::setMonitorMode( bool b )
+
bool OWirelessNetworkInterface::monitorMode() const