#ifndef __VOM_PREFIX_H__
#define __VOM_PREFIX_H__
-#include <boost/asio/ip/address.hpp>
-
#include "vom/enum_base.hpp"
+#include <boost/asio/ip/address.hpp>
namespace VOM {
/**
const static l3_proto_t IPV6;
const static l3_proto_t MPLS;
- bool is_ipv4();
- bool is_ipv6();
+ bool is_ipv4() const;
+ bool is_ipv6() const;
static const l3_proto_t& from_address(const boost::asio::ip::address& addr);
* Constructor with string and length
*/
prefix_t(const std::string& s, uint8_t len);
+
/**
* Copy Constructor
*/
prefix_t(const prefix_t&);
+
/**
* Constructor with VPP API prefix representation
*/
const static prefix_t ZEROv6;
/**
- * Convert the prefix into VPP API parameters
- */
+ * Convert the prefix into VPP API parameters
+ */
void to_vpp(uint8_t* is_ip6, uint8_t* addr, uint8_t* len) const;
/**
*/
uint8_t m_len;
};
+
+/**
+* A prefix defintion. Address + length
+*/
+class mprefix_t
+{
+public:
+ /**
+ * Default Constructor - creates ::/0
+ */
+ mprefix_t();
+ /**
+ * Constructor for (S,G)
+ */
+ mprefix_t(const boost::asio::ip::address& saddr,
+ const boost::asio::ip::address& gaddr);
+ /*
+ * Constructor for (*,G)
+ */
+ mprefix_t(const boost::asio::ip::address& gaddr);
+
+ /*
+ * Constructor for (*,G/n)
+ */
+ mprefix_t(const boost::asio::ip::address& gaddr, uint8_t len);
+
+ /**
+ *Constructor for (S,G)
+ */
+ mprefix_t(const boost::asio::ip::address& saddr,
+ const boost::asio::ip::address& gaddr,
+ uint16_t len);
+
+ /**
+ * Copy Constructor
+ */
+ mprefix_t(const mprefix_t&);
+
+ /**
+ * Destructor
+ */
+ ~mprefix_t();
+
+ /**
+ * Get the address
+ */
+ const boost::asio::ip::address& grp_address() const;
+ const boost::asio::ip::address& src_address() const;
+
+ /**
+ * Get the network mask width
+ */
+ uint8_t mask_width() const;
+
+ /**
+ * Assignement
+ */
+ mprefix_t& operator=(const mprefix_t&);
+
+ /**
+ * Less than operator
+ */
+ bool operator<(const mprefix_t& o) const;
+
+ /**
+ * equals operator
+ */
+ bool operator==(const mprefix_t& o) const;
+
+ /**
+ * not equal opartor
+ */
+ bool operator!=(const mprefix_t& o) const;
+
+ /**
+ * convert to string format for debug purposes
+ */
+ std::string to_string() const;
+
+ /**
+ * The all Zeros prefix
+ */
+ const static mprefix_t ZERO;
+
+ /**
+ * The all Zeros v6 prefix
+ */
+ const static mprefix_t ZEROv6;
+
+ /**
+ * Get the L3 protocol
+ */
+ l3_proto_t l3_proto() const;
+
+private:
+ /**
+ * The address
+ */
+ boost::asio::ip::address m_gaddr;
+ boost::asio::ip::address m_saddr;
+
+ /**
+ * The prefix length
+ */
+ uint8_t m_len;
};
+}; // namespace route
+
boost::asio::ip::address_v4 operator|(const boost::asio::ip::address_v4& addr1,
const boost::asio::ip::address_v4& addr2);
/**
* Convert a VPP byte stinrg into a boost addresss
*/
-boost::asio::ip::address from_bytes(uint8_t is_ip6, uint8_t* array);
+boost::asio::ip::address from_bytes(uint8_t is_ip6, const uint8_t* array);
};
/*