本文整理汇总了Java中org.onosproject.net.flow.criteria.Criteria类的典型用法代码示例。如果您正苦于以下问题:Java Criteria类的具体用法?Java Criteria怎么用?Java Criteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Criteria类属于org.onosproject.net.flow.criteria包,在下文中一共展示了Criteria类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFilteringObjective
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
private void createFilteringObjective(boolean install, Interface intf) {
VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ?
VlanId.vlanId(ASSIGNED_VLAN) :
egressVlan();
FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
// first add filter for the interface
fob.withKey(Criteria.matchInPort(intf.connectPoint().port()))
.addCondition(Criteria.matchEthDst(intf.mac()))
.addCondition(Criteria.matchVlanId(intf.vlan()));
fob.withPriority(PRIORITY_OFFSET);
if (intf.vlan() == VlanId.NONE) {
TrafficTreatment tt = DefaultTrafficTreatment.builder()
.pushVlan().setVlanId(assignedVlan).build();
fob.withMeta(tt);
}
fob.permit().fromApp(routerAppId);
sendFilteringObjective(install, fob, intf);
if (controlPlaneConnectPoint != null) {
// then add the same mac/vlan filters for control-plane connect point
fob.withKey(Criteria.matchInPort(controlPlaneConnectPoint.port()));
sendFilteringObjective(install, fob, intf);
}
}
示例2: createMcastFilteringObjective
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
private void createMcastFilteringObjective(boolean install, Interface intf) {
VlanId assignedVlan = (egressVlan().equals(VlanId.NONE)) ?
VlanId.vlanId(ASSIGNED_VLAN) :
egressVlan();
FilteringObjective.Builder fob = DefaultFilteringObjective.builder();
// first add filter for the interface
fob.withKey(Criteria.matchInPort(intf.connectPoint().port()))
.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST,
MacAddress.IPV4_MULTICAST_MASK))
.addCondition(Criteria.matchVlanId(ingressVlan()));
fob.withPriority(PRIORITY_OFFSET);
TrafficTreatment tt = DefaultTrafficTreatment.builder()
.pushVlan().setVlanId(assignedVlan).build();
fob.withMeta(tt);
fob.permit().fromApp(routerAppId);
sendFilteringObjective(install, fob, intf);
}
示例3: matchIPv6ExthdrFlagsTest
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests IPv6 Extension Header pseudo-field flags criterion.
*/
@Test
public void matchIPv6ExthdrFlagsTest() {
int exthdrFlags =
Criterion.IPv6ExthdrFlags.NONEXT.getValue() |
Criterion.IPv6ExthdrFlags.ESP.getValue() |
Criterion.IPv6ExthdrFlags.AUTH.getValue() |
Criterion.IPv6ExthdrFlags.DEST.getValue() |
Criterion.IPv6ExthdrFlags.FRAG.getValue() |
Criterion.IPv6ExthdrFlags.ROUTER.getValue() |
Criterion.IPv6ExthdrFlags.HOP.getValue() |
Criterion.IPv6ExthdrFlags.UNREP.getValue() |
Criterion.IPv6ExthdrFlags.UNSEQ.getValue();
Criterion criterion = Criteria.matchIPv6ExthdrFlags(exthdrFlags);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
示例4: filterObjBuilder
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Creates a filtering objective builder for multicast.
*
* @param deviceId Device ID
* @param ingressPort ingress port of the multicast stream
* @param assignedVlan assigned VLAN ID
* @return filtering objective builder
*/
private FilteringObjective.Builder filterObjBuilder(DeviceId deviceId, PortNumber ingressPort,
VlanId assignedVlan) {
FilteringObjective.Builder filtBuilder = DefaultFilteringObjective.builder();
filtBuilder.withKey(Criteria.matchInPort(ingressPort))
.addCondition(Criteria.matchEthDstMasked(MacAddress.IPV4_MULTICAST,
MacAddress.IPV4_MULTICAST_MASK))
.addCondition(Criteria.matchVlanId(egressVlan()))
.withPriority(SegmentRoutingService.DEFAULT_PRIORITY);
// vlan assignment is valid only if this instance is master
if (srManager.mastershipService.isLocalMaster(deviceId)) {
TrafficTreatment tt = DefaultTrafficTreatment.builder()
.pushVlan().setVlanId(assignedVlan).build();
filtBuilder.withMeta(tt);
}
return filtBuilder.permit().fromApp(srManager.appId);
}
示例5: testTrafficSelectorEncode
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests encoding of a traffic selector object.
*/
@Test
public void testTrafficSelectorEncode() {
Criterion inPort = Criteria.matchInPort(PortNumber.portNumber(0));
Criterion ethSrc = Criteria.matchEthSrc(MacAddress.valueOf("11:22:33:44:55:66"));
Criterion ethDst = Criteria.matchEthDst(MacAddress.valueOf("44:55:66:77:88:99"));
Criterion ethType = Criteria.matchEthType(Ethernet.TYPE_IPV4);
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
TrafficSelector selector = sBuilder
.add(inPort)
.add(ethSrc)
.add(ethDst)
.add(ethType)
.build();
ObjectNode selectorJson = trafficSelectorCodec.encode(selector, context);
assertThat(selectorJson, TrafficSelectorJsonMatcher.matchesTrafficSelector(selector));
}
示例6: testEquals
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests equals(), hashCode() and toString() methods.
*/
@Test
public void testEquals() {
final TrafficSelector selector1 = DefaultTrafficSelector.builder()
.add(Criteria.matchLambda(new OchSignal(GridType.FLEX, ChannelSpacing.CHL_100GHZ, 1, 1)))
.build();
final TrafficSelector sameAsSelector1 = DefaultTrafficSelector.builder()
.add(Criteria.matchLambda(new OchSignal(GridType.FLEX, ChannelSpacing.CHL_100GHZ, 1, 1)))
.build();
final TrafficSelector selector2 = DefaultTrafficSelector.builder()
.add(Criteria.matchLambda(new OchSignal(GridType.FLEX, ChannelSpacing.CHL_50GHZ, 1, 1)))
.build();
new EqualsTester()
.addEqualityGroup(selector1, sameAsSelector1)
.addEqualityGroup(selector2)
.testEquals();
}
示例7: filteringObjective
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests adding a filtering objective.
*/
@Test
public void filteringObjective() {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
FilteringObjective filter =
DefaultFilteringObjective.builder()
.fromApp(NetTestTools.APP_ID)
.withMeta(treatment)
.makePermanent()
.deny()
.addCondition(Criteria.matchEthType(12))
.add();
manager.activate();
manager.filter(id1, filter);
TestTools.assertAfter(RETRY_MS, () ->
assertThat(filteringObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasSize(0));
assertThat(filteringObjectives, hasItem("of:d1"));
assertThat(nextObjectives, hasSize(0));
}
示例8: read
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
@Override
public ExtensionCriterion read(Kryo kryo, Input input,
Class<ExtensionCriterion> type) {
ExtensionSelectorType exType = (ExtensionSelectorType) kryo.readClassAndObject(input);
DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);
DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
DriverHandler handler = new DefaultDriverHandler(
new DefaultDriverData(driverService.getDriver(deviceId), deviceId));
ExtensionSelectorResolver resolver = handler.behaviour(ExtensionSelectorResolver.class);
ExtensionSelector selector = resolver.getExtensionSelector(exType);
byte[] bytes = (byte[]) kryo.readClassAndObject(input);
selector.deserialize(bytes);
return Criteria.extension(selector, deviceId);
}
示例9: decodeCriterion
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
@Override
public Criterion decodeCriterion(ObjectNode json) {
JsonNode oduSignalId = nullIsIllegal(json.get(CriterionCodec.ODU_SIGNAL_ID),
CriterionCodec.TRIBUTARY_PORT_NUMBER + MISSING_MEMBER_MESSAGE);
int tributaryPortNumber = nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_PORT_NUMBER),
CriterionCodec.TRIBUTARY_PORT_NUMBER + MISSING_MEMBER_MESSAGE).asInt();
int tributarySlotLen = nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_SLOT_LEN),
CriterionCodec.TRIBUTARY_SLOT_LEN + MISSING_MEMBER_MESSAGE).asInt();
byte[] tributarySlotBitmap = HexString.fromHexString(
nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP),
CriterionCodec.TRIBUTARY_SLOT_BITMAP + MISSING_MEMBER_MESSAGE).asText());
return Criteria.matchOduSignalId(
OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap));
}
示例10: matchIcmpv6CodeTest
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests ICMP v6 code criterion.
*/
@Test
public void matchIcmpv6CodeTest() {
Criterion criterion = Criteria.matchIcmpv6Code((byte) 250);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
示例11: matchIPv6FlowLabelTest
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests IPv6 flow label criterion.
*/
@Test
public void matchIPv6FlowLabelTest() {
Criterion criterion = Criteria.matchIPv6FlowLabel(0xffffe);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
示例12: programTunnelBcastRules
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
@Override
public void programTunnelBcastRules(DeviceId deviceId,
SegmentationId segmentationId,
Iterable<PortNumber> localVmPorts,
Iterable<PortNumber> localTunnelPorts,
Objective.Operation type) {
if (localVmPorts == null || localTunnelPorts == null) {
log.info("No other host port or tunnel ports in the device");
return;
}
Sets.newHashSet(localTunnelPorts).stream().forEach(tp -> {
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(tp)
.add(Criteria.matchTunnelId(Long
.parseLong(segmentationId.toString())))
.matchEthDst(MacAddress.BROADCAST).build();
TrafficTreatment.Builder treatment = DefaultTrafficTreatment
.builder();
for (PortNumber outPort : localVmPorts) {
treatment.setOutput(outPort);
}
ForwardingObjective.Builder objective = DefaultForwardingObjective
.builder().withTreatment(treatment.build())
.withSelector(selector).fromApp(appId).makePermanent()
.withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
if (type.equals(Objective.Operation.ADD)) {
if (Sets.newHashSet(localVmPorts).size() == 0) {
flowObjectiveService.forward(deviceId, objective.remove());
} else {
flowObjectiveService.forward(deviceId, objective.add());
}
} else {
flowObjectiveService.forward(deviceId, objective.remove());
}
});
}
示例13: matchInPhyPortTest
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests in physical port criterion.
*/
@Test
public void matchInPhyPortTest() {
Criterion criterion = Criteria.matchInPhyPort(port);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
示例14: matchIcmpv6TypeTest
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
/**
* Tests ICMP v6 type criterion.
*/
@Test
public void matchIcmpv6TypeTest() {
Criterion criterion = Criteria.matchIcmpv6Type((byte) 250);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
示例15: getVRouterFlowObjBuilders
import org.onosproject.net.flow.criteria.Criteria; //导入依赖的package包/类
private Set<FilteringObjective.Builder> getVRouterFlowObjBuilders(Set<MacAddress> macAddresses) {
ImmutableSet.Builder<FilteringObjective.Builder> setBuilder = ImmutableSet.builder();
macAddresses.forEach(macAddress -> {
FilteringObjective.Builder fobuilder = DefaultFilteringObjective.builder();
fobuilder.withKey(Criteria.matchInPort(PortNumber.ANY))
.addCondition(Criteria.matchEthDst(macAddress))
.permit()
.withPriority(SegmentRoutingService.DEFAULT_PRIORITY)
.fromApp(srManager.appId);
setBuilder.add(fobuilder);
});
return setBuilder.build();
}