本文整理汇总了Java中org.onosproject.net.flow.TrafficSelector类的典型用法代码示例。如果您正苦于以下问题:Java TrafficSelector类的具体用法?Java TrafficSelector怎么用?Java TrafficSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrafficSelector类属于org.onosproject.net.flow包,在下文中一共展示了TrafficSelector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
@Override
public void run() {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Constraint> constraint = Lists.newArrayList();
List<Host> hosts = Lists.newArrayList(hostService.getHosts());
while (!hosts.isEmpty()) {
Host src = hosts.remove(0);
for (Host dst : hosts) {
HostToHostIntent intent = HostToHostIntent.builder()
.appId(appId)
.one(src.id())
.two(dst.id())
.selector(selector)
.treatment(treatment)
.constraints(constraint)
.build();
existingIntents.add(intent);
intentService.submit(intent);
}
}
}
示例2: programExternalOut
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
@Override
public void programExternalOut(DeviceId deviceId,
SegmentationId segmentationId,
PortNumber outPort, MacAddress sourceMac,
Objective.Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchTunnelId(Long.parseLong(segmentationId.toString()))
.matchEthSrc(sourceMac).build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.setOutput(outPort).build();
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment).withSelector(selector)
.fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(MAC_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, objective.add());
} else {
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例3: populateRuleToGateway
import org.onosproject.net.flow.TrafficSelector; //导入依赖的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);
}
示例4: processVniTable
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
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);
}
示例5: processEthDstOnlyFilter
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
protected List<FlowRule> processEthDstOnlyFilter(EthCriterion ethCriterion,
ApplicationId applicationId) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchEthDst(ethCriterion.mac());
treatment.transition(UNICAST_ROUTING_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
return ImmutableList.<FlowRule>builder().add(rule).build();
}
示例6: processMcastEthDstFilter
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
protected List<FlowRule> processMcastEthDstFilter(EthCriterion ethCriterion,
ApplicationId applicationId) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
selector.matchEthType(Ethernet.TYPE_IPV4);
selector.matchEthDstMasked(ethCriterion.mac(), ethCriterion.mask());
treatment.transition(MULTICAST_ROUTING_TABLE);
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DEFAULT_PRIORITY)
.fromApp(applicationId)
.makePermanent()
.forTable(TMAC_TABLE).build();
return ImmutableList.<FlowRule>builder().add(rule).build();
}
示例7: MplsIntent
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
/**
* Creates a new point-to-point intent with the supplied ingress/egress
* ports, labels and constraints.
*
* @param appId application identifier
* @param selector traffic selector
* @param treatment treatment
* @param ingressPoint ingress port
* @param ingressLabel ingress MPLS label
* @param egressPoint egress port
* @param egressLabel egress MPLS label
* @param constraints optional list of constraints
* @param priority priority to use for flows generated by this intent
* @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
*/
private MplsIntent(ApplicationId appId,
Key key,
TrafficSelector selector,
TrafficTreatment treatment,
ConnectPoint ingressPoint,
Optional<MplsLabel> ingressLabel,
ConnectPoint egressPoint,
Optional<MplsLabel> egressLabel,
List<Constraint> constraints,
int priority) {
super(appId, key, Collections.emptyList(), selector, treatment, constraints,
priority);
this.ingressPoint = checkNotNull(ingressPoint);
this.ingressLabel = checkNotNull(ingressLabel);
this.egressPoint = checkNotNull(egressPoint);
this.egressLabel = checkNotNull(egressLabel);
checkArgument(!ingressPoint.equals(egressPoint),
"ingress and egress should be different (ingress: %s, egress: %s)",
ingressPoint, egressPoint);
}
示例8: programSnatSameSegmentRules
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
@Override
public void programSnatSameSegmentRules(DeviceId deviceId, SegmentationId matchVni,
IpAddress srcIP, IpAddress dstIP, MacAddress ethDst,
MacAddress ethSrc, IpAddress ipSrc,
SegmentationId actionVni, Objective.Operation type) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(Long.parseLong(matchVni.segmentationId()))
.matchIPSrc(IpPrefix.valueOf(srcIP, PREFIC_LENGTH))
.matchIPDst(IpPrefix.valueOf(dstIP, PREFIC_LENGTH)).build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.setEthDst(ethDst).setEthSrc(ethSrc).setIpSrc(ipSrc)
.setTunnelId(Long.parseLong(actionVni.segmentationId()));
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
.withPriority(SNAT_SAME_SEG_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, objective.add());
} else {
flowObjectiveService.forward(deviceId, objective.remove());
}
}
示例9: processEthDstOnlyFilter
import org.onosproject.net.flow.TrafficSelector; //导入依赖的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();
}
示例10: transitFlow
import org.onosproject.net.flow.TrafficSelector; //导入依赖的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());
}
示例11: removeVxLanFlowRule
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
/**
* Removes the flow rules between traffic from VMs in different Cnode.
*
* @param deviceId device id
* @param vmIp ip
* @param vni vni which removed VM was belonged
*/
private void removeVxLanFlowRule(DeviceId deviceId, Ip4Address vmIp, long vni) {
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
sBuilder.matchEthType(Ethernet.TYPE_IPV4)
.matchTunnelId(vni)
.matchIPDst(vmIp.toIpPrefix());
ForwardingObjective fo = DefaultForwardingObjective.builder()
.withSelector(sBuilder.build())
.withTreatment(DefaultTrafficTreatment.builder().build())
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withPriority(SWITCHING_RULE_PRIORITY)
.fromApp(appId)
.remove();
flowObjectiveService.forward(deviceId, fo);
}
示例12: processTableMissDrop
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
protected void processTableMissDrop(boolean install, int table, String description) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.drop();
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(DROP_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(table).build();
processFlowRule(install, rule, description);
}
示例13: processVlanFiler
import org.onosproject.net.flow.TrafficSelector; //导入依赖的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);
}
示例14: processVlanMplsTable
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
protected void processVlanMplsTable(boolean install) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment
.builder();
FlowRuleOperations.Builder ops = FlowRuleOperations.builder();
FlowRule rule;
selector.matchVlanId(VlanId.ANY);
treatment.transition(VLAN_TABLE);
rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(VLAN_MPLS_TABLE).build();
processFlowRule(true, rule, "Provisioned vlan/mpls table");
}
示例15: processLocalTable
import org.onosproject.net.flow.TrafficSelector; //导入依赖的package包/类
private void processLocalTable(boolean install) {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment
.builder()
.punt();
FlowRule rule = DefaultFlowRule.builder()
.forDevice(deviceId)
.withSelector(selector.build())
.withTreatment(treatment.build())
.withPriority(CONTROLLER_PRIORITY)
.fromApp(appId)
.makePermanent()
.forTable(LOCAL_TABLE).build();
processFlowRule(true, rule, "Provisioned Local table");
}