author | mickeyl <mickeyl> | 2003-05-08 17:35:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-08 17:35:05 (UTC) |
commit | 41ca770b8bea964ea9c5905b1df1209fe4720f89 (patch) (unidiff) | |
tree | 585b10184e6afc283055ce3f7348ae19969b5174 /libopie2 | |
parent | 197cdbb5ca34517c077b69bb8517787ab1e52aeb (diff) | |
download | opie-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
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 4 | ||||
-rw-r--r-- | libopie2/examples/opieui/opieui.pro | 2 | ||||
-rw-r--r-- | libopie2/opiecore/oapplication.cpp | 12 | ||||
-rw-r--r-- | libopie2/opiecore/oapplication.h | 0 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 22 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.h | 18 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 3 |
7 files changed, 56 insertions, 5 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index fd68772..6326ad0 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,2 +1,3 @@ | |||
1 | #include <opie2/onetwork.h> | 1 | #include <opie2/onetwork.h> |
2 | #include <opie2/omanufacturerdb.h> | ||
2 | 3 | ||
@@ -15,2 +16,5 @@ int main( int argc, char** argv ) | |||
15 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); | 16 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); |
17 | qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); | ||
18 | qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); | ||
19 | qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); | ||
16 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); | 20 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); |
diff --git a/libopie2/examples/opieui/opieui.pro b/libopie2/examples/opieui/opieui.pro index b52f013..ad66f47 100644 --- a/libopie2/examples/opieui/opieui.pro +++ b/libopie2/examples/opieui/opieui.pro | |||
@@ -1,3 +1,3 @@ | |||
1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
2 | SUBDIRS = olistviewdemo oversatileviewdemo | 2 | SUBDIRS = olistviewdemo |
3 | 3 | ||
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp index 7a6c174..06d8ba2 100644 --- a/libopie2/opiecore/oapplication.cpp +++ b/libopie2/opiecore/oapplication.cpp | |||
@@ -33,2 +33,5 @@ | |||
33 | 33 | ||
34 | #include <signal.h> | ||
35 | #include <stdio.h> | ||
36 | |||
34 | OApplication* OApplication::_instance = 0; | 37 | OApplication* OApplication::_instance = 0; |
@@ -87,2 +90,11 @@ void OApplication::init() | |||
87 | OApplication::_instance = this; | 90 | OApplication::_instance = this; |
91 | |||
92 | /* register SIGSEGV handler to give programs an option | ||
93 | * to exit gracefully, e.g. save or close devices or files. | ||
94 | struct sigaction sa; | ||
95 | sa.sa_handler = ( void (*)(int) ) &segv_handler; | ||
96 | sa.sa_flags = SA_SIGINFO | SA_RESTART; | ||
97 | sigemptyset(&sa.sa_mask); | ||
98 | sigaction(SIGSEGV, &sa, NULL); | ||
99 | */ | ||
88 | } | 100 | } |
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h index 94ac488..1bd34e2 100644 --- a/libopie2/opiecore/oapplication.h +++ b/libopie2/opiecore/oapplication.h | |||
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.skipWhiteSpace(); | ||
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 | ||
78 | s.readLine(); | 88 | s.readLine(); |
79 | //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); | 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 | |||
109 | const 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 | */ | ||
21 | class OManufacturerDB | 27 | class 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 | |||
@@ -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 | |||
131 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | 132 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) |