*/
#include "vom/gbp_contract.hpp"
+#include "vom/api_types.hpp"
#include "vom/gbp_contract_cmds.hpp"
#include "vom/singular_db_funcs.hpp"
{
if (m_hw) {
HW::enqueue(new gbp_contract_cmds::create_cmd(
- m_hw, m_src_epg_id, m_dst_epg_id, m_acl->handle()));
+ m_hw, m_src_epg_id, m_dst_epg_id, m_acl->handle(), m_gbp_rules));
}
}
{
std::ostringstream s;
s << "gbp-contract:[{" << m_src_epg_id << ", " << m_dst_epg_id << "}, "
- << m_acl->to_string() << "]";
+ << m_acl->to_string();
+ if (m_gbp_rules.size()) {
+ auto it = m_gbp_rules.cbegin();
+ while (it != m_gbp_rules.cend()) {
+ s << it->to_string();
+ ++it;
+ }
+ }
+ s << "]";
return (s.str());
}
+void
+gbp_contract::set_gbp_rules(const gbp_contract::gbp_rules_t& gbp_rules)
+{
+ m_gbp_rules = gbp_rules;
+}
+
void
gbp_contract::update(const gbp_contract& r)
{
/*
- * create the table if it is not yet created
- */
+ * create the table if it is not yet created
+ */
if (rc_t::OK != m_hw.rc()) {
HW::enqueue(new gbp_contract_cmds::create_cmd(
- m_hw, m_src_epg_id, m_dst_epg_id, m_acl->handle()));
+ m_hw, m_src_epg_id, m_dst_epg_id, m_acl->handle(), m_gbp_rules));
}
}
gbp_contract gbpc(payload.contract.src_epg, payload.contract.dst_epg,
*acl);
OM::commit(key, gbpc);
-
+ if (payload.contract.n_rules) {
+ gbp_contract::gbp_rules_t rules;
+ for (u8 i = 0; i < payload.contract.n_rules; i++) {
+ const gbp_rule::action_t action =
+ gbp_rule::action_t::from_int(payload.contract.rules[i].action);
+ const gbp_rule::hash_mode_t hm = gbp_rule::hash_mode_t::from_int(
+ payload.contract.rules[i].nh_set.hash_mode);
+ gbp_rule::next_hops_t nhs;
+ for (u8 j = 0; j < payload.contract.rules[i].nh_set.n_nhs; j++) {
+ gbp_rule::next_hop_t nh(
+ from_api(payload.contract.rules[i].nh_set.nhs[j].ip),
+ from_api(payload.contract.rules[i].nh_set.nhs[j].mac),
+ payload.contract.rules[i].nh_set.nhs[j].bd_id,
+ payload.contract.rules[i].nh_set.nhs[j].rd_id);
+ nhs.insert(nh);
+ }
+ gbp_rule::next_hop_set_t next_hop_set(hm, nhs);
+ gbp_rule gr(i, next_hop_set, action);
+ rules.insert(gr);
+ }
+ gbpc.set_gbp_rules(rules);
+ }
VOM_LOG(log_level_t::DEBUG) << "read: " << gbpc.to_string();
}
}