18 #include <vapi/tapv2.api.vapi.hpp> 23 namespace tap_interface_cmds {
33 , m_l2_address(l2_address)
39 msg_t req(con.
ctx(), std::ref(*
this));
41 auto& payload = req.get_request().get_payload();
42 memset(payload.host_if_name, 0,
sizeof(payload.host_if_name));
43 memcpy(payload.host_if_name,
45 std::min(
m_name.length(),
sizeof(payload.host_if_name)));
46 payload.host_if_name_set = 1;
49 if (m_prefix.
address().is_v6()) {
50 m_prefix.
to_vpp((uint8_t*)&payload.host_ip6_prefix_set,
51 payload.host_ip6_prefix.address,
52 &payload.host_ip6_prefix.len);
54 m_prefix.
to_vpp((uint8_t*)&payload.host_ip4_prefix_set,
55 payload.host_ip4_prefix.address,
56 &payload.host_ip4_prefix.len);
57 payload.host_ip4_prefix_set = 1;
62 m_l2_address.
to_bytes(payload.host_mac_addr, 6);
63 payload.host_mac_addr_set = 1;
66 payload.id = 0xffffffff;
67 payload.use_random_mac = 1;
68 payload.tx_ring_sz = 1024;
69 payload.rx_ring_sz = 1024;
100 msg_t req(con.
ctx(), std::ref(*
this));
102 auto& payload = req.get_request().get_payload();
117 std::ostringstream s;
134 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
146 return (
"tapv2-itf-dump");
static const rc_t NOOP
The HW write/update action was/has not been attempted.
bool operator==(const tapv2_dump_cmd &i) const
Comparison operator - only used for UT.
const boost::asio::ip::address & address() const
Get the address.
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
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.
Error codes that VPP will return during a HW write.
static const l2_address_t ZERO
An all 0's L2 address.
Type def of a L2 address as read from VPP.
rc_t wait()
Wait on the commands promise.
T & data()
Return the data read/written.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
A cmd class that Dumps all the Vpp Interfaces.
const std::string & m_name
The name of the interface to be created.
std::string to_string() const
convert to string format for debug purposes
A representation of the connection to VPP.
void to_vpp(uint8_t *is_ip6, uint8_t *addr, uint8_t *len) const
Convert the prefix into VPP API parameters.
rc_t issue(connection &con)
Issue the command to VPP/HW.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
A representation of an interface in VPP.
static const rc_t OK
The HW write was successfull.
DEFINE_VAPI_MSG_IDS_TAPV2_API_JSON
tapv2_delete_cmd(HW::item< handle_t > &item)
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
void insert_interface()
add the created interface to the DB
The VPP Object Model (VOM) library.
tapv2_dump_cmd()
Default Constructor.
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.
static const prefix_t ZERO
The all Zeros prefix.
tapv2_create_cmd(HW::item< handle_t > &item, const std::string &name, const route::prefix_t &prefix, const l2_address_t &l2_address)
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
vapi::Tap_create_v2 msg_t
convenient typedef