summaryrefslogtreecommitdiff
path: root/libopie2/opienet/onetutils.cpp
authormickeyl <mickeyl>2003-04-07 18:07:38 (UTC)
committer mickeyl <mickeyl>2003-04-07 18:07:38 (UTC)
commitcac6a08e456a057a19cc1fc56824fc98ff4f0bc1 (patch) (unidiff)
treeb17fa559629bcb9f49d685d3ec8b8dddc6a20f46 /libopie2/opienet/onetutils.cpp
parent75f029f87d4c84b37ccfe1c81ef205a6cd5fca79 (diff)
downloadopie-cac6a08e456a057a19cc1fc56824fc98ff4f0bc1.zip
opie-cac6a08e456a057a19cc1fc56824fc98ff4f0bc1.tar.gz
opie-cac6a08e456a057a19cc1fc56824fc98ff4f0bc1.tar.bz2
- add OManufacturerDB
- API extensions for OMacAddress - add data packet recognition for miniwellenreiter
Diffstat (limited to 'libopie2/opienet/onetutils.cpp') (more/less context) (ignore 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
@@ -28,12 +28,13 @@
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/onetutils.h> 32#include <opie2/onetutils.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/omanufacturerdb.h>
34 35
35#include <net/if.h> 36#include <net/if.h>
36 37
37#include <cstdio> 38#include <cstdio>
38using namespace std; 39using namespace std;
39 40
@@ -106,22 +107,30 @@ OMacAddress OMacAddress::fromString( const QString& str )
106 index -= 3; 107 index -= 3;
107 } 108 }
108 return (const unsigned char*) &buf; 109 return (const unsigned char*) &buf;
109} 110}
110 111
111 112
112QString OMacAddress::toString() const 113QString OMacAddress::toString( bool substitute ) const
113{ 114{
114 QString s; 115 QString manu;
115 s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", 116 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
116 _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff, 117 QString serial;
117 _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 118 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
118 return s; 119 if ( !substitute ) return manu+serial;
120 // fallback - if no vendor is found, just use the number
121 QString textmanu = OManufacturerDB::instance()->lookup( manu );
122 return textmanu.isNull() ? manu+serial : textmanu + serial;
119} 123}
120 124
121 125
126QString OMacAddress::manufacturer() const
127{
128 return OManufacturerDB::instance()->lookup( toString() );
129}
130
122bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 131bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
123{ 132{
124 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 133 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
125} 134}
126 135
127 136