24 singular_db<interface_span::key_t, interface_span> interface_span::m_db;
31 : m_itf_from(itf_from.singular())
32 , m_itf_to(itf_to.singular())
39 : m_itf_from(o.m_itf_from)
40 , m_itf_to(o.m_itf_to)
42 , m_config(o.m_config)
51 m_db.release(make_pair(m_itf_from->key(), m_itf_to->key()),
this);
55 interface_span::sweep()
59 m_config, m_itf_from->handle(), m_itf_to->handle()));
71 interface_span::replay()
75 m_config, m_itf_from->handle(), m_itf_to->handle(), m_state));
83 s <<
"Itf Span-config:" 84 <<
" itf-from:" << m_itf_from->to_string()
85 <<
" itf-to:" << m_itf_to->to_string() <<
" state:" << m_state.
to_string();
95 m_config, m_itf_from->handle(), m_itf_to->handle(), m_state));
102 os <<
"[" << key.first <<
", " << key.second <<
"]";
107 std::shared_ptr<interface_span>
110 return (m_db.find_or_add(
111 make_pair(temp.m_itf_from->key(), temp.m_itf_to->key()), temp));
114 std::shared_ptr<interface_span>
117 return find_or_add(*
this);
128 interface_span::event_handler::handle_replay()
136 std::shared_ptr<interface_span_cmds::dump_cmd>
cmd =
137 std::make_shared<interface_span_cmds::dump_cmd>();
142 for (
auto& record : *cmd) {
143 auto& payload = record.get_payload();
145 std::shared_ptr<interface> itf_from =
147 std::shared_ptr<interface> itf_to =
interface::find(payload.sw_if_index_to);
153 << itf_to->to_string()
166 interface_span::event_handler::order()
const 186 interface_span::state_t::state_t(
int v,
const std::string& s)
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
A template base class for all enum types.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
static const state_t TX_ENABLED
TX enable state.
static rc_t write()
Write/Execute all commands hitherto enqueued.
static const log_level_t DEBUG
static const state_t TX_RX_ENABLED
TX and RX enable state.
std::shared_ptr< interface_span > singular() const
Return the 'singular instance' of the interface_span that matches this object.
A command class that configures the interface span.
A cmd class that Unconfigs interface span.
std::string to_string() const
convert to string format for debug purposes
static const state_t DISABLED
DISABLED state.
static void dump(std::ostream &os)
Dump all interface_spans into the stream provided.
A representation of an interface in VPP.
std::pair< interface::key_t, interface::key_t > key_t
The key type for interface_spans.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
static void enqueue(cmd *f)
Enqueue A command for execution.
vhost_vring_state_t state
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
Then L2/objects that bind to interfaces, BD, ACLS, etc.
The VPP Object Model (VOM) library.
A representation of a method call to VPP.
~interface_span()
Destructor.
static state_t from_int(uint8_t val)
Convert VPP's numerical value to enum type.
interface_span(const interface &itf_from, const interface &itf_to, state_t state)
Construct a new object matching the desried state.
static const state_t RX_ENABLED
RX enable state.
const std::string & to_string() const
convert to string format for debug purposes
A representation of interface span configuration.
static bool register_listener(listener *listener)
Register a listener of events.
The state of the interface - rx/tx or both to be mirrored.