2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief EUI64 inline non-template implementation */
21 #include <boost/lambda/lambda.hpp>
22 #include "MACAddress.hh"
24 #define prefix_ inline
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 prefix_ senf::EUI64::EUI64(boost::uint64_t v)
29 (*this)[0] = (v>>56) & 0xffu;
30 (*this)[1] = (v>>48) & 0xffu;
31 (*this)[2] = (v>>40) & 0xffu;
32 (*this)[3] = (v>>32) & 0xffu;
33 (*this)[4] = (v>>24) & 0xffu;
34 (*this)[5] = (v>>16) & 0xffu;
35 (*this)[6] = (v>> 8) & 0xffu;
36 (*this)[7] = (v ) & 0xffu;
39 prefix_ senf::EUI64::EUI64(senf::NoInit_t)
42 prefix_ senf::EUI64 senf::EUI64::from_mac(MACAddress const & mac)
44 EUI64 eui (senf::noinit);
56 prefix_ bool senf::EUI64::isMACCompatible()
59 return (*this)[3] == 0xffu && (*this)[4] == 0xfeu;
62 prefix_ bool senf::EUI64::local()
65 return (*this)[0]&0x02;
68 prefix_ bool senf::EUI64::group()
71 return (*this)[0]&0x01;
74 prefix_ senf::EUI64::operator bool()
77 using boost::lambda::_1;
78 return std::find_if(begin(),end(), _1 != 0x00u) != end();
81 prefix_ boost::uint64_t senf::EUI64::uint64()
84 return (boost::uint64_t((*this)[0])<<56)
85 | (boost::uint64_t((*this)[1])<<48)
86 | (boost::uint64_t((*this)[2])<<40)
87 | (boost::uint64_t((*this)[3])<<32)
88 | (boost::uint64_t((*this)[4])<<24)
89 | (boost::uint64_t((*this)[5])<<16)
90 | (boost::uint64_t((*this)[6])<< 8)
91 | (boost::uint64_t((*this)[7]) );
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
101 // comment-column: 40
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"