summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetutils.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opienet/onetutils.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/onetutils.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 2485f30..236f108 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -22,24 +22,25 @@
 :     =  ...= . :.=-
 -.   .:....=;==+<; 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.
*/
#include <opie2/onetutils.h>
#include <opie2/onetwork.h>
+#include <opie2/omanufacturerdb.h>
#include <net/if.h>
#include <cstdio>
using namespace std;
#define IW_PRIV_TYPE_MASK 0x7000
#define IW_PRIV_TYPE_NONE 0x0000
#define IW_PRIV_TYPE_BYTE 0x1000
#define IW_PRIV_TYPE_CHAR 0x2000
#define IW_PRIV_TYPE_INT 0x4000
#define IW_PRIV_TYPE_FLOAT 0x5000
@@ -100,34 +101,42 @@ OMacAddress OMacAddress::fromString( const QString& str )
int index = 14;
for ( int i = 5; i >= 0; --i )
{
buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
if ( !ok ) return OMacAddress::unknown;
addr.truncate( index );
index -= 3;
}
return (const unsigned char*) &buf;
}
-QString OMacAddress::toString() const
+QString OMacAddress::toString( bool substitute ) const
{
- QString s;
- s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
- _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff,
- _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
- return s;
+ QString manu;
+ manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
+ QString serial;
+ serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
+ if ( !substitute ) return manu+serial;
+ // fallback - if no vendor is found, just use the number
+ QString textmanu = OManufacturerDB::instance()->lookup( manu );
+ return textmanu.isNull() ? manu+serial : textmanu + serial;
}
+QString OMacAddress::manufacturer() const
+{
+ return OManufacturerDB::instance()->lookup( toString() );
+}
+
bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
{
return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
}
/*======================================================================================
* OHostAddress
*======================================================================================*/
/*======================================================================================