public static Optional<HeaderSpace> intersect(HeaderSpace h1, HeaderSpace h2) { checkArgument(isUnconstrained(h1.getSrcOrDstIps())); checkArgument(isUnconstrained(h2.getSrcOrDstIps())); checkArgument(isUnconstrained(h1.getSrcOrDstPorts())); checkArgument(isUnconstrained(h2.getSrcOrDstPorts())); checkArgument(isUnconstrained(h1.getSrcOrDstProtocols())); checkArgument(isUnconstrained(h2.getSrcOrDstProtocols())); try { return Optional.of( HeaderSpace.builder() .setDscps(intersectSimpleSets(h1.getDscps(), h2.getDscps())) .setDstIps(intersection(h1.getDstIps(), h2.getDstIps())) .setDstPorts(intersectSubRangeSets(h1.getDstPorts(), h2.getDstPorts())) .setDstProtocols(intersectSimpleSets(h1.getDstProtocols(), h2.getDstProtocols())) .setIpProtocols(intersectSimpleSets(h1.getIpProtocols(), h2.getIpProtocols())) .setIcmpCodes(intersectSubRangeSets(h1.getIcmpCodes(), h2.getIcmpCodes())) .setIcmpTypes(intersectSubRangeSets(h1.getIcmpTypes(), h2.getIcmpTypes())) .setNotDstIps(AclIpSpace.union(h1.getNotDstIps(), h2.getNotDstIps())) .setNotDstPorts(Sets.union(h1.getNotDstPorts(), h2.getNotDstPorts())) .setNotSrcIps(AclIpSpace.union(h1.getNotSrcIps(), h2.getNotSrcIps())) .setNotSrcPorts(Sets.union(h1.getNotSrcPorts(), h2.getNotSrcPorts())) .setSrcIps(AclIpSpace.intersection(h1.getSrcIps(), h2.getSrcIps())) .setSrcOrDstPorts(intersectSubRangeSets(h1.getSrcOrDstPorts(), h2.getSrcOrDstPorts())) .setSrcPorts(intersectSubRangeSets(h1.getSrcPorts(), h2.getSrcPorts())) .setTcpFlags(intersectTcpFlagMatchConditions(h1.getTcpFlags(), h2.getTcpFlags())) .build()); } catch (NoIntersection e) { return Optional.empty(); } }
.toBuilder() .setDstIps(nullIpSpace) .setNotDstIps(nullIpSpace) .setNotSrcIps(nullIpSpace) .setSrcIps(nullIpSpace)
@Override public AclLineMatchExpr visitMatchHeaderSpace(MatchHeaderSpace matchHeaderSpace) { HeaderSpace headerSpace = matchHeaderSpace.getHeaderspace(); IpSpace dstIps = rename(headerSpace.getDstIps()); IpSpace notDstIps = rename(headerSpace.getNotDstIps()); IpSpace srcIps = rename(headerSpace.getSrcIps()); IpSpace notSrcIps = rename(headerSpace.getNotSrcIps()); IpSpace srcOrDstIps = rename(headerSpace.getSrcOrDstIps()); MatchHeaderSpace newMatchHeaderSpace = new MatchHeaderSpace( headerSpace .toBuilder() .setDstIps(dstIps) .setNotDstIps(notDstIps) .setSrcIps(srcIps) .setNotSrcIps(notSrcIps) .setSrcOrDstIps(srcOrDstIps) .build()); _literalsMap.put(matchHeaderSpace, newMatchHeaderSpace); return newMatchHeaderSpace; }
.toBuilder() .setDstIps(simplifyPositiveIpConstraint(dstIps)) .setNotDstIps(simplifyNegativeIpConstraint(notDstIps)) .setNotSrcIps(simplifyNegativeIpConstraint(notSrcIps)) .setSrcIps(simplifyPositiveIpConstraint(srcIps))
hsb.setNotDstIps(original.accept(new IpSpaceDereferencer(namedIpSpaces)));
.setNegate(_negate) .setNotDscps(_notDscps) .setNotDstIps(_notDstIps) .setNotDstPorts(_notDstPorts) .setNotDstProtocols(_notDstProtocols)
@Override public HeaderSpace specialize(HeaderSpace headerSpace) { return headerSpace .toBuilder() // combine dstIps and notDstIps into dstIps .setDstIps(specializeIpSpace(headerSpace.getDstIps(), _dstIpSpaceSpecializer)) .setNotDstIps(specializeIpSpace(headerSpace.getNotDstIps(), _dstIpSpaceSpecializer)) .setDstPorts(specializeSubRange(headerSpace.getDstPorts(), _pkt.getDstPort())) .setNotDstPorts(specializeSubRange(headerSpace.getNotDstPorts(), _pkt.getDstPort())) .setIpProtocols(specializeIpProtocols(headerSpace.getIpProtocols())) .setIcmpCodes(specializeSubRange(headerSpace.getIcmpCodes(), _pkt.getIcmpCode())) .setIcmpTypes(specializeSubRange(headerSpace.getIcmpTypes(), _pkt.getIcmpType())) .setSrcOrDstIps( specializeIpSpace( headerSpace.getSrcOrDstIps(), _dstIpSpaceSpecializer, _srcIpSpaceSpecializer)) .setSrcOrDstPorts( specializeSubRange( headerSpace.getSrcOrDstPorts(), _pkt.getSrcPort(), _pkt.getDstPort())) .setSrcPorts(specializeSubRange(headerSpace.getSrcPorts(), _pkt.getSrcPort())) .setNotSrcPorts(specializeSubRange(headerSpace.getNotSrcPorts(), _pkt.getSrcPort())) .setSrcIps(specializeIpSpace(headerSpace.getSrcIps(), _srcIpSpaceSpecializer)) .setNotSrcIps(specializeIpSpace(headerSpace.getNotSrcIps(), _srcIpSpaceSpecializer)) .setTcpFlags(specializeTcpFlags(headerSpace.getTcpFlags())) .build(); }
@Override public void applyTo( HeaderSpace.Builder headerSpaceBuilder, JuniperConfiguration jc, Warnings w, Configuration c) { headerSpaceBuilder.setNotDstIps( AclIpSpace.union(headerSpaceBuilder.getNotDstIps(), _ipWildcard.toIpSpace())); }