From: tho Date: Mon, 26 Jan 2009 10:41:55 +0000 (+0000) Subject: added MACAddress::uint64() X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=aa9838dbb3f1b68f17c13acbb3b94a53664d8a3b;p=senf.git added MACAddress::uint64() git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1075 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/Protocols/Raw/MACAddress.cci b/Socket/Protocols/Raw/MACAddress.cci index 45eb66c..a2ec274 100644 --- a/Socket/Protocols/Raw/MACAddress.cci +++ b/Socket/Protocols/Raw/MACAddress.cci @@ -108,6 +108,18 @@ prefix_ boost::uint64_t senf::MACAddress::eui64() (boost::uint64_t( (*this)[5] ) ); } +prefix_ boost::uint64_t senf::MACAddress::uint64() + const +{ + return + (boost::uint64_t( (*this)[0] ) << 40) | + (boost::uint64_t( (*this)[1] ) << 32) | + (boost::uint64_t( (*this)[2] ) << 24) | + (boost::uint64_t( (*this)[3] ) << 16) | + (boost::uint64_t( (*this)[4] ) << 8) | + (boost::uint64_t( (*this)[5] ) ); +} + ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Socket/Protocols/Raw/MACAddress.hh b/Socket/Protocols/Raw/MACAddress.hh index 3b1e94c..6d28887 100644 --- a/Socket/Protocols/Raw/MACAddress.hh +++ b/Socket/Protocols/Raw/MACAddress.hh @@ -48,7 +48,7 @@ namespace senf { The following statements all create the same MAC address 00:1A:2B:3C:4D:5F \code // Used to construct constant MAC addresses - MACAddress(0x001A2B3C4D5Flu) + MACAddress(0x001A2B3C4D5Fllu) // Construct a MAC address from it's string representation: MACAddress::from_string("00:1a:2b:3c:4d:5f") // case is ignored @@ -128,6 +128,7 @@ namespace senf { boost::uint32_t nic() const; ///< Return last 3 bytes of the address boost::uint64_t eui64() const; ///< Build EUI-64 from the MAC address + boost::uint64_t uint64() const; ///< Return MAC address as uint64 value std::string toString() const; ///< Return string representation of MAC address like 12:34:56:78:90:ab diff --git a/Socket/Protocols/Raw/MACAddress.test.cc b/Socket/Protocols/Raw/MACAddress.test.cc index a678df6..683139d 100644 --- a/Socket/Protocols/Raw/MACAddress.test.cc +++ b/Socket/Protocols/Raw/MACAddress.test.cc @@ -84,6 +84,8 @@ BOOST_AUTO_UNIT_TEST(macAddress) BOOST_CHECK_EQUAL( mac, senf::MACAddress::from_eui64(0xa1b2c3fffed4e5f6llu) ); BOOST_CHECK_THROW( senf::MACAddress::from_eui64(0u), senf::AddressSyntaxException ); + + BOOST_CHECK_EQUAL( senf::MACAddress(0x1a2b3c4d5e6fULL).uint64(), 0x1a2b3c4d5e6fULL); } ///////////////////////////////cc.e////////////////////////////////////////