VOM: stats
[vpp.git] / extras / vom / vom / interface.cpp
index bbbc187..f2f32b4 100644 (file)
@@ -58,6 +58,8 @@ interface::interface(const std::string& name,
   , m_table_id(route::DEFAULT_TABLE)
   , m_l2_address(l2_address_t::ZERO, rc_t::UNSET)
   , m_stats_type(stats_type_t::NORMAL)
+  , m_stats({})
+  , m_listener(nullptr)
   , m_oper(oper_state_t::DOWN)
   , m_tag(tag)
 {
@@ -76,6 +78,8 @@ interface::interface(const std::string& name,
   , m_table_id(m_rd->table_id())
   , m_l2_address(l2_address_t::ZERO, rc_t::UNSET)
   , m_stats_type(stats_type_t::NORMAL)
+  , m_stats({})
+  , m_listener(nullptr)
   , m_oper(oper_state_t::DOWN)
   , m_tag(tag)
 {
@@ -90,6 +94,8 @@ interface::interface(const interface& o)
   , m_table_id(o.m_table_id)
   , m_l2_address(o.m_l2_address)
   , m_stats_type(o.m_stats_type)
+  , m_stats(o.m_stats)
+  , m_listener(o.m_listener)
   , m_oper(o.m_oper)
   , m_tag(o.m_tag)
 {
@@ -177,7 +183,7 @@ interface::sweep()
   }
 
   if (m_listener) {
-    disable_stats();
+    disable_stats_i();
   }
 
   // If the interface is up, bring it down
@@ -412,12 +418,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)
@@ -448,22 +456,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);
 }