本文整理汇总了Java中org.onosproject.net.flow.FlowRule.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java FlowRule.Builder方法的具体用法?Java FlowRule.Builder怎么用?Java FlowRule.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.FlowRule
的用法示例。
在下文中一共展示了FlowRule.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processForward
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
private Collection<FlowRule> processForward(ForwardingObjective fwd) {
log.debug("Processing forwarding object");
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(fwd.selector())
.withTreatment(fwd.treatment())
.withPriority(fwd.priority())
.fromApp(fwd.appId())
.forTable(SOFTWARE_TABLE_START);
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(TIME_OUT);
}
return Collections.singletonList(ruleBuilder.build());
}
示例2: processVersatile
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
private Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
log.debug("Processing versatile forwarding objective");
TrafficSelector selector = fwd.selector();
TrafficTreatment tb = fwd.treatment();
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder().fromApp(fwd.appId()).withPriority(fwd.priority())
.forDevice(deviceId).withSelector(selector).withTreatment(tb).makeTemporary(TIME_OUT);
ruleBuilder.withPriority(fwd.priority());
if (fwd.priority() == 100) {
ruleBuilder.forTable(ENCAP_OUTPUT_TABLE);
} else if (fwd.priority() == 200) {
ruleBuilder.forTable(TUN_SEND_TABLE);
} else {
ruleBuilder.forTable(CLASSIFIER_TABLE);
}
if (fwd.permanent()) {
ruleBuilder.makePermanent();
}
return Collections.singletonList(ruleBuilder.build());
}
示例3: reassemblyFlowRule
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
private Collection<FlowRule> reassemblyFlowRule(FlowRule.Builder ruleBuilder,
TrafficTreatment tb,
Integer transition,
Integer forTable) {
if (transition != null) {
TrafficTreatment.Builder newTraffic = DefaultTrafficTreatment
.builder();
tb.allInstructions().forEach(t -> newTraffic.add(t));
newTraffic.transition(transition);
ruleBuilder.withTreatment(newTraffic.build());
} else {
ruleBuilder.withTreatment(tb);
}
if (forTable != null) {
ruleBuilder.forTable(forTable);
}
return Collections.singletonList(ruleBuilder.build());
}
示例4: processVlanFiler
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
@Override
protected FlowRule.Builder processVlanFiler(FilteringObjective filt, VlanIdCriterion vlan, PortCriterion port) {
log.debug("adding rule for VLAN: {}", vlan.vlanId());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchVlanId(vlan.vlanId());
selector.matchInPort(port.port());
treatment.transition(ETHER_TABLE);
treatment.deferred().popVlan();
return DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.makePermanent()
.forTable(VLAN_TABLE);
}
示例5: activate
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
@Activate
protected void activate() {
ApplicationId id = applicationService.getId("home.parham.sdnfv101");
/*
* Let's build the rule for it's source.
*/
FlowRule.Builder fb = DefaultFlowRule.builder();
/* General flow information */
fb.forDevice(DeviceId.deviceId("of:00000000000000b0"));
fb.makePermanent();
fb.withPriority(10);
fb.fromApp(id);
/* Flow selection */
TrafficSelector.Builder sb = DefaultTrafficSelector.builder();
sb.matchInPort(PortNumber.portNumber(3));
fb.withSelector(sb.build());
/* Flow treatment */
TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
tb.setOutput(PortNumber.NORMAL);
fb.withTreatment(tb.build());
/* Flow applying */
FlowRule f = fb.build();
this.flowRuleService.applyFlowRules(f);
}
示例6: processVersatile
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
private Collection<FlowRule> processVersatile(ForwardingObjective forwardingObjective) {
log.debug("Processing versatile forwarding objective");
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(forwardingObjective.selector())
.withTreatment(forwardingObjective.treatment())
.withPriority(forwardingObjective.priority())
.fromApp(forwardingObjective.appId());
if (forwardingObjective.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(TIME_OUT);
}
//ARP & DHCP Rule
EthTypeCriterion ethCriterion =
(EthTypeCriterion) forwardingObjective.selector().getCriterion(Criterion.Type.ETH_TYPE);
UdpPortCriterion udpPortCriterion = (UdpPortCriterion) forwardingObjective
.selector().getCriterion(Criterion.Type.UDP_DST);
if (ethCriterion != null) {
if (ethCriterion.ethType().toShort() == Ethernet.TYPE_ARP ||
ethCriterion.ethType().toShort() == Ethernet.TYPE_LLDP) {
ruleBuilder.forTable(VNI_TABLE);
return Collections.singletonList(ruleBuilder.build());
} else if (udpPortCriterion != null && udpPortCriterion.udpPort().toInt() == DHCP_SERVER_PORT) {
ruleBuilder.forTable(VNI_TABLE);
return Collections.singletonList(ruleBuilder.build());
}
}
return Collections.emptySet();
}
示例7: flowRuleBuilder
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
/**
* Returns a new, pre-configured flow rule builder.
*
* @param did a device id
* @param tableName a table name
* @return a new flow rule builder
*/
protected FlowRule.Builder flowRuleBuilder(DeviceId did, String tableName) throws FlowRuleGeneratorException {
Map<String, Integer> tableMap = bmv2Context.interpreter().tableIdMap().inverse();
if (tableMap.get(tableName) == null) {
throw new FlowRuleGeneratorException("Unknown table " + tableName);
}
return DefaultFlowRule.builder()
.forDevice(did)
.forTable(tableMap.get(tableName))
.fromApp(appId)
.withPriority(FLOW_PRIORITY)
.makePermanent();
}
示例8: processArpTraffic
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
@Override
protected Collection<FlowRule> processArpTraffic(ForwardingObjective fwd, FlowRule.Builder rule) {
log.warn("Driver automatically handles ARP packets by punting to controller "
+ " from ETHER table");
pass(fwd);
return Collections.emptyList();
}
示例9: processEthFiler
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
protected FlowRule.Builder processEthFiler(FilteringObjective filt, EthCriterion eth, PortCriterion port) {
log.debug("adding rule for MAC: {}", eth.mac());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthDst(eth.mac());
treatment.transition(VLAN_MPLS_TABLE);
return DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.makePermanent()
.forTable(MAC_TABLE);
}
示例10: processIpFilter
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
@Override
protected FlowRule.Builder processIpFilter(FilteringObjective filt, IPCriterion ip, PortCriterion port) {
log.debug("adding rule for IP: {}", ip.ip());
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchIPDst(ip.ip());
treatment.transition(LOCAL_TABLE);
return DefaultFlowRule.builder()
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(HIGHEST_PRIORITY)
.makePermanent()
.forTable(FIB_TABLE);
}
示例11: processSpecific
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
/**
* SoftRouter has a single specific table - the FIB Table. It emulates
* LPM matching of dstIP by using higher priority flows for longer prefixes.
* Flows are forwarded using flow-actions
*
* @param fwd The forwarding objective of type simple
* @return A collection of flow rules meant to be delivered to the flowrule
* subsystem. Typically the returned collection has a single flowrule.
* May return empty collection in case of failures.
*
*/
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
log.debug("Processing specific forwarding objective to next:{}", fwd.nextId());
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethType =
(EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
// XXX currently supporting only the L3 unicast table
if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
IpPrefix ipPrefix = ((IPCriterion)
selector.getCriterion(Criterion.Type.IPV4_DST)).ip();
TrafficSelector.Builder filteredSelector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
if (ipPrefix.prefixLength() != 0) {
filteredSelector.matchIPDst(ipPrefix);
}
TrafficTreatment tt = null;
if (fwd.nextId() != null) {
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
if (next == null) {
log.error("next-id {} does not exist in store", fwd.nextId());
return Collections.emptySet();
}
tt = appKryo.deserialize(next.data());
if (tt == null) {
log.error("Error in deserializing next-id {}", fwd.nextId());
return Collections.emptySet();
}
}
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.withPriority(fwd.priority())
.forDevice(deviceId)
.withSelector(filteredSelector.build());
if (tt != null) {
ruleBuilder.withTreatment(tt);
}
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(fwd.timeout());
}
ruleBuilder.forTable(FIB_TABLE);
return Collections.singletonList(ruleBuilder.build());
}
示例12: processEthDstSpecific
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
@Override
protected Collection<FlowRule> processEthDstSpecific(ForwardingObjective fwd) {
List<FlowRule> rules = new ArrayList<>();
// Build filtered selector
TrafficSelector selector = fwd.selector();
EthCriterion ethCriterion = (EthCriterion) selector
.getCriterion(Criterion.Type.ETH_DST);
VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) selector
.getCriterion(Criterion.Type.VLAN_VID);
if (vlanIdCriterion == null) {
log.warn("Forwarding objective for bridging requires vlan. Not "
+ "installing fwd:{} in dev:{}", fwd.id(), deviceId);
fail(fwd, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
TrafficSelector.Builder filteredSelectorBuilder =
DefaultTrafficSelector.builder();
// Do not match MacAddress for subnet broadcast entry
if (!ethCriterion.mac().equals(MacAddress.NONE)) {
filteredSelectorBuilder.matchEthDst(ethCriterion.mac());
log.debug("processing L2 forwarding objective:{} -> next:{} in dev:{}",
fwd.id(), fwd.nextId(), deviceId);
} else {
log.debug("processing L2 Broadcast forwarding objective:{} -> next:{} "
+ "in dev:{} for vlan:{}",
fwd.id(), fwd.nextId(), deviceId, vlanIdCriterion.vlanId());
}
filteredSelectorBuilder.matchVlanId(vlanIdCriterion.vlanId());
TrafficSelector filteredSelector = filteredSelectorBuilder.build();
if (fwd.treatment() != null) {
log.warn("Ignoring traffic treatment in fwd rule {} meant for L2 table"
+ "for dev:{}. Expecting only nextId", fwd.id(), deviceId);
}
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
if (fwd.nextId() != null) {
NextGroup next = getGroupForNextObjective(fwd.nextId());
if (next != null) {
List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
// we only need the top level group's key to point the flow to it
Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
if (group != null) {
treatmentBuilder.deferred().group(group.id());
} else {
log.warn("Group with key:{} for next-id:{} not found in dev:{}",
gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
}
}
treatmentBuilder.immediate().transition(ACL_TABLE);
TrafficTreatment filteredTreatment = treatmentBuilder.build();
// Build bridging table entries
FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder();
flowRuleBuilder.fromApp(fwd.appId())
.withPriority(fwd.priority())
.forDevice(deviceId)
.withSelector(filteredSelector)
.withTreatment(filteredTreatment)
.forTable(BRIDGING_TABLE);
if (fwd.permanent()) {
flowRuleBuilder.makePermanent();
} else {
flowRuleBuilder.makeTemporary(fwd.timeout());
}
rules.add(flowRuleBuilder.build());
return rules;
}
示例13: processVersatile
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
@Override
protected Collection<FlowRule> processVersatile(ForwardingObjective fwd) {
log.info("Processing versatile forwarding objective");
EthTypeCriterion ethType =
(EthTypeCriterion) fwd.selector().getCriterion(Criterion.Type.ETH_TYPE);
if (ethType == null) {
log.error("Versatile forwarding objective must include ethType");
fail(fwd, ObjectiveError.BADPARAMS);
return Collections.emptySet();
}
if (fwd.nextId() == null && fwd.treatment() == null) {
log.error("Forwarding objective {} from {} must contain "
+ "nextId or Treatment", fwd.selector(), fwd.appId());
return Collections.emptySet();
}
TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
fwd.selector().criteria().forEach(criterion -> {
if (criterion instanceof VlanIdCriterion) {
// avoid matching on vlans
return;
} else {
sbuilder.add(criterion);
}
});
// XXX driver does not currently do type checking as per Tables 65-67 in
// OFDPA 2.0 spec. The only allowed treatment is a punt to the controller.
TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
if (fwd.treatment() != null) {
for (Instruction ins : fwd.treatment().allInstructions()) {
if (ins instanceof OutputInstruction) {
OutputInstruction o = (OutputInstruction) ins;
if (o.port() == PortNumber.CONTROLLER) {
// emulating real ofdpa behavior by popping off internal
// vlan before sending to controller
ttBuilder.popVlan();
ttBuilder.add(o);
} else {
log.warn("Only allowed treatments in versatile forwarding "
+ "objectives are punts to the controller");
}
} else {
log.warn("Cannot process instruction in versatile fwd {}", ins);
}
}
}
if (fwd.nextId() != null) {
// overide case
NextGroup next = getGroupForNextObjective(fwd.nextId());
List<Deque<GroupKey>> gkeys = appKryo.deserialize(next.data());
// we only need the top level group's key to point the flow to it
Group group = groupService.getGroup(deviceId, gkeys.get(0).peekFirst());
if (group == null) {
log.warn("Group with key:{} for next-id:{} not found in dev:{}",
gkeys.get(0).peekFirst(), fwd.nextId(), deviceId);
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
ttBuilder.deferred().group(group.id());
}
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.withPriority(fwd.priority())
.forDevice(deviceId)
.withSelector(sbuilder.build())
.withTreatment(ttBuilder.build())
.makePermanent()
.forTable(ACL_TABLE);
return Collections.singletonList(ruleBuilder.build());
}
示例14: processSpecific
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
private Collection<FlowRule> processSpecific(ForwardingObjective fwd) {
log.debug("Processing specific forwarding objective");
TrafficSelector selector = fwd.selector();
EthTypeCriterion ethType =
(EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE);
if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) {
fail(fwd, ObjectiveError.UNSUPPORTED);
return Collections.emptySet();
}
// Must have metadata as key.
TrafficSelector filteredSelector =
DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchMetadata(DEFAULT_METADATA)
.matchIPDst(
((IPCriterion)
selector.getCriterion(Criterion.Type.IPV4_DST)).ip())
.build();
TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
if (fwd.nextId() != null) {
NextGroup next = flowObjectiveStore.getNextGroup(fwd.nextId());
GroupKey key = appKryo.deserialize(next.data());
Group group = groupService.getGroup(deviceId, key);
if (group == null) {
log.warn("The group left!");
fail(fwd, ObjectiveError.GROUPMISSING);
return Collections.emptySet();
}
tb.group(group.id());
}
FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.withPriority(ROUTE_TABLE_PRIORITY)
.forDevice(deviceId)
.withSelector(filteredSelector)
.withTreatment(tb.build());
if (fwd.permanent()) {
ruleBuilder.makePermanent();
} else {
ruleBuilder.makeTemporary(fwd.timeout());
}
ruleBuilder.forTable(ROUTE_TABLE);
return Collections.singletonList(ruleBuilder.build());
}
示例15: installDownstreamRules
import org.onosproject.net.flow.FlowRule; //导入方法依赖的package包/类
private void installDownstreamRules(ForwardingObjective fwd) {
List<Pair<Instruction, Instruction>> vlanOps =
vlanOps(fwd,
L2ModificationInstruction.L2SubType.VLAN_POP);
if (vlanOps == null) {
return;
}
Instructions.OutputInstruction output = (Instructions.OutputInstruction) fetchOutput(fwd, "downstream");
if (output == null) {
return;
}
Pair<Instruction, Instruction> popAndRewrite = vlanOps.remove(0);
TrafficSelector selector = fwd.selector();
Criterion outerVlan = selector.getCriterion(Criterion.Type.VLAN_VID);
Criterion innerVlan = selector.getCriterion(Criterion.Type.INNER_VLAN_VID);
Criterion inport = selector.getCriterion(Criterion.Type.IN_PORT);
Criterion bullshit = Criteria.matchMetadata(output.port().toLong());
if (outerVlan == null || innerVlan == null || inport == null) {
log.error("Forwarding objective is underspecified: {}", fwd);
fail(fwd, ObjectiveError.BADPARAMS);
return;
}
Criterion innerVid = Criteria.matchVlanId(((VlanIdCriterion) innerVlan).vlanId());
FlowRule.Builder outer = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.forDevice(deviceId)
.makePermanent()
.withPriority(fwd.priority())
.withSelector(buildSelector(inport, outerVlan, bullshit))
.withTreatment(buildTreatment(popAndRewrite.getLeft(),
Instructions.transition(QQ_TABLE)));
FlowRule.Builder inner = DefaultFlowRule.builder()
.fromApp(fwd.appId())
.forDevice(deviceId)
.forTable(QQ_TABLE)
.makePermanent()
.withPriority(fwd.priority())
.withSelector(buildSelector(inport, innerVid))
.withTreatment(buildTreatment(popAndRewrite.getLeft(),
output));
applyRules(fwd, inner, outer);
}