25 namespace interface_cmds {
27 const std::string&
name)
28 : create_cmd(item, name)
35 msg_t req(con.
ctx(), std::ref(*
this));
57 const std::string&
name)
65 msg_t req(con.
ctx(), std::ref(*
this));
67 auto& payload = req.get_request().get_payload();
69 payload.use_random_hw_addr = 1;
70 memset(payload.host_if_name, 0,
sizeof(payload.host_if_name));
71 memcpy(payload.host_if_name,
m_name.c_str(),
72 std::min(
m_name.length(),
sizeof(payload.host_if_name)));
94 const std::string&
name,
95 const std::string& tag)
104 msg_t req(con.
ctx(), std::ref(*
this));
106 auto& payload = req.get_request().get_payload();
107 memset(payload.sock_filename, 0,
sizeof(payload.sock_filename));
108 memcpy(payload.sock_filename,
m_name.c_str(),
109 std::min(
m_name.length(),
sizeof(payload.sock_filename)));
110 memset(payload.tag, 0,
sizeof(payload.tag));
113 memcpy(payload.tag, m_tag.c_str(),
114 std::min(m_tag.length(),
sizeof(payload.tag)));
116 payload.is_server = 0;
117 payload.use_custom_mac = 0;
118 payload.renumber = 0;
134 std::ostringstream s;
149 msg_t req(con.
ctx(), std::ref(*
this));
151 auto& payload = req.get_request().get_payload();
166 std::ostringstream s;
173 const std::string&
name)
181 msg_t req(con.
ctx(), std::ref(*
this));
183 auto& payload = req.get_request().get_payload();
184 memset(payload.host_if_name, 0,
sizeof(payload.host_if_name));
185 memcpy(payload.host_if_name,
m_name.c_str(),
186 std::min(
m_name.length(),
sizeof(payload.host_if_name)));
199 std::ostringstream s;
206 const std::string&
name)
214 msg_t req(con.
ctx(), std::ref(*
this));
216 auto& payload = req.get_request().get_payload();
229 std::ostringstream s;
251 msg_t req(con.
ctx(), std::ref(*
this));
253 auto& payload = req.get_request().get_payload();
254 payload.sw_if_index = m_hdl.
data().
value();
265 std::ostringstream s;
283 return ((m_hdl == other.m_hdl) && (m_proto == other.m_proto) &&
290 msg_t req(con.
ctx(), std::ref(*
this));
292 auto& payload = req.get_request().get_payload();
293 payload.sw_if_index = m_hdl.
data().
value();
294 payload.is_ipv6 = m_proto.
is_ipv6();
305 std::ostringstream s;
327 msg_t req(con.
ctx(), std::ref(*
this));
329 auto& payload = req.get_request().get_payload();
330 payload.sw_if_index = m_hdl.
data().
value();
332 sizeof(payload.mac_address));
342 std::ostringstream s;
362 (m_enable == other.m_enable));
368 msg_t req(con.
ctx(), std::ref(*
this));
370 auto& payload = req.get_request().get_payload();
371 payload.sw_if_index = m_hdl.
value();
372 payload.enable_disable = m_enable;
382 std::ostringstream s;
405 m_reg.reset(
new reg_t(con.
ctx(), std::ref(*(static_cast<event_cmd*>(
this)))));
410 msg_t req(con.
ctx(), std::ref(*(static_cast<rpc_cmd*>(
this))));
412 auto& payload = req.get_request().get_payload();
413 payload.enable_disable = 1;
414 payload.pid = getpid();
429 msg_t req(con.
ctx(), std::ref(*(static_cast<rpc_cmd*>(
this))));
431 auto& payload = req.get_request().get_payload();
432 payload.enable_disable = 0;
433 payload.pid = getpid();
443 std::lock_guard<interface_cmds::events_cmd> lg(*
this);
444 std::vector<interface::event> events;
446 for (
auto& msg : *
this) {
447 auto& payload = msg.get_payload();
449 handle_t handle(payload.sw_if_index);
460 events.push_back({ *sp, oper_state });
472 return (
"itf-events");
488 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
490 auto& payload = m_dump->get_request().get_payload();
491 payload.name_filter_valid = 0;
519 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
531 return (
"vhost-itf-dump");
543 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
555 return (
"af-packet-itf-dump");
567 msg_t req(con.
ctx(), std::ref(*
this));
569 auto& payload = req.get_request().get_payload();
572 memset(payload.tag, 0,
sizeof(payload.tag));
573 memcpy(payload.tag, m_name.c_str(), m_name.length());
582 std::ostringstream s;
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const set_mac_cmd &i) const
Comparison operator - only used for UT.
static const rc_t NOOP
The HW write/update action was/has not been attempted.
void retire(connection &con)
Retires the command - unsubscribe from the events.
delete_cmd(HW::item< handle_t > &item, const std::string &name)
vhost_create_cmd(HW::item< handle_t > &item, const std::string &name, const std::string &tag)
DEFINE_VAPI_MSG_IDS_AF_PACKET_API_JSON
std::string to_string() const
convert to string format for debug purposes
uint32_t value() const
get the value of the handle
void remove_interface()
remove the deleted interface from the DB
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.
set_tag(HW::item< handle_t > &item, const std::string &name)
Constructor taking the HW::item to update.
rc_t issue(connection &con)
Issue the command to VPP/HW.
A cmd class that Dumps all the Vpp interfaces.
collect_detail_stats_change_cmd(HW::item< interface::stats_type_t > &item, const handle_t &h, bool enable)
Constructor taking the HW::item to update and the handle of the interface.
std::string to_string() const
convert to string format for debug purposes
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t rc() const
Get the HW return code.
A command class to set tag on interfaces.
Error codes that VPP will return during a HW write.
static const log_level_t DEBUG
An L3 protocol can be used to construct a prefix that is used to match packets are part of a route...
set_mac_cmd(HW::item< l2_address_t > &item, const HW::item< handle_t > &h)
Constructor taking the HW::item to update and the handle of the interface.
void flush()
flush/free all the events thus far reeived.
create_cmd(HW::item< handle_t > &item, const std::string &name)
A command class that enables detailed stats collection on an interface.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
int value() const
Return the value of the enum - same as integer conversion.
The oper state of the interface.
rc_t wait()
Wait on the commands promise.
T & data()
Return the data read/written.
bool operator==(const set_table_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const events_cmd &i) const
Comparison operator - only used for UT.
DEFINE_VAPI_MSG_IDS_VPE_API_JSON
rc_t issue(connection &con)
Issue the command to VPP/HW.
vhost_vring_state_t state
rc_t issue(connection &con)
Issue the command to VPP/HW.
A command class that changes the MAC address on an interface.
const std::string & m_name
The name of the interface to be created.
dump_cmd()
Default Constructor.
A representation of the connection to VPP.
std::string to_string() const
convert to string format for debug purposes
set_table_cmd(HW::item< route::table_id_t > &item, const l3_proto_t &proto, const HW::item< handle_t > &h)
Constructor taking the HW::item to update and the name handle of the interface whose table is to chan...
DEFINE_VAPI_MSG_IDS_VHOST_USER_API_JSON
rc_t issue(connection &con)
Issue the command to VPP/HW.
state_change_cmd(HW::item< interface::admin_state_t > &s, const HW::item< handle_t > &h)
Constructor taking the HW::item to update and the name handle of the interface whose state is to chan...
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
rc_t issue(connection &con)
Issue the command to VPP/HW.
A class that listens to interface Events.
A base class for all RPC commands to VPP.
mac_address_t to_mac() const
MAC address conversion.
af_packet_delete_cmd(HW::item< handle_t > &item, const std::string &name)
Constructor taking the HW::item to update and the name of the interface to delete.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const af_packet_dump_cmd &i) const
Comparison operator - only used for UT.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
bool operator==(const state_change_cmd &i) const
Comparison operator - only used for UT.
A cmd class that changes the admin state.
vhost_dump_cmd()
Default Constructor.
af_packet_create_cmd(HW::item< handle_t > &item, const std::string &name)
Constructor taking the HW::item to update and the name of the interface to create.
A command class that binds an interface to an L3 table.
A command class represents our desire to recieve interface events.
std::string to_string() const
convert to string format for debug purposes
std::unique_ptr< vapi::Event_registration< vapi::Sw_interface_event > > m_reg
The VAPI event registration.
A cmd class that Dumps all the Vpp Interfaces.
rc_t issue(connection &con)
Issue the command to VPP/HW.
bool operator==(const vhost_dump_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
A type declaration of an interface handle in VPP.
const std::string & to_string() const
convert to string format for debug purposes
vapi::Event_registration< vapi::Sw_interface_event > reg_t
rc_t issue(connection &con)
Issue the command to VPP/HW.
rc_t issue(connection &con)
Issue the command to VPP/HW.
static const rc_t OK
The HW write was successfull.
void notify()
Called when it's time to poke the listeners.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
const std::string m_name
The name of the interface to be created.
loopback_delete_cmd(HW::item< handle_t > &item)
Constructor taking the HW::item to update.
static oper_state_t from_int(uint8_t val)
Convert VPP's numerical value to enum type.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
void insert_interface()
add the created interface to the DB
The VPP Object Model (VOM) library.
DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON
virtual void handle_interface_event(std::vector< event > es)=0
Virtual function called on the listener when the command has data ready to process.
rc_t issue(connection &con)
Issue the command to VPP/HW.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
vhost_delete_cmd(HW::item< handle_t > &item, const std::string &name)
An Event command base class.
std::string to_string() const
convert to string format for debug purposes
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
events_cmd(interface::event_listener &el)
Constructor taking the listner to notify.
A cmd class that Dumps all the Vpp interfaces.
bool operator==(const set_tag &i) const
Comparison operator - only used for UT.
loopback_create_cmd(HW::item< handle_t > &item, const std::string &name)
Constructor taking the HW::item to update and the name of the interface to create.
std::string to_string() const
convert to string format for debug purposes
HW::item< handle_t > & m_hw_item
A reference to an object's HW::item that the command will update.
HW::item< handle_t > & item()
return the HW item the command updates
rc_t issue(connection &con)
Issue the command to VPP/HW.
vapi::Create_loopback msg_t
convenient typedef
std::string to_string() const
convert to string format for debug purposes
bool operator==(const collect_detail_stats_change_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes