GBP V2
[vpp.git] / src / vpp-api / vom / types.cpp
index c5325d2..c6093eb 100644 (file)
@@ -28,9 +28,6 @@ rc_t::rc_t(int v, const std::string s)
   : enum_base<rc_t>(v, s)
 {
 }
-rc_t::~rc_t()
-{
-}
 
 const rc_t&
 rc_t::from_vpp_retval(int32_t rv)
@@ -39,7 +36,11 @@ rc_t::from_vpp_retval(int32_t rv)
     return (rc_t::OK);
   }
   if (-68 == rv) {
-    // interface laready exists
+    // sub interface already exists
+    return (rc_t::OK);
+  }
+  if (-79 == rv) {
+    // interface already exists
     return (rc_t::OK);
   }
 
@@ -49,9 +50,8 @@ rc_t::from_vpp_retval(int32_t rv)
 const rc_t rc_t::UNSET(0, "un-set");
 const rc_t rc_t::NOOP(1, "no-op");
 const rc_t rc_t::OK(2, "ok");
-const rc_t rc_t::INPROGRESS(3, "in-progess");
-const rc_t rc_t::INVALID(4, "invalid");
-const rc_t rc_t::TIMEOUT(5, "timeout");
+const rc_t rc_t::INVALID(3, "invalid");
+const rc_t rc_t::TIMEOUT(4, "timeout");
 
 const handle_t handle_t::INVALID(~0);
 
@@ -95,6 +95,12 @@ handle_t::value() const
   return (m_value);
 }
 
+void
+handle_t::reset()
+{
+  m_value = ~0;
+}
+
 std::ostream&
 operator<<(std::ostream& os, const handle_t& h)
 {
@@ -262,8 +268,64 @@ direction_t::direction_t(int v, const std::string s)
   : enum_base(v, s)
 {
 }
+std::ostream&
+operator<<(std::ostream& os, const direction_t& dir)
+{
+  os << dir.to_string();
+  return os;
+}
+
+const ethertype_t ethertype_t::ARP(0x0806, "arp");
+const ethertype_t ethertype_t::FCOE(0x8906, "fcoe");
+const ethertype_t ethertype_t::IPV4(0x0800, "ipv4");
+const ethertype_t ethertype_t::IPV6(0x86DD, "ipv6");
+const ethertype_t ethertype_t::MAC_SECURITY(0x88E5, "mac-security");
+const ethertype_t ethertype_t::MPLS_UNICAST(0x8847, "mpls-unicast");
+const ethertype_t ethertype_t::TRILL(0x22F3, "trill");
+const ethertype_t ethertype_t::UNSPECIFIED(0x0, "unspecified");
+
+ethertype_t::ethertype_t(int v, const std::string s)
+  : enum_base(v, s)
+{
 }
 
+std::ostream&
+operator<<(std::ostream& os, const ethertype_t& ether)
+{
+  os << ether.to_string();
+  return os;
+}
+
+const ethertype_t&
+ethertype_t::from_numeric_val(uint16_t numeric)
+{
+  if (0x0806 == numeric) {
+    return (ethertype_t::ARP);
+  }
+  if (0x8906 == numeric) {
+    return (ethertype_t::FCOE);
+  }
+  if (0x0800 == numeric) {
+    return (ethertype_t::IPV4);
+  }
+  if (0x86DD == numeric) {
+    return (ethertype_t::IPV6);
+  }
+  if (0x88E5 == numeric) {
+    return (ethertype_t::MAC_SECURITY);
+  }
+  if (0x8847 == numeric) {
+    return (ethertype_t::MPLS_UNICAST);
+  }
+  if (0x22F3 == numeric) {
+    return (ethertype_t::TRILL);
+  }
+
+  return (ethertype_t::UNSPECIFIED);
+}
+
+}; // namespace VOM
+
 /*
  * fd.io coding-style-patch-verification: ON
  *