Fixes for 'make UNATTENDED=yes CC=clang CXX=clang verify'
[vpp.git] / src / vpp-api / vom / dhcp_config.cpp
index bf9b036..7d97fa1 100644 (file)
  */
 
 #include "vom/dhcp_config.hpp"
-#include "vom/cmd.hpp"
+#include "vom/dhcp_config_cmds.hpp"
+#include "vom/singular_db_funcs.hpp"
 
 namespace VOM {
 /**
  * A DB of all DHCP configs
  */
-singular_db<interface::key_type, dhcp_config> dhcp_config::m_db;
+singular_db<interface::key_t, dhcp_config> dhcp_config::m_db;
 
 dhcp_config::event_handler dhcp_config::m_evh;
 
-dhcp_config::dhcp_config(const interface& itf, const std::string& hostname)
+dhcp_config::dhcp_config(const interface& itf,
+                         const std::string& hostname,
+                         bool set_broadcast_flag)
   : m_itf(itf.singular())
   , m_hostname(hostname)
   , m_client_id(l2_address_t::ZERO)
+  , m_set_broadcast_flag(set_broadcast_flag)
   , m_binding(0)
 {
 }
 
 dhcp_config::dhcp_config(const interface& itf,
                          const std::string& hostname,
-                         const l2_address_t& client_id)
+                         const l2_address_t& client_id,
+                         bool set_broadcast_flag)
   : m_itf(itf.singular())
   , m_hostname(hostname)
   , m_client_id(client_id)
+  , m_set_broadcast_flag(set_broadcast_flag)
   , m_binding(0)
 {
 }
@@ -46,6 +52,7 @@ dhcp_config::dhcp_config(const dhcp_config& o)
   : m_itf(o.m_itf)
   , m_hostname(o.m_hostname)
   , m_client_id(o.m_client_id)
+  , m_set_broadcast_flag(o.m_set_broadcast_flag)
   , m_binding(0)
 {
 }
@@ -58,11 +65,25 @@ dhcp_config::~dhcp_config()
   m_db.release(m_itf->key(), this);
 }
 
+bool
+dhcp_config::operator==(const dhcp_config& l) const
+{
+  return ((key() == l.key()) && (m_hostname == l.m_hostname) &&
+          (m_client_id == l.m_client_id));
+}
+
+const dhcp_config::key_t&
+dhcp_config::key() const
+{
+  return (m_itf->key());
+}
+
 void
 dhcp_config::sweep()
 {
   if (m_binding) {
-    HW::enqueue(new unbind_cmd(m_binding, m_itf->handle(), m_hostname));
+    HW::enqueue(
+      new dhcp_config_cmds::unbind_cmd(m_binding, m_itf->handle(), m_hostname));
   }
   HW::write();
 }
@@ -70,15 +91,15 @@ dhcp_config::sweep()
 void
 dhcp_config::dump(std::ostream& os)
 {
-  m_db.dump(os);
+  db_dump(m_db, os);
 }
 
 void
 dhcp_config::replay()
 {
   if (m_binding) {
-    HW::enqueue(
-      new bind_cmd(m_binding, m_itf->handle(), m_hostname, m_client_id));
+    HW::enqueue(new dhcp_config_cmds::bind_cmd(m_binding, m_itf->handle(),
+                                               m_hostname, m_client_id));
   }
 }
 
@@ -99,8 +120,8 @@ dhcp_config::update(const dhcp_config& desired)
  * the desired state is always that the interface should be created
  */
   if (!m_binding) {
-    HW::enqueue(
-      new bind_cmd(m_binding, m_itf->handle(), m_hostname, m_client_id));
+    HW::enqueue(new dhcp_config_cmds::bind_cmd(m_binding, m_itf->handle(),
+                                               m_hostname, m_client_id));
   }
 }
 
@@ -110,6 +131,12 @@ dhcp_config::find_or_add(const dhcp_config& temp)
   return (m_db.find_or_add(temp.m_itf->key(), temp));
 }
 
+std::shared_ptr<dhcp_config>
+dhcp_config::find(const key_t& k)
+{
+  return (m_db.find(k));
+}
+
 std::shared_ptr<dhcp_config>
 dhcp_config::singular() const
 {
@@ -154,7 +181,7 @@ dhcp_config::event_handler::order() const
 void
 dhcp_config::event_handler::show(std::ostream& os)
 {
-  m_db.dump(os);
+  db_dump(m_db, os);
 }
 }