summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp24
-rw-r--r--libopie2/opienet/omanufacturerdb.h18
-rw-r--r--libopie2/opienet/onetutils.cpp5
3 files changed, 41 insertions, 6 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index ea15125..c185fc5 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -62,2 +62,3 @@ OManufacturerDB::OManufacturerDB()
62 QString manu; 62 QString manu;
63 QString extManu;
63 while (!s.atEnd()) 64 while (!s.atEnd())
@@ -72,3 +73,2 @@ OManufacturerDB::OManufacturerDB()
72 { 73 {
73 s.readLine();
74 continue; 74 continue;
@@ -77,4 +77,14 @@ OManufacturerDB::OManufacturerDB()
77 s >> manu; 77 s >> manu;
78 s.readLine(); 78 s.skipWhiteSpace();
79 //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); 79 s >> extManu;
80 if ( extManu[0] == '#' ) // we have an extended manufacturer
81 {
82 s.skipWhiteSpace();
83 extManu = s.readLine();
84 qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
85 manufacturersExt.insert( addr, extManu );
86 }
87 else
88 s.readLine();
89 qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
80 manufacturers.insert( addr, manu ); 90 manufacturers.insert( addr, manu );
@@ -96 +106,9 @@ const QString& OManufacturerDB::lookup( const QString& macaddr ) const
96} 106}
107
108
109const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
110{
111 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
112 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
113}
114
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index cb0b6c8..651f624 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -20,2 +20,8 @@
20 20
21/**
22 * @brief A Ethernet card vendor database.
23 *
24 * This class encapsulates the lookup of Ethernet vendor given a
25 * certain Mac Address. Only the first three bytes define the vendor.
26 */
21class OManufacturerDB 27class OManufacturerDB
@@ -23,5 +29,14 @@ class OManufacturerDB
23 public: 29 public:
24 //FIXME make us consistent -zecke I use self(), sandman inst() you use instance() so we need to chose one! 30 /**
31 * @returns the one-and-only @ref OManufacturerDB instance.
32 */
25 static OManufacturerDB* instance(); 33 static OManufacturerDB* instance();
34 /**
35 * @returns the short manufacturer string given a @a macaddr.
36 */
26 const QString& lookup( const QString& macaddr ) const; 37 const QString& lookup( const QString& macaddr ) const;
38 /**
39 * @returns the enhanced manufacturer string given a @a macaddr.
40 */
41 const QString& lookupExt( const QString& macaddr ) const;
27 42
@@ -33,2 +48,3 @@ class OManufacturerDB
33 QMap<QString, QString> manufacturers; 48 QMap<QString, QString> manufacturers;
49 QMap<QString, QString> manufacturersExt;
34 static OManufacturerDB* _instance; 50 static OManufacturerDB* _instance;
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index e05efc2..08c40b4 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -121,3 +121,3 @@ QString OMacAddress::toString( bool substitute ) const
121 QString textmanu = OManufacturerDB::instance()->lookup( manu ); 121 QString textmanu = OManufacturerDB::instance()->lookup( manu );
122 return textmanu.isNull() ? manu+serial : textmanu + serial; 122 return textmanu.isNull() ? manu+serial : textmanu+serial;
123} 123}
@@ -127,5 +127,6 @@ QString OMacAddress::manufacturer() const
127{ 127{
128 return OManufacturerDB::instance()->lookup( toString() ); 128 return OManufacturerDB::instance()->lookupExt( toString() );
129} 129}
130 130
131
131bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 132bool operator==( const OMacAddress &m1, const OMacAddress &m2 )