X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fvom%2Fvom%2Fprefix.hpp;h=fada1d3e2749c080f4713f0dd693991bd299ef81;hb=038e1dfbd;hp=3950f6fd0366fc13198163223897b392e04d25fb;hpb=164e5f8c63652028ecb9c3570e1ea8618b163071;p=vpp.git diff --git a/extras/vom/vom/prefix.hpp b/extras/vom/vom/prefix.hpp index 3950f6fd036..fada1d3e274 100644 --- a/extras/vom/vom/prefix.hpp +++ b/extras/vom/vom/prefix.hpp @@ -16,9 +16,8 @@ #ifndef __VOM_PREFIX_H__ #define __VOM_PREFIX_H__ -#include - #include "vom/enum_base.hpp" +#include namespace VOM { /** @@ -57,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); @@ -76,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 +{ +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 @@ -111,10 +149,12 @@ public: * 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 */ @@ -170,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; /** @@ -205,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); @@ -253,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); }; /*