32 std::map<handle_t, std::weak_ptr<interface>> interface::m_hdl_db;
34 interface::event_handler interface::m_evh;
61 , m_table_id(m_rd->table_id())
73 , m_table_id(o.m_table_id)
74 , m_l2_address(o.m_l2_address)
82 return ((
key() == i.
key()) &&
83 (m_l2_address.
data() == i.m_l2_address.
data()) &&
84 (m_state == i.m_state) && (m_rd == i.m_rd) && (m_type == i.m_type) &&
85 (m_oper == i.m_oper));
89 : m_status(
rc_t::NOOP)
126 interface::handle_i()
const 134 return (m_l2_address.data());
140 return m_db.cbegin();
172 std::queue<cmd*> cmds;
182 std::queue<cmd*> cmds;
208 m_db.release(m_name,
this);
214 std::ostringstream s;
215 s <<
"interface:[" << m_name <<
" type:" << m_type.to_string()
217 << m_l2_address.to_string() <<
"]";
220 s <<
" rd:" << m_rd->to_string();
223 s <<
" admin-state:" << m_state.to_string()
224 <<
" oper-state:" << m_oper.to_string() <<
"]";
275 interface::update(
const interface& desired)
281 std::queue<cmd*> cmds;
298 if (m_state.update(desired.m_state)) {
305 if (m_l2_address.update(desired.m_l2_address)) {
313 if (m_rd != desired.m_rd) {
321 if (it->second.lock()->itf().key() ==
key())
322 it->second.lock()->sweep();
335 if (it->second.lock()->itf().key() ==
key())
336 it->second.lock()->replay();
339 }
else if (!m_table_id && m_rd) {
352 m_l2_address.update(addr);
383 std::shared_ptr<interface>
386 return (
m_db.find_or_add(
key(), *
this));
389 std::shared_ptr<interface>
395 std::shared_ptr<interface>
398 return (
m_db.find(k));
401 std::shared_ptr<interface>
404 return (m_hdl_db[handle].lock());
410 std::shared_ptr<interface> sp =
find(key);
413 m_hdl_db[item.
data()] = sp;
420 m_hdl_db.erase(item.
data());
435 std::shared_ptr<interface_cmds::dump_cmd>
cmd =
436 std::make_shared<interface_cmds::dump_cmd>();
441 for (
auto& itf_record : *cmd) {
442 std::shared_ptr<interface> itf =
457 std::shared_ptr<l3_binding_cmds::dump_v4_cmd> dcmd =
458 std::make_shared<l3_binding_cmds::dump_v4_cmd>(
464 for (
auto& l3_record : *dcmd) {
465 auto& payload = l3_record.get_payload();
467 payload.prefix_length);
478 interface::event_handler::event_handler()
485 interface::event_handler::handle_replay()
491 interface::event_handler::order()
const static const rc_t NOOP
The HW write/update action was/has not been attempted.
void release()
release/remove an interface form the singular store
sll srl srl sll sra u16x4 i
A command class represents our desire to recieve interface stats.
virtual ~interface()
Destructor.
static void dump(std::ostream &os)
Dump all interfaces into the stream provided.
static const type_t AFPACKET
AF-Packet interface type.
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.
HW::item< handle_t > m_hdl
The SW interface handle VPP has asigned to the interface.
virtual void sweep(void)
Sweep/reap the object if still stale.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
static rc_t write()
Write/Execute all commands hitherto enqueued.
HW::item< bool > & status()
Return the HW::item representing the status.
A command class to set tag on interfaces.
Error codes that VPP will return during a HW write.
static const log_level_t DEBUG
static const_iterator_t cbegin()
A command class to create TAP interfaces in VPP.
std::string to_string() const
convert to string format for debug purposes
const handle_t & handle() const
Return VPP's handle to this object.
The oper state of the interface.
Type def of a L2 address as read from VPP.
T & data()
Return the data read/written.
static const_iterator_t cbegin()
static singular_db< key_t, interface > m_db
A map of all interfaces key against the interface's name.
static const type_t LOCAL
Local interface type (specific to VPP)
A command class that binds an interface to an L3 table.
rc_t rc() const
Get the HW return code.
static const l3_proto_t IPV4
static const_iterator_t cend()
static const l3_proto_t IPV6
HW::item< bool > m_status
The status of the subscription.
A command class to delete TAP interfaces in VPP.
static const table_id_t DEFAULT_TABLE
The table-id for the default table.
virtual std::queue< cmd * > & mk_create_cmd(std::queue< cmd * > &cmds)
Virtual functions to construct an interface create commands.
std::string to_string() const
convert to string format for debug purposes
static void remove(const HW::item< handle_t > &item)
remove an interface from the DB keyed on handle
event_listener()
Default Constructor.
const l2_address_t & l2_address() const
Return the L2 Address.
A class that listens to interface Stats.
stat_listener()
Default Constructor.
virtual bool operator==(const interface &i) const
Comparison operator - only used for UT.
static std::shared_ptr< interface > new_interface(const vapi_payload_sw_interface_details &vd)
Factory method to construct a new interface from the VPP record.
A command class to create Loopback interfaces in VPP.
A cmd class that changes the admin state.
static void add(const key_t &name, const HW::item< handle_t > &item)
Add an interface to the DB keyed on handle.
A command class that binds an interface to an L3 table.
The admin state of the interface.
A representation of an interface in VPP.
HW::item< bool > & status()
Return the HW::item representing the status.
A command class to create af_packet interfaces in VPP.
A type declaration of an interface handle in VPP.
std::shared_ptr< interface > singular() const
Return the matching'singular' of the interface.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
static const rc_t OK
The HW write was successfull.
const std::string & name() const
Return the interface type.
static void enqueue(cmd *f)
Enqueue A command for execution.
virtual std::shared_ptr< interface > singular_i() const
Return the matching 'singular' of the interface.
vhost_vring_state_t state
A cmd class that Dumps all the IPv4 L3 configs.
A command class represents our desire to recieve interface stats.
virtual std::queue< cmd * > & mk_delete_cmd(std::queue< cmd * > &cmds)
Virtual functions to construct an interface delete commands.
interface(const std::string &name, type_t type, admin_state_t state)
Construct a new object matching the desried state.
A command class to delete af-packet interfaces in VPP.
The VPP Object Model (VOM) library.
A command class to delete loopback interfaces in VPP.
static const admin_state_t UP
Admin UP state.
A representation of a method call to VPP.
static const rc_t UNSET
The value un-set.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
static const type_t BVI
A brideged Virtual interface (aka SVI or IRB)
HW::item< bool > m_status
The status of the subscription.
void set(const l2_address_t &addr)
Set the L2 Address.
static const admin_state_t DOWN
Admin DOWN state.
A representation of L3 configuration on an interface.
static const type_t TAP
TAP interface type.
static const_iterator_t cend()
singular_db< const std::string, interface >::const_iterator const_iterator_t
The iterator type.
virtual std::string to_string(void) const
convert to string format for debug purposes
static const type_t LOOPBACK
loopback interface type
std::string key_t
The key for interface's key.
const type_t & type() const
Return the interface type.
static bool register_listener(listener *listener)
Register a listener of events.
const key_t & key() const
Return the interface type.
void enable_stats(stat_listener &el)
Enable stats for this interface.
interfaces are the root of the dependency graph