EUI64.cci
Go to the documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026
00027
00028
00029 #include <algorithm>
00030 #include <boost/lambda/lambda.hpp>
00031 #include "MACAddress.hh"
00032
00033 #define prefix_ inline
00034
00035
00036 prefix_ senf::EUI64::EUI64(boost::uint64_t v)
00037 {
00038 (*this)[0] = (v>>56) & 0xffu;
00039 (*this)[1] = (v>>48) & 0xffu;
00040 (*this)[2] = (v>>40) & 0xffu;
00041 (*this)[3] = (v>>32) & 0xffu;
00042 (*this)[4] = (v>>24) & 0xffu;
00043 (*this)[5] = (v>>16) & 0xffu;
00044 (*this)[6] = (v>> 8) & 0xffu;
00045 (*this)[7] = (v ) & 0xffu;
00046 }
00047
00048 prefix_ senf::EUI64::EUI64(senf::NoInit_t)
00049 {}
00050
00051 prefix_ senf::EUI64 senf::EUI64::from_mac(MACAddress const & mac)
00052 {
00053 EUI64 eui (senf::noinit);
00054 eui[0] = mac[0];
00055 eui[1] = mac[1];
00056 eui[2] = mac[2];
00057 eui[3] = 0xffu;
00058 eui[4] = 0xfeu;
00059 eui[5] = mac[3];
00060 eui[6] = mac[4];
00061 eui[7] = mac[5];
00062 return eui;
00063 }
00064
00065 prefix_ bool senf::EUI64::isMACCompatible()
00066 const
00067 {
00068 return (*this)[3] == 0xffu && (*this)[4] == 0xfeu;
00069 }
00070
00071 prefix_ bool senf::EUI64::local()
00072 const
00073 {
00074 return (*this)[0]&0x02;
00075 }
00076
00077 prefix_ bool senf::EUI64::group()
00078 const
00079 {
00080 return (*this)[0]&0x01;
00081 }
00082
00083 prefix_ bool senf::EUI64::boolean_test()
00084 const
00085 {
00086 using boost::lambda::_1;
00087 return std::find_if(begin(),end(), _1 != 0x00u) != end();
00088 }
00089
00090 prefix_ boost::uint64_t senf::EUI64::uint64()
00091 const
00092 {
00093 return (boost::uint64_t((*this)[0])<<56)
00094 | (boost::uint64_t((*this)[1])<<48)
00095 | (boost::uint64_t((*this)[2])<<40)
00096 | (boost::uint64_t((*this)[3])<<32)
00097 | (boost::uint64_t((*this)[4])<<24)
00098 | (boost::uint64_t((*this)[5])<<16)
00099 | (boost::uint64_t((*this)[6])<< 8)
00100 | (boost::uint64_t((*this)[7]) );
00101 }
00102
00103
00104 #undef prefix_
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115