Search in sources :

Example 11 with PiExactFieldMatch

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()));
}
Also used : PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) TcpFlagsCriterion(org.onosproject.net.flow.criteria.TcpFlagsCriterion) Test(org.junit.Test)

Example 12 with PiExactFieldMatch

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()));
}
Also used : IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) Test(org.junit.Test)

Example 13 with PiExactFieldMatch

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()));
}
Also used : PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) Test(org.junit.Test)

Example 14 with PiExactFieldMatch

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()));
}
Also used : MplsTcCriterion(org.onosproject.net.flow.criteria.MplsTcCriterion) PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) Test(org.junit.Test)

Example 15 with PiExactFieldMatch

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()));
}
Also used : MplsLabel(org.onlab.packet.MplsLabel) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) Test(org.junit.Test)

Aggregations

PiExactFieldMatch (org.onosproject.net.pi.runtime.PiExactFieldMatch)36 Test (org.junit.Test)30 PiTernaryFieldMatch (org.onosproject.net.pi.runtime.PiTernaryFieldMatch)10 PiLpmFieldMatch (org.onosproject.net.pi.runtime.PiLpmFieldMatch)6 PiOptionalFieldMatch (org.onosproject.net.pi.runtime.PiOptionalFieldMatch)5 PiRangeFieldMatch (org.onosproject.net.pi.runtime.PiRangeFieldMatch)4 MacAddress (org.onlab.packet.MacAddress)3 TpPort (org.onlab.packet.TpPort)3 ImmutableByteSequence (org.onlab.util.ImmutableByteSequence)3 PiFieldMatch (org.onosproject.net.pi.runtime.PiFieldMatch)3 ByteString (com.google.protobuf.ByteString)2 ByteSequenceTrimException (org.onlab.util.ImmutableByteSequence.ByteSequenceTrimException)2 SctpPortCriterion (org.onosproject.net.flow.criteria.SctpPortCriterion)2 TcpPortCriterion (org.onosproject.net.flow.criteria.TcpPortCriterion)2 UdpPortCriterion (org.onosproject.net.flow.criteria.UdpPortCriterion)2 P4InfoOuterClass (p4.config.v1.P4InfoOuterClass)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 EthType (org.onlab.packet.EthType)1 Ip4Address (org.onlab.packet.Ip4Address)1 Ip4Prefix (org.onlab.packet.Ip4Prefix)1