use of 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 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testProgramUdpFlow_NoSrcDstPortRange.
@Test
public void testProgramUdpFlow_NoSrcDstPortRange() {
AceIpBuilder builder = new AceIpBuilder();
AceIpv4Builder v4builder = new AceIpv4Builder();
v4builder.setSourceIpv4Network(new Ipv4Prefix("10.1.1.1/24"));
v4builder.setDestinationIpv4Network(new Ipv4Prefix("20.1.1.1/24"));
builder.setAceIpVersion(v4builder.build());
builder.setSourcePortRange(null);
builder.setDestinationPortRange(null);
short protocol = 1;
builder.setProtocol(protocol);
Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programUdpFlow(builder.build());
List<MatchInfoBase> flowMatches = flowMatchesMap.get("UDP_SOURCE_ALL_");
AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchUdpSourcePort.class);
AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchUdpDestinationPort.class);
}
use of 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 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testprogramTcpFlow_WithSrcDstPortRange.
@Test
public void testprogramTcpFlow_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.programTcpFlow(builder.build());
List<MatchInfoBase> srcFlowMatches = new ArrayList<>();
List<MatchInfoBase> dstFlowMatches = new ArrayList<>();
for (String flowId : flowMatchesMap.keySet()) {
if (flowId.startsWith("TCP_SOURCE_")) {
srcFlowMatches.addAll(flowMatchesMap.get(flowId));
}
if (flowId.startsWith("TCP_DESTINATION_")) {
dstFlowMatches.addAll(flowMatchesMap.get(flowId));
}
}
AclServiceTestUtils.verifyGeneralFlows(srcFlowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
List<MatchInfoBase> tcpSrcMatches = srcFlowMatches.stream().filter(item -> item instanceof NxMatchTcpSourcePort).collect(Collectors.toList());
assertEquals(new NxMatchTcpSourcePort(1024, 65535), tcpSrcMatches.get(0));
AclServiceTestUtils.verifyGeneralFlows(dstFlowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
List<MatchInfoBase> tcpDstMatches = dstFlowMatches.stream().filter(item -> item instanceof NxMatchTcpDestinationPort).collect(Collectors.toList());
assertEquals(new NxMatchTcpDestinationPort(1024, 65535), tcpDstMatches.get(0));
}
use of 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 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testprogramIcmpFlow.
@Test
public void testprogramIcmpFlow() {
AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", "1024", "2048", (short) 1);
Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programIcmpFlow(builder.build());
List<MatchInfoBase> flowMatches = flowMatchesMap.entrySet().iterator().next().getValue();
AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
int matches = 0;
MatchIcmpv4 check = new MatchIcmpv4((short) 1024, (short) 2048);
for (MatchInfoBase flowMatch : flowMatches) {
if (check.equals(flowMatch)) {
matches++;
}
}
assertEquals(2, matches);
}
use of 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 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testprogramTcpFlow_NoSrcDstPortRange.
@Test
public void testprogramTcpFlow_NoSrcDstPortRange() {
AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", null, null, (short) 1);
Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programTcpFlow(builder.build());
List<MatchInfoBase> flowMatches = flowMatchesMap.get("TCP_SOURCE_ALL_");
AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchTcpSourcePort.class);
AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchTcpDestinationPort.class);
}
use of 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 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testaddDstIpMatches_v4.
@Test
public void testaddDstIpMatches_v4() {
AceIpBuilder builder = new AceIpBuilder();
AceIpv4Builder v4builder = new AceIpv4Builder();
v4builder.setDestinationIpv4Network(new Ipv4Prefix("10.1.1.1/24"));
builder.setAceIpVersion(v4builder.build());
List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addDstIpMatches(builder.build());
assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
assertTrue(flowMatches.contains(new MatchIpv4Destination("10.1.1.1", "24")));
}
Aggregations