-rw-r--r-- | libopie2/opienet/onetutils.cpp | 19 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 8 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 39 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 7 |
4 files changed, 37 insertions, 36 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index c8c494a..9c3e650 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp @@ -2,5 +2,3 @@ This file is part of the Opie Project - - (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. @@ -138,2 +136,17 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) +OHostAddress::OHostAddress() + :QHostAddress() +{ +} + + +OHostAddress::OHostAddress( Q_UINT32 ip4Addr ) + :QHostAddress( ip4Addr ) +{ +} + + +OHostAddress::~OHostAddress() +{ +} diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 25c9238..f08738c 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h @@ -2,4 +2,3 @@ This file is part of the Opie Project - (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. @@ -91,6 +90,7 @@ class OHostAddress : public QHostAddress { - /*public: + public: OHostAddress(); + OHostAddress( Q_UINT32 ip4Addr ); ~OHostAddress(); - */ + private: diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 1deb051..0649ca2 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -2,4 +2,3 @@ This file is part of the Opie Project - Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. @@ -87,6 +86,2 @@ void ONetwork::synchronize() // gather available interfaces by inspecting /proc/net/dev - //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices - //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices - //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev - _interfaces.clear(); @@ -204,3 +199,2 @@ void ONetworkInterface::init() odebug << "ONetworkInterface::init()" << oendl; - memset( &_ifr, 0, sizeof( struct ifreq ) ); @@ -272,13 +266,6 @@ void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) -QString ONetworkInterface::ipV4Address() const -{ - if ( ioctl( SIOCGIFADDR ) ) +OHostAddress ONetworkInterface::ipV4Address() const { struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; - //FIXME: Use QHostAddress here - return QString( inet_ntoa( sa->sin_addr ) ); - } - else - return "<unknown>"; - + return ioctl( SIOCGIFADDR ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); } @@ -317,12 +304,6 @@ void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) -QString ONetworkInterface::ipV4Netmask() const -{ - if ( ioctl( SIOCGIFNETMASK ) ) +OHostAddress ONetworkInterface::ipV4Netmask() const { struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; - //FIXME: Use QHostAddress here - return QString( inet_ntoa( sa->sin_addr ) ); - } - else - return "<unknown>"; + return ioctl( SIOCGIFNETMASK ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); } @@ -549,3 +530,11 @@ void OWirelessNetworkInterface::buildInformation() - if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) + int result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); + if ( result == -1 ) + { + owarn << "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (" << strerror( errno ) << ") - retrying with smaller buffer..." << oendl; + wrq.u.data.length = sizeof( struct iw_range ); + result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); + } + + if ( result == -1 ) { diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index f0c4450..b13c7a3 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -2,4 +2,3 @@ This file is part of the Opie Project - Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. @@ -200,3 +199,3 @@ class ONetworkInterface : public QObject */ - QString ipV4Address() const; //TODO: make this return an OHostAddress + OHostAddress ipV4Address() const; /** @@ -219,3 +218,3 @@ class ONetworkInterface : public QObject */ - QString ipV4Netmask() const; //TODO: make this return an OHostAddress + OHostAddress ipV4Netmask() const; /** |