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));
}
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));
}
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);
}
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));
}
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));
}
Aggregations