Search in sources :

Example 31 with PiExactFieldMatch

use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.

the class PiCriterionTranslatorsTest method testVlanPcpCriterion.

@Test
public void testVlanPcpCriterion() throws Exception {
    byte[] vlanPcp = new byte[1];
    random.nextBytes(vlanPcp);
    int bitWidth = 3;
    VlanPcpCriterion criterion = (VlanPcpCriterion) Criteria.matchVlanPcp(vlanPcp[0]);
    PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
    assertThat(exactMatch.value().asReadOnlyBuffer().get(), is(criterion.priority()));
}
Also used : VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) Test(org.junit.Test)

Example 32 with PiExactFieldMatch

use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.

the class PiCriterionTranslatorsTest method testIcmpv6TypeCriterion.

@Test
public void testIcmpv6TypeCriterion() throws Exception {
    short icmpv6Type = (short) random.nextInt(256);
    int bitWidth = 16;
    Icmpv6TypeCriterion criterion = (Icmpv6TypeCriterion) Criteria.matchIcmpv6Type(icmpv6Type);
    PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
    assertThat(exactMatch.value().asReadOnlyBuffer().getShort(), is(criterion.icmpv6Type()));
}
Also used : Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) Test(org.junit.Test)

Example 33 with PiExactFieldMatch

use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.

the class PiCriterionTranslatorsTest method testArpPaCriterion.

@Test
public void testArpPaCriterion() throws Exception {
    Ip4Address ip = Ip4Address.valueOf(random.nextInt());
    int bitWidth = ip.toOctets().length * 8;
    ArpPaCriterion criterion = (ArpPaCriterion) Criteria.matchArpTpa(ip);
    PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
    assertThat(exactMatch.value().asReadOnlyBuffer().getInt(), is(criterion.ip().toInt()));
}
Also used : ArpPaCriterion(org.onosproject.net.flow.criteria.ArpPaCriterion) Ip4Address(org.onlab.packet.Ip4Address) PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) Test(org.junit.Test)

Example 34 with PiExactFieldMatch

use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.

the class PiCriterionTranslatorsTest method testIPv6FlowLabelCriterion.

@Test
public void testIPv6FlowLabelCriterion() throws Exception {
    int flowLabel = random.nextInt();
    int bitWidth = 32;
    IPv6FlowLabelCriterion criterion = (IPv6FlowLabelCriterion) Criteria.matchIPv6FlowLabel(flowLabel);
    PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
    assertThat(exactMatch.value().asReadOnlyBuffer().getInt(), is(criterion.flowLabel()));
}
Also used : PiExactFieldMatch(org.onosproject.net.pi.runtime.PiExactFieldMatch) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) Test(org.junit.Test)

Example 35 with PiExactFieldMatch

use of org.onosproject.net.pi.runtime.PiExactFieldMatch in project onos by opennetworkinglab.

the class PiCriterionTranslatorsTest method testTunnelIdCriterion.

@Test
public void testTunnelIdCriterion() throws Exception {
    long tunnelId = random.nextLong();
    int bitWidth = 64;
    TunnelIdCriterion criterion = (TunnelIdCriterion) Criteria.matchTunnelId(tunnelId);
    PiExactFieldMatch exactMatch = (PiExactFieldMatch) translateCriterion(criterion, fieldId, EXACT, bitWidth);
    assertThat(exactMatch.value().asReadOnlyBuffer().getLong(), is(criterion.tunnelId()));
}
Also used : TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) 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