18 #include <vapi/tap.api.vapi.hpp> 21 namespace tap_interface_cmds {
23 const std::string& name,
28 , m_l2_address(l2_address)
35 msg_t req(con.
ctx(), std::ref(*
this));
37 auto& payload = req.get_request().get_payload();
38 memset(payload.tap_name, 0,
sizeof(payload.tap_name));
39 memcpy(payload.tap_name,
m_name.c_str(),
40 std::min(
m_name.length(),
sizeof(payload.tap_name)));
42 if (m_prefix.
address().is_v6()) {
43 m_prefix.
to_vpp(&payload.ip6_address_set, payload.ip6_address,
44 &payload.ip6_mask_width);
46 m_prefix.
to_vpp(&payload.ip4_address_set, payload.ip4_address,
47 &payload.ip4_mask_width);
48 payload.ip4_address_set = 1;
53 m_l2_address.
to_bytes(payload.mac_address, 6);
55 payload.use_random_mac = 1;
109 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
121 return (
"tap-itf-dump");
HW::item< handle_t > & m_hw_item
A reference to an object's HW::item that the command will update.
rc_t issue(connection &con)
Issue the command to VPP/HW.
void to_bytes(uint8_t *array, uint8_t len) const
Convert to byte array.
std::string to_string() const
convert to string format for debug purposes
Error codes that VPP will return during a HW write.
std::string to_string() const
convert to string format for debug purposes
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.
create_cmd(HW::item< handle_t > &item, const std::string &name, route::prefix_t &prefix, const l2_address_t &l2_address)
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.
A representation of the connection to VPP.
std::string to_string() const
convert to string format for debug purposes
A functor class that creates an interface.
HW::item< handle_t > & item()
return the HW item the command updates
rc_t issue(connection &con)
Issue the command to VPP/HW.
dump_cmd()
Default Constructor.
#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.
A cmd class that Dumps all the Vpp Interfaces.
static const rc_t OK
The HW write was successfull.
delete_cmd(HW::item< handle_t > &item)
A functor class that deletes a Tap interface.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
The VPP Object Model (VOM) library.
rc_t issue(connection &con)
Issue the command to VPP/HW.
static const prefix_t ZERO
The all Zeros prefix.
vapi::Tap_connect msg_t
convenient typedef
const boost::asio::ip::address & address() const
Get the address.
HW::item< handle_t > wait()
Wait on the commands promise.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.