dhcp ip: DSCP settings for transmitted DHCP packets
[vpp.git] / extras / vom / vom / prefix.hpp
index 8365541..fada1d3 100644 (file)
@@ -56,8 +56,8 @@ public:
   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);
 
@@ -75,6 +75,45 @@ private:
  */
 std::ostream& operator<<(std::ostream& os, const l3_proto_t& l3p);
 
+/**
+ * IP DSCP values
+ */
+class ip_dscp_t : public enum_base<ip_dscp_t>
+{
+public:
+  /* unfortunately some of the CSX names are defined in terminos.h
+   * as macros, hence the longer names */
+  const static ip_dscp_t DSCP_CS0;
+  const static ip_dscp_t DSCP_CS1;
+  const static ip_dscp_t DSCP_CS2;
+  const static ip_dscp_t DSCP_CS3;
+  const static ip_dscp_t DSCP_CS4;
+  const static ip_dscp_t DSCP_CS5;
+  const static ip_dscp_t DSCP_CS6;
+  const static ip_dscp_t DSCP_CS7;
+  const static ip_dscp_t DSCP_AF11;
+  const static ip_dscp_t DSCP_AF12;
+  const static ip_dscp_t DSCP_AF13;
+  const static ip_dscp_t DSCP_AF21;
+  const static ip_dscp_t DSCP_AF22;
+  const static ip_dscp_t DSCP_AF23;
+  const static ip_dscp_t DSCP_AF31;
+  const static ip_dscp_t DSCP_AF32;
+  const static ip_dscp_t DSCP_AF33;
+  const static ip_dscp_t DSCP_AF41;
+  const static ip_dscp_t DSCP_AF42;
+  const static ip_dscp_t DSCP_AF43;
+  const static ip_dscp_t DSCP_EF;
+
+  /**
+   * Constructor allows the creation of any DSCP value
+   */
+  ip_dscp_t(int v);
+
+private:
+  ip_dscp_t(int v, const std::string& s);
+};
+
 namespace route {
 /**
  * type def the table-id
@@ -171,8 +210,8 @@ public:
   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;
 
   /**
@@ -206,8 +245,115 @@ private:
    */
   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);
 
@@ -254,7 +400,7 @@ uint32_t mask_width(const boost::asio::ip::address& addr);
 /**
  * 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);
 };
 
 /*