Search in sources :

Example 11 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceOFFlowBuilderTest method testaddSrcIpMatches_v4.

@Test
public void testaddSrcIpMatches_v4() {
    AceIpBuilder builder = new AceIpBuilder();
    AceIpv4Builder v4builder = new AceIpv4Builder();
    v4builder.setSourceIpv4Network(new Ipv4Prefix("10.1.1.1/24"));
    builder.setAceIpVersion(v4builder.build());
    List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addSrcIpMatches(builder.build());
    assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
    assertTrue(flowMatches.contains(new MatchIpv4Source("10.1.1.1", "24")));
}
Also used : AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) AceIpv4Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchIpv4Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 12 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceOFFlowBuilderTest method testprogramOtherProtocolFlow.

@Test
public void testprogramOtherProtocolFlow() {
    AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", null, null, (short) 1);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programOtherProtocolFlow(builder.build());
    List<MatchInfoBase> flowMatches = flowMatchesMap.get("OTHER_PROTO" + "1");
    AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
}
Also used : AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) ArrayList(java.util.ArrayList) List(java.util.List) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 13 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceOFFlowBuilderTest method testprogramUdpFlow_WithSrcDstPortRange.

@Test
public void testprogramUdpFlow_WithSrcDstPortRange() {
    AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", "1024", "1024", (short) 1);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programUdpFlow(builder.build());
    List<MatchInfoBase> srcFlowMatches = new ArrayList<>();
    List<MatchInfoBase> dstFlowMatches = new ArrayList<>();
    for (String flowId : flowMatchesMap.keySet()) {
        if (flowId.startsWith("UDP_SOURCE_")) {
            srcFlowMatches.addAll(flowMatchesMap.get(flowId));
        }
        if (flowId.startsWith("UDP_DESTINATION_")) {
            dstFlowMatches.addAll(flowMatchesMap.get(flowId));
        }
    }
    AclServiceTestUtils.verifyGeneralFlows(srcFlowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    List<MatchInfoBase> udpSrcMatches = srcFlowMatches.stream().filter(item -> item instanceof NxMatchUdpSourcePort).collect(Collectors.toList());
    assertEquals(new NxMatchUdpSourcePort(1024, 65535), udpSrcMatches.get(0));
    AclServiceTestUtils.verifyGeneralFlows(dstFlowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    List<MatchInfoBase> udpDstMatches = dstFlowMatches.stream().filter(item -> item instanceof NxMatchUdpDestinationPort).collect(Collectors.toList());
    assertEquals(new NxMatchUdpDestinationPort(1024, 65535), udpDstMatches.get(0));
}
Also used : MatchIpv4Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source) NxMatchUdpSourcePort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchUdpSourcePort) NxMatchTcpSourcePort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTcpSourcePort) NxMatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchUdpDestinationPort) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Collectors(java.util.stream.Collectors) NxMatchTcpDestinationPort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTcpDestinationPort) ArrayList(java.util.ArrayList) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Map(java.util.Map) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) AceIpv4Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder) Assert.assertEquals(org.junit.Assert.assertEquals) AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NxMatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchUdpDestinationPort) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) NxMatchUdpSourcePort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchUdpSourcePort) Test(org.junit.Test)

Example 14 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceOFFlowBuilderTest method testaddSrcIpMatches_v4NoSrcNetwork.

@Test
public void testaddSrcIpMatches_v4NoSrcNetwork() {
    AceIpBuilder builder = new AceIpBuilder();
    AceIpv4Builder v4builder = new AceIpv4Builder();
    v4builder.setSourceIpv4Network(null);
    builder.setAceIpVersion(v4builder.build());
    List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addSrcIpMatches(builder.build());
    assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, MatchIpv4Source.class);
}
Also used : AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) AceIpv4Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 15 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceOFFlowBuilderTest method testaddDstIpMatches_v4NoDstNetwork.

@Test
public void testaddDstIpMatches_v4NoDstNetwork() {
    AceIpBuilder builder = new AceIpBuilder();
    AceIpv4Builder v4builder = new AceIpv4Builder();
    v4builder.setDestinationIpv4Network(null);
    builder.setAceIpVersion(v4builder.build());
    List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addDstIpMatches(builder.build());
    assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, MatchIpv4Destination.class);
}
Also used : AceIpBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder) AceIpv4Builder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Aggregations

MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)70 ArrayList (java.util.ArrayList)60 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)33 BigInteger (java.math.BigInteger)18 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)18 List (java.util.List)16 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)15 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)13 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)11 Test (org.junit.Test)10 NxMatchCtState (org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState)10 AceIpBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder)10 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)9 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)8 MatchIpv4Source (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source)7 AceIpv4Builder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder)7 HashMap (java.util.HashMap)6 NxCtAction (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction)6