AclServiceOFFlowBuilder { public static List<MatchInfoBase> addDstIpMatches(AceIp acl) { List<MatchInfoBase> flowMatches = new ArrayList<>(); if (acl.getAceIpVersion() instanceof AceIpv4) { flowMatches.add(MatchEthernetType.IPV4); Ipv4Prefix dstNetwork = ((AceIpv4)acl.getAceIpVersion()).getDestinationIpv4Network(); if (null != dstNetwork && !dstNetwork.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) { flowMatches.add(new MatchIpv4Destination(dstNetwork)); } } else if (acl.getAceIpVersion() instanceof AceIpv6) { flowMatches.add(MatchEthernetType.IPV6); Ipv6Prefix dstNetwork = ((AceIpv6)acl.getAceIpVersion()).getDestinationIpv6Network(); if (null != dstNetwork && !dstNetwork.getValue().equals(AclConstants.IPV6_ALL_NETWORK)) { flowMatches.add(new MatchIpv6Destination(dstNetwork)); } } return flowMatches; } private  AclServiceOFFlowBuilder(); @Nullable static Map<String, List<MatchInfoBase>> programIpFlow(Matches matches); static Map<String,List<MatchInfoBase>> programEtherFlow(AceIp acl); static Map<String,List<MatchInfoBase>> programOtherProtocolFlow(AceIp acl); static Map<String,List<MatchInfoBase>> programIcmpFlow(AceIp acl); static Map<String,List<MatchInfoBase>> programTcpFlow(AceIp acl); static Map<String,List<MatchInfoBase>> programUdpFlow(AceIp acl); static List<MatchInfoBase> addSrcIpMatches(AceIp acl); static List<MatchInfoBase> addDstIpMatches(AceIp acl); static List<MatchInfoBase> addLPortTagMatches(int lportTag, int conntrackState, int conntrackMask,
            Class<? extends ServiceModeBase> serviceMode); static List<InstructionInfo> getDropInstructionInfo(); static List<InstructionInfo> getResubmitInstructionInfo(short tableId); static List<InstructionInfo> getGotoInstructionInfo(short gotoTableId); static Map<Integer,Integer> getLayer4MaskForRange(int portMin, int portMax);  }
@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"))); }
@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); }