vom: Add support for BVI interface
[vpp.git] / extras / vom / vom / interface.cpp
index 504511e..40f9607 100644 (file)
@@ -275,13 +275,17 @@ interface::key() const
 std::queue<cmd*>&
 interface::mk_create_cmd(std::queue<cmd*>& q)
 {
-  if ((type_t::LOOPBACK == m_type) || (type_t::BVI == m_type)) {
+  if (type_t::LOOPBACK == m_type) {
     q.push(new interface_cmds::loopback_create_cmd(m_hdl, m_name));
     q.push(new interface_cmds::set_tag(m_hdl, m_name));
     /*
      * set the m_tag for pretty-print
      */
     m_tag = m_name;
+  } else if (type_t::BVI == m_type) {
+    q.push(new interface_cmds::bvi_create_cmd(m_hdl, m_name));
+    q.push(new interface_cmds::set_tag(m_hdl, m_name));
+    m_tag = m_name;
   } else if (type_t::AFPACKET == m_type) {
     q.push(new interface_cmds::af_packet_create_cmd(m_hdl, m_name));
     if (!m_tag.empty())
@@ -301,8 +305,10 @@ interface::mk_create_cmd(std::queue<cmd*>& q)
 std::queue<cmd*>&
 interface::mk_delete_cmd(std::queue<cmd*>& q)
 {
-  if ((type_t::LOOPBACK == m_type) || (type_t::BVI == m_type)) {
+  if (type_t::LOOPBACK == m_type) {
     q.push(new interface_cmds::loopback_delete_cmd(m_hdl));
+  } else if (type_t::BVI == m_type) {
+    q.push(new interface_cmds::bvi_delete_cmd(m_hdl));
   } else if (type_t::AFPACKET == m_type) {
     q.push(new interface_cmds::af_packet_delete_cmd(m_hdl, m_name));
   } else if (type_t::VHOST == m_type) {
@@ -394,9 +400,7 @@ interface::set(const admin_state_t& state)
 void
 interface::set(const l2_address_t& addr)
 {
-  assert(rc_t::UNSET == m_l2_address.rc());
-  m_l2_address.set(rc_t::NOOP);
-  m_l2_address.update(addr);
+  m_l2_address = { addr, rc_t::NOOP };
 }
 
 void
@@ -418,12 +422,14 @@ interface::set(const std::string& tag)
 }
 
 void
-interface::set(counter_t count, const std::string& stat_type)
+interface::set(const counter_t& count, const std::string& stat_type)
 {
   if ("rx" == stat_type)
     m_stats.m_rx = count;
   else if ("tx" == stat_type)
     m_stats.m_tx = count;
+  else if ("drops" == stat_type)
+    m_stats.m_drop = count;
   else if ("rx-unicast" == stat_type)
     m_stats.m_rx_unicast = count;
   else if ("tx-unicast" == stat_type)
@@ -454,22 +460,12 @@ std::ostream&
 operator<<(std::ostream& os, const interface::stats_t& stats)
 {
   os << "["
-     << "rx [packets " << stats.m_rx.packets << ", bytes " << stats.m_rx.bytes
-     << "]"
-     << " rx-unicast [packets " << stats.m_rx_unicast.packets << ", bytes "
-     << stats.m_rx_unicast.bytes << "]"
-     << " rx-multicast [packets " << stats.m_rx_multicast.packets << ", bytes "
-     << stats.m_rx_multicast.bytes << "]"
-     << " rx-broadcast [packets " << stats.m_rx_broadcast.packets << ", bytes "
-     << stats.m_rx_broadcast.bytes << "]"
-     << " tx [packets " << stats.m_tx.packets << ", bytes " << stats.m_tx.bytes
-     << "]"
-     << " tx-unicast [packets " << stats.m_tx_unicast.packets << ", bytes "
-     << stats.m_tx_unicast.bytes << "]"
-     << " tx-multicast [packets " << stats.m_tx_multicast.packets << ", bytes "
-     << stats.m_tx_multicast.bytes << "]"
-     << " tx-broadcast [packets " << stats.m_tx_broadcast.packets << ", bytes "
-     << stats.m_tx_broadcast.bytes << "]]" << std::endl;
+     << "rx " << stats.m_rx << " rx-unicast " << stats.m_rx_unicast
+     << " rx-multicast " << stats.m_rx_multicast << " rx-broadcast "
+     << stats.m_rx_broadcast << " tx " << stats.m_tx << " tx-unicast "
+     << stats.m_tx_unicast << " tx-multicast " << stats.m_tx_multicast
+     << " tx-broadcast " << stats.m_tx_broadcast << " drops " << stats.m_drop
+     << "]" << std::endl;
 
   return (os);
 }