#include "vom/l2_binding.hpp"
namespace VOM {
+
+const bridge_domain::learning_mode_t bridge_domain::learning_mode_t::ON(1,
+ "on");
+const bridge_domain::learning_mode_t bridge_domain::learning_mode_t::OFF(0,
+ "off");
+
+bridge_domain::learning_mode_t::learning_mode_t(int v, const std::string& s)
+ : enum_base<bridge_domain::learning_mode_t>(v, s)
+{
+}
+
/**
* A DB of al the interfaces, key on the name
*/
/**
* Construct a new object matching the desried state
*/
-bridge_domain::bridge_domain(uint32_t id)
+bridge_domain::bridge_domain(uint32_t id, const learning_mode_t& lmode)
: m_id(id)
+ , m_learning_mode(lmode)
{
}
bridge_domain::bridge_domain(const bridge_domain& o)
: m_id(o.m_id)
+ , m_learning_mode(o.m_learning_mode)
{
}
bridge_domain::replay()
{
if (rc_t::OK == m_id.rc()) {
- HW::enqueue(new bridge_domain_cmds::create_cmd(m_id));
+ HW::enqueue(new bridge_domain_cmds::create_cmd(m_id, m_learning_mode));
}
}
* the desired state is always that the interface should be created
*/
if (rc_t::OK != m_id.rc()) {
- HW::enqueue(new bridge_domain_cmds::create_cmd(m_id));
+ HW::enqueue(new bridge_domain_cmds::create_cmd(m_id, m_learning_mode));
}
}
class bridge_domain : public object_base
{
public:
+ /**
+ * Bridge Domain Learning mode
+ */
+ struct learning_mode_t : enum_base<learning_mode_t>
+ {
+ const static learning_mode_t ON;
+ const static learning_mode_t OFF;
+
+ private:
+ /**
+ * Private constructor taking the value and the string name
+ */
+ learning_mode_t(int v, const std::string& s);
+ };
+
/**
* The value of the defaultbridge domain
*/
/**
* Construct a new object matching the desried state
*/
- bridge_domain(uint32_t id);
+ bridge_domain(uint32_t id,
+ const learning_mode_t& lmode = learning_mode_t::ON);
+
/**
* Copy Constructor
*/
bridge_domain(const bridge_domain& o);
+
/**
* Destructor
*/
*/
HW::item<uint32_t> m_id;
+ /**
+ * The leanring mode of the bridge
+ */
+ learning_mode_t m_learning_mode;
+
/**
* A map of all interfaces key against the interface's name
*/
namespace VOM {
namespace bridge_domain_cmds {
-create_cmd::create_cmd(HW::item<uint32_t>& item)
+create_cmd::create_cmd(HW::item<uint32_t>& item,
+ const bridge_domain::learning_mode_t& lmode)
: rpc_cmd(item)
+ , m_learning_mode(lmode)
{
}
payload.flood = 1;
payload.uu_flood = 1;
payload.forward = 1;
- payload.learn = 1;
+ payload.learn = m_learning_mode.value();
payload.arp_term = 1;
payload.mac_age = 0;
payload.is_add = 1;
/**
* Constructor
*/
- create_cmd(HW::item<uint32_t>& item);
+ create_cmd(HW::item<uint32_t>& item,
+ const bridge_domain::learning_mode_t& lmode);
/**
* Issue the command to VPP/HW
* Comparison operator - only used for UT
*/
bool operator==(const create_cmd& i) const;
+
+private:
+ /**
+ * the learning mode for the bridge
+ */
+ bridge_domain::learning_mode_t m_learning_mode;
};
/**
#include <deque>
#include <map>
+#include <memory>
#include <ostream>
#include <string>
+#include <vector>
namespace VOM {
/**
namespace VOM {
namespace route {
+ip_route::event_handler ip_route::m_evh;
singular_db<ip_route::key_t, ip_route> ip_route::m_db;
const path::special_t path::special_t::STANDARD(0, "standard");
#include "vom/route_domain_cmds.hpp"
namespace VOM {
+
+route_domain::event_handler route_domain::m_evh;
+
/**
* A DB of al the interfaces, key on the name
*/
{
m_db.dump(os);
}
+
+void
+route_domain::event_handler::handle_populate(const client_db::key_t& key)
+{
+}
+
+route_domain::event_handler::event_handler()
+{
+ OM::register_listener(this);
+ inspect::register_handler({ "rd", "route-domain" }, "Route Domains", this);
+}
+
+void
+route_domain::event_handler::handle_replay()
+{
+ m_db.replay();
+}
+
+dependency_t
+route_domain::event_handler::order() const
+{
+ return (dependency_t::TABLE);
}
+
+void
+route_domain::event_handler::show(std::ostream& os)
+{
+ m_db.dump(os);
+}
+
+}; // namespace VOPM
+
/*
* fd.io coding-style-patch-verification: ON
*
#ifndef __VOM_ROUTE_DOMAIN_H__
#define __VOM_ROUTE_DOMAIN_H__
+#include "vom/inspect.hpp"
#include "vom/object_base.hpp"
#include "vom/om.hpp"
#include "vom/prefix.hpp"
void replay(void);
private:
+ /**
+ * Class definition for listeners to OM events
+ */
+ class event_handler : public OM::listener, public inspect::command_handler
+ {
+ public:
+ event_handler();
+ virtual ~event_handler() = default;
+
+ /**
+ * Handle a populate event
+ */
+ void handle_populate(const client_db::key_t& key);
+
+ /**
+ * Handle a replay event
+ */
+ void handle_replay();
+
+ /**
+ * Show the object in the Singular DB
+ */
+ void show(std::ostream& os);
+
+ /**
+ * Get the sortable Id of the listener
+ */
+ dependency_t order() const;
+ };
+
+ /**
+ * Instance of the event handler to register with OM
+ */
+ static event_handler m_evh;
+
/**
* Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
*/
bridge_domain bd1(33);
HW::item<uint32_t> hw_bd(33, rc_t::OK);
- ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd));
+ ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::ON));
TRY_CHECK_RC(OM::write(franz, bd1));
TRY_CHECK_RC(OM::write(franz, vxt));
// bridge-domain create
- bridge_domain bd1(33);
+ bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF);
HW::item<uint32_t> hw_bd(33, rc_t::OK);
- ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd));
+ ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd, bridge_domain::learning_mode_t::OFF));
TRY_CHECK_RC(OM::write(franz, bd1));