20 namespace gbp_contract_cmds {
32 , m_gbp_rules(gbp_rules)
33 , m_allowed_ethertypes(allowed_ethertypes)
40 return ((m_acl == other.m_acl) && (m_sclass == other.m_sclass) &&
41 (m_dclass == other.m_dclass) && (m_gbp_rules == other.m_gbp_rules) &&
42 (m_allowed_ethertypes == other.m_allowed_ethertypes));
45 #define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0])) 50 size_t n_rules = m_gbp_rules.size();
55 auto& payload = req.get_request().get_payload();
57 payload.contract.acl_index = m_acl.
value();
58 payload.contract.sclass = m_sclass;
59 payload.contract.dclass = m_dclass;
60 payload.contract.n_rules =
n_rules;
61 payload.contract.n_ether_types = m_allowed_ethertypes.size();
63 for (
auto tt : m_allowed_ethertypes) {
64 payload.contract.allowed_ethertypes[ii] = tt.value();
66 if (ii ==
ARRAY_LEN(payload.contract.allowed_ethertypes))
71 for (
auto rule : m_gbp_rules) {
87 uint8_t jj = 0, nh_size = (next_hops.size() > 8) ? 8 : next_hops.size();
89 payload.contract.rules[ii].nh_set.n_nhs = nh_size;
90 for (
auto nh : next_hops) {
91 to_api(nh.getIp(), payload.contract.rules[ii].nh_set.nhs[jj].ip);
92 to_api(nh.getMac(), payload.contract.rules[ii].nh_set.nhs[jj].mac);
93 payload.contract.rules[ii].nh_set.nhs[jj].bd_id = nh.getBdId();
94 payload.contract.rules[ii].nh_set.nhs[jj].rd_id = nh.getRdId();
108 std::ostringstream s;
110 <<
" sclass:" << m_sclass <<
" dclass:" << m_dclass <<
" acl:" << m_acl;
112 for (
auto e : m_allowed_ethertypes)
131 return ((m_sclass == other.m_sclass) && (m_dclass == other.m_dclass));
137 msg_t req(con.
ctx(), 0, std::ref(*
this));
139 auto& payload = req.get_request().get_payload();
141 payload.contract.acl_index = ~0;
142 payload.contract.sclass = m_sclass;
143 payload.contract.dclass = m_dclass;
153 std::ostringstream s;
155 <<
" sclass:" << m_sclass <<
" dclass:" << m_dclass;
169 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
181 return (
"gbp-contract-dump");
std::string to_string() const
convert to string format for debug purposes
uint32_t value() const
get the value of the handle
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 issue(connection &con)
Issue the command to VPP/HW.
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
A cmd class that Dumps all the GBP contracts.
Error codes that VPP will return during a HW write.
create_cmd(HW::item< uint32_t > &item, sclass_t sclass, sclass_t dclass, const handle_t &acl, const gbp_contract::gbp_rules_t &gbp_rules, const gbp_contract::ethertype_set_t &allowed_ethertypes)
Constructor.
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
rc_t wait()
Wait on the commands promise.
std::string to_string() const
convert to string format for debug purposes
std::set< ethertype_t > ethertype_set_t
A set of allowed ethertypes.
A representation of the connection to VPP.
static const hash_mode_t SYMMETRIC
Flow hash is calculated based on SRC IP, DST IP and Protocol.
A base class for all RPC commands to VPP.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
static const action_t REDIRECT
Redirect action.
bool operator==(const delete_cmd &i) const
Comparison operator - only used for UT.
rc_t issue(connection &con)
Issue the command to VPP/HW.
A type declaration of an interface handle in VPP.
A command class that creates or updates the GBP contract.
static const rc_t OK
The HW write was successfull.
delete_cmd(HW::item< uint32_t > &item, sclass_t sclass, sclass_t dclass)
Constructor.
std::set< gbp_rule > gbp_rules_t
set of gbp rules
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
The VPP Object Model (VOM) library.
std::set< next_hop_t > next_hops_t
unordered set of next hops
static const hash_mode_t SRC_IP
Flow Hash is calculated based on SRC IP in case of load balancing.
A cmd class that deletes a GBP contract.
bool operator==(const create_cmd &i) const
Comparison operator - only used for UT.
u16 allowed_ethertypes[16]
static const action_t PERMIT
Permit action.
HW::item< uint32_t > & m_hw_item
A reference to an object's HW::item that the command will update.
HW::item< uint32_t > & item()
return the HW item the command updates
vapi::Gbp_contract_add_del msg_t
convenient typedef
std::string to_string() const
convert to string format for debug purposes