author | mickeyl <mickeyl> | 2004-05-01 16:13:43 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-05-01 16:13:43 (UTC) |
commit | d5abd7878f553f5ac0a41966b27f4c09389d3cfd (patch) (side-by-side diff) | |
tree | 3140d1d1fe012c03c6c26bc587faeea5501f0b28 /libopie2 | |
parent | 5a64ec5a21bb254c0e6a57e379cd1afc25259f19 (diff) | |
download | opie-d5abd7878f553f5ac0a41966b27f4c09389d3cfd.zip opie-d5abd7878f553f5ac0a41966b27f4c09389d3cfd.tar.gz opie-d5abd7878f553f5ac0a41966b27f4c09389d3cfd.tar.bz2 |
- fix off-by-one bug in OChannelHopper
- fix bug in OPacket which broke everything using it
- expose both wireless extension versions (runtime + compile time) through API
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 12 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 10 | ||||
-rw-r--r-- | libopie2/opienet/opcap.cpp | 4 |
3 files changed, 18 insertions, 8 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index b6c9876..e141097 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -116,13 +116,13 @@ void ONetwork::synchronize() _interfaces.insert( str, iface );
s.readLine();
}
}
-short ONetwork::wirelessExtensionVersion()
+short ONetwork::wirelessExtensionCompileVersion()
{
return WIRELESS_EXT;
}
int ONetwork::count() const
@@ -379,13 +379,13 @@ bool ONetworkInterface::isWireless() const *======================================================================================*/
OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface )
:QObject( 0, "Mickey's funky hopper" ),
_iface( iface ), _interval( 0 ), _tid( 0 )
{
- int _maxChannel = iface->channels()+1;
+ int _maxChannel = iface->channels();
// generate fancy hopping sequence honoring the device capabilities
if ( _maxChannel >= 1 ) _channels.append( 1 );
if ( _maxChannel >= 7 ) _channels.append( 7 );
if ( _maxChannel >= 13 ) _channels.append( 13 );
if ( _maxChannel >= 2 ) _channels.append( 2 );
if ( _maxChannel >= 8 ) _channels.append( 8 );
@@ -396,13 +396,12 @@ OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) if ( _maxChannel >= 10 ) _channels.append( 10 );
if ( _maxChannel >= 5 ) _channels.append( 5 );
if ( _maxChannel >= 11 ) _channels.append( 11 );
if ( _maxChannel >= 6 ) _channels.append( 6 );
if ( _maxChannel >= 12 ) _channels.append( 12 );
_channel = _channels.begin();
-
}
OChannelHopper::~OChannelHopper()
{
}
@@ -558,22 +557,29 @@ void OWirelessNetworkInterface::buildInformation() memcpy( &range, buffer, sizeof range );
odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl;
for ( int i = 0; i < range.num_frequency; ++i )
{
int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 );
+ odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl;
_channels.insert( freq, i+1 );
}
}
memcpy( &_range, buffer, sizeof( struct iw_range ) );
odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl;
free(buffer);
}
+short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const
+{
+ return _range.we_version_compiled;
+}
+
+
void OWirelessNetworkInterface::buildPrivateList()
{
odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl;
struct iw_priv_args priv[IW_MAX_PRIV_DEF];
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index f5fbe1d..a49c8fb 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -122,13 +122,13 @@ class ONetwork : public QObject * e.g. after issuing a cardctl insert */ void synchronize(); /** * @returns the wireless extension version used at compile time. **/ - static short wirelessExtensionVersion(); + static short wirelessExtensionCompileVersion(); protected: ONetwork(); private: static ONetwork* _instance; @@ -448,14 +448,18 @@ class OWirelessNetworkInterface : public ONetworkInterface /** * @return signal strength to associated neighbour (in percent). * In infrastructure mode, this is the signal strength of the Access Point. * In other modes the result is driver dependent. */ virtual int signalStrength() const; - /** @internal commit pending changes to the driver - * + /** + * @returns the wireless extension version used by the interface driver. + **/ + short wirelessExtensionDriverVersion() const; + /** + * @internal commit pending changes to the driver */ void commit() const; protected: void buildInformation(); void buildPrivateList(); diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index f8ebe6b..a9dc577 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp @@ -55,15 +55,15 @@ namespace Net { *======================================================================================*/ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) :QObject( parent, "Generic" ), _hdr( header ), _data( 0 ) { - _data = new unsigned char[sizeof data]; + _data = new unsigned char[ header.len ]; assert( _data ); - memcpy( const_cast<unsigned char*>(_data), data, sizeof data ); + memcpy( const_cast<unsigned char*>(_data), data, header.len ); // We have to copy the data structure here, because the 'data' pointer handed by libpcap // points to an internal region which is reused by lipcap. odebug << "OPacket: Length = " << header.len << ", Caplen = " << header.caplen << oendl; _end = (unsigned char*) _data + header.len; switch ( datalink ) |