ApplicationId applicationId) { if (vlanIdCriterion == null) { return processEthDstOnlyFilter(ethCriterion, applicationId, filt.priority()); .withSelector(selectorIp.build()) .withTreatment(treatmentIp.build()) .withPriority(filt.priority()).fromApp(applicationId) .makePermanent().forTable(tmacTableId).build(); log.debug("adding IP ETH rule for MAC: {}", ethCriterion.mac()); .forDevice(deviceId).withSelector(selectorMpls.build()) .withTreatment(treatmentMpls.build()) .withPriority(filt.priority()).fromApp(applicationId) .makePermanent().forTable(tmacTableId).build(); log.debug("adding MPLS ETH rule for MAC: {}", ethCriterion.mac());
protected List<FlowRule> processVlanIdFilter(VlanIdCriterion vlanIdCriterion, FilteringObjective filt, VlanId assignedVlan, ApplicationId applicationId) { List<FlowRule> rules = new ArrayList<>(); log.debug("adding rule for VLAN: {}", vlanIdCriterion.vlanId()); TrafficSelector.Builder selector = DefaultTrafficSelector .builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment .builder(); PortCriterion p = (PortCriterion) filt.key(); if (vlanIdCriterion.vlanId() != VlanId.NONE) { selector.matchVlanId(vlanIdCriterion.vlanId()); selector.matchInPort(p.port()); } else { selector.matchInPort(p.port()); treatment.immediate().pushVlan().setVlanId(assignedVlan); } treatment.transition(tmacTableId); FlowRule rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(filt.priority()).fromApp(applicationId) .makePermanent().forTable(vlanTableId).build(); rules.add(rule); return rules; }
private void buildAndApplyRule(FilteringObjective filter, TrafficSelector selector, TrafficTreatment treatment) { FlowRule rule = DefaultFlowRule.builder() .fromApp(filter.appId()) .forDevice(deviceId) .forTable(0) .makePermanent() .withSelector(selector) .withTreatment(treatment) .withPriority(filter.priority()) .build(); FlowRuleOperations.Builder opsBuilder = FlowRuleOperations.builder(); switch (filter.type()) { case PERMIT: opsBuilder.add(rule); break; case DENY: opsBuilder.remove(rule); break; default: log.warn("Unknown filter type : {}", filter.type()); fail(filter, ObjectiveError.UNSUPPORTED); } applyFlowRules(opsBuilder, filter); }
.withTreatment(actions.build()) .fromApp(filter.appId()) .withPriority(filter.priority());