author | mickeyl <mickeyl> | 2005-05-16 17:48:03 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-16 17:48:03 (UTC) |
commit | d2426de3452342ab4af8e95214b9ff408f30744e (patch) (side-by-side diff) | |
tree | 41eb23ab226a83778112aaf6d14ab3e8fc5dc896 | |
parent | a0276f0957bd503491e8d435b7ad1a6479ce24eb (diff) | |
download | opie-d2426de3452342ab4af8e95214b9ff408f30744e.zip opie-d2426de3452342ab4af8e95214b9ff408f30744e.tar.gz opie-d2426de3452342ab4af8e95214b9ff408f30744e.tar.bz2 |
- add ONetworkInterfaceDriverInfo block extracting info using ethtool ioctls
- adjust example
-rw-r--r-- | examples/opienet/onetworkdemo/onetworkdemo.cpp | 5 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 26 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 31 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 7 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 2 |
5 files changed, 60 insertions, 11 deletions
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.cpp b/examples/opienet/onetworkdemo/onetworkdemo.cpp index e0c93a2..b3a1115 100644 --- a/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/examples/opienet/onetworkdemo/onetworkdemo.cpp @@ -39,24 +39,29 @@ using namespace Opie::Net; int main( int argc, char** argv ) { odebug << "OPIE Network Demo" << oendl; ONetwork* net = ONetwork::instance(); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; + ONetworkInterfaceDriverInfo info = it.current()->driverInfo(); + odebug << "DEMO: DriverName reported as '" << info.name() << "'" << oendl; + odebug << "DEMO: DriverVersion reported as '" << info.version() << "'" << oendl; + odebug << "DEMO: DriverFirmware reported as '" << info.firmware() << "'" << oendl; + odebug << "DEMO: DriverBus reported as '" << info.bus() << "'" << oendl; odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; if ( it.current()->isWireless() ) { OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 32f5355..25c9238 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h @@ -91,24 +91,50 @@ class OHostAddress : public QHostAddress { /*public: OHostAddress(); ~OHostAddress(); */ private: class Private; Private *d; }; /*====================================================================================== + * ONetworkInterfaceDriverInfo + *======================================================================================*/ + +class ONetworkInterfaceDriverInfo +{ + public: + ONetworkInterfaceDriverInfo( const QString& name = "<unknown>", + const QString& version = "<unknown>", + const QString& firmware = "<unknown>", + const QString& bus = "<unknown>" ) : + _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { }; + ~ONetworkInterfaceDriverInfo() { }; + + QString name() const { return _name; }; + QString version() const { return _version; }; + QString firmware() const { return _firmware; }; + QString bus() const { return _bus; }; + + private: + const QString _name; + const QString _version; + const QString _firmware; + const QString _bus; +}; + +/*====================================================================================== * OPrivateIOCTL *======================================================================================*/ class OPrivateIOCTL : public QObject { public: OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); ~OPrivateIOCTL(); int numberGetArgs() const; int typeGetArgs() const; int numberSetArgs() const; diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 05513f8..1deb051 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -20,56 +20,58 @@ ++= -. .` .: 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. */ /* OPIE */ - #include <opie2/onetwork.h> #include <opie2/ostation.h> #include <opie2/odebug.h> +using namespace Opie::Core; /* QT */ - #include <qfile.h> #include <qtextstream.h> #include <qapplication.h> -/* UNIX */ - +/* STD */ #include <assert.h> #include <arpa/inet.h> #include <errno.h> +#include <stdarg.h> #include <string.h> #include <stdlib.h> #include <math.h> +#include <unistd.h> +#include <net/if_arp.h> +#include <net/ethernet.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> -#include <unistd.h> +#include <linux/types.h> #include <linux/sockios.h> -#include <net/if_arp.h> -#include <net/ethernet.h> -#include <stdarg.h> +#define u64 __u64 +#define u32 __u32 +#define u16 __u16 +#define u8 __u8 +#include <linux/ethtool.h> #ifndef NODEBUG #include <opie2/odebugmapper.h> - -using namespace Opie::Core; using namespace Opie::Net::Internal; DebugMapper* debugmapper = new DebugMapper(); #endif /*====================================================================================== * ONetwork *======================================================================================*/ namespace Opie { namespace Net { ONetwork* ONetwork::_instance = 0; @@ -372,48 +374,57 @@ bool ONetworkInterface::promiscuousMode() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_PROMISC; } bool ONetworkInterface::isWireless() const { return ioctl( SIOCGIWNAME ); } +ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const +{ + struct ethtool_drvinfo info; + info.cmd = ETHTOOL_GDRVINFO; + _ifr.ifr_data = (caddr_t) &info; + return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo(); +} + /*====================================================================================== * OChannelHopper *======================================================================================*/ OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) :QObject( 0, "Mickey's funky hopper" ), _iface( iface ), _interval( 0 ), _tid( 0 ) { 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 ); if ( _maxChannel >= 3 ) _channels.append( 3 ); if ( _maxChannel >= 14 ) _channels.append( 14 ); if ( _maxChannel >= 9 ) _channels.append( 9 ); if ( _maxChannel >= 4 ) _channels.append( 4 ); 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 ); + //FIXME: Add 802.11a/g channels _channel = _channels.begin(); } OChannelHopper::~OChannelHopper() { } bool OChannelHopper::isActive() const { return _tid; diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index fa9f39f..f0c4450 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -193,44 +193,51 @@ class ONetworkInterface : public QObject 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. + * @note This operation needs root privileges * @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; + /** + * @returns a ONetworkInterfaceDriverInfo driver information block + * @note This operation needs root privileges + * @warning This is not supported by all drivers + */ + ONetworkInterfaceDriverInfo driverInfo() 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: diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 460de0a..854e5ff 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro @@ -9,25 +9,25 @@ HEADERS = 802_11_user.h \ onetutils.h \ onetwork.h \ opcap.h \ ostation.h SOURCES = odebugmapper.cpp \ omanufacturerdb.cpp \ onetutils.cpp \ onetwork.cpp \ opcap.cpp \ ostation.cpp INTERFACES = TARGET = opienet2 -VERSION = 1.8.6 +VERSION = 1.8.7 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lpcap !contains( platform, x11 ) { include( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } |