Search in sources :

Example 6 with PiExactFieldMatch

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

Example 7 with PiExactFieldMatch

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

Example 8 with PiExactFieldMatch

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

Example 9 with PiExactFieldMatch

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

Example 10 with PiExactFieldMatch

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