Search in sources :

Example 26 with PiExactFieldMatch

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

Example 27 with PiExactFieldMatch

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

Example 28 with PiExactFieldMatch

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

Example 29 with PiExactFieldMatch

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

Example 30 with PiExactFieldMatch

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