本文整理汇总了Java中org.onosproject.net.flow.DefaultTrafficTreatment.builder方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTrafficTreatment.builder方法的具体用法?Java DefaultTrafficTreatment.builder怎么用?Java DefaultTrafficTreatment.builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.DefaultTrafficTreatment
的用法示例。
在下文中一共展示了DefaultTrafficTreatment.builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateRuleToGateway
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private void populateRuleToGateway(Device d, Device gatewayDevice, long vni) {
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(vni)
.matchEthDst(GATEWAYMAC);
tBuilder.extension(buildNiciraExtenstion(d.id(), config.nodes().get(gatewayDevice.id())), d.id())
.setOutput(getTunnelPort(d.id()));
ForwardingObjective fo = DefaultForwardingObjective.builder()
.withSelector(sBuilder.build())
.withTreatment(tBuilder.build())
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(ROUTING_RULE_PRIORITY)
.fromApp(appId)
.add();
flowObjectiveService.forward(d.id(), fo);
}
示例2: populateTableMissEntry
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
protected void populateTableMissEntry(int tableToAdd,
boolean toControllerNow,
boolean toControllerWrite,
boolean toTable, int tableToSend) {
TrafficSelector selector = DefaultTrafficSelector.builder().build();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
if (toControllerNow) {
tBuilder.setOutput(PortNumber.CONTROLLER);
}
if (toControllerWrite) {
tBuilder.deferred().setOutput(PortNumber.CONTROLLER);
}
if (toTable) {
tBuilder.transition(tableToSend);
}
FlowRule flow = DefaultFlowRule.builder().forDevice(deviceId)
.withSelector(selector).withTreatment(tBuilder.build())
.withPriority(0).fromApp(appId).makePermanent()
.forTable(tableToAdd).build();
flowRuleService.applyFlowRules(flow);
}
示例3: programExportPortArpClassifierRules
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
@Override
public void programExportPortArpClassifierRules(Port exportPort,
DeviceId deviceId,
Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(EtherType.ARP.ethType().toShort())
.matchInPort(exportPort.number()).build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(L3_CLASSIFIER_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, objective.add());
} else {
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例4: processNextTreatment
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
@Override
protected TrafficTreatment processNextTreatment(TrafficTreatment treatment) {
TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
tb.add(Instructions.popVlan());
treatment.immediate().stream()
.filter(i -> {
switch (i.type()) {
case L2MODIFICATION:
L2ModificationInstruction l2i = (L2ModificationInstruction) i;
if (l2i.subtype() == VLAN_ID ||
l2i.subtype() == VLAN_POP ||
l2i.subtype() == VLAN_POP ||
l2i.subtype() == ETH_DST ||
l2i.subtype() == ETH_SRC) {
return true;
}
case OUTPUT:
return true;
default:
return false;
}
}).forEach(i -> tb.add(i));
return tb.build();
}
示例5: processMacTable
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private void processMacTable(boolean install) {
TrafficSelector.Builder selector;
TrafficTreatment.Builder treatment;
// Bcast rule
selector = DefaultTrafficSelector.builder();
treatment = DefaultTrafficTreatment.builder();
selector.matchEthDst(MacAddress.BROADCAST);
treatment.transition(VLAN_MPLS_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(MAC_TABLE).build();
processFlowRule(true, rule, "Provisioned mac table transition");
//Drop rule
processTableMissDrop(true, MAC_TABLE, "Provisioned mac table drop action");
}
示例6: transitFlow
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private FlowRule transitFlow(PortNumber inPort, Link link,
MplsPathIntent intent,
MplsLabel prevLabel,
MplsLabel outLabel) {
// Ignore the ingress Traffic Selector and use only the MPLS label
// assigned in the previous link
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchInPort(inPort).matchEthType(Ethernet.MPLS_UNICAST)
.matchMplsLabel(prevLabel);
TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
// Set the new label only if the label on the packet is
// different
if (!prevLabel.equals(outLabel)) {
treat.setMpls(outLabel);
}
treat.setOutput(link.src().port());
return createFlowRule(intent, link.src().deviceId(), selector.build(), treat.build());
}
示例7: processEthDstOnlyFilter
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
protected List<FlowRule> processEthDstOnlyFilter(EthCriterion ethCriterion,
ApplicationId applicationId, int priority) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchEthDst(ethCriterion.mac());
treatment.transition(TABLE_IPV4_UNICAST);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(priority)
.fromApp(applicationId)
.makePermanent()
.forTable(TABLE_TMAC).build();
return ImmutableList.<FlowRule>builder().add(rule).build();
}
示例8: testRouteAddNoVlans
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Tests adding a route. All interfaces have no VLAN Ids configured.
*
* We verify that the synchronizer records the correct state and that the
* correct intent is submitted to the IntentService.
*/
@Test
public void testRouteAddNoVlans() {
ResolvedRoute route = new ResolvedRoute(PREFIX1,
Ip4Address.valueOf("192.168.30.1"),
MacAddress.valueOf("00:00:00:00:00:03"));
// Construct a MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV4).matchIPDst(PREFIX1);
TrafficTreatment.Builder treatmentBuilder =
DefaultTrafficTreatment.builder();
treatmentBuilder.setEthDst(MacAddress.valueOf("00:00:00:00:00:03"));
Set<ConnectPoint> ingressPoints = new HashSet<>();
ingressPoints.add(SW1_ETH1);
ingressPoints.add(SW2_ETH1);
MultiPointToSinglePointIntent intent =
MultiPointToSinglePointIntent.builder()
.appId(APPID)
.key(Key.of(PREFIX1.toString(), APPID))
.selector(selectorBuilder.build())
.treatment(treatmentBuilder.build())
.ingressPoints(ingressPoints)
.egressPoint(SW3_ETH1)
.constraints(SdnIpFib.CONSTRAINTS)
.build();
// Setup the expected intents
intentSynchronizer.submit(eqExceptId(intent));
replay(intentSynchronizer);
// Send in the added event
routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED, route));
verify(intentSynchronizer);
}
示例9: processIpFilter
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的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);
}
示例10: packetOut
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private void packetOut(Ethernet ethernet, DeviceId deviceId, int portNum, OpenstackRouter router) {
PacketService packetService = getService(PacketService.class);
IPv4 iPacket = (IPv4) ethernet.getPayload();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
switch (iPacket.getProtocol()) {
case IPv4.PROTOCOL_TCP:
TCP tcpPacket = (TCP) iPacket.getPayload();
tcpPacket.setSourcePort(portNum);
tcpPacket.resetChecksum();
tcpPacket.setParent(iPacket);
iPacket.setPayload(tcpPacket);
break;
case IPv4.PROTOCOL_UDP:
UDP udpPacket = (UDP) iPacket.getPayload();
udpPacket.setSourcePort(portNum);
udpPacket.resetChecksum();
udpPacket.setParent(iPacket);
iPacket.setPayload(udpPacket);
break;
default:
log.error("Temporally, this method can process UDP and TCP protocol.");
return;
}
iPacket.setSourceAddress(getExternalIp(router).toString());
iPacket.resetChecksum();
iPacket.setParent(ethernet);
ethernet.setPayload(iPacket);
ethernet.setSourceMACAddress(config.gatewayExternalInterfaceMac())
.setDestinationMACAddress(config.physicalRouterMac());
ethernet.resetChecksum();
treatment.setOutput(port.number());
packetService.emit(new DefaultOutboundPacket(deviceId, treatment.build(),
ByteBuffer.wrap(ethernet.serialize())));
}
示例11: processClassifierTable
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
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);
}
示例12: buildTreatment
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private TrafficTreatment buildTreatment() {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
for (OFInstruction in : instructions) {
switch (in.getType()) {
case GOTO_TABLE:
builder.transition(((int) ((OFInstructionGotoTable) in)
.getTableId().getValue()));
break;
case WRITE_METADATA:
OFInstructionWriteMetadata m = (OFInstructionWriteMetadata) in;
builder.writeMetadata(m.getMetadata().getValue(),
m.getMetadataMask().getValue());
break;
case WRITE_ACTIONS:
builder.deferred();
buildActions(((OFInstructionWriteActions) in).getActions(),
builder);
break;
case APPLY_ACTIONS:
builder.immediate();
buildActions(((OFInstructionApplyActions) in).getActions(),
builder);
break;
case CLEAR_ACTIONS:
builder.wipeDeferred();
break;
case EXPERIMENTER:
break;
case METER:
break;
default:
log.warn("Unknown instructions type {}", in.getType());
}
}
return builder.build();
}
示例13: processIpFilter
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
@Override
protected 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);
}
示例14: DefaultPacketContext
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Creates a new packet context.
*
* @param time creation time
* @param inPkt inbound packet
* @param outPkt outbound packet
* @param block whether the context is blocked or not
*/
protected DefaultPacketContext(long time, InboundPacket inPkt,
OutboundPacket outPkt, boolean block) {
super();
this.time = time;
this.inPkt = inPkt;
this.outPkt = outPkt;
this.block = new AtomicBoolean(block);
this.builder = DefaultTrafficTreatment.builder();
}
示例15: generateAclFlow
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Generates ACL flow rule according to ACL rule
* and install it into related device.
*/
private void generateAclFlow(AclRule rule, DeviceId deviceId) {
if (rule == null || aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) {
return;
}
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
FlowEntry.Builder flowEntry = DefaultFlowEntry.builder();
selectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
if (rule.srcIp() != null) {
selectorBuilder.matchIPSrc(rule.srcIp());
if (rule.dstIp() != null) {
selectorBuilder.matchIPDst(rule.dstIp());
}
} else {
selectorBuilder.matchIPDst(rule.dstIp());
}
if (rule.ipProto() != 0) {
selectorBuilder.matchIPProtocol(Integer.valueOf(rule.ipProto()).byteValue());
}
if (rule.dstTpPort() != 0) {
switch (rule.ipProto()) {
case IPv4.PROTOCOL_TCP:
selectorBuilder.matchTcpDst(TpPort.tpPort(rule.dstTpPort()));
break;
case IPv4.PROTOCOL_UDP:
selectorBuilder.matchUdpDst(TpPort.tpPort(rule.dstTpPort()));
break;
default:
break;
}
}
if (rule.action() == AclRule.Action.ALLOW) {
treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
}
flowEntry.forDevice(deviceId);
flowEntry.withPriority(aclStore.getPriorityByDevice(deviceId));
flowEntry.withSelector(selectorBuilder.build());
flowEntry.withTreatment(treatment.build());
flowEntry.fromApp(appId);
flowEntry.makePermanent();
// install flow rule
flowRuleService.applyFlowRules(flowEntry.build());
log.debug("ACL flow rule {} is installed in {}.", flowEntry.build(), deviceId);
aclStore.addRuleToFlowMapping(rule.id(), flowEntry.build());
aclStore.addRuleToDeviceMapping(rule.id(), deviceId);
}