20 namespace gbp_contract_cmds {
29 , m_src_epg_id(src_epg_id)
30 , m_dst_epg_id(dst_epg_id)
32 , m_gbp_rules(gbp_rules)
33 , m_allowed_ethertypes(allowed_ethertypes)
40 return ((m_acl == other.m_acl) && (m_src_epg_id == other.m_src_epg_id) &&
41 (m_dst_epg_id == other.m_dst_epg_id) &&
42 (m_gbp_rules == other.m_gbp_rules) &&
43 (m_allowed_ethertypes == other.m_allowed_ethertypes));
49 size_t n_rules = m_gbp_rules.size();
50 size_t n_et_rules = 0;
54 auto& payload = req.get_request().get_payload();
56 payload.contract.acl_index = m_acl.
value();
57 payload.contract.src_epg = m_src_epg_id;
58 payload.contract.dst_epg = m_dst_epg_id;
61 payload.contract.n_rules =
n_rules;
63 for (
auto rule : m_gbp_rules) {
79 uint8_t jj = 0, nh_size = (next_hops.size() > 8) ? 8 : next_hops.size();
81 payload.contract.rules[ii].nh_set.n_nhs = nh_size;
82 for (
auto nh : next_hops) {
83 to_api(nh.getIp(), payload.contract.rules[ii].nh_set.nhs[jj].ip);
84 to_api(nh.getMac(), payload.contract.rules[ii].nh_set.nhs[jj].mac);
85 payload.contract.rules[ii].nh_set.nhs[jj].bd_id = nh.getBdId();
86 payload.contract.rules[ii].nh_set.nhs[jj].rd_id = nh.getRdId();
95 data = (((
u8*)&payload.contract.n_ether_types) +
96 (
sizeof(payload.contract.rules[0]) * payload.contract.n_rules));
97 *data = m_allowed_ethertypes.size();
100 for (
auto tt : m_allowed_ethertypes) {
113 std::ostringstream s;
115 <<
" src-epg-id:" << m_src_epg_id <<
" dst-epg-id:" << m_dst_epg_id
125 , m_src_epg_id(src_epg_id)
126 , m_dst_epg_id(dst_epg_id)
133 return ((m_src_epg_id == other.m_src_epg_id) &&
134 (m_dst_epg_id == other.m_dst_epg_id));
140 msg_t req(con.
ctx(), 0, 0, std::ref(*
this));
142 auto& payload = req.get_request().get_payload();
144 payload.contract.acl_index = ~0;
145 payload.contract.src_epg = m_src_epg_id;
146 payload.contract.dst_epg = m_dst_epg_id;
156 std::ostringstream s;
158 <<
" src-epg-id:" << m_src_epg_id <<
" dst-epg-id:" << m_dst_epg_id;
172 m_dump.reset(
new msg_t(con.
ctx(), std::ref(*
this)));
184 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
uint32_t epg_id_t
EPG IDs are 32 bit integers.
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.
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.
u16 allowed_ethertypes[n_ether_types]
A representation of the connection to VPP.
void to_api(const ip_address_t &a, vapi_type_address &v)
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.
delete_cmd(HW::item< bool > &item, epg_id_t src_epg_id, epg_id_t dst_epg_id)
Constructor.
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.
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.
create_cmd(HW::item< bool > &item, epg_id_t src_epg_id, epg_id_t dst_epg_id, const handle_t &acl, const gbp_contract::gbp_rules_t &gbp_rules, const gbp_contract::ethertype_set_t &allowed_ethertypes)
Constructor.
static const action_t PERMIT
Permit action.
HW::item< bool > & m_hw_item
A reference to an object's HW::item that the command will update.
HW::item< bool > & 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