Diffstat (limited to 'libopie2/opienet/onetutils.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index b317810..0fb21ff 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp @@ -62,7 +62,7 @@ const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); OMacAddress::OMacAddress( unsigned char* p ) { - memcpy( _bytes, p, 6 ); // D'OH! memcpy in my sources... eeek... + memcpy( _bytes, p, 6 ); } @@ -83,6 +83,32 @@ OMacAddress::~OMacAddress() } +#ifdef QT_NO_DEBUG +inline +#endif +const unsigned char* OMacAddress::native() const +{ + return (const unsigned char*) &_bytes; +} + + +OMacAddress OMacAddress::fromString( const QString& str ) +{ + QString addr( str ); + unsigned char buf[6]; + bool ok = true; + int index = 14; + for ( int i = 5; i >= 0; --i ) + { + buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); + if ( !ok ) return OMacAddress::unknown; + addr.truncate( index ); + index -= 3; + } + return (const unsigned char*) &buf; +} + + QString OMacAddress::toString() const { QString s; |