Skip to content

Commit

Permalink
changes for version 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Foley committed Mar 2, 2024
1 parent b595686 commit d649f6f
Show file tree
Hide file tree
Showing 50 changed files with 4,166 additions and 1,069 deletions.
69 changes: 42 additions & 27 deletions IPAddress/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
Version 5.5:

-added a collection type for dual IPv4/v6 tries and another for dual IPv4/v6 associative tries, issue #103
-trie performance improvements for all trie operations
-added shortestPrefixMatch trie methods
-added enumerate methods, the inverse of the increment methods, to find the position of an address in a subnet, or to find the distance between two addresses
-added an increment method accepting a BigInteger argument to IPv6Address and IPv6AddressSection
-added the ability to construct an IPv6Address from two longs
-added replace methods to address classes that take address sections
-added overlaps methods to check for overlapping subnets, and for checking sequential range overlap with a subnet
-added floor/lower/ceiling/higher methods to the address trie types, these methods were previously accessible only from trie sets
-added the extraneous digits IPv4 parsing option allow_inet_aton_extraneous_digits, issue #105.
-includes the fix to invalid radix argument infinite loop, issue #118


Version 5.4:

added PrefixBlockAllocator for automatic CIDR prefix block allocation
added AddedTree and AssociativeAddedTree classes for expanded constructAddedNodesTree methods
added getBlockSize and getBitsForCount in AddressItem
added matchUnordered and matchOrdered in Address
eliminated invalid AddressValueException when joining a range with the IPv4 max value to an IPv6 range, issue #86
fix to generation of strings from parsed address data, issue #87
fix to IPv4 address primitive int upper value generation, issue #96
-added PrefixBlockAllocator for automatic CIDR prefix block allocation
-added AddedTree and AssociativeAddedTree classes for expanded constructAddedNodesTree methods
-added getBlockSize and getBitsForCount in AddressItem
-added matchUnordered and matchOrdered in Address
-eliminated invalid AddressValueException when joining a range with the IPv4 max value to an IPv6 range, issue #86
-fix to generation of strings from parsed address data, issue #87
-fix to IPv4 address primitive int upper value generation, issue #96


Version 5.3:

This version introduces address tries, associative address tries, address sets backed by address tries, and maps backed by associative address tries

added AddressTrie and its subclasses for IPv4, IPv6 and MAC
added AssociativeAddressTrie and its subclasses for IPv4, IPv6 and MAC
tries can be used as Java collections framework navigable set
associative tries can be used as Java collections framework navigable map
added testBit and isOneBit methods to all series and segments
-added AddressTrie and its subclasses for IPv4, IPv6 and MAC
-added AssociativeAddressTrie and its subclasses for IPv4, IPv6 and MAC
-tries can be used as Java collections framework navigable set
-associative tries can be used as Java collections framework navigable map
-added testBit and isOneBit methods to all series and segments


Version 5.2:

This version introduces methods for Java 8 functional-style operations.

added stream methods for addresses, address sections, address segments, and ip address sequential ranges: stream, prefixStream, prefixStream(int prefixLength), prefixBlockStream, prefixBlockStream(int prefixLength), blockStream(int segmentCount), sequentialBlockStream, segmentsStream
added corresponding spliterator methods: spliterator, prefixSpliterator, prefixSpliterator(int prefixLength), prefixBlockSpliterator, prefixBlockSpliterator(int prefixLength), blockSpliterator(int segmentCount), sequentialBlockSpliterator, segmentsSpliterator
added functions to create a single stream from multiple spliterators in AddressComponentRange:
<T extends AddressComponent> Stream<T> stream(Function<T, Stream<? extends T>> addrStreamFunc, T ...components)
<T extends AddressComponent> Stream<T> stream(Function<T, Stream<? extends T>> addrStreamFunc, Collection<? extends T> components)
added coverWithPrefixBlock method to find single covering prefix block, the smallest prefix block covering two subnets or addresses
added IPAddressString and HostName parsed mask access through getMask method
made sub-typing of address classes easier by loosening restrictions on using multiple network objects
altered network mask with prefix length so that it is single host
-added stream methods for addresses, address sections, address segments, and ip address sequential ranges: stream, prefixStream, prefixStream(int prefixLength), prefixBlockStream, prefixBlockStream(int prefixLength), blockStream(int segmentCount), sequentialBlockStream, segmentsStream
-added corresponding spliterator methods: spliterator, prefixSpliterator, prefixSpliterator(int prefixLength), prefixBlockSpliterator, prefixBlockSpliterator(int prefixLength), blockSpliterator(int segmentCount), sequentialBlockSpliterator, segmentsSpliterator
-added functions to create a single stream from multiple spliterators in AddressComponentRange:
-<T extends AddressComponent> Stream<T> stream(Function<T, Stream<? extends T>> addrStreamFunc, T ...components)
-<T extends AddressComponent> Stream<T> stream(Function<T, Stream<? extends T>> addrStreamFunc, Collection<? extends T> components)
-added coverWithPrefixBlock method to find single covering prefix block, the smallest prefix block covering two subnets or addresses
-added IPAddressString and HostName parsed mask access through getMask method
-made sub-typing of address classes easier by loosening restrictions on using multiple network objects
-altered network mask with prefix length so that it is single host


Version 5.1:

Mostly parsing and masking improvements.

getSequentialRange() method added to IPAddressString for direct access to sequential range
improved handling of masking and bitwise-oring subnets. isMaskCompatibleWithRange replaced by maskRange, same with bitwise-or.
getDivisionGrouping() method added to IPAddressString for "as-is" parsing
toString() for division strings adjusted, no longer using '*' due to varying bit lengths for divisions and potentially no segment separator to indicate bit length, also using radix matching parsed string
reverse ranges allowed in parsed strings
improved control/support of inferred range boundaries
-getSequentialRange() method added to IPAddressString for direct access to sequential range
-improved handling of masking and bitwise-oring subnets. isMaskCompatibleWithRange replaced by maskRange, same with bitwise-or.
-getDivisionGrouping() method added to IPAddressString for "as-is" parsing
-toString() for division strings adjusted, no longer using '*' due to varying bit lengths for divisions and potentially no segment separator to indicate bit length, also using radix matching parsed string
-reverse ranges allowed in parsed strings
-improved control/support of inferred range boundaries


Version 5 release:
Expand Down
34 changes: 34 additions & 0 deletions IPAddress/src/inet.ipaddr/inet/ipaddr/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,19 @@ public boolean prefixEquals(Address other) {
return getSection().prefixEquals(other.getSection());
}

/**
* Returns whether this is same type and version of the given address and whether it overlaps with the values in the given address or subnet
*
* @param other
* @return
*/
public boolean overlaps(Address other) {
if(other == this) {
return true;
}
return getSection().overlaps(other.getSection());
}

/**
* Returns whether this is same type and version of the given address and whether it contains all values in the given address or subnet
*
Expand All @@ -512,6 +525,27 @@ public boolean contains(Address other) {
}
return getSection().contains(other.getSection());
}

/**
* Indicates where an address sits relative to the subnet ordering.
* <p>
* Determines how many address elements of a subnet precede the given address element, if the address is in the subnet.
* If above the subnet range, it is the distance to the upper boundary added to the subnet address count, and if below the subnet range, the distance to the lower boundary.
* <p>
* In other words, if the given address is not in the subnet but above it, returns the number of addresses preceding the address from the upper subnet boundary,
* added to the total number of subnet addresses. If the given address is not in the subnet but below it, returns the number of addresses following the address to the lower subnet boundary.
* <p>
* enumerate returns null when the argument is a multi-valued subnet. The argument must be an individual address.
* <p>
* When this address is also single-valued, the returned value is the distance (difference) between this address and the argument address.
* <p>
* enumerate is the inverse of the increment method:
* <ul><li>subnet.enumerate(subnet.increment(inc)) = inc</li>
* <li>subnet.increment(subnet.enumerate(newAddr)) = newAddr</li></ul>
*
* If the given address does not have the same version or type as this subnet or address, then null is returned.
*/
public abstract BigInteger enumerate(Address other);

@Override
public boolean isSequential() {
Expand Down
65 changes: 50 additions & 15 deletions IPAddress/src/inet.ipaddr/inet/ipaddr/AddressSection.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package inet.ipaddr;

import java.math.BigInteger;
import java.util.Iterator;
import java.util.stream.Stream;

Expand All @@ -28,7 +29,7 @@
*
*/
public interface AddressSection extends AddressSegmentSeries {

/**
* Determines if one section contains another.
* <p>
Expand All @@ -40,7 +41,41 @@ public interface AddressSection extends AddressSegmentSeries {
* @return whether this section contains the given address section
*/
boolean contains(AddressSection other);


/**
* Determines if one section overlaps with another.
* <p>
* Sections must have the same number of segments to be comparable.
* <p>
* For sections which are aware of their position in an address (IPv6 and MAC), their respective positions must match to be comparable.
*
* @param other
* @return whether this section overlaps with the given address section
*/
boolean overlaps(AddressSection other);

/**
* Indicates where an address section sits relative to the ordering of individual address sections within this section.
* <p>
* Determines how many address section elements precede the given address section element, if the given address section is within this address section.
* If above the range, it is the distance to the upper boundary added to the address section count, and if below the range, the distance to the lower boundary.
* <p>
* In other words, if the given address section is not in this section but above it, returns the number of individual address sections preceding the given address section from the upper section boundary,
* added to the total number of individual address sections within. If the given address section is not in this section but below it, returns the number of individual address sections following the given address section to the lower section boundary.
* <p>
* enumerate returns null when the argument is a multi-valued section. The argument must be an individual address section.
* <p>
* When this address section is also single-valued, the returned value is the distance (difference) between this address section and the argument address section.
* <p>
* enumerate is the inverse of the increment method:
* <ul><li>section.enumerate(section.increment(inc)) = inc</li>
* <li>section.increment(section.enumerate(individualSection)) = individualSection</li></ul>
*
* If the given address section does not have the same version or type as this address section, then null is returned.
* If the given address section is the same version and type, but has a different segment count, then SizeMismatchException is thrown.
*/
BigInteger enumerate(AddressSection other);

/**
* Determines if the argument section matches this section up to the prefix length of this section.
* <p>
Expand All @@ -54,40 +89,40 @@ public interface AddressSection extends AddressSegmentSeries {
* @return whether the argument section has the same address section prefix as this
*/
boolean prefixEquals(AddressSection other);

@Override
AddressSection getLower();

@Override
AddressSection getUpper();

@Override
AddressSection reverseSegments();

@Override
AddressSection reverseBits(boolean perByte);

@Override
AddressSection reverseBytes();

@Override
AddressSection reverseBytesPerSegment();

@Override
AddressSection toPrefixBlock();

@Override @Deprecated
AddressSection removePrefixLength();

@Override
AddressSection withoutPrefixLength();

@Override @Deprecated
AddressSection removePrefixLength(boolean zeroed);

@Override
AddressSection adjustPrefixBySegment(boolean nextSegment);

@Override
AddressSection adjustPrefixBySegment(boolean nextSegment, boolean zeroed);

Expand All @@ -112,7 +147,7 @@ public interface AddressSection extends AddressSegmentSeries {

@Override
Iterator<? extends AddressSection> iterator();

@Override
AddressComponentSpliterator<? extends AddressSection> spliterator();

Expand All @@ -121,7 +156,7 @@ public interface AddressSection extends AddressSegmentSeries {

@Override
Iterator<? extends AddressSection> prefixIterator();

@Override
AddressComponentSpliterator<? extends AddressSection> prefixSpliterator();

Expand All @@ -130,7 +165,7 @@ public interface AddressSection extends AddressSegmentSeries {

@Override
Iterator<? extends AddressSection> prefixBlockIterator();

@Override
AddressComponentSpliterator<? extends AddressSection> prefixBlockSpliterator();

Expand Down
2 changes: 2 additions & 0 deletions IPAddress/src/inet.ipaddr/inet/ipaddr/AddressSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public interface AddressSegment extends AddressComponent, AddressGenericDivision

boolean matchesWithMask(int lowerValue, int upperValue, int mask);

boolean overlaps(AddressSegment other);

boolean contains(AddressSegment other);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public interface AddressSegmentSeries extends AddressDivisionSeries, AddressComp
AddressSegmentSeries getLower();

/**
* If this represents a series with ranging values, returns a series representing the upper values of the range
* If this represents a series with ranging values, returns a series representing the upper values of the range.
* If this represents a series with a single value in each segment, returns this.
*
* @return
Expand Down
49 changes: 35 additions & 14 deletions IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,32 @@ protected boolean isFromSameString(HostIdentifierString other) {
return false;
}

/**
* Returns true if this address overlaps with the given address or subnet
*
* @param other
* @return
*/
@Override
public boolean overlaps(IPAddress other) {
return super.overlaps(other);
}

/**
* Returns true if this address overlaps with the given address or subnet
*
* @param other
* @return
*/
@Override
public boolean overlaps(IPAddressSeqRange other) {
return other.overlaps(this);
}

/**
* Returns whether this contains all values of the given address or subnet
* <p>
* Implements the same method in {@link IPAddressRange}.
*
* @param other
* @return
Expand All @@ -682,6 +706,16 @@ public boolean containsNonZeroHosts(IPAddress other) {
return getSection().containsNonZeroHosts(other.getSection());
}

/**
* Indicates where an address sits relative to the subnet ordering.
* <p>
* For more details, see the equivalent method {@link #enumerate(Address)}.
* This method satisfies the implementation of {@link IPAddressRange}.
*
*/
@Override
public abstract BigInteger enumerate(IPAddress other);

/**
* Returns whether the prefix of this address contains all values of the same bits in the given address or subnet
*
Expand Down Expand Up @@ -718,20 +752,7 @@ public boolean isZeroHost(int networkPrefixLength) {

@Override
public boolean contains(IPAddressSeqRange otherRange) {
if(compareLowValues(otherRange.getLower(), getLower()) >= 0 &&
compareLowValues(otherRange.getUpper(), getUpper()) <= 0) {
if(isSequential()) {
return true;
}
Iterator<? extends IPAddress> iterator = sequentialBlockIterator();
while(iterator.hasNext()) {
IPAddress sequential = iterator.next();
if(sequential.contains(otherRange)) {
return true;
}
}
}
return false;
return otherRange.isContainedBy(this);
}

static int compareLowValues(IPAddress one, IPAddress two) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@ ipaddress.host.error.invalid.service.hyphen.end=service name cannot end in a hyp
ipaddress.host.error.invalid.service.hyphen.start=service name cannot start with a hyphen
ipaddress.host.error.invalid.service.hyphen.consecutive=service name cannot have consecutive hyphens
ipaddress.host.error.invalid.port.service=invalid port or service name character at index:
ipaddress.error.zoneAndCIDRPrefix=zone and prefix combined
ipaddress.error.zone=IPv6 zone not allowed
ipaddress.error.CIDRNotAllowed=CIDR prefix or mask not allowed for this address
ipaddress.error.wildcardOrRangeIPv6=Wildcards and ranges are not supported for IPv6 addresses
ipaddress.error.mixedVersions=Please specify either IPv4 or IPv6 addresses, but not both
ipaddress.error.mixedVersions=please specify either IPv4 or IPv6 addresses, but not both
ipaddress.error.mixedNetworks=Address components have different networks
ipaddress.error.nullNetwork=network is null
ipaddress.error.version.mismatch=Unable to convert version of argument address
Expand Down Expand Up @@ -125,9 +122,9 @@ ipaddress.error.exceeds.size=exceeds address size
ipaddress.error.index.exceeds.prefix.length=index exceeds prefix length
ipaddress.error.null.segment=Section or grouping array contains a null value
ipaddress.error.inconsistent.prefixes=Segments invalid due to inconsistent prefix values
ipaddress.error.invalid.position=Invalid index into address
ipaddress.error.address.not.block=Address is neither a CIDR prefix block nor an individual address
ipaddress.error.address.out.of.range=Address not within the assigned range
ipaddress.error.invalid.position=invalid index into address
ipaddress.error.address.not.block=address is neither a CIDR prefix block nor an individual address
ipaddress.error.address.out.of.range=address not within the assigned range
ipaddress.error.address.lower.exceeds.upper=invalid address range, lower bound exceeds upper:
ipaddress.error.lower.below.range=below range:
ipaddress.error.lower.above.range=above range:
Expand Down
Loading

0 comments on commit d649f6f

Please sign in to comment.