VOM: Additions to allow uses to UT applications that use VOM
- find object by key
- compare objects
Change-Id: I36ec8612be9482bcef7ceced2a59f7403f77b3e8
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
diff --git a/src/vpp-api/vom/bridge_domain_arp_entry.cpp b/src/vpp-api/vom/bridge_domain_arp_entry.cpp
index ee34dbb..e8ae30f 100644
--- a/src/vpp-api/vom/bridge_domain_arp_entry.cpp
+++ b/src/vpp-api/vom/bridge_domain_arp_entry.cpp
@@ -25,22 +25,22 @@
bridge_domain_arp_entry::bridge_domain_arp_entry(
const bridge_domain& bd,
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+ const boost::asio::ip::address& ip_addr,
+ const mac_address_t& mac)
: m_hw(false)
, m_bd(bd.singular())
- , m_mac(mac)
, m_ip_addr(ip_addr)
+ , m_mac(mac)
{
}
bridge_domain_arp_entry::bridge_domain_arp_entry(
- const mac_address_t& mac,
- const boost::asio::ip::address& ip_addr)
+ const boost::asio::ip::address& ip_addr,
+ const mac_address_t& mac)
: m_hw(false)
, m_bd(nullptr)
- , m_mac(mac)
, m_ip_addr(ip_addr)
+ , m_mac(mac)
{
/*
* the route goes in the default table
@@ -54,8 +54,8 @@
const bridge_domain_arp_entry& bde)
: m_hw(bde.m_hw)
, m_bd(bde.m_bd)
- , m_mac(bde.m_mac)
, m_ip_addr(bde.m_ip_addr)
+ , m_mac(bde.m_mac)
{
}
@@ -64,7 +64,19 @@
sweep();
// not in the DB anymore.
- m_db.release(std::make_tuple(m_bd->id(), m_mac, m_ip_addr), this);
+ m_db.release(key(), this);
+}
+
+const bridge_domain_arp_entry::key_t
+bridge_domain_arp_entry::key() const
+{
+ return (std::make_pair(m_bd->key(), m_ip_addr));
+}
+
+bool
+bridge_domain_arp_entry::operator==(const bridge_domain_arp_entry& bdae) const
+{
+ return ((key() == bdae.key()) && (m_mac == bdae.m_mac));
}
void
@@ -111,8 +123,13 @@
std::shared_ptr<bridge_domain_arp_entry>
bridge_domain_arp_entry::find_or_add(const bridge_domain_arp_entry& temp)
{
- return (m_db.find_or_add(
- std::make_tuple(temp.m_bd->id(), temp.m_mac, temp.m_ip_addr), temp));
+ return (m_db.find_or_add(temp.key(), temp));
+}
+
+std::shared_ptr<bridge_domain_arp_entry>
+bridge_domain_arp_entry::find(const key_t& k)
+{
+ return (m_db.find(k));
}
std::shared_ptr<bridge_domain_arp_entry>
@@ -127,15 +144,6 @@
m_db.dump(os);
}
-std::ostream&
-operator<<(std::ostream& os, const bridge_domain_arp_entry::key_t& key)
-{
- os << "[" << std::get<0>(key) << ", " << std::get<1>(key) << ", "
- << std::get<2>(key) << "]";
-
- return (os);
-}
-
bridge_domain_arp_entry::event_handler::event_handler()
{
OM::register_listener(this);