*/
#include "vom/dhcp_config.hpp"
-#include "vom/cmd.hpp"
+#include "vom/dhcp_config_cmds.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)
{
}
: 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)
{
}
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();
}
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));
}
}
* 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));
}
}
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
{