use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testEthTypeCriterion.
@Test
public void testEthTypeCriterion() throws Exception {
EthType ethType = new EthType(random.nextInt());
int bitWidth = 16;
EthTypeCriterion criterion = (EthTypeCriterion) Criteria.matchEthType(ethType);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is(criterion.ethType().toShort()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testArpHaCriterionn.
@Test
public void testArpHaCriterionn() throws Exception {
MacAddress mac = MacAddress.valueOf(random.nextLong());
int bitWidth = mac.toBytes().length * 8;
ArpHaCriterion criterion = (ArpHaCriterion) Criteria.matchArpTha(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 testUdpPortCriterion.
@Test
public void testUdpPortCriterion() throws Exception {
TpPort value1 = TpPort.tpPort(random.nextInt(65536));
TpPort value2 = TpPort.tpPort(random.nextInt(65536));
TpPort mask = TpPort.tpPort(random.nextInt(65536));
int bitWidth = 16;
UdpPortCriterion criterion = (UdpPortCriterion) Criteria.matchUdpDst(value1);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
UdpPortCriterion maskedCriterion = (UdpPortCriterion) Criteria.matchUdpDstMasked(value2, mask);
PiTernaryFieldMatch ternaryMatch = (PiTernaryFieldMatch) translateCriterion(maskedCriterion, fieldId, TERNARY, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is((short) criterion.udpPort().toInt()));
assertThat(ternaryMatch.value().asReadOnlyBuffer().getShort(), is((short) maskedCriterion.udpPort().toInt()));
assertThat(ternaryMatch.mask().asReadOnlyBuffer().getShort(), is((short) maskedCriterion.mask().toInt()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testEthCriterion.
@Test
public void testEthCriterion() throws Exception {
MacAddress value1 = MacAddress.valueOf(random.nextLong());
MacAddress value2 = MacAddress.valueOf(random.nextLong());
MacAddress mask = MacAddress.valueOf(random.nextLong());
int bitWidth = value1.toBytes().length * 8;
EthCriterion criterion = (EthCriterion) Criteria.matchEthDst(value1);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
EthCriterion maskedCriterion = (EthCriterion) Criteria.matchEthDstMasked(value2, mask);
PiTernaryFieldMatch ternaryMatch = (PiTernaryFieldMatch) translateCriterion(maskedCriterion, fieldId, TERNARY, bitWidth);
assertThat(exactMatch.value().asArray(), is(criterion.mac().toBytes()));
assertThat(ternaryMatch.value().asArray(), is(maskedCriterion.mac().toBytes()));
assertThat(ternaryMatch.mask().asArray(), is(maskedCriterion.mask().toBytes()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testIPDscpCriterion.
@Test
public void testIPDscpCriterion() throws Exception {
byte[] ipDscp = new byte[1];
random.nextBytes(ipDscp);
IPDscpCriterion criterion = (IPDscpCriterion) Criteria.matchIPDscp(ipDscp[0]);
int bitWidth = 6;
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().get(), is(criterion.ipDscp()));
}
Aggregations