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 EUI64 public header */
26 #ifndef HH_SENF_Socket_Protocols_Raw_EUI64_
27 #define HH_SENF_Socket_Protocols_Raw_EUI64_ 1
31 #include <boost/cstdint.hpp>
32 #include <boost/array.hpp>
33 #include "../../../Utils/Tags.hh"
34 #include "../../../Utils/safe_bool.hh"
36 //#include "EUI64.mpp"
37 ///////////////////////////////hh.p////////////////////////////////////////
43 /** \brief EUI-64 data type
45 An EUI-64 is a 64 bit (8 octet) id. The id is represented as an 8 byte sequence in network
46 byte order. An EUI64 can be converted from/to several other representations
49 <tr><td><tt>boost::uint64_t</tt></td>
50 <td><tt>senf::EUI64(0x1a2b3c4d5f607182ull)</tt><br/>
51 <i>eui64</i><tt>.uint64()</tt></td></tr>
52 <tr><td><tt>std::string</tt></td>
53 <td><tt>senf::EUI64::from_string("1a:2b:3c:4d-5f:60:71:82")</tt><br/>
54 <tt>senf::str(</tt><i>eui64</i><tt>)</tt></td></tr>
55 <tr><td><i>raw data</i></td>
56 <td><tt>senf::EUI64::from_data(</tt><i>iterator</i><tt>)</tt><br/>
57 <i>eui64</i><tt>.begin()</tt></td></tr>
58 <tr><td>senf::MACAddress<br/> (aka EUI-48)</td>
59 <td><tt>senf::EUI64::from_mac(</tt><i>mac-address</i><tt>)</tt><br/>
60 <tt>senf::MACAddress::from_eui64(</tt><i>eui64</i><tt>)</tt></td></tr>
63 Additionally, a senf::MACAddress can be converted into an EUI64 and vice versa.
68 : public boost::array<boost::uint8_t,8>,
69 public senf::comparable_safe_bool<EUI64>
72 ///////////////////////////////////////////////////////////////////////////
73 ///\name Structors and default members
76 // default copy constructor
77 // default copy assignment
79 // no conversion constructors
81 explicit EUI64(boost::uint64_t v=0u); ///< Construct EUI-64
82 explicit EUI64(senf::NoInit_t); ///< Construct <em>uninitialized</em> EUI-64
84 static EUI64 from_mac(MACAddress const & mac);
85 ///< Construct EUI-64 from senf::MACAddress
86 static EUI64 from_string(std::string const & s);
87 ///< Construct EUI-64 from string representation
88 /**< The string representation consists of 8 octets in
89 hexadecimal notation spearated by ':' or '-' */
90 template <class InputIterator>
91 static EUI64 from_data(InputIterator i);
92 ///< Construct EUI-64 from 8 data octets
93 /**< The iterator \a i must point to a sequence of 8
94 octets in network byte order. */
97 ///////////////////////////////////////////////////////////////////////////
99 bool isMACCompatible() const; ///< \c true, if EUI64 is MAC compatible, \c false otherwise
100 /**< An EUI64 is MAC compatible if bytes 4th and 5th byte
101 (in network byte order) are 0xfffe. */
102 bool boolean_test() const; ///< \c true, if EUI64 is != 0, \c false otherwise
103 boost::uint64_t uint64() const; ///< Return EUI64 as integer number
106 /** \brief Write out EUI64 in it's string representation to stream
109 std::ostream & operator<<(std::ostream & os, EUI64 const & v);
111 /** \brief Read EUI64 string representation from stream
114 std::istream & operator>>(std::istream & is, EUI64 & v);
118 ///////////////////////////////hh.e////////////////////////////////////////
120 //#include "EUI64.ct"
128 // comment-column: 40
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"