00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Packets_80221Bundle_MIHTypes_
00027 #define HH_SENF_Packets_80221Bundle_MIHTypes_ 1
00028
00029
00030 #include <senf/Socket/Protocols/Raw/MACAddress.hh>
00031 #include <senf/Socket/Protocols/INet/INet4Address.hh>
00032 #include <senf/Socket/Protocols/INet/INet6Address.hh>
00033 #include <boost/function_output_iterator.hpp>
00034 #include <boost/iterator/filter_iterator.hpp>
00035 #include <boost/variant.hpp>
00036
00037
00038
00039
00040 namespace senf {
00041
00042 class MIHFId
00043 : public boost::variant< boost::blank, senf::MACAddress, senf::INet4Address,
00044 senf::INet6Address, std::string, senf::EUI64 >,
00045 public boost::less_than_comparable<MIHFId>,
00046 public boost::equality_comparable<MIHFId>
00047 {
00048 public:
00049 static MIHFId const Multicast;
00050 enum Type { MulticastType, MACAddress, INet4Address, INet6Address, String, EUI64 };
00051
00052 MIHFId();
00053 MIHFId(senf::MACAddress const & addr);
00054 MIHFId(senf::INet4Address const & addr);
00055 MIHFId(senf::INet6Address const & addr);
00056 MIHFId(std::string const & addr);
00057 MIHFId(senf::EUI64 const & addr);
00058
00059 Type type() const;
00060 bool operator==(MIHFId const & other) const;
00061 bool operator<(MIHFId const & other) const;
00062
00063 private:
00064 struct GetTypeVisitor : public boost::static_visitor<Type> {
00065 Type operator()(boost::blank const &) const { return MulticastType; }
00066 Type operator()(senf::MACAddress const &) const { return MACAddress; }
00067 Type operator()(senf::INet4Address const &) const { return INet4Address; }
00068 Type operator()(senf::INet6Address const &) const { return INet6Address; }
00069 Type operator()(std::string const & ) const { return String; }
00070 Type operator()(senf::EUI64 const &) const { return EUI64; }
00071 };
00072 struct EqualsVisitor : public boost::static_visitor<bool> {
00073 template <typename T, typename U>
00074 bool operator()(T const &, U const &) const {
00075 return false;
00076 }
00077 template <typename T>
00078 bool operator()( const T & lhs, const T & rhs ) const {
00079 return lhs == rhs;
00080 }
00081 };
00082 struct LessThanVisitor : public boost::static_visitor<bool> {
00083 template <typename T, typename U>
00084 bool operator()(T const &, U const &) const {
00085 return false;
00086 }
00087 template <typename T>
00088 bool operator()( const T & lhs, const T & rhs ) const {
00089 return lhs < rhs;
00090 }
00091 };
00092 };
00093
00094 }
00095
00096
00097 #include "MIHTypes.cci"
00098
00099
00100 #endif
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111