Search in sources :

Example 1 with PiMatchFieldId

use of org.onosproject.net.pi.model.PiMatchFieldId in project onos by opennetworkinglab.

the class PiExactFieldMatchTest method testConstruction.

/**
 * Checks the construction of a PiExactFieldMatch object.
 */
@Test
public void testConstruction() {
    final ImmutableByteSequence value = copyFrom(0x0806);
    final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
    PiExactFieldMatch piExactFieldMatch = new PiExactFieldMatch(piMatchField, value);
    assertThat(piExactFieldMatch, is(notNullValue()));
    assertThat(piExactFieldMatch.value(), is(value));
    assertThat(piExactFieldMatch.type(), is(PiMatchType.EXACT));
}
Also used : PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) ImmutableByteSequence(org.onlab.util.ImmutableByteSequence) Test(org.junit.Test)

Example 2 with PiMatchFieldId

use of org.onosproject.net.pi.model.PiMatchFieldId in project onos by opennetworkinglab.

the class PiLpmFieldMatchTest method testConstruction.

/**
 * Checks the construction of a PiLpmFieldMatch object.
 */
@Test
public void testConstruction() {
    final ImmutableByteSequence value = copyFrom(0x0a01010a);
    int prefix = 24;
    final PiMatchFieldId piMatchField = PiMatchFieldId.of(IPV4_HEADER_NAME + DOT + DST_ADDR);
    PiLpmFieldMatch piLpmFieldMatch = new PiLpmFieldMatch(piMatchField, value, prefix);
    assertThat(piLpmFieldMatch, is(notNullValue()));
    assertThat(piLpmFieldMatch.value(), is(value));
    assertThat(piLpmFieldMatch.prefixLength(), is(prefix));
    assertThat(piLpmFieldMatch.type(), is(PiMatchType.LPM));
}
Also used : PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) ImmutableByteSequence(org.onlab.util.ImmutableByteSequence) Test(org.junit.Test)

Example 3 with PiMatchFieldId

use of org.onosproject.net.pi.model.PiMatchFieldId in project onos by opennetworkinglab.

the class PiFieldMatchTest method basics.

@Test
public void basics() {
    final PiMatchFieldId piMatchField = PiMatchFieldId.of(ETH_HEADER_NAME + DOT + ETH_TYPE);
    PiFieldMatch piFieldMatch = new PiExactFieldMatch(piMatchField, copyFrom(0x0806));
    assertEquals(piFieldMatch.fieldId(), piMatchField);
    assertEquals(piFieldMatch.type(), PiMatchType.EXACT);
}
Also used : PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) Test(org.junit.Test)

Example 4 with PiMatchFieldId

use of org.onosproject.net.pi.model.PiMatchFieldId in project onos by opennetworkinglab.

the class PiRangeFieldMatchTest method testConstruction.

/**
 * Checks the construction of a PiRangeFieldMatch object.
 */
@Test
public void testConstruction() {
    final ImmutableByteSequence high = copyFrom(0x50);
    final ImmutableByteSequence low = copyFrom(0x00);
    final PiMatchFieldId piMatchField = PiMatchFieldId.of(VLAN_HEADER_NAME + DOT + VID);
    PiRangeFieldMatch piRangeFieldMatch = new PiRangeFieldMatch(piMatchField, low, high);
    assertThat(piRangeFieldMatch, is(notNullValue()));
    assertThat(piRangeFieldMatch.lowValue(), is(low));
    assertThat(piRangeFieldMatch.highValue(), is(high));
    assertThat(piRangeFieldMatch.type(), is(PiMatchType.RANGE));
}
Also used : PiMatchFieldId(org.onosproject.net.pi.model.PiMatchFieldId) ImmutableByteSequence(org.onlab.util.ImmutableByteSequence) Test(org.junit.Test)

Example 5 with PiMatchFieldId

use of org.onosproject.net.pi.model.PiMatchFieldId 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)

Aggregations

PiMatchFieldId (org.onosproject.net.pi.model.PiMatchFieldId)15 Test (org.junit.Test)10 ImmutableByteSequence (org.onlab.util.ImmutableByteSequence)7 PiTableId (org.onosproject.net.pi.model.PiTableId)5 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)4 PiActionId (org.onosproject.net.pi.model.PiActionId)3 PiAction (org.onosproject.net.pi.runtime.PiAction)3 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)3 Criterion (org.onosproject.net.flow.criteria.Criterion)2 PiActionModel (org.onosproject.net.pi.model.PiActionModel)2 PiMatchFieldModel (org.onosproject.net.pi.model.PiMatchFieldModel)2 PiTableModel (org.onosproject.net.pi.model.PiTableModel)2 PiExactFieldMatch (org.onosproject.net.pi.runtime.PiExactFieldMatch)2 PiFieldMatch (org.onosproject.net.pi.runtime.PiFieldMatch)2 PiLpmFieldMatch (org.onosproject.net.pi.runtime.PiLpmFieldMatch)2 PiOptionalFieldMatch (org.onosproject.net.pi.runtime.PiOptionalFieldMatch)2 PiRangeFieldMatch (org.onosproject.net.pi.runtime.PiRangeFieldMatch)2 PiTernaryFieldMatch (org.onosproject.net.pi.runtime.PiTernaryFieldMatch)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ImmutableMap (com.google.common.collect.ImmutableMap)1