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 | 4 | ||||
-rw-r--r-- | libopie2/opiecore/oapplication.cpp | 12 | ||||
-rw-r--r-- | libopie2/opiecore/oapplication.h | 2 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 24 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.h | 18 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 5 |
7 files changed, 60 insertions, 9 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,7 +1,8 @@ | |||
1 | #include <opie2/onetwork.h> | 1 | #include <opie2/onetwork.h> |
2 | #include <opie2/omanufacturerdb.h> | ||
2 | 3 | ||
3 | int main( int argc, char** argv ) | 4 | int main( int argc, char** argv ) |
4 | { | 5 | { |
5 | qDebug( "OPIE Network Demo" ); | 6 | qDebug( "OPIE Network Demo" ); |
6 | 7 | ||
7 | ONetwork* net = ONetwork::instance(); | 8 | ONetwork* net = ONetwork::instance(); |
@@ -10,12 +11,15 @@ int main( int argc, char** argv ) | |||
10 | 11 | ||
11 | while ( it.current() ) | 12 | while ( it.current() ) |
12 | { | 13 | { |
13 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 14 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); |
14 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 15 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); |
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() ); |
17 | if ( it.current()->isWireless() ) | 21 | if ( it.current()->isWireless() ) |
18 | { | 22 | { |
19 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 23 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
20 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 24 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); |
21 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 25 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); |
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 | |||
@@ -28,12 +28,15 @@ | |||
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <opie2/oapplication.h> | 31 | #include <opie2/oapplication.h> |
32 | #include <opie2/oconfig.h> | 32 | #include <opie2/oconfig.h> |
33 | 33 | ||
34 | #include <signal.h> | ||
35 | #include <stdio.h> | ||
36 | |||
34 | OApplication* OApplication::_instance = 0; | 37 | OApplication* OApplication::_instance = 0; |
35 | 38 | ||
36 | /**************************************************************************************************/ | 39 | /**************************************************************************************************/ |
37 | /* OApplicationPrivate | 40 | /* OApplicationPrivate |
38 | /**************************************************************************************************/ | 41 | /**************************************************************************************************/ |
39 | 42 | ||
@@ -82,12 +85,21 @@ OConfig* OApplication::config() | |||
82 | void OApplication::init() | 85 | void OApplication::init() |
83 | { | 86 | { |
84 | d = new OApplicationPrivate(); | 87 | d = new OApplicationPrivate(); |
85 | if ( !OApplication::_instance ) | 88 | if ( !OApplication::_instance ) |
86 | { | 89 | { |
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 | } |
89 | else | 101 | else |
90 | { | 102 | { |
91 | qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); | 103 | qFatal( "OApplication: Can't create more than one OApplication object. Aborting." ); |
92 | } | 104 | } |
93 | } | 105 | } |
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 | |||
@@ -38,13 +38,13 @@ | |||
38 | class OApplicationPrivate; | 38 | class OApplicationPrivate; |
39 | class OConfig; | 39 | class OConfig; |
40 | 40 | ||
41 | class OApplication: public QPEApplication | 41 | class OApplication: public QPEApplication |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | /** | 46 | /** |
47 | * Constructor. Parses command-line arguments and sets the window caption. | 47 | * Constructor. Parses command-line arguments and sets the window caption. |
48 | * | 48 | * |
49 | * @param rAppName application name. Will be used for finding the | 49 | * @param rAppName application name. Will be used for finding the |
50 | * associated message, icon and configuration files | 50 | * associated message, icon and configuration files |
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 | |||
@@ -57,29 +57,39 @@ OManufacturerDB::OManufacturerDB() | |||
57 | else | 57 | else |
58 | { | 58 | { |
59 | qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); | 59 | qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); |
60 | QTextStream s( &file ); | 60 | QTextStream s( &file ); |
61 | QString addr; | 61 | QString addr; |
62 | QString manu; | 62 | QString manu; |
63 | QString extManu; | ||
63 | while (!s.atEnd()) | 64 | while (!s.atEnd()) |
64 | { | 65 | { |
65 | s >> addr; | 66 | s >> addr; |
66 | if ( !addr ) // read nothing!? | 67 | if ( !addr ) // read nothing!? |
67 | { | 68 | { |
68 | continue; | 69 | continue; |
69 | } | 70 | } |
70 | else | 71 | else |
71 | if ( addr[0] == '#' ) | 72 | if ( addr[0] == '#' ) |
72 | { | 73 | { |
73 | s.readLine(); | ||
74 | continue; | 74 | continue; |
75 | } | 75 | } |
76 | s.skipWhiteSpace(); | 76 | s.skipWhiteSpace(); |
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 ); |
81 | 91 | ||
82 | } | 92 | } |
83 | } | 93 | } |
84 | 94 | ||
85 | } | 95 | } |
@@ -91,6 +101,14 @@ OManufacturerDB::~OManufacturerDB() | |||
91 | 101 | ||
92 | 102 | ||
93 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const | 103 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const |
94 | { | 104 | { |
95 | return manufacturers[macaddr.upper().left(8)]; | 105 | return manufacturers[macaddr.upper().left(8)]; |
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 | |||
@@ -15,24 +15,40 @@ | |||
15 | 15 | ||
16 | #ifndef OMANUFACTURERDB_H | 16 | #ifndef OMANUFACTURERDB_H |
17 | #define OMANUFACTURERDB_H | 17 | #define OMANUFACTURERDB_H |
18 | 18 | ||
19 | #include <qmap.h> | 19 | #include <qmap.h> |
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 |
22 | { | 28 | { |
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 | ||
28 | protected: | 43 | protected: |
29 | OManufacturerDB(); | 44 | OManufacturerDB(); |
30 | virtual ~OManufacturerDB(); | 45 | virtual ~OManufacturerDB(); |
31 | 46 | ||
32 | private: | 47 | private: |
33 | QMap<QString, QString> manufacturers; | 48 | QMap<QString, QString> manufacturers; |
49 | QMap<QString, QString> manufacturersExt; | ||
34 | static OManufacturerDB* _instance; | 50 | static OManufacturerDB* _instance; |
35 | }; | 51 | }; |
36 | 52 | ||
37 | #endif | 53 | #endif |
38 | 54 | ||
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 | |||
@@ -116,21 +116,22 @@ QString OMacAddress::toString( bool substitute ) const | |||
116 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); | 116 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); |
117 | QString serial; | 117 | QString serial; |
118 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 118 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
119 | if ( !substitute ) return manu+serial; | 119 | if ( !substitute ) return manu+serial; |
120 | // fallback - if no vendor is found, just use the number | 120 | // fallback - if no vendor is found, just use the number |
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 | } |
124 | 124 | ||
125 | 125 | ||
126 | QString OMacAddress::manufacturer() const | 126 | 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 ) |
132 | { | 133 | { |
133 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; | 134 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; |
134 | } | 135 | } |
135 | 136 | ||
136 | 137 | ||