4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief EUI64 inline non-template implementation */
35 #include <boost/lambda/lambda.hpp>
36 #include "MACAddress.hh"
38 #define prefix_ inline
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41 prefix_ senf::EUI64::EUI64(boost::uint64_t v)
43 (*this)[0] = (v>>56) & 0xffu;
44 (*this)[1] = (v>>48) & 0xffu;
45 (*this)[2] = (v>>40) & 0xffu;
46 (*this)[3] = (v>>32) & 0xffu;
47 (*this)[4] = (v>>24) & 0xffu;
48 (*this)[5] = (v>>16) & 0xffu;
49 (*this)[6] = (v>> 8) & 0xffu;
50 (*this)[7] = (v ) & 0xffu;
53 prefix_ senf::EUI64::EUI64(senf::NoInit_t)
56 prefix_ senf::EUI64 senf::EUI64::from_mac(MACAddress const & mac)
58 EUI64 eui (senf::noinit);
70 prefix_ bool senf::EUI64::isMACCompatible()
73 return (*this)[3] == 0xffu && (*this)[4] == 0xfeu;
76 prefix_ bool senf::EUI64::local()
79 return (*this)[0]&0x02;
82 prefix_ bool senf::EUI64::group()
85 return (*this)[0]&0x01;
88 prefix_ bool senf::EUI64::boolean_test()
91 using boost::lambda::_1;
92 return std::find_if(begin(),end(), _1 != 0x00u) != end();
95 prefix_ boost::uint64_t senf::EUI64::uint64()
98 return (boost::uint64_t((*this)[0])<<56)
99 | (boost::uint64_t((*this)[1])<<48)
100 | (boost::uint64_t((*this)[2])<<40)
101 | (boost::uint64_t((*this)[3])<<32)
102 | (boost::uint64_t((*this)[4])<<24)
103 | (boost::uint64_t((*this)[5])<<16)
104 | (boost::uint64_t((*this)[6])<< 8)
105 | (boost::uint64_t((*this)[7]) );
108 //-/////////////////////////////////////////////////////////////////////////////////////////////////
115 // comment-column: 40
116 // c-file-style: "senf"
117 // indent-tabs-mode: nil
118 // ispell-local-dictionary: "american"
119 // compile-command: "scons -u test"