author | mickeyl <mickeyl> | 2004-02-23 15:59:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 15:59:05 (UTC) |
commit | 20b0e62e6c23cdaed9a30d6fad73431edc60be53 (patch) (side-by-side diff) | |
tree | a179f858449e56b04883267c61141f163b4dfbac /libopie2/opienet | |
parent | 68c8d3eb878f9ba913c42368fbb253d7320c62be (diff) | |
download | opie-20b0e62e6c23cdaed9a30d6fad73431edc60be53.zip opie-20b0e62e6c23cdaed9a30d6fad73431edc60be53.tar.gz opie-20b0e62e6c23cdaed9a30d6fad73431edc60be53.tar.bz2 |
addition to API: OWirelessNetworkInterface::signalStrength() [wip]
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 8 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 20 |
2 files changed, 21 insertions, 7 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index d918193..16fa8ae 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -943,48 +943,56 @@ OStationList* OWirelessNetworkInterface::scanNetwork() 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;
}
offset += we->len;
we = (struct iw_event*) &buffer[offset];
}
return stations;
return stations;
}
else
{
odebug << " - no results (timeout) :(" << oendl;
return stations;
}
}
+int OWirelessNetworkInterface::signalStrength() const
+{
+ int max = _range.max_qual.level;
+ odebug << "signalStrength(): max quality seems to be " << max << "dBM" << oendl;
+ return 50;
+}
+
+
bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
{
#ifndef NODEBUG
int result = ::ioctl( _sfd, call, &iwreq );
if ( result == -1 )
odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
<< debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
else
odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
<< debugmapper->map( call ) << "' - Status: Ok." << oendl;
return ( result != -1 );
#else
return ::ioctl( _sfd, call, &iwreq ) != -1;
#endif
}
bool OWirelessNetworkInterface::wioctl( int call ) const
{
strcpy( _iwr.ifr_name, name() );
return wioctl( call, _iwr );
}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index bc9e299..9b8a0d4 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -1,28 +1,28 @@ /* This file is part of the Opie Project - Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + Copyright (C) 2003-2004 by Michael 'Mickey' Lauer + =. <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -39,55 +39,55 @@ #include <opie2/ostation.h> /* QT */ #include <qvaluelist.h> #include <qdict.h> #include <qmap.h> #include <qobject.h> #include <qhostaddress.h> class ONetworkInterface; class OWirelessNetworkInterface; class OChannelHopper; class OMonitoringInterface; /*====================================================================================== * ONetwork *======================================================================================*/ /** * @brief A container class for all network interfaces * * This class provides access to all available network interfaces of your computer. * - * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class ONetwork : public QObject { Q_OBJECT - public: + public: typedef QDict<ONetworkInterface> InterfaceMap; typedef QDictIterator<ONetworkInterface> InterfaceIterator; public: /** * @returns the number of available interfaces */ int count() const; /** * @returns a pointer to the (one and only) @ref ONetwork instance. */ static ONetwork* instance(); /** * @returns an iterator usable for iterating through all network interfaces. */ InterfaceIterator iterator() const; /** * @returns true, if the @a interface supports the wireless extension protocol. */ bool isWirelessInterface( const char* interface ) const; /** * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. * @see ONetworkInterface */ @@ -103,49 +103,49 @@ class ONetwork : public QObject **/ static short wirelessExtensionVersion(); protected: ONetwork(); private: static ONetwork* _instance; InterfaceMap _interfaces; }; /*====================================================================================== * ONetworkInterface *======================================================================================*/ /** * @brief A network interface wrapper. * * This class provides a wrapper for a network interface. All the cumbersume details of * Linux ioctls are hidden under a convenient high-level interface. * @warning Most of the setting methods contained in this class require the appropriate * process permissions to work. * - * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class ONetworkInterface : public QObject { friend class OMonitoringInterface; friend class OCiscoMonitoringInterface; friend class OWlanNGMonitoringInterface; friend class OHostAPMonitoringInterface; friend class OOrinocoMonitoringInterface; public: /** * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, * but access them via @ref ONetwork::interface(). */ ONetworkInterface( QObject* parent, const char* name ); /** * Destructor. */ virtual ~ONetworkInterface(); /** * Associates a @a monitoring interface with this network interface. * @note This is currently only useful with @ref OWirelessNetworkInterface objects. */ void setMonitoring( OMonitoringInterface* monitoring ); @@ -213,49 +213,49 @@ class ONetworkInterface : public QObject protected: const int _sfd; mutable ifreq _ifr; OMonitoringInterface* _mon; protected: struct ifreq& ifr() const; virtual void init(); bool ioctl( int call ) const; bool ioctl( int call, struct ifreq& ) const; }; /*====================================================================================== * OChannelHopper *======================================================================================*/ /** * @brief A radio frequency channel hopper. * * This class provides a channel hopper for radio frequencies. A channel hopper frequently * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. * This is necessary when in monitoring mode and scanning for other devices, because * the radio frequency hardware can only detect packets sent on the same frequency. * - * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class OChannelHopper : public QObject { Q_OBJECT public: /** * Constructor. */ OChannelHopper( OWirelessNetworkInterface* ); /** * Destructor. */ virtual ~OChannelHopper(); /** * @returns true, if the channel hopper is hopping channels */ bool isActive() const; /** * @returns the last hopped channel */ int channel() const; /** * Set the channel hopping @a interval. @@ -273,49 +273,49 @@ class OChannelHopper : public QObject */ void hopped( int ); protected: virtual void timerEvent( QTimerEvent* ); private: OWirelessNetworkInterface* _iface; int _interval; int _tid; QValueList<int> _channels; QValueList<int>::Iterator _channel; }; /*====================================================================================== * OWirelessNetworkInterface *======================================================================================*/ /** * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. * * This class provides a high-level encapsulation of the Linux wireless extension API. * - * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + * @author Michael 'Mickey' Lauer <mickey@vanille.de> */ class OWirelessNetworkInterface : public ONetworkInterface { friend class OMonitoringInterface; friend class OCiscoMonitoringInterface; friend class OWlanNGMonitoringInterface; friend class OHostAPMonitoringInterface; friend class OOrinocoMonitoringInterface; friend class OPrivateIOCTL; public: /** * Constructor. */ OWirelessNetworkInterface( QObject* parent, const char* name ); /** * Destructor. */ virtual ~OWirelessNetworkInterface(); /** * Setting the @a channel of the interface changes the radio frequency (RF) * of the corresponding wireless network device. * @note Common channel range is within [1-14]. A value of 0 is not allowed. @@ -393,48 +393,54 @@ class OWirelessNetworkInterface : public ONetworkInterface /** * @returns true if the interface is associated to an access point * @note: This information is only valid if the interface is in managed mode. */ virtual bool isAssociated() const; /** * @returns the MAC address of the Access Point if the device is in infrastructure mode. * @returns a (more or less random) cell ID address if the device is in adhoc mode. */ virtual OMacAddress associatedAP() const; /** * Set the @a ssid (Service Set ID) string. This is used to decide * which network to associate with (use "any" to let the driver decide). */ virtual void setSSID( const QString& ssid ); /** * @returns the current SSID (Service Set ID). */ virtual QString SSID() const; /** * Perform scanning the wireless network neighbourhood. * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! */ virtual OStationList* scanNetwork(); + /** + * @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 * */ void commit() const; protected: void buildInformation(); void buildPrivateList(); void dumpInformation() const; virtual void init(); struct iwreq& iwr() const; bool wioctl( int call ) const; bool wioctl( int call, struct iwreq& ) const; protected: mutable struct iwreq _iwr; QMap<int,int> _channels; struct iw_range _range; private: OChannelHopper* _hopper; }; |