@Override public SourcePortRange build() { return new SourcePortRangeImpl(this); }
@Override public DestinationPortRange build() { return new DestinationPortRangeImpl(this); }
SourcePortRangeImpl(SourcePortRangeBuilder base) { this._lowerPort = base.getLowerPort(); this._upperPort = base.getUpperPort(); this.augmentation = ImmutableMap.copyOf(base.augmentation); }
public MatchesBuilder matchesBuilder(MatchesBuilder matchesBuilder, int dstPort) { SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder() .setLowerPort(PortNumber.getDefaultInstance("0")) .setUpperPort(PortNumber.getDefaultInstance("0")); PortNumber portNumber = new PortNumber(dstPort); DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder() .setLowerPort(portNumber) .setUpperPort(portNumber); AceIpBuilder aceIpBuilder = new AceIpBuilder() .setSourcePortRange(sourcePortRangeBuilder.build()) .setDestinationPortRange(destinationPortRangeBuilder.build()) .setProtocol((short)6); return matchesBuilder.setAceType(aceIpBuilder.build()); }
if (acl.getAceIpVersion() instanceof AceIpv4 ) { flowMatches.add(new MatchInfo(MatchFieldType.icmp_v4, new long[] { sourcePortRange.getLowerPort().getValue(), sourcePortRange.getUpperPort().getValue() })); flowId = flowId + "V4_SOURCE_" + sourcePortRange.getLowerPort().getValue() + sourcePortRange.getUpperPort().getValue(); } else if (acl.getAceIpVersion() instanceof AceIpv6 ) { flowMatches.add(new MatchInfo(MatchFieldType.icmp_v6, new long[] { sourcePortRange.getLowerPort().getValue(), sourcePortRange.getUpperPort().getValue() })); flowId = flowId + "V6_SOURCE_" + sourcePortRange.getLowerPort().getValue() + "_" + sourcePortRange.getUpperPort().getValue() + "_"; if (acl.getAceIpVersion() instanceof AceIpv4 ) { flowMatches.add(new MatchInfo(MatchFieldType.icmp_v4, new long[] { destinationPortRange.getLowerPort().getValue(), destinationPortRange.getUpperPort().getValue() })); flowId = flowId + "V4_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_"; } else if (acl.getAceIpVersion() instanceof AceIpv6 ) { flowMatches.add(new MatchInfo(MatchFieldType.icmp_v6, new long[] { destinationPortRange.getLowerPort().getValue(), destinationPortRange.getUpperPort().getValue() })); flowId = flowId + "V6_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
private AceBuilder toAceBuilder(SecurityRule securityRule) { AceIpBuilder aceIpBuilder = new AceIpBuilder(); SecurityRuleAttrBuilder securityRuleAttrBuilder = new SecurityRuleAttrBuilder(); SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder(); DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder(); boolean isDirectionIngress = false; if (securityRule.getDirection() != null) { destinationPortRangeBuilder.setUpperPort(new PortNumber(securityRule.getPortRangeMax())); destinationPortRangeBuilder.setLowerPort(new PortNumber(securityRule.getPortRangeMin())); aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
public DestinationPortRangeBuilder(DestinationPortRange base) { this._lowerPort = base.getLowerPort(); this._upperPort = base.getUpperPort(); if (base instanceof DestinationPortRangeImpl) { DestinationPortRangeImpl impl = (DestinationPortRangeImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") Map<Class<? extends Augmentation<DestinationPortRange>>, Augmentation<DestinationPortRange>> aug =((AugmentationHolder<DestinationPortRange>) base).augmentations(); if (!aug.isEmpty()) { this.augmentation = new HashMap<>(aug); } } }
public SourcePortRangeBuilder(SourcePortRange base) { this._lowerPort = base.getLowerPort(); this._upperPort = base.getUpperPort(); if (base instanceof SourcePortRangeImpl) { SourcePortRangeImpl impl = (SourcePortRangeImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") Map<Class<? extends Augmentation<SourcePortRange>>, Augmentation<SourcePortRange>> aug =((AugmentationHolder<SourcePortRange>) base).augmentations(); if (!aug.isEmpty()) { this.augmentation = new HashMap<>(aug); } } }
if (!Objects.equals(_lowerPort, other.getLowerPort())) { return false; if (!Objects.equals(_upperPort, other.getUpperPort())) { return false; if (!e.getValue().equals(other.augmentation(e.getKey()))) { return false;
private void addIpProtocolMatch(AceIp aceIp) { int srcPort = 0; int dstPort = 0; // TODO Ranges are not supported yet if (aceIp.getSourcePortRange() != null && aceIp.getSourcePortRange().getLowerPort() != null) { srcPort = aceIp.getSourcePortRange().getLowerPort().getValue(); } if (aceIp.getDestinationPortRange() != null && aceIp.getDestinationPortRange().getLowerPort() != null) { dstPort = aceIp.getDestinationPortRange().getLowerPort().getValue(); } MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol()); MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), srcPort, dstPort); }
if (!Objects.equals(_lowerPort, other.getLowerPort())) { return false; if (!Objects.equals(_upperPort, other.getUpperPort())) { return false; if (!e.getValue().equals(other.augmentation(e.getKey()))) { return false;
public MatchBuilder buildMatch(Matches matches) { MatchBuilder matchBuilder = new MatchBuilder(); if (matches.getAceType() instanceof AceIp) { AceIp aceIp = (AceIp)matches.getAceType(); if (aceIp.getAceIpVersion() instanceof AceIpv4) { //AceIpv4 aceIpv4 = (AceIpv4) aceIp.getAceIpVersion(); //MatchUtils.createSrcL3IPv4Match(matchBuilder, aceIpv4.getSourceIpv4Network()); //MatchUtils.createDstL3IPv4Match(matchBuilder, aceIpv4.getDestinationIpv4Network()); MatchUtils.createIpProtocolMatch(matchBuilder, aceIp.getProtocol()); MatchUtils.addLayer4Match(matchBuilder, aceIp.getProtocol().intValue(), 0, aceIp.getDestinationPortRange().getLowerPort().getValue().intValue()); } } else if (matches.getAceType() instanceof AceEth) { AceEth aceEth = (AceEth) matches.getAceType(); MatchUtils.createEthSrcMatch(matchBuilder, new MacAddress(aceEth.getSourceMacAddress().getValue())); MatchUtils.createDestEthMatch(matchBuilder, new MacAddress(aceEth.getDestinationMacAddress().getValue()), new MacAddress(aceEth.getDestinationMacAddressMask().getValue())); } LOG.info("buildMatch: {}", matchBuilder.build()); return matchBuilder; }
DestinationPortRangeImpl(DestinationPortRangeBuilder base) { this._lowerPort = base.getLowerPort(); this._upperPort = base.getUpperPort(); this.augmentation = ImmutableMap.copyOf(base.augmentation); }
public SourcePortRangeBuilder addAugmentation(Class<? extends Augmentation<SourcePortRange>> augmentationType, Augmentation<SourcePortRange> augmentationValue) { if (augmentationValue == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentationValue); return this; }
public DestinationPortRangeBuilder addAugmentation(Class<? extends Augmentation<DestinationPortRange>> augmentationType, Augmentation<DestinationPortRange> augmentationValue) { if (augmentationValue == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentationValue); return this; }
DestinationPortRangeBuilder destinationPortRange = new DestinationPortRangeBuilder(); SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder(); sourcePortRangeBuilder.setLowerPort(new PortNumber(flowClassifier.getSourcePortRangeMin())); sourcePortRangeBuilder.setUpperPort(new PortNumber(flowClassifier.getSourcePortRangeMax())); destinationPortRange.setLowerPort(new PortNumber(flowClassifier.getDestinationPortRangeMin())); destinationPortRange.setUpperPort(new PortNumber(flowClassifier.getDestinationPortRangeMax())); aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build()); aceIpBuilder.setDestinationPortRange(destinationPortRange.build());
Map<Integer, Integer> portMaskMap = getLayer4MaskForRange(sourcePortRange.getLowerPort().getValue(), sourcePortRange.getUpperPort().getValue()); for (Integer port: portMaskMap.keySet()) { List<MatchInfoBase> flowMatches = new ArrayList<>(); Map<Integer, Integer> portMaskMap = getLayer4MaskForRange(destinationPortRange.getLowerPort().getValue(), destinationPortRange.getUpperPort().getValue()); for (Integer port: portMaskMap.keySet()) { List<MatchInfoBase> flowMatches = new ArrayList<>();
private ObjectNode getDestinationPortRangeObjectNode(AceIp aceIp) { if (aceIp == null) { return null; } ObjectNode destinationPortRangeNode = null; DestinationPortRange destinationPortRange = aceIp.getDestinationPortRange(); if (destinationPortRange != null) { destinationPortRangeNode = mapper.createObjectNode(); if (destinationPortRange.getLowerPort() != null) { destinationPortRangeNode.put(_LOWER_PORT, destinationPortRange.getLowerPort().getValue()); } if (destinationPortRange.getUpperPort() != null) { destinationPortRangeNode.put(_UPPER_PORT, destinationPortRange.getUpperPort().getValue()); } } return destinationPortRangeNode; }
private ObjectNode getSourcePortRangeObjectNode(AceIp aceIp) { if (aceIp == null) { return null; } ObjectNode sourcePortRangeNode = null; SourcePortRange sourcePortRange = aceIp.getSourcePortRange(); if (sourcePortRange != null) { sourcePortRangeNode = mapper.createObjectNode(); if (sourcePortRange.getLowerPort() != null) { sourcePortRangeNode.put(_LOWER_PORT, sourcePortRange.getLowerPort().getValue()); } if (sourcePortRange.getUpperPort() != null) { sourcePortRangeNode.put(_UPPER_PORT, sourcePortRange.getUpperPort().getValue()); } } return sourcePortRangeNode; }
Map<Integer, Integer> portMaskMap = getLayer4MaskForRange(sourcePortRange.getLowerPort().getValue(), sourcePortRange.getUpperPort().getValue()); for (Integer port: portMaskMap.keySet()) { List<MatchInfoBase> flowMatches = new ArrayList<>(); Map<Integer, Integer> portMaskMap = getLayer4MaskForRange(destinationPortRange.getLowerPort().getValue(), destinationPortRange.getUpperPort().getValue()); for (Integer port: portMaskMap.keySet()) { List<MatchInfoBase> flowMatches = new ArrayList<>();