summaryrefslogtreecommitdiff
path: root/libopie2/opienet
authormickeyl <mickeyl>2003-05-08 17:35:05 (UTC)
committer mickeyl <mickeyl>2003-05-08 17:35:05 (UTC)
commit41ca770b8bea964ea9c5905b1df1209fe4720f89 (patch) (side-by-side diff)
tree585b10184e6afc283055ce3f7348ae19969b5174 /libopie2/opienet
parent197cdbb5ca34517c077b69bb8517787ab1e52aeb (diff)
downloadopie-41ca770b8bea964ea9c5905b1df1209fe4720f89.zip
opie-41ca770b8bea964ea9c5905b1df1209fe4720f89.tar.gz
opie-41ca770b8bea964ea9c5905b1df1209fe4720f89.tar.bz2
- sync manufacturer list with ethereal
- fix onetworkdemo example - add API for short/extended manufacturer names
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()
QString manu;
+ QString extManu;
while (!s.atEnd())
@@ -72,3 +73,2 @@ OManufacturerDB::OManufacturerDB()
{
- s.readLine();
continue;
@@ -77,4 +77,14 @@ OManufacturerDB::OManufacturerDB()
s >> manu;
- s.readLine();
- //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu );
+ s.skipWhiteSpace();
+ s >> extManu;
+ if ( extManu[0] == '#' ) // we have an extended manufacturer
+ {
+ s.skipWhiteSpace();
+ extManu = s.readLine();
+ qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
+ manufacturersExt.insert( addr, extManu );
+ }
+ else
+ s.readLine();
+ qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
manufacturers.insert( addr, manu );
@@ -96 +106,9 @@ const QString& OManufacturerDB::lookup( const QString& macaddr ) const
}
+
+
+const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
+{
+ QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
+ return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
+}
+
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 @@
+/**
+ * @brief A Ethernet card vendor database.
+ *
+ * This class encapsulates the lookup of Ethernet vendor given a
+ * certain Mac Address. Only the first three bytes define the vendor.
+ */
class OManufacturerDB
@@ -23,5 +29,14 @@ class OManufacturerDB
public:
- //FIXME make us consistent -zecke I use self(), sandman inst() you use instance() so we need to chose one!
+ /**
+ * @returns the one-and-only @ref OManufacturerDB instance.
+ */
static OManufacturerDB* instance();
+ /**
+ * @returns the short manufacturer string given a @a macaddr.
+ */
const QString& lookup( const QString& macaddr ) const;
+ /**
+ * @returns the enhanced manufacturer string given a @a macaddr.
+ */
+ const QString& lookupExt( const QString& macaddr ) const;
@@ -33,2 +48,3 @@ class OManufacturerDB
QMap<QString, QString> manufacturers;
+ QMap<QString, QString> manufacturersExt;
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
QString textmanu = OManufacturerDB::instance()->lookup( manu );
- return textmanu.isNull() ? manu+serial : textmanu + serial;
+ return textmanu.isNull() ? manu+serial : textmanu+serial;
}
@@ -127,5 +127,6 @@ QString OMacAddress::manufacturer() const
{
- return OManufacturerDB::instance()->lookup( toString() );
+ return OManufacturerDB::instance()->lookupExt( toString() );
}
+
bool operator==( const OMacAddress &m1, const OMacAddress &m2 )