Search in sources :

Example 16 with Criterion

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

the class CriterionCodecTest method matchSctpSrcMaskedTest.

/**
 * Tests source SCTP port masked criterion.
 */
@Test
public void matchSctpSrcMaskedTest() {
    Criterion criterion = Criteria.matchSctpSrcMasked(tpPort, tpPortMask);
    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 17 with Criterion

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

the class CriterionCodecTest method matchIPEcnTest.

/**
 * Tests IP ECN criterion.
 */
@Test
public void matchIPEcnTest() {
    Criterion criterion = Criteria.matchIPEcn((byte) 3);
    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 18 with Criterion

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

the class CriterionCodecTest method matchIPv6NDTargetAddressTest.

/**
 * Tests IPV6 target address criterion.
 */
@Test
public void matchIPv6NDTargetAddressTest() {
    Criterion criterion = Criteria.matchIPv6NDTargetAddress(Ip6Address.valueOf("1111:2222::"));
    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 19 with Criterion

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

the class CriterionCodecTest method matchPiTypeDecodingTest.

/**
 * Tests protocol-independent type criterion decoding.
 */
@Test
public void matchPiTypeDecodingTest() throws IOException {
    Criterion criterion = getCriterion("PiCriterion.json");
    Assert.assertThat(criterion.type(), is(Criterion.Type.PROTOCOL_INDEPENDENT));
    Collection<PiFieldMatch> piFieldMatches = ((PiCriterion) criterion).fieldMatches();
    for (PiFieldMatch piFieldMatch : piFieldMatches) {
        switch(piFieldMatch.type()) {
            case EXACT:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("ingress_port"));
                Assert.assertThat(((PiExactFieldMatch) piFieldMatch).value(), is(copyFrom((byte) 0x10)));
                break;
            case LPM:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("src_addr"));
                Assert.assertThat(((PiLpmFieldMatch) piFieldMatch).value(), is(copyFrom(0xa010101)));
                Assert.assertThat(((PiLpmFieldMatch) piFieldMatch).prefixLength(), is(24));
                break;
            case TERNARY:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("dst_addr"));
                Assert.assertThat(((PiTernaryFieldMatch) piFieldMatch).value(), is(copyFrom(0xa010101)));
                Assert.assertThat(((PiTernaryFieldMatch) piFieldMatch).mask(), is(copyFrom(0xfffffff)));
                break;
            case RANGE:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("egress_port"));
                Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).highValue(), is(copyFrom((byte) 0x20)));
                Assert.assertThat(((PiRangeFieldMatch) piFieldMatch).lowValue(), is(copyFrom((byte) 0x10)));
                break;
            case OPTIONAL:
                Assert.assertThat(piFieldMatch.fieldId().id(), is("eth_dst"));
                Assert.assertThat(((PiOptionalFieldMatch) piFieldMatch).value(), is(copyFrom(new byte[] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 })));
                break;
            default:
                Assert.fail();
        }
    }
}
Also used : PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) PiCriterion(org.onosproject.net.flow.criteria.PiCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) CriterionJsonMatcher.matchesCriterion(org.onosproject.codec.impl.CriterionJsonMatcher.matchesCriterion) PiFieldMatch(org.onosproject.net.pi.runtime.PiFieldMatch) Test(org.junit.Test)

Example 20 with Criterion

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

the class CriterionCodecTest method matchOchSignal.

/**
 * Tests lambda criterion.
 */
@Test
public void matchOchSignal() {
    Lambda ochSignal = Lambda.ochSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 4, 8);
    Criterion criterion = Criteria.matchLambda(ochSignal);
    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) Lambda(org.onosproject.net.Lambda) 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