summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetwork.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp38
1 files changed, 33 insertions, 5 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 546be9e..0a74019 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -35,12 +35,13 @@
#include <opie2/odebug.h>
/* QT */
#include <qfile.h>
#include <qtextstream.h>
+#include <qapplication.h>
/* UNIX */
#include <assert.h>
#include <arpa/inet.h>
#include <errno.h>
@@ -50,12 +51,13 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <linux/sockios.h>
#include <net/if_arp.h>
+#include <net/ethernet.h>
#include <stdarg.h>
#ifndef NODEBUG
#include <opie2/odebugmapper.h>
using namespace Opie::Core;
@@ -488,12 +490,20 @@ bool OWirelessNetworkInterface::isAssociated() const
{
//FIXME: handle different modes
return !(associatedAP() == OMacAddress::unknown);
}
+void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const
+{
+ _iwr.u.ap_addr.sa_family = ARPHRD_ETHER;
+ ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN);
+ wioctl( SIOCSIWAP );
+}
+
+
OMacAddress OWirelessNetworkInterface::associatedAP() const
{
if ( ioctl( SIOCGIWAP ) )
return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0];
else
return OMacAddress::unknown;
@@ -903,19 +913,17 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
results = true;
continue;
}
else if ( errno == EAGAIN)
{
odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl;
- #if 0
if ( qApp )
{
qApp->processEvents( 100 );
continue;
}
- #endif
tv.tv_sec = 0;
tv.tv_usec = 100000;
continue;
}
}
@@ -1124,27 +1132,47 @@ OStationList* OWirelessNetworkInterface::scanNetwork()
stations->last()->type = modeToString( we->u.mode );
break;
}
case SIOCGIWFREQ:
{
odebug << "SIOCGIWFREQ" << oendl;
- stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
+ if ( we->u.freq.m > 1000 )
+ stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ];
+ else
+ stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e ));
break;
}
case SIOCGIWESSID:
{
odebug << "SIOCGIWESSID" << oendl;
we->u.essid.length = '\0'; // make sure it is zero terminated
stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer);
odebug << "ESSID: " << stations->last()->ssid << oendl;
break;
}
+ case IWEVQUAL:
+ {
+ odebug << "IWEVQUAL" << oendl;
+ stations->last()->level = static_cast<int>(we->u.qual.level);
+ break; /* Quality part of statistics (scan) */
+ }
+ case SIOCGIWENCODE:
+ {
+ odebug << "SIOCGIWENCODE" << oendl;
+ stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED);
+ break;
+ }
+
+ case SIOCGIWRATE:
+ {
+ odebug << "SIOCGIWRATE" << oendl;
+ stations->last()->rates.append(we->u.bitrate.value);
+ break;
+ }
case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break;
- case SIOCGIWENCODE: odebug << "SIOCGIWENCODE" << oendl; break;
case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */
- case IWEVQUAL: odebug << "IWEVQUAL" << oendl; break; /* Quality part of statistics (scan) */
case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */
case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */
case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */
default: odebug << "unhandled event" << oendl;
}