+ 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);
+ }