00001 // $Id: MACAddress.hh 1742 2010-11-04 14:51:56Z g0dil $ 00002 // 00003 // Copyright (C) 2007 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #ifndef HH_SENF_Socket_Protocols_Raw_MACAddress_ 00027 #define HH_SENF_Socket_Protocols_Raw_MACAddress_ 1 00028 00029 // Custom includes 00030 #include <iostream> 00031 #include <boost/cstdint.hpp> 00032 #include <boost/array.hpp> 00033 #include <boost/utility.hpp> 00034 #include <boost/type_traits.hpp> 00035 #include <senf/Utils/safe_bool.hh> 00036 #include <senf/Utils/Tags.hh> 00037 00038 //#include "MACAddress.mpp" 00039 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00040 00041 namespace senf { 00042 00043 class EUI64; 00044 00082 struct MACAddress 00083 : public boost::array<boost::uint8_t,6>, 00084 public comparable_safe_bool<MACAddress> 00085 { 00086 static MACAddress const Broadcast; 00087 static MACAddress const None; 00088 00089 MACAddress(); 00090 MACAddress(senf::NoInit_t); 00091 explicit MACAddress(boost::uint64_t v); 00092 00093 static MACAddress from_string(std::string const & s); 00095 00101 template <class InputIterator> 00102 static MACAddress from_data(InputIterator i); 00104 00108 static MACAddress from_eui64(senf::EUI64 const & eui); 00110 00117 bool local() const; 00118 bool multicast() const; 00119 bool broadcast() const; 00120 bool boolean_test() const; 00121 00122 boost::uint32_t oui() const; 00123 boost::uint32_t nic() const; 00124 00125 boost::uint64_t eui64() const; 00126 boost::uint64_t uint64() const; 00127 }; 00128 00132 std::ostream & operator<<(std::ostream & os, MACAddress const & mac); 00138 std::istream & operator>>(std::istream & os, MACAddress & mac); 00139 00140 bool operator==(MACAddress const & mac, EUI64 const & eui64); 00141 bool operator==(EUI64 const & eui64, MACAddress const & mac); 00142 00143 } 00144 00145 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00146 #include "MACAddress.cci" 00147 #include "MACAddress.ct" 00148 //#include "MACAddress.cti" 00149 #endif 00150 00151 00152 // Local Variables: 00153 // mode: c++ 00154 // fill-column: 100 00155 // comment-column: 40 00156 // c-file-style: "senf" 00157 // indent-tabs-mode: nil 00158 // ispell-local-dictionary: "american" 00159 // compile-command: "scons -u test" 00160 // End: