EUI64.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Socket_Protocols_Raw_EUI64_
18 #define HH_SENF_Socket_Protocols_Raw_EUI64_ 1
19 
20 // Custom includes
21 #include <iosfwd>
22 #include <boost/cstdint.hpp>
23 #include <boost/array.hpp>
24 #include <senf/Utils/Tags.hh>
25 
26 //#include "EUI64.mpp"
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 
31  struct MACAddress;
32 
66  struct EUI64
67  : public boost::array<boost::uint8_t,8>
68  {
69  //-////////////////////////////////////////////////////////////////////////
71  //\{
72 
73  static EUI64 const None;
74 
75  explicit EUI64(boost::uint64_t v=0u);
76  explicit EUI64(senf::NoInit_t);
77 
78  static EUI64 from_mac(MACAddress const & mac);
80  static EUI64 from_string(std::string const & s);
82 
85  template <class InputIterator>
86  static EUI64 from_data(InputIterator i);
88 
91  //\}
92  //-////////////////////////////////////////////////////////////////////////
93 
94  bool isMACCompatible() const;
95 
97  bool local() const;
98 
101  bool group() const;
102 
104  explicit operator bool() const;
105  boost::uint64_t uint64() const;
106  };
107 
111  std::ostream & operator<<(std::ostream & os, EUI64 const & v);
112 
116  std::istream & operator>>(std::istream & is, EUI64 & v);
117 
118 }
119 
120 //-/////////////////////////////////////////////////////////////////////////////////////////////////
121 #include "EUI64.cci"
122 //#include "EUI64.ct"
123 #include "EUI64.cti"
124 #endif
125 
126 
127 // Local Variables:
128 // mode: c++
129 // fill-column: 100
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"
135 // End:
static EUI64 from_string(std::string const &s)
Construct EUI-64 from string representation.
Definition: EUI64.cc:31
EUI-64 data type.
Definition: EUI64.hh:66
EUI64(boost::uint64_t v=0u)
Construct EUI-64.
Ethernet MAC address.
Definition: MACAddress.hh:72
bool group() const
true if the group bit is set, false otherwise
static EUI64 const None
The empty (0) address.
Definition: EUI64.hh:73
static EUI64 from_data(InputIterator i)
Construct EUI-64 from 8 data octets.
NoInit_t
bool local() const
true if the local bit is set, false otherwise
std::istream & operator>>(std::istream &is, EUI64 &v)
Read EUI64 string representation from stream.
static EUI64 from_mac(MACAddress const &mac)
Construct EUI-64 from senf::MACAddress.
boost::uint64_t uint64() const
Return EUI64 as integer number.
bool isMACCompatible() const
true, if EUI64 is MAC compatible, false otherwise
std::ostream & operator<<(std::ostream &os, EUI64 const &v)
Write out EUI64 in it&#39;s string representation to stream.