26 namespace interface_cmds {
28 const std::string& name)
29 : create_cmd(item, name)
36 msg_t req(con.
ctx(), std::ref(*
this));
58 const std::string& name)
66 msg_t req(con.
ctx(), std::ref(*
this));
68 auto& payload = req.get_request().get_payload();
70 payload.use_random_hw_addr = 1;
71 memset(payload.host_if_name, 0,
sizeof(payload.host_if_name));
72 memcpy(payload.host_if_name,
m_name.c_str(),
73 std::min(
m_name.length(),
sizeof(payload.host_if_name)));
95 const std::string& name)
103 msg_t req(con.
ctx(), std::ref(*
this));
105 auto& payload = req.get_request().get_payload();
107 memset(payload.tap_name, 0,
sizeof(payload.tap_name));
108 memcpy(payload.tap_name,
m_name.c_str(),
109 std::min(
m_name.length(),
sizeof(payload.tap_name)));
110 payload.use_random_mac = 1;
126 std::ostringstream s;
140 msg_t req(con.
ctx(), std::ref(*
this));
142 auto& payload = req.get_request().get_payload();
157 std::ostringstream s;
164 const std::string& name)
172 msg_t req(con.
ctx(), std::ref(*
this));
174 auto& payload = req.get_request().get_payload();
175 memset(payload.host_if_name, 0,
sizeof(payload.host_if_name));
176 memcpy(payload.host_if_name,
m_name.c_str(),
177 std::min(
m_name.length(),
sizeof(payload.host_if_name)));
190 std::ostringstream s;
212 std::ostringstream s;
234 msg_t req(con.
ctx(), std::ref(*
this));
236 auto& payload = req.get_request().get_payload();
237 payload.sw_if_index = m_hdl.
data().
value();
250 std::ostringstream s;
268 return ((m_hdl == other.m_hdl) && (m_proto == other.m_proto) &&
275 msg_t req(con.
ctx(), std::ref(*
this));
277 auto& payload = req.get_request().get_payload();
278 payload.sw_if_index = m_hdl.
data().
value();
279 payload.is_ipv6 = m_proto.
is_ipv6();
292 std::ostringstream s;
314 msg_t req(con.
ctx(), std::ref(*
this));
316 auto& payload = req.get_request().get_payload();
317 payload.sw_if_index = m_hdl.
data().
value();
319 sizeof(payload.mac_address));
331 std::ostringstream s;
354 m_reg.reset(
new reg_t(con.
ctx(), std::ref(*(static_cast<event_cmd*>(
this)))));
359 msg_t req(con.
ctx(), std::ref(*(static_cast<rpc_cmd*>(
this))));
361 auto& payload = req.get_request().get_payload();
362 payload.enable_disable = 1;
363 payload.pid = getpid();
378 msg_t req(con.
ctx(), std::ref(*(static_cast<rpc_cmd*>(
this))));
380 auto& payload = req.get_request().get_payload();
381 payload.enable_disable = 0;
382 payload.pid = getpid();
398 return (
"itf-events");
408 , m_swifindex(handle)
424 m_reg.reset(
new reg_t(con.
ctx(), std::ref(*(static_cast<event_cmd*>(
this)))));
429 msg_t req(con.
ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(
this))));
431 auto& payload = req.get_request().get_payload();
432 payload.enable_disable = 1;
433 payload.pid = getpid();
436 payload.sw_ifs[0] = m_swifindex.
value();
451 msg_t req(con.
ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(
this))));
453 auto& payload = req.get_request().get_payload();
454 payload.enable_disable = 0;
455 payload.pid = getpid();
457 payload.sw_ifs[0] = m_swifindex.
value();
473 std::ostringstream s;
474 s <<
"itf-stats-enable itf:" << m_swifindex.
to_string();
484 , m_swifindex(handle)
500 msg_t req(con.
ctx(), 1, std::ref(*
this));
502 auto& payload = req.get_request().get_payload();
503 payload.enable_disable = 0;
504 payload.pid = getpid();
507 payload.sw_ifs[0] = m_swifindex.
value();
519 std::ostringstream s;
520 s <<
"itf-stats-disable itf:" << m_swifindex.
to_string();
533 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
535 auto& payload = m_dump->get_request().get_payload();
536 payload.name_filter_valid = 0;
560 msg_t req(con.
ctx(), std::ref(*
this));
562 auto& payload = req.get_request().get_payload();
565 memcpy(payload.tag, m_name.c_str(), m_name.length());
576 std::ostringstream s;
bool operator==(const set_tag &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
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)
HW::item< handle_t > & m_hw_item
A reference to an object's HW::item that the command will update.
bool operator==(const set_mac_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
A command class represents our desire to recieve interface stats.
rc_t issue(connection &con)
Issue the command to VPP/HW.
DEFINE_VAPI_MSG_IDS_AF_PACKET_API_JSON
int value() const
Return the value of the enum - same as integer conversion.
void remove_interface()
add the created interface to the DB
uint32_t value() const
get the value of the handle
set_tag(HW::item< handle_t > &item, const std::string &name)
Constructor taking the HW::item to update.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const set_table_cmd &i) const
Comparison operator - only used for UT.
void notify()
Called when it's time to poke the listeners.
rc_t issue(connection &con)
Issue the command to VPP/HW.
stats_disable_cmd(const handle_t &handle)
Constructor taking the listner to notify.
A command class to set tag on interfaces.
Error codes that VPP will return during a HW write.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
Types belonging to Routing.
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.
create_cmd(HW::item< handle_t > &item, const std::string &name)
virtual void handle_interface_event(interface_cmds::events_cmd *cmd)=0
Virtual function called on the listener when the command has data ready to process.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
T & data()
Return the data read/written.
rc_t issue(connection &con)
Issue the command to VPP/HW.
DEFINE_VAPI_MSG_IDS_VPE_API_JSON
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
A command class that binds an interface to an L3 table.
const std::string & m_name
The name of the interface to be created.
dump_cmd()
Default Constructor.
A representation of the connection to VPP.
bool operator==(const events_cmd &i) const
Comparison operator - only used for UT.
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...
A class that listens to interface Stats.
std::string to_string() const
convert to string format for debug purposes
tap_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.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
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.
rc_t issue(connection &con)
Issue the command to VPP/HW.
HW::item< handle_t > & item()
return the HW item the command updates
A class that listens to interface Events.
A base class for all RPC commands to VPP.
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.
bool operator==(const stats_enable_cmd &i) const
Comparison operator - only used for UT.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
A cmd class that changes the admin state.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
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.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
A command class represents our desire to recieve interface events.
stats_enable_cmd(interface::stat_listener &el, const handle_t &handle)
Constructor taking the listner to notify.
DEFINE_VAPI_MSG_IDS_STATS_API_JSON
std::unique_ptr< vapi::Event_registration< vapi::Sw_interface_event > > m_reg
The VAPI event registration.
rc_t issue(connection &con)
Issue the command to VPP/HW.
A type declaration of an interface handle in VPP.
vapi::Event_registration< vapi::Sw_interface_event > reg_t
rc_t issue(connection &con)
Issue the command to VPP/HW.
static const rc_t OK
The HW write was successfull.
bool operator==(const state_change_cmd &i) const
Comparison operator - only used for UT.
void notify()
Called when it's time to poke the listeners.
DEFINE_VAPI_MSG_IDS_TAP_API_JSON
vhost_vring_state_t state
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.
A command class represents our desire to recieve interface stats.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
rc_t issue(connection &con)
Issue the command to VPP/HW.
void insert_interface()
add the created interface to the DB
The VPP Object Model (VOM) library.
DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON
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.
tap_delete_cmd(HW::item< handle_t > &item)
Constructor taking the HW::item to update.
virtual void handle_interface_stat(interface_cmds::stats_enable_cmd *cmd)=0
Virtual function called on the listener when the command has data ready to process.
vapi::Create_loopback msg_t
convenient typedef
An Event command base class.
rc_t issue(connection &con)
Issue the command to VPP/HW.
const std::string & to_string() const
convert to string format for debug purposes
void retire(connection &con)
Retires the command - unsubscribe from the stats.
rc_t issue(connection &con)
Issue the command to VPP/HW.
events_cmd(interface::event_listener &el)
Constructor taking the listner to notify.
A cmd class that Dumps all the Vpp interfaces.
std::string to_string() const
convert to string format for debug purposes
mac_address_t to_mac() const
MAC address conversion.
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.
bool operator==(const stats_disable_cmd &i) const
Comparison operator - only used for UT.
HW::item< handle_t > wait()
Wait on the commands promise.
rc_t issue(connection &con)
Issue the command to VPP/HW.