Search in sources :

Example 6 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchIPv6FlowLabelTest.

/**
 * Tests IPv6 flow label criterion.
 */
@Test
public void matchIPv6FlowLabelTest() {
    Criterion criterion = Criteria.matchIPv6FlowLabel(0xffffe);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Example 7 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchTcpDstTest.

/**
 * Tests destination TCP port criterion.
 */
@Test
public void matchTcpDstTest() {
    Criterion criterion = Criteria.matchTcpDst(tpPort);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Example 8 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchTcpSrcTest.

/**
 * Tests source TCP port criterion.
 */
@Test
public void matchTcpSrcTest() {
    Criterion criterion = Criteria.matchTcpSrc(tpPort);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Example 9 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchPiTypeEncodingTest.

/**
 * Tests protocol-independent type criterion encoding.
 */
@Test
public void matchPiTypeEncodingTest() {
    PiMatchFieldId ethMatchFieldId = PiMatchFieldId.of("ethernet_t.etherType");
    byte[] matchExactBytes1 = { 0x08, 0x00 };
    Criterion exactBytesCriterion = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactBytes1).build();
    ObjectNode exactResult = criterionCodec.encode(exactBytesCriterion, context);
    assertThat(exactResult, matchesCriterion(exactBytesCriterion));
    PiMatchFieldId ipv4MatchFieldId = PiMatchFieldId.of("ipv4_t.dstAddr");
    int mask = 0x00ffffff;
    byte[] matchLpmBytes1 = { 0x0a, 0x01, 0x01, 0x01 };
    Criterion lpmBytesCriterion = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
    ObjectNode lpmResult = criterionCodec.encode(lpmBytesCriterion, context);
    assertThat(lpmResult, matchesCriterion(lpmBytesCriterion));
    byte[] matchTernaryBytes1 = { 0x0a, 0x01, 0x01, 0x01 };
    byte[] matchTernaryMaskBytes = { 0x7f, 0x7f, 0x7f, 0x00 };
    Criterion ternaryBytesCriterion = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryBytes1, matchTernaryMaskBytes).build();
    ObjectNode ternaryResult = criterionCodec.encode(ternaryBytesCriterion, context);
    assertThat(ternaryResult, matchesCriterion(ternaryBytesCriterion));
    byte[] matchRangeBytes1 = { 0x10 };
    byte[] matchRangeHighBytes = { 0x30 };
    Criterion rangeBytesCriterion = PiCriterion.builder().matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
    ObjectNode rangeResult = criterionCodec.encode(rangeBytesCriterion, context);
    assertThat(rangeResult, matchesCriterion(rangeBytesCriterion));
    byte[] matchOptionalBytes = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
    Criterion optionalBytesCriterion = PiCriterion.builder().matchOptional(ethMatchFieldId, matchOptionalBytes).build();
    ObjectNode optionalResult = criterionCodec.encode(optionalBytesCriterion, context);
    assertThat(optionalResult, matchesCriterion(optionalBytesCriterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) Test(org.junit.Test)

Example 10 with Criterion

use of org.onosproject.net.flow.criteria.Criterion in project onos by opennetworkinglab.

the class CriterionCodecTest method matchIPDscpTest.

/**
 * Tests IP DSCP criterion.
 */
@Test
public void matchIPDscpTest() {
    Criterion criterion = Criteria.matchIPDscp((byte) 63);
    ObjectNode result = criterionCodec.encode(criterion, context);
    assertThat(result, matchesCriterion(criterion));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) Test(org.junit.Test)

Aggregations

Criterion (org.onosproject.net.flow.criteria.Criterion)122 Test (org.junit.Test)54 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)54 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)51 CriterionJsonMatcher.matchesCriterion (org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion)46 VlanIdCriterion (org.onosproject.net.flow.criteria.VlanIdCriterion)43 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)42 EthCriterion (org.onosproject.net.flow.criteria.EthCriterion)39 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)39 Instruction (org.onosproject.net.flow.instructions.Instruction)37 EthTypeCriterion (org.onosproject.net.flow.criteria.EthTypeCriterion)35 TrafficSelector (org.onosproject.net.flow.TrafficSelector)33 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)29 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)25 FlowRule (org.onosproject.net.flow.FlowRule)25 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)24 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)22 Instructions (org.onosproject.net.flow.instructions.Instructions)19 List (java.util.List)17