20 namespace gbp_contract_cmds {
34 , m_gbp_rules(gbp_rules)
35 , m_allowed_ethertypes(allowed_ethertypes)
42 return ((m_acl == other.m_acl) && (m_sclass == other.m_sclass) &&
43 (m_scope == other.m_scope) && (m_dclass == other.m_dclass) &&
44 (m_gbp_rules == other.m_gbp_rules) &&
45 (m_allowed_ethertypes == other.m_allowed_ethertypes));
48 #define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0])) 53 size_t n_rules = m_gbp_rules.size();
58 auto& payload = req.get_request().get_payload();
60 payload.contract.acl_index = m_acl.
value();
61 payload.contract.scope = m_scope;
62 payload.contract.sclass = m_sclass;
63 payload.contract.dclass = m_dclass;
64 payload.contract.n_rules =
n_rules;
65 payload.contract.n_ether_types = m_allowed_ethertypes.size();
67 for (
auto tt : m_allowed_ethertypes) {
68 payload.contract.allowed_ethertypes[ii] = tt.value();
70 if (ii ==
ARRAY_LEN(payload.contract.allowed_ethertypes))
75 for (
auto rule : m_gbp_rules) {
91 uint8_t jj = 0, nh_size = (next_hops.size() > 8) ? 8 : next_hops.size();
93 payload.contract.rules[ii].nh_set.n_nhs = nh_size;
94 for (
auto nh : next_hops) {
95 to_api(
nh.getIp(), payload.contract.rules[ii].nh_set.nhs[jj].ip);
96 to_api(
nh.getMac(), payload.contract.rules[ii].nh_set.nhs[jj].mac);
97 payload.contract.rules[ii].nh_set.nhs[jj].bd_id =
nh.getBdId();
98 payload.contract.rules[ii].nh_set.nhs[jj].rd_id =
nh.getRdId();
112 std::ostringstream s;
114 <<
" sclass:" << m_sclass <<
" dclass:" << m_dclass <<
" acl:" << m_acl;
116 for (
auto e : m_allowed_ethertypes)
137 return ((m_sclass == other.m_sclass) && (m_dclass == other.m_dclass));
143 msg_t req(con.
ctx(), 0, std::ref(*
this));
145 auto& payload = req.get_request().get_payload();
147 payload.contract.acl_index = ~0;
148 payload.contract.scope = m_scope;
149 payload.contract.sclass = m_sclass;
150 payload.contract.dclass = m_dclass;
160 std::ostringstream s;
162 <<
" sclass:" << m_sclass <<
" dclass:" << m_dclass;
176 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
188 return (
"gbp-contract-dump");
create_cmd(HW::item< uint32_t > &item, scope_t scope, 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.
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.
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.
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.
delete_cmd(HW::item< uint32_t > &item, scope_t scope, sclass_t sclass, sclass_t dclass)
Constructor.
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