@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); }
public static Map<String,List<MatchInfoBase>> programUdpFlow(AceIp acl) { Map<String,List<MatchInfoBase>> flowMatchesMap = new HashMap<>(); SourcePortRange sourcePortRange = acl.getSourcePortRange(); DestinationPortRange destinationPortRange = acl.getDestinationPortRange(); if (sourcePortRange == null && destinationPortRange == null) { List<MatchInfoBase> flowMatches = new ArrayList<>(); flowMatches.addAll(addSrcIpMatches(acl)); flowMatches.addAll(addDstIpMatches(acl)); flowMatches.add(new MatchIpProtocol(acl.getProtocol().toJava())); String flowId = "UDP_SOURCE_ALL_"; flowMatchesMap.put(flowId,flowMatches); return flowMatchesMap; } if (sourcePortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( sourcePortRange.getLowerPort().getValue().toJava(), sourcePortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpSourcePort::new, "UDP_SOURCE_"); } if (destinationPortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( destinationPortRange.getLowerPort().getValue().toJava(), destinationPortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpDestinationPort::new, "UDP_DESTINATION_"); } return flowMatchesMap; }
AclServiceOFFlowBuilder { public static Map<String,List<MatchInfoBase>> programUdpFlow(AceIp acl) { Map<String,List<MatchInfoBase>> flowMatchesMap = new HashMap<>(); SourcePortRange sourcePortRange = acl.getSourcePortRange(); DestinationPortRange destinationPortRange = acl.getDestinationPortRange(); if (sourcePortRange == null && destinationPortRange == null) { List<MatchInfoBase> flowMatches = new ArrayList<>(); flowMatches.addAll(addSrcIpMatches(acl)); flowMatches.addAll(addDstIpMatches(acl)); flowMatches.add(new MatchIpProtocol(acl.getProtocol().toJava())); String flowId = "UDP_SOURCE_ALL_"; flowMatchesMap.put(flowId,flowMatches); return flowMatchesMap; } if (sourcePortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( sourcePortRange.getLowerPort().getValue().toJava(), sourcePortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpSourcePort::new, "UDP_SOURCE_"); } if (destinationPortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( destinationPortRange.getLowerPort().getValue().toJava(), destinationPortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpDestinationPort::new, "UDP_DESTINATION_"); } return flowMatchesMap; } }
AclServiceOFFlowBuilder { public static Map<String,List<MatchInfoBase>> programUdpFlow(AceIp acl) { Map<String,List<MatchInfoBase>> flowMatchesMap = new HashMap<>(); SourcePortRange sourcePortRange = acl.getSourcePortRange(); DestinationPortRange destinationPortRange = acl.getDestinationPortRange(); if (sourcePortRange == null && destinationPortRange == null) { List<MatchInfoBase> flowMatches = new ArrayList<>(); flowMatches.addAll(addSrcIpMatches(acl)); flowMatches.addAll(addDstIpMatches(acl)); flowMatches.add(new MatchIpProtocol(acl.getProtocol().toJava())); String flowId = "UDP_SOURCE_ALL_"; flowMatchesMap.put(flowId,flowMatches); return flowMatchesMap; } if (sourcePortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( sourcePortRange.getLowerPort().getValue().toJava(), sourcePortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpSourcePort::new, "UDP_SOURCE_"); } if (destinationPortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( destinationPortRange.getLowerPort().getValue().toJava(), destinationPortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpDestinationPort::new, "UDP_DESTINATION_"); } return flowMatchesMap; } private  AclServiceOFFlowBuilder(); }
AclServiceOFFlowBuilder { public static Map<String,List<MatchInfoBase>> programUdpFlow(AceIp acl) { Map<String,List<MatchInfoBase>> flowMatchesMap = new HashMap<>(); SourcePortRange sourcePortRange = acl.getSourcePortRange(); DestinationPortRange destinationPortRange = acl.getDestinationPortRange(); if (sourcePortRange == null && destinationPortRange == null) { List<MatchInfoBase> flowMatches = new ArrayList<>(); flowMatches.addAll(addSrcIpMatches(acl)); flowMatches.addAll(addDstIpMatches(acl)); flowMatches.add(new MatchIpProtocol(acl.getProtocol().toJava())); String flowId = "UDP_SOURCE_ALL_"; flowMatchesMap.put(flowId,flowMatches); return flowMatchesMap; } if (sourcePortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( sourcePortRange.getLowerPort().getValue().toJava(), sourcePortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpSourcePort::new, "UDP_SOURCE_"); } if (destinationPortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( destinationPortRange.getLowerPort().getValue().toJava(), destinationPortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpDestinationPort::new, "UDP_DESTINATION_"); } return flowMatchesMap; } 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); }
AclServiceOFFlowBuilder { public static Map<String,List<MatchInfoBase>> programUdpFlow(AceIp acl) { Map<String,List<MatchInfoBase>> flowMatchesMap = new HashMap<>(); SourcePortRange sourcePortRange = acl.getSourcePortRange(); DestinationPortRange destinationPortRange = acl.getDestinationPortRange(); if (sourcePortRange == null && destinationPortRange == null) { List<MatchInfoBase> flowMatches = new ArrayList<>(); flowMatches.addAll(addSrcIpMatches(acl)); flowMatches.addAll(addDstIpMatches(acl)); flowMatches.add(new MatchIpProtocol(acl.getProtocol().toJava())); String flowId = "UDP_SOURCE_ALL_"; flowMatchesMap.put(flowId,flowMatches); return flowMatchesMap; } if (sourcePortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( sourcePortRange.getLowerPort().getValue().toJava(), sourcePortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpSourcePort::new, "UDP_SOURCE_"); } if (destinationPortRange != null) { Map<Integer, Integer> portMaskMap = getLayer4MaskForRange( destinationPortRange.getLowerPort().getValue().toJava(), destinationPortRange.getUpperPort().getValue().toJava()); updateFlowMatches(acl, portMaskMap, flowMatchesMap, NxMatchUdpDestinationPort::new, "UDP_DESTINATION_"); } return flowMatchesMap; } 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);  }