-rw-r--r-- | libopie2/opienet/onetwork.h | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index a49c8fb..057b1a0 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -1,260 +1,247 @@ /* This file is part of the Opie Project 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. */ #ifndef ONETWORK_H #define ONETWORK_H -#if !defined( OPIE_WE_VERSION ) - #warning No wireless extension specified; autodetecting... - #include <linux/version.h> - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) - #define OPIE_WE_VERSION 15 - #else - #define OPIE_WE_VERSION 16 - #endif // LINUX_VERSION_CODE < KERNEL_VERSION(2.4.23) -#endif // !defined( OPIE_WE_VERSION ) - -#if OPIE_WE_VERSION == 15 -#include "wireless.15.h" -#warning Using WE V15 -#endif -#if OPIE_WE_VERSION == 16 -#include "wireless.16.h" -#warning Using WE V16 -#endif - /* OPIE */ - #include <opie2/onetutils.h> #include <opie2/ostation.h> /* QT */ - #include <qvaluelist.h> #include <qdict.h> #include <qmap.h> #include <qobject.h> #include <qhostaddress.h> +/* STD */ +// hacky workaround until we have a user space wireless.h +#include <net/if.h> +#define _LINUX_IF_H +#include <linux/wireless.h> +#ifndef IW_MAX_PRIV_DEF +#define IW_MAX_PRIV_DEF 128 +#endif + namespace Opie { namespace Net { - 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@vanille.de> */ class ONetwork : public QObject { Q_OBJECT 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 is present. */ bool isPresent( const char* interface ) 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 */ ONetworkInterface* interface( const QString& interface ) const; /** * @internal Rebuild the internal interface database * @note Sometimes it might be useful to call this from client code, * e.g. after issuing a cardctl insert */ void synchronize(); /** * @returns the wireless extension version used at compile time. **/ static short wirelessExtensionCompileVersion(); protected: ONetwork(); private: static ONetwork* _instance; InterfaceMap _interfaces; class Private; Private *d; }; /*====================================================================================== * 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@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 ); /** * @returns the currently associated monitoring interface or 0, if no monitoring is associated. */ OMonitoringInterface* monitoring() const; /** * Setting an interface to promiscuous mode enables the device to receive * all packets on the shared medium - as opposed to packets which are addressed to this interface. */ bool setPromiscuousMode( bool ); /** * @returns true if the interface is set to promiscuous mode. */ bool promiscuousMode() const; /** * Setting an interface to up enables it to receive packets. */ bool setUp( bool ); /** * @returns true if the interface is up. */ bool isUp() const; /** * @returns true if the interface is a loopback interface. */ bool isLoopback() const; /** * @returns true if the interface is featuring supports the wireless extension protocol. */ bool isWireless() const; /** * Associate the IP address @ addr with the interface. */ void setIPV4Address( const QHostAddress& addr ); /** * @returns the IPv4 address associated with the interface. */ QString ipV4Address() const; //TODO: make this return an OHostAddress /** * Associate the MAC address @a addr with the interface. * @note It can be necessary to shut down the interface prior to calling this method. * @warning This is not supported by all drivers. */ void setMacAddress( const OMacAddress& addr ); /** * @returns the MAC address associated with the interface. */ OMacAddress macAddress() const; /** * Associate the IPv4 @a netmask with the interface. */ void setIPV4Netmask( const QHostAddress& netmask ); /** * @returns the IPv4 netmask associated with the interface. */ QString ipV4Netmask() const; //TODO: make this return an OHostAddress /** * @returns the data link type currently associated with the interface. * @see #include <net/if_arp.h> for possible values. */ int dataLinkType() const; 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; private: class Private; Private *d; }; /*====================================================================================== * OChannelHopper *======================================================================================*/ /** * @brief A radio frequency channel hopper. * |