use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testTcpFlagsCriterion.
@Test
public void testTcpFlagsCriterion() throws Exception {
int pbbIsid = random.nextInt(1 << 12);
int bitWidth = 12;
TcpFlagsCriterion criterion = (TcpFlagsCriterion) Criteria.matchTcpFlags(pbbIsid);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is((short) criterion.flags()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testIPProtocolCriterion.
@Test
public void testIPProtocolCriterion() throws Exception {
short proto = (short) random.nextInt(256);
int bitWidth = 16;
IPProtocolCriterion criterion = (IPProtocolCriterion) Criteria.matchIPProtocol(proto);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is(criterion.protocol()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testIPEcnCriterion.
@Test
public void testIPEcnCriterion() throws Exception {
byte[] ipEcn = new byte[1];
random.nextBytes(ipEcn);
int bitWidth = 2;
IPEcnCriterion criterion = (IPEcnCriterion) Criteria.matchIPEcn(ipEcn[0]);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().get(), is(criterion.ipEcn()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testMplsTcCriterion.
@Test
public void testMplsTcCriterion() throws Exception {
byte[] mplsTc = new byte[1];
random.nextBytes(mplsTc);
int bitWidth = 16;
MplsTcCriterion criterion = (MplsTcCriterion) Criteria.matchMplsTc(mplsTc[0]);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().get(1), is(criterion.tc()));
}
use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.
the class PiCriterionTranslatorsTest method testMplsCriterion.
@Test
public void testMplsCriterion() throws Exception {
MplsLabel mplsLabel = MplsLabel.mplsLabel(random.nextInt(1 << 20));
int bitWidth = 32;
MplsCriterion criterion = (MplsCriterion) Criteria.matchMplsLabel(mplsLabel);
PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
assertThat(exactMatch.value().asReadOnlyBuffer().getInt(), is(criterion.label().toInt()));
}
Aggregations