Fixes for 'make UNATTENDED=yes CC=clang CXX=clang verify'
[vpp.git] / src / vpp-api / vom / acl_ethertype.cpp
index 043f0b0..9092517 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "vom/acl_ethertype.hpp"
 #include "vom/acl_ethertype_cmds.hpp"
+#include "vom/singular_db_funcs.hpp"
 
 namespace VOM {
 namespace ACL {
@@ -95,6 +96,10 @@ acl_ethertype::~acl_ethertype()
 void
 acl_ethertype::sweep()
 {
+  if (m_binding) {
+    HW::enqueue(new acl_ethertype_cmds::unbind_cmd(m_binding, m_itf->handle()));
+  }
+  HW::write();
 }
 
 const acl_ethertype::key_t&
@@ -118,7 +123,7 @@ acl_ethertype::find(const key_t& key)
 void
 acl_ethertype::dump(std::ostream& os)
 {
-  m_db.dump(os);
+  db_dump(m_db, os);
 }
 
 void
@@ -187,7 +192,41 @@ acl_ethertype::event_handler::handle_replay()
 void
 acl_ethertype::event_handler::handle_populate(const client_db::key_t& key)
 {
-  // FIXME
+  /*
+   * dump VPP acl ethertypes
+   */
+  std::shared_ptr<acl_ethertype_cmds::dump_cmd> cmd =
+    std::make_shared<acl_ethertype_cmds::dump_cmd>(~0);
+
+  HW::enqueue(cmd);
+  HW::write();
+
+  for (auto& record : *cmd) {
+    auto& payload = record.get_payload();
+    handle_t hdl(payload.sw_if_index);
+    std::shared_ptr<interface> itf = interface::find(hdl);
+    uint8_t n_input = payload.n_input;
+    uint8_t count = payload.count;
+    ethertype_rules_t ler;
+    if (itf) {
+      for (int i = 0; i < count; i++) {
+        ethertype_t e = ethertype_t::from_numeric_val(payload.whitelist[i]);
+        if (n_input) {
+          ethertype_rule_t er(e, direction_t::INPUT);
+          ler.insert(er);
+          n_input--;
+        } else {
+          ethertype_rule_t er(e, direction_t::OUTPUT);
+          ler.insert(er);
+        }
+      }
+      if (!ler.empty()) {
+        acl_ethertype a_e(*itf, ler);
+        VOM_LOG(log_level_t::DEBUG) << "ethertype dump: " << a_e.to_string();
+        OM::commit(key, a_e);
+      }
+    }
+  }
 }
 
 dependency_t
@@ -199,7 +238,7 @@ acl_ethertype::event_handler::order() const
 void
 acl_ethertype::event_handler::show(std::ostream& os)
 {
-  m_db.dump(os);
+  db_dump(m_db, os);
 }
 };
 };