summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/bridge_domain_arp_entry.cpp
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2017-11-23 12:15:00 -0800
committerNeale Ranns <nranns@cisco.com>2017-11-24 14:04:48 +0000
commitfd920609819a5b10d3d7c8d34fe4fa4214c7da22 (patch)
treefb0b5c3b5a9ba56308ef704ef922e959aafad17f /src/vpp-api/vom/bridge_domain_arp_entry.cpp
parent227bf211ab65e7aed6862fc881cc949c342200fd (diff)
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>
Diffstat (limited to 'src/vpp-api/vom/bridge_domain_arp_entry.cpp')
-rw-r--r--src/vpp-api/vom/bridge_domain_arp_entry.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/vpp-api/vom/bridge_domain_arp_entry.cpp b/src/vpp-api/vom/bridge_domain_arp_entry.cpp
index ee34dbbce5b..e8ae30f7642 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::event_handler bridge_domain_arp_entry::m_evh;
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 @@ bridge_domain_arp_entry::bridge_domain_arp_entry(
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 @@ bridge_domain_arp_entry::~bridge_domain_arp_entry()
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 @@ bridge_domain_arp_entry::update(const bridge_domain_arp_entry& r)
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 @@ bridge_domain_arp_entry::dump(std::ostream& os)
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);