use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testVlanIdCriterion.
@Test
public void testVlanIdCriterion() throws Exception {
VlanId vlanId = VlanId.vlanId((short) random.nextInt(255));
int bitWidth = 16;
VlanIdCriterion criterion = (VlanIdCriterion) Criteria.matchVlanId(vlanId);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is(criterion.vlanId().toShort()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testIPv6NDLinkLayerAddressCriterion.
@Test
public void testIPv6NDLinkLayerAddressCriterion() throws Exception {
MacAddress mac = MacAddress.valueOf(random.nextLong());
int bitWidth = mac.toBytes().length * 8;
IPv6NDLinkLayerAddressCriterion criterion = (IPv6NDLinkLayerAddressCriterion) Criteria.matchIPv6NDSourceLinkLayerAddress(mac);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asArray(), is(criterion.mac().toBytes()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testArpOpCriterion.
@Test
public void testArpOpCriterion() throws Exception {
int arpOp = random.nextInt();
int bitWidth = 32;
ArpOpCriterion criterion = (ArpOpCriterion) Criteria.matchArpOp(arpOp);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getInt(), is(criterion.arpOp()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testIcmpCodeCriterion.
@Test
public void testIcmpCodeCriterion() throws Exception {
short icmpCode = (short) random.nextInt(256);
int bitWidth = 16;
IcmpCodeCriterion criterion = (IcmpCodeCriterion) Criteria.matchIcmpCode(icmpCode);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is(criterion.icmpCode()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testIcmpv6CodeCriterion.
@Test
public void testIcmpv6CodeCriterion() throws Exception {
short icmpv6Code = (short) random.nextInt(256);
int bitWidth = 16;
Icmpv6CodeCriterion criterion = (Icmpv6CodeCriterion) Criteria.matchIcmpv6Code(icmpv6Code);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is(criterion.icmpv6Code()));
}
Aggregations