18 #include <vapi/tap.api.vapi.hpp> 19 #include <vapi/tapv2.api.vapi.hpp> 25 namespace tap_interface_cmds {
30 const std::string&
name,
35 , m_l2_address(l2_address)
42 msg_t req(con.
ctx(), std::ref(*
this));
44 auto& payload = req.get_request().get_payload();
45 memset(payload.host_if_name, 0,
sizeof(payload.host_if_name));
46 memcpy(payload.host_if_name,
m_name.c_str(),
47 std::min(
m_name.length(),
sizeof(payload.host_if_name)));
48 payload.host_if_name_set = 1;
51 if (m_prefix.
address().is_v6()) {
52 m_prefix.
to_vpp(&payload.host_ip6_addr_set, payload.host_ip6_addr,
53 &payload.host_ip6_prefix_len);
55 m_prefix.
to_vpp(&payload.host_ip4_addr_set, payload.host_ip4_addr,
56 &payload.host_ip4_prefix_len);
57 payload.host_ip4_addr_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;
101 msg_t req(con.
ctx(), std::ref(*
this));
103 auto& payload = req.get_request().get_payload();
118 std::ostringstream s;
137 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
149 return (
"tapv2-itf-dump");
static const rc_t NOOP
The HW write/update action was/has not been attempted.
void remove_interface()
remove the deleted interface from the DB
uint32_t value() const
get the value of the handle
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.
Error codes that VPP will return during a HW write.
static const l2_address_t ZERO
An all 0's L2 address.
std::string to_string() const
convert to string format for debug purposes
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
A cmd class that Dumps all the Vpp Interfaces.
rc_t rc() const
Get the HW return code.
const std::string & m_name
The name of the interface to be created.
A representation of the connection to VPP.
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 tapv2_dump_cmd &i) const
Comparison operator - only used for UT.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
void to_vpp(uint8_t *is_ip6, uint8_t *addr, uint8_t *len) const
Convert the prefix into VPP API parameters.
A representation of an interface in VPP.
DEFINE_VAPI_MSG_IDS_TAP_API_JSON
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.
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.
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.
std::string to_string() const
convert to string format for debug purposes
const boost::asio::ip::address & address() const
Get the address.
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