本文整理汇总了Java中org.onosproject.net.flow.criteria.Criteria.matchEthType方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.matchEthType方法的具体用法?Java Criteria.matchEthType怎么用?Java Criteria.matchEthType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.criteria.Criteria
的用法示例。
在下文中一共展示了Criteria.matchEthType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFilteringObjectiveEncode
import org.onosproject.net.flow.criteria.Criteria; //导入方法依赖的package包/类
/**
* Tests encoding of a FilteringObjective object.
*/
@Test
public void testFilteringObjectiveEncode() {
Criterion condition1 = Criteria.matchVlanId(VlanId.ANY);
Criterion condition2 = Criteria.matchEthType((short) 0x8844);
FilteringObjective filteringObj = DefaultFilteringObjective.builder()
.makePermanent()
.permit()
.fromApp(APP_ID)
.withPriority(60)
.addCondition(condition1)
.addCondition(condition2)
.add();
// TODO: need to add test case for TrafficTreatment (META in filteringObj)
ObjectNode filteringObjJson = filteringObjectiveCodec.encode(filteringObj, context);
assertThat(filteringObjJson, matchesFilteringObjective(filteringObj));
}
示例2: testForwardingObjectiveEncode
import org.onosproject.net.flow.criteria.Criteria; //导入方法依赖的package包/类
/**
* Tests encoding of a ForwardingObjective object.
*/
@Test
public void testForwardingObjectiveEncode() {
Criterion criterion1 = Criteria.matchVlanId(VlanId.ANY);
Criterion criterion2 = Criteria.matchEthType((short) 0x8844);
TrafficSelector selector = DefaultTrafficSelector.builder()
.add(criterion1)
.add(criterion2)
.build();
ForwardingObjective forwardingObj = DefaultForwardingObjective.builder()
.makePermanent()
.fromApp(APP_ID)
.withPriority(60)
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.nextStep(1)
.withSelector(selector)
.add();
ObjectNode forwardingObjJson = forwardingObjectiveCodec.encode(forwardingObj, context);
assertThat(forwardingObjJson, matchesForwardingObjective(forwardingObj));
}
示例3: 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));
}
示例4: decodeCriterion
import org.onosproject.net.flow.criteria.Criteria; //导入方法依赖的package包/类
@Override
public Criterion decodeCriterion(ObjectNode json) {
JsonNode ethTypeNode = nullIsIllegal(json.get(CriterionCodec.ETH_TYPE),
CriterionCodec.ETH_TYPE + MISSING_MEMBER_MESSAGE);
int ethType;
if (ethTypeNode.isInt()) {
ethType = ethTypeNode.asInt();
} else {
ethType = Integer.decode(ethTypeNode.textValue());
}
return Criteria.matchEthType(ethType);
}
示例5: matchEthTypeTest
import org.onosproject.net.flow.criteria.Criteria; //导入方法依赖的package包/类
/**
* Tests ethernet type criterion.
*/
@Test
public void matchEthTypeTest() {
Criterion criterion = Criteria.matchEthType((short) 0x8844);
ObjectNode result = criterionCodec.encode(criterion, context);
assertThat(result, matchesCriterion(criterion));
}
示例6: testFlowRuleEncode
import org.onosproject.net.flow.criteria.Criteria; //导入方法依赖的package包/类
/**
* Checks that a simple rule encodes properly.
*/
@Test
public void testFlowRuleEncode() {
DeviceId deviceId = DeviceId.deviceId("of:000000000000000a");
Instruction output = Instructions.createOutput(PortNumber.portNumber(0));
Instruction modL2Src = Instructions.modL2Src(MacAddress.valueOf("11:22:33:44:55:66"));
Instruction modL2Dst = Instructions.modL2Dst(MacAddress.valueOf("44:55:66:77:88:99"));
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
TrafficTreatment treatment = tBuilder
.add(output)
.add(modL2Src)
.add(modL2Dst)
.build();
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();
FlowRule permFlowRule = DefaultFlowRule.builder()
.withCookie(1)
.forTable(1)
.withPriority(1)
.makePermanent()
.withTreatment(treatment)
.withSelector(selector)
.forDevice(deviceId).build();
FlowRule tempFlowRule = DefaultFlowRule.builder()
.withCookie(1)
.forTable(1)
.withPriority(1)
.makeTemporary(1000)
.withTreatment(treatment)
.withSelector(selector)
.forDevice(deviceId).build();
ObjectNode permFlowRuleJson = flowRuleCodec.encode(permFlowRule, context);
ObjectNode tempFlowRuleJson = flowRuleCodec.encode(tempFlowRule, context);
assertThat(permFlowRuleJson, FlowRuleJsonMatcher.matchesFlowRule(permFlowRule));
assertThat(tempFlowRuleJson, FlowRuleJsonMatcher.matchesFlowRule(tempFlowRule));
}