2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief MACAddress inline non-template implementation */
26 #include <boost/lambda/lambda.hpp>
28 #define prefix_ inline
29 ///////////////////////////////cci.p///////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////////////
34 prefix_ senf::MACAddress::MACAddress()
36 std::fill(begin(),end(),0u);
39 prefix_ senf::MACAddress::MACAddress(NoInit_t)
42 prefix_ senf::MACAddress::MACAddress(boost::uint64_t v)
44 (*this)[0] = boost::uint8_t( v>>40 );
45 (*this)[1] = boost::uint8_t( v>>32 );
46 (*this)[2] = boost::uint8_t( v>>24 );
47 (*this)[3] = boost::uint8_t( v>>16 );
48 (*this)[4] = boost::uint8_t( v>> 8 );
49 (*this)[5] = boost::uint8_t( v );
52 prefix_ bool senf::MACAddress::local()
55 return (*this)[0] & 0x02;
58 prefix_ bool senf::MACAddress::multicast()
61 return (*this)[0] & 0x01;
64 prefix_ bool senf::MACAddress::broadcast()
67 using boost::lambda::_1;
68 return std::find_if(begin(),end(), _1 != 0xffu) == end();
71 prefix_ bool senf::MACAddress::boolean_test()
74 using boost::lambda::_1;
75 return std::find_if(begin(),end(), _1 != 0x00u) != end();
78 prefix_ boost::uint32_t senf::MACAddress::oui()
82 (boost::uint32_t((*this)[0])<<16) |
83 (boost::uint32_t((*this)[1])<<8) |
87 prefix_ boost::uint32_t senf::MACAddress::nic()
91 (boost::uint32_t((*this)[3])<<16) |
92 (boost::uint32_t((*this)[4])<<8) |
96 prefix_ boost::uint64_t senf::MACAddress::eui64()
100 (boost::uint64_t( (*this)[0] ) << 56) |
101 (boost::uint64_t( (*this)[1] ) << 48) |
102 (boost::uint64_t( (*this)[2] ) << 40) |
103 (boost::uint64_t( 0xfffe ) << 24) |
104 (boost::uint64_t( (*this)[3] ) << 16) |
105 (boost::uint64_t( (*this)[4] ) << 8) |
106 (boost::uint64_t( (*this)[5] ) );
109 ///////////////////////////////cci.e///////////////////////////////////////
116 // comment-column: 40
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"