private TrafficSelector buildNeighborSolicitationSelector() { return DefaultTrafficSelector.builder() .matchEthType(TYPE_IPV6) .matchIPProtocol(PROTOCOL_ICMP6) .matchIcmpv6Type(NEIGHBOR_SOLICITATION) .build(); }
public static TrafficTreatment unionTrafficTreatment(TrafficTreatment tt1, TrafficTreatment tt2) { TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); for (Instruction instruction : tt1.allInstructions()) { treatmentBuilder.add(instruction); } for (Instruction instruction : tt2.allInstructions()) { treatmentBuilder.add(instruction); } return treatmentBuilder.build(); }
private TrafficSelector buildArpSelector() { return DefaultTrafficSelector.builder() .matchEthType(TYPE_ARP) .build(); }
private void processClassifierTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(CLASSIFIER_TABLE).build(); applyRules(install, rule); }
private FlowRule createFlowRule(OpticalOduIntent intent, DeviceId deviceId, TrafficSelector selector, TrafficTreatment treat) { return DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector) .withTreatment(treat) .withPriority(intent.priority()) .fromApp(appId) .makePermanent() .build(); }
private void applyRules(boolean install, FlowRule rule) { FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); ops = install ? ops.add(rule) : ops.remove(rule); flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { @Override public void onSuccess(FlowRuleOperations ops) { log.info("ONOSW provisioned " + rule.tableId() + " table"); } @Override public void onError(FlowRuleOperations ops) { log.info("ONOSW failed to provision " + rule.tableId() + " table"); } })); }
private void applyFlowRules(FlowRuleOperations.Builder builder, Objective objective) { flowRuleService.apply(builder.build(new FlowRuleOperationsContext() { @Override public void onSuccess(FlowRuleOperations ops) { pass(objective); } @Override public void onError(FlowRuleOperations ops) { fail(objective, ObjectiveError.FLOWINSTALLATIONFAILED); } })); }
/** * Creates a predicate that checks the flow type of a flow entry is the same as * the specified live type. * * @param liveType flow live type to be checked * @return predicate */ private static Predicate<FlowEntry> hasLiveType(FlowEntry.FlowLiveType liveType) { return flowEntry -> flowEntry.liveType() == liveType; } }
@Override public void run() { flowRuleService.apply(this.op); } }
private void processArpTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(ARP_TABLE).build(); applyRules(install, rule); }
private TrafficSelector buildNeighborAdvertisementSelector() { return DefaultTrafficSelector.builder() .matchEthType(TYPE_IPV6) .matchIPProtocol(PROTOCOL_ICMP6) .matchIcmpv6Type(NEIGHBOR_ADVERTISEMENT) .build(); }
private void applyRules(boolean install, FlowRule flowRule) { FlowRuleOperations.Builder flowOpsBuilder = FlowRuleOperations.builder(); flowOpsBuilder = install ? flowOpsBuilder.add(flowRule) : flowOpsBuilder.remove(flowRule); flowRuleService.apply(flowOpsBuilder.build(new FlowRuleOperationsContext() { @Override public void onSuccess(FlowRuleOperations ops) { log.debug("Provisioned vni or forwarding table"); } @Override public void onError(FlowRuleOperations ops) { log.debug("Failed to privision vni or forwarding table"); } })); }
private void processL3fwdTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(SNAT_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(L3FWD_TABLE).build(); applyRules(install, rule); }
private void processDnatTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(DNAT_TABLE).build(); applyRules(install, rule); }
private void processMacTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.drop(); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(MAC_TABLE).build(); applyRules(install, rule); }
private void processSnatTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(MAC_TABLE); treatment.add(Instructions.createOutput(PortNumber.CONTROLLER)); FlowRule rule; rule = DefaultFlowRule.builder().forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(TABLE_MISS_PRIORITY).fromApp(appId) .makePermanent().forTable(SNAT_TABLE).build(); applyRules(install, rule); }
private void processForwardingTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.drop(); FlowRule flowRule = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(DROP_PRIORITY) .fromApp(appId) .makePermanent() .forTable(FORWARDING_TABLE) .build(); applyRules(install, flowRule); }
private void processVniTable(boolean install) { TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.transition(FORWARDING_TABLE); FlowRule flowRule = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(selector.build()) .withTreatment(treatment.build()) .withPriority(DROP_PRIORITY) .fromApp(appId) .makePermanent() .forTable(VNI_TABLE) .build(); applyRules(install, flowRule); }