4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief MACAddress inline non-template implementation */
28 #include <boost/lambda/lambda.hpp>
30 #define prefix_ inline
31 ///////////////////////////////cci.p///////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////
36 prefix_ senf::MACAddress::MACAddress()
38 std::fill(begin(),end(),0u);
41 prefix_ senf::MACAddress::MACAddress(senf::NoInit_t)
44 prefix_ senf::MACAddress::MACAddress(boost::uint64_t v)
46 (*this)[0] = boost::uint8_t( v>>40 );
47 (*this)[1] = boost::uint8_t( v>>32 );
48 (*this)[2] = boost::uint8_t( v>>24 );
49 (*this)[3] = boost::uint8_t( v>>16 );
50 (*this)[4] = boost::uint8_t( v>> 8 );
51 (*this)[5] = boost::uint8_t( v );
54 prefix_ bool senf::MACAddress::local()
57 return (*this)[0] & 0x02;
60 prefix_ bool senf::MACAddress::multicast()
63 return (*this)[0] & 0x01;
66 prefix_ bool senf::MACAddress::broadcast()
69 using boost::lambda::_1;
70 return std::find_if(begin(),end(), _1 != 0xffu) == end();
73 prefix_ bool senf::MACAddress::boolean_test()
76 using boost::lambda::_1;
77 return std::find_if(begin(),end(), _1 != 0x00u) != end();
80 prefix_ boost::uint32_t senf::MACAddress::oui()
84 (boost::uint32_t((*this)[0])<<16) |
85 (boost::uint32_t((*this)[1])<<8) |
89 prefix_ boost::uint32_t senf::MACAddress::nic()
93 (boost::uint32_t((*this)[3])<<16) |
94 (boost::uint32_t((*this)[4])<<8) |
98 prefix_ boost::uint64_t senf::MACAddress::eui64()
102 (boost::uint64_t( (*this)[0] ) << 56) |
103 (boost::uint64_t( (*this)[1] ) << 48) |
104 (boost::uint64_t( (*this)[2] ) << 40) |
105 (boost::uint64_t( 0xfffe ) << 24) |
106 (boost::uint64_t( (*this)[3] ) << 16) |
107 (boost::uint64_t( (*this)[4] ) << 8) |
108 (boost::uint64_t( (*this)[5] ) );
111 prefix_ boost::uint64_t senf::MACAddress::uint64()
115 (boost::uint64_t( (*this)[0] ) << 40) |
116 (boost::uint64_t( (*this)[1] ) << 32) |
117 (boost::uint64_t( (*this)[2] ) << 24) |
118 (boost::uint64_t( (*this)[3] ) << 16) |
119 (boost::uint64_t( (*this)[4] ) << 8) |
120 (boost::uint64_t( (*this)[5] ) );
123 ///////////////////////////////cci.e///////////////////////////////////////
130 // comment-column: 40
131 // c-file-style: "senf"
132 // indent-tabs-mode: nil
133 // ispell-local-dictionary: "american"
134 // compile-command: "scons -u test"