Class MACAddress
- All Implemented Interfaces:
AddressComponent, AddressSegmentSeries, AddressComponentRange, AddressDivisionSeries, AddressItem, AddressItemRange, AddressStringDivisionSeries, Serializable, Comparable<AddressItem>, Iterable<MACAddress>
You can construct a MAC address from a byte array, from a long, from a Address.SegmentValueProvider,
from a NetworkInterface, from a MACAddressSection of 6 or 8 segments, or from an array of 6 or 8 MACAddressSegment objects.
To construct one from a String use
MACAddressString.toAddress() or MACAddressString.getAddress()
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Address
Address.AddressValueProvider, Address.SegmentValueProvider -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final charstatic final charstatic final charstatic final Stringstatic final intstatic final charstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final charFields inherited from class Address
ADDRESS_HIGH_VALUE_COMPARATOR, ADDRESS_LOW_VALUE_COMPARATOR, ALTERNATIVE_RANGE_SEPARATOR, ALTERNATIVE_RANGE_SEPARATOR_STR, ALTERNATIVE_SEGMENT_WILDCARD_STR, DEFAULT_ADDRESS_COMPARATOR, HEX_PREFIX, OCTAL_PREFIX, RANGE_SEPARATOR, RANGE_SEPARATOR_STR, SEGMENT_SQL_SINGLE_WILDCARD, SEGMENT_SQL_SINGLE_WILDCARD_STR, SEGMENT_SQL_WILDCARD, SEGMENT_SQL_WILDCARD_STR, SEGMENT_WILDCARD, SEGMENT_WILDCARD_STR -
Constructor Summary
ConstructorsConstructorDescriptionMACAddress(byte[] bytes) Constructs a MAC address.MACAddress(long address) Constructs a MAC address.MACAddress(long address, boolean extended) Constructs a MAC address.MACAddress(Address.SegmentValueProvider valueProvider) Constructs a MAC addressMACAddress(Address.SegmentValueProvider valueProvider, boolean extended) Constructs a MAC addressMACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider) Constructs a MAC addressMACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, boolean extended) Constructs a MAC addressMACAddress(MACAddressSection section) Constructs a MAC address.MACAddress(MACAddressSegment[] segments) Constructs a MAC address.Constructs a MAC address for a network interface. -
Method Summary
Modifier and TypeMethodDescriptionadjustPrefixBySegment(boolean nextSegment) Increases or decreases prefix length to the next segment boundary.adjustPrefixBySegment(boolean nextSegment, boolean zeroed) Increases or decreases prefix length to the next segment boundary.adjustPrefixLength(int adjustment) Increases or decreases prefix length by the given increment.adjustPrefixLength(int adjustment, boolean zeroed) Increases or decreases prefix length by the given increment.applyPrefixLength(int prefixLength) Deprecated.Indicates where an address sits relative to the subnet ordering.intProvides the number of bits comprising this address itemintReturns the number of bits comprising each segment in this series.intProvides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8intReturns the number of bytes comprising each segment in this series.getDivision(int index) Useful for using an instance in a "for-each loop".getLower()If this represents a series with ranging values, returns a series representing the lower values of the range.intReturns the maximum possible segment value for this type of address.Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)Gets the subsection from the series that comprises all segmentsgetSection(int index) Gets the subsection from the series starting from the given index The first segment is at index 0.getSection(int index, int endIndex) Gets the subsection from the series starting from the given index and ending just before the give endIndex The first segment is at index 0.getSegment(int index) Returns the segment from this series at the given index.Returns the segments of this series of segments as an array.getUpper()If this represents a series with ranging values, returns a series representing the upper values of the range.increment(long increment) Returns the series from the subnet that is the given increment upwards into the subnet range, with the increment of 0 returning the first address in the range.incrementBoundary(long increment) If the given increment is positive, adds the value to the upper series (AddressSegmentSeries.getUpper()) in the subnet range to produce a new series.booleanbooleanisEUI64(boolean asMAC) Whether this section is consistent with an IPv6 EUI64 section, which means it came from an extended 8 byte address, and the corresponding segments in the middle match 0xff and 0xff/fe for MAC/not-MACbooleanbooleanisLocal()Local MAC addresses have the second least significant bit of the first octet set to 1.booleanReturns whether this address is a MAC addressbooleanMulticast MAC addresses have the least significant bit of the first octet set to 1.booleanbooleanUniversal MAC addresses have second the least significant bit of the first octet set to 0.iterator()Iterates through the individual address components.longstatic intIterates through the individual prefix blocks.Partitions and traverses through the individual prefix blocks for the prefix length of this series.Returns a sequential stream of the individual prefix blocks for the prefix length of this series.Iterates through the individual prefixes.Partitions and traverses through the individual prefixes for the prefix length of this series.Returns a sequential stream of the individual prefixes for the prefix length of this series.Deprecated.removePrefixLength(boolean zeroed) Deprecated.replace(int startIndex, int endIndex, MACAddress replacement, int replacementIndex) Replaces segments starting from startIndex and ending before endIndex with the same number of segments starting at replacementStartIndex from the replacement sectionreplace(int startIndex, MACAddressSection replacement) Replaces segments starting from startIndex with as many segments as possible from the replacement sectionreverseBits(boolean perByte) Use to produce: "MSB format", "IBM format", "Token-Ring format", and "non-canonical form" See RFC 2469 section 2 Also see https://en.wikipedia.org/wiki/MAC_addressReturns a new segment series with the bytes reversed.Returns a new segment series with the bytes reversed within each segment.Returns a new segment series with the segments reversed.Iterates through the individual segments.Partitions and traverses through the individual segment arrays.Returns a sequential stream of the individual segment arrays.setPrefixLength(int prefixLength) Sets the prefix length.setPrefixLength(int prefixLength, boolean zeroed) Sets the prefix length.Partitions and traverses through the individual address components.stream()Returns a sequential stream of the individual address components.Returns a host identifier string representation for this address, which will be already validated.toEUI64(boolean asMAC) Convert to IPv6 EUI-64 section http://standards.ieee.org/develop/regauth/tut/eui64.pdfConverts to an Ipv6 address section.Converts to a link-local Ipv6 address.If this address is a MAC address, returns thatMACAddress.toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions) Returns an address in which the range of values match the block for the OUI (organizationally unique identifier)If this series has a prefix length, returns the block for that prefix.toString()longProvides the same address with no prefix.Methods inherited from class Address
contains, containsPrefixBlock, containsSinglePrefixBlock, defaultIpv4Network, defaultIpv6Network, defaultMACNetwork, equals, getBlockCount, getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixCount, getPrefixCount, getPrefixLength, getPrefixLengthForSingleBlock, getSegmentCount, getSegments, getSegments, getSegmentStrings, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, includesMax, includesZero, isFullRange, isIPAddress, isMax, isMultiple, isPrefixBlock, isPrefixed, isSameAddress, isSequential, isSinglePrefixBlock, isZero, matchOrdered, matchUnordered, overlaps, prefixEquals, toCanonicalString, toCompressedString, toHexString, toIPAddress, toNormalizedStringMethods inherited from interface AddressDivisionSeries
getSequentialBlockIndex, isMoreMethods inherited from interface AddressItem
compareToMethods inherited from interface AddressSegmentSeries
isOneBit, testBit
-
Field Details
-
COLON_SEGMENT_SEPARATOR
public static final char COLON_SEGMENT_SEPARATOR- See Also:
-
DASH_SEGMENT_SEPARATOR
public static final char DASH_SEGMENT_SEPARATOR- See Also:
-
SPACE_SEGMENT_SEPARATOR
public static final char SPACE_SEGMENT_SEPARATOR- See Also:
-
DOTTED_SEGMENT_SEPARATOR
public static final char DOTTED_SEGMENT_SEPARATOR- See Also:
-
DASHED_SEGMENT_RANGE_SEPARATOR
public static final char DASHED_SEGMENT_RANGE_SEPARATOR- See Also:
-
DASHED_SEGMENT_RANGE_SEPARATOR_STR
-
BITS_PER_SEGMENT
public static final int BITS_PER_SEGMENT- See Also:
-
BYTES_PER_SEGMENT
public static final int BYTES_PER_SEGMENT- See Also:
-
MEDIA_ACCESS_CONTROL_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_SEGMENT_COUNT- See Also:
-
MEDIA_ACCESS_CONTROL_BIT_COUNT
public static final int MEDIA_ACCESS_CONTROL_BIT_COUNT- See Also:
-
MEDIA_ACCESS_CONTROL_DOTTED_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_SEGMENT_COUNT- See Also:
-
MEDIA_ACCESS_CONTROL_DOTTED_64_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_64_SEGMENT_COUNT- See Also:
-
MEDIA_ACCESS_CONTROL_DOTTED_BITS_PER_SEGMENT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_BITS_PER_SEGMENT- See Also:
-
MEDIA_ACCESS_CONTROL_SINGLE_DASHED_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_SINGLE_DASHED_SEGMENT_COUNT- See Also:
-
EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT- See Also:
-
EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT- See Also:
-
EXTENDED_UNIQUE_IDENTIFIER_48_BIT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_48_BIT_COUNT- See Also:
-
EXTENDED_UNIQUE_IDENTIFIER_64_BIT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_64_BIT_COUNT- See Also:
-
DEFAULT_TEXTUAL_RADIX
public static final int DEFAULT_TEXTUAL_RADIX- See Also:
-
MAX_VALUE_PER_SEGMENT
public static final int MAX_VALUE_PER_SEGMENT- See Also:
-
MAX_VALUE_PER_DOTTED_SEGMENT
public static final int MAX_VALUE_PER_DOTTED_SEGMENT- See Also:
-
ORGANIZATIONAL_UNIQUE_IDENTIFIER_SEGMENT_COUNT
public static final int ORGANIZATIONAL_UNIQUE_IDENTIFIER_SEGMENT_COUNT- See Also:
-
ORGANIZATIONAL_UNIQUE_IDENTIFIER_BIT_COUNT
public static final int ORGANIZATIONAL_UNIQUE_IDENTIFIER_BIT_COUNT- See Also:
-
-
Constructor Details
-
MACAddress
Constructs a MAC address.- Parameters:
segments- the address segments- Throws:
AddressValueException
-
MACAddress
Constructs a MAC address.- Parameters:
section- the address segments- Throws:
AddressValueException
-
MACAddress
Constructs a MAC address.- Throws:
AddressValueException
-
MACAddress
Constructs a MAC address for a network interface.- Throws:
SocketException
-
MACAddress
Constructs a MAC address.- Throws:
AddressValueException
-
MACAddress
Constructs a MAC address.- Throws:
AddressValueException
-
MACAddress
public MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, boolean extended) Constructs a MAC address- Parameters:
lowerValueProvider- supplies the 1 byte lower values for each segmentupperValueProvider- supplies the 1 byte upper values for each segment
-
MACAddress
public MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider) Constructs a MAC address- Parameters:
lowerValueProvider- supplies the 1 byte lower values for each segmentupperValueProvider- supplies the 1 byte upper values for each segment
-
MACAddress
public MACAddress(Address.SegmentValueProvider valueProvider, boolean extended) throws AddressValueException Constructs a MAC address- Parameters:
valueProvider- supplies the 1 byte value for each segment- Throws:
AddressValueException
-
MACAddress
Constructs a MAC address- Parameters:
valueProvider- supplies the 1 byte value for each segment
-
-
Method Details
-
enumerate
Description copied from class:AddressIndicates where an address sits relative to the subnet ordering.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 less one, and if below the subnet range, the distance to the lower boundary.
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 one less than 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.
enumerate returns null when the argument is a multi-valued subnet. The argument must be an individual address.
When this address is also single-valued, the returned value is the distance (difference) between this address and the argument address.
enumerate is the inverse of the increment method:
- subnet.enumerate(subnet.increment(inc)) = inc
- subnet.increment(subnet.enumerate(newAddr)) = newAddr
If the given address does not have the same version or type as this subnet or address, then null is returned.
-
getNetwork
Description copied from interface:AddressComponentReturns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)- Specified by:
getNetworkin interfaceAddressComponent- Returns:
-
getIPv6Network
-
getAddressCreator
-
isExtended
public boolean isExtended() -
isMACAddress
public boolean isMACAddress()Description copied from class:AddressReturns whether this address is a MAC address- Overrides:
isMACAddressin classAddress- Returns:
- whether this address is a MAC address
-
toMACAddress
Description copied from class:AddressIf this address is a MAC address, returns thatMACAddress. Otherwise, returns null.- Overrides:
toMACAddressin classAddress- Returns:
- the MAC address
-
isAllAddresses
public boolean isAllAddresses() -
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series that comprises all segments- Specified by:
getSectionin interfaceAddressSegmentSeries- Overrides:
getSectionin classAddress- Returns:
-
getDivision
- Specified by:
getDivisionin interfaceAddressDivisionSeries- Specified by:
getDivisionin interfaceAddressStringDivisionSeries- Returns:
- the given division in this series. The first is at index 0.
-
getSegment
Description copied from interface:AddressSegmentSeriesReturns the segment from this series at the given index. The first segment is at index 0. A segment is an address division, seeAddressDivisionSeries.getDivision(int), the difference being that all segments in a given series are the same bit count, while divisions can have variable length.- Specified by:
getSegmentin interfaceAddressSegmentSeries- Returns:
-
getSegments
Description copied from interface:AddressSegmentSeriesReturns the segments of this series of segments as an array. This must create a new array, so for efficiency useAddressSegmentSeries.getSegment(int)andAddressSegmentSeries.getSegmentCount()instead when feasible.- Specified by:
getSegmentsin interfaceAddressSegmentSeries- Returns:
-
maxSegmentValue
public static int maxSegmentValue() -
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegmentSeriesReturns the maximum possible segment value for this type of address. Note this is not the maximum value of the range of segment values in this specific address, this is the maximum value of any segment for this address type, and is usually determined by the number of bits per segment.- Specified by:
getMaxSegmentValuein interfaceAddressSegmentSeries- Returns:
- the maximum possible segment value for a series of the same type
-
getByteCount
public int getByteCount()Description copied from interface:AddressItemProvides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8- Specified by:
getByteCountin interfaceAddressItem- Overrides:
getByteCountin classAddress- Returns:
- the number of bytes
-
getBitCount
public int getBitCount()Description copied from interface:AddressItemProvides the number of bits comprising this address item- Specified by:
getBitCountin interfaceAddressDivisionSeries- Specified by:
getBitCountin interfaceAddressItem- Overrides:
getBitCountin classAddress- Returns:
- the number of bits
-
getBytesPerSegment
public int getBytesPerSegment()Description copied from interface:AddressSegmentSeriesReturns the number of bytes comprising each segment in this series. Segments in the same series are equal length.- Specified by:
getBytesPerSegmentin interfaceAddressSegmentSeries- Returns:
-
getBitsPerSegment
public int getBitsPerSegment()Description copied from interface:AddressSegmentSeriesReturns the number of bits comprising each segment in this series. Segments in the same series are equal length.- Specified by:
getBitsPerSegmentin interfaceAddressSegmentSeries- Returns:
-
getIterable
Description copied from interface:AddressComponentRangeUseful for using an instance in a "for-each loop". Otherwise just callAddressComponentRange.iterator()directly.- Specified by:
getIterablein interfaceAddressComponentRange- Specified by:
getIterablein interfaceAddressSegmentSeries- Specified by:
getIterablein classAddress- Returns:
-
iterator
Description copied from interface:AddressComponentRangeIterates through the individual address components.An address component can represent an individual segment, address, or section, or it can represent multiple, typically a subnet of addresses or a range of segment or section values.
Call
AddressItem.isMultiple()to determine if this instance represents multiple, orAddressItem.getCount()for the count.- Specified by:
iteratorin interfaceAddressComponentRange- Specified by:
iteratorin interfaceAddressSegmentSeries- Specified by:
iteratorin interfaceIterable<MACAddress>- Specified by:
iteratorin classAddress- Returns:
-
spliterator
Description copied from interface:AddressComponentRangePartitions and traverses through the individual address components.- Specified by:
spliteratorin interfaceAddressComponent- Specified by:
spliteratorin interfaceAddressComponentRange- Specified by:
spliteratorin interfaceAddressSegmentSeries- Specified by:
spliteratorin interfaceIterable<MACAddress>- Specified by:
spliteratorin classAddress- Returns:
-
stream
Description copied from interface:AddressComponentRangeReturns a sequential stream of the individual address components. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
streamin interfaceAddressComponentRange- Specified by:
streamin interfaceAddressSegmentSeries- Specified by:
streamin classAddress- Returns:
-
prefixBlockIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()- Specified by:
prefixBlockIteratorin interfaceAddressSegmentSeries- Specified by:
prefixBlockIteratorin classAddress
-
prefixBlockSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual prefix blocks for the prefix length of this series.- Specified by:
prefixBlockSpliteratorin interfaceAddressSegmentSeries- Specified by:
prefixBlockSpliteratorin classAddress- Returns:
-
prefixBlockStream
Description copied from interface:AddressSegmentSeriesReturns a sequential stream of the individual prefix blocks for the prefix length of this series. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixBlockStreamin interfaceAddressSegmentSeries- Specified by:
prefixBlockStreamin classAddress- Returns:
-
prefixIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()- Specified by:
prefixIteratorin interfaceAddressSegmentSeries- Specified by:
prefixIteratorin classAddress
-
prefixSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual prefixes for the prefix length of this series.- Specified by:
prefixSpliteratorin interfaceAddressSegmentSeries- Specified by:
prefixSpliteratorin classAddress- Returns:
-
prefixStream
Description copied from interface:AddressSegmentSeriesReturns a sequential stream of the individual prefixes for the prefix length of this series. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixStreamin interfaceAddressSegmentSeries- Specified by:
prefixStreamin classAddress- Returns:
-
segmentsIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual segments.- Specified by:
segmentsIteratorin interfaceAddressSegmentSeries
-
segmentsSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual segment arrays.- Specified by:
segmentsSpliteratorin interfaceAddressSegmentSeries- Returns:
-
segmentsStream
Description copied from interface:AddressSegmentSeriesReturns a sequential stream of the individual segment arrays. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
segmentsStreamin interfaceAddressSegmentSeries- Returns:
-
increment
Description copied from interface:AddressSegmentSeriesReturns the series from the subnet that is the given increment upwards into the subnet range, with the increment of 0 returning the first address in the range.If the subnet has multiple values and the increment exceeds the subnet size, then the amount by which it exceeds the size - 1 is added to the upper series of the range (the final iterator value).
If the increment is negative, it is added to the lower series of the range (the first iterator value).
If the subnet is just a single address values, the series is simply incremented by the given value, positive or negative.
If a subnet has multiple values, a positive increment value is equivalent to the same number of values from the
AddressSegmentSeries.iterator()For instance, a increment of 0 is the first value from the iterator, an increment of 1 is the second value from the iterator, and so on. A negative increment added to the subnet count is equivalent to the same number of values preceding the upper bound of the iterator. For instance, an increment of count - 1 is the last value from the iterator, an increment of count - 2 is the second last value, and so on.An increment of size count gives you the series just above the highest series of the subnet. To get the series just below the lowest series of the subnet, use the increment -1.
- Specified by:
incrementin interfaceAddressSegmentSeries- Specified by:
incrementin classAddress- Parameters:
increment-- Returns:
-
incrementBoundary
Description copied from interface:AddressSegmentSeriesIf the given increment is positive, adds the value to the upper series (AddressSegmentSeries.getUpper()) in the subnet range to produce a new series. If the given increment is negative, adds the value to the lower series (AddressSegmentSeries.getLower()) in the subnet range to produce a new series. If the increment is zero, returns this.In the case where the series is a single value, this simply returns the address produced by adding the given increment to this address series.
- Specified by:
incrementBoundaryin interfaceAddressSegmentSeries- Specified by:
incrementBoundaryin classAddress- Parameters:
increment-- Returns:
-
getLower
Description copied from interface:AddressSegmentSeriesIf this represents a series with ranging values, returns a series representing the lower values of the range. If this represents an series with a single value in each segment, returns this.- Specified by:
getLowerin interfaceAddressComponentRange- Specified by:
getLowerin interfaceAddressSegmentSeries- Specified by:
getLowerin classAddress- Returns:
-
getUpper
Description copied from interface:AddressSegmentSeriesIf 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.- Specified by:
getUpperin interfaceAddressComponentRange- Specified by:
getUpperin interfaceAddressSegmentSeries- Specified by:
getUpperin classAddress- Returns:
-
longValue
public long longValue() -
upperLongValue
public long upperLongValue() -
reverseBits
Use to produce: "MSB format", "IBM format", "Token-Ring format", and "non-canonical form" See RFC 2469 section 2 Also see https://en.wikipedia.org/wiki/MAC_address- Specified by:
reverseBitsin interfaceAddressComponent- Specified by:
reverseBitsin interfaceAddressSegmentSeries- Specified by:
reverseBitsin classAddress- Parameters:
perByte- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversed- Returns:
-
reverseBytes
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the bytes reversed.- Specified by:
reverseBytesin interfaceAddressComponent- Specified by:
reverseBytesin interfaceAddressSegmentSeries- Specified by:
reverseBytesin classAddress- Returns:
-
reverseBytesPerSegment
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the bytes reversed within each segment.- Specified by:
reverseBytesPerSegmentin interfaceAddressSegmentSeries- Specified by:
reverseBytesPerSegmentin classAddress- Returns:
-
reverseSegments
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the segments reversed. This does not throwIncompatibleAddressExceptionsince all address series can reverse their segments.- Specified by:
reverseSegmentsin interfaceAddressSegmentSeries- Specified by:
reverseSegmentsin classAddress- Returns:
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesRemoves the prefix length while zeroing out the bits beyond the prefix.If the series already has a prefix length, the bits outside the prefix become zero. Use
AddressSegmentSeries.withoutPrefixLength()to remove the prefix length without changing the series values.Equivalent to calling removePrefixLength(true)
- Specified by:
removePrefixLengthin interfaceAddressSegmentSeries- Specified by:
removePrefixLengthin classAddress- Returns:
- See Also:
-
withoutPrefixLength
Description copied from interface:AddressSegmentSeriesProvides the same address with no prefix. The values remain unchanged.Use
AddressSegmentSeries.removePrefixLength()as an alternative that deletes the host at the same time by zeroing the host values.- Specified by:
withoutPrefixLengthin interfaceAddressSegmentSeries- Specified by:
withoutPrefixLengthin classAddress
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesRemoves the prefix length. If zeroed is false, the bits that were host bits do not become zero, unlikeAddressSegmentSeries.removePrefixLength()- Specified by:
removePrefixLengthin interfaceAddressSegmentSeries- Specified by:
removePrefixLengthin classAddress- Parameters:
zeroed- whether the bits outside the prefix become zero- Returns:
-
applyPrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesApplies the given prefix length to create a new segment series.Similar to
AddressSegmentSeries.setPrefixLength(int)except that prefix lengths are never increased. When this series already has a prefix length that is less than or equal to the requested prefix length, this series is returned.Otherwise the returned series has the given prefix length.
The bits moved outside the prefix will become zero in the returned series.
- Specified by:
applyPrefixLengthin interfaceAddressSegmentSeries- Specified by:
applyPrefixLengthin classAddress- Parameters:
prefixLength-- Returns:
- See Also:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length to the next segment boundary.Follows the same rules as
AddressSegmentSeries.adjustPrefixLength(int):
When prefix length is increased, the bits moved within the prefix become zero. When a prefix length is decreased, the bits moved outside the prefix become zero. To avoid the zeroing behaviour, useAddressSegmentSeries.adjustPrefixBySegment(boolean, boolean)with second arg false.- Specified by:
adjustPrefixBySegmentin interfaceAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin classAddress- Parameters:
nextSegment- whether to move prefix to previous or following segment boundary- Returns:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length to the next segment boundary.- Specified by:
adjustPrefixBySegmentin interfaceAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin classAddress- Parameters:
nextSegment- whether to move prefix to previous or following segment boundaryzeroed- whether the bits that move from one side of the prefix to the other become zero or retain their original values- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length by the given increment.When prefix length is increased, the bits moved within the prefix become zero. When the prefix is extended beyond the segment series boundary, it is removed. When a prefix length is decreased, the bits moved outside the prefix become zero. To avoid the zeroing behaviour, use
AddressSegmentSeries.adjustPrefixLength(int, boolean)with second arg false.- Specified by:
adjustPrefixLengthin interfaceAddressSegmentSeries- Specified by:
adjustPrefixLengthin classAddress- Parameters:
adjustment-- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length by the given increment.- Specified by:
adjustPrefixLengthin interfaceAddressSegmentSeries- Specified by:
adjustPrefixLengthin classAddress- Parameters:
adjustment- the incrementzeroed- whether the bits that move from one side of the prefix to the other become zero or retain their original values- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeriesSets the prefix length.If this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero. For an alternative that does not set bits to zero, use
AddressSegmentSeries.setPrefixLength(int, boolean)with the second argument as false.When the prefix is extended beyond the segment series boundary, it is removed.
The bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.
- Specified by:
setPrefixLengthin interfaceAddressSegmentSeries- Specified by:
setPrefixLengthin classAddress- Parameters:
prefixLength-- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeriesSets the prefix length.When the prefix is extended beyond the segment series boundary, it is removed.
- Specified by:
setPrefixLengthin interfaceAddressSegmentSeries- Specified by:
setPrefixLengthin classAddress- Parameters:
zeroed- whether the bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series starting from the given index The first segment is at index 0.- Specified by:
getSectionin interfaceAddressSegmentSeries- Parameters:
index-- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series starting from the given index and ending just before the give endIndex The first segment is at index 0.- Specified by:
getSectionin interfaceAddressSegmentSeries- Parameters:
index-endIndex-- Returns:
-
getODISection
-
getOUISection
-
toOUIPrefixBlock
Returns an address in which the range of values match the block for the OUI (organizationally unique identifier)- Returns:
-
toPrefixBlock
Description copied from interface:AddressSegmentSeriesIf this series has a prefix length, returns the block for that prefix. Otherwise, this address series is returned.- Specified by:
toPrefixBlockin interfaceAddressSegmentSeries- Specified by:
toPrefixBlockin classAddress- Returns:
- the block of address series for the prefix length
-
toLinkLocalIPv6
Converts to a link-local Ipv6 address. Any MAC prefix length is ignored. Other elements of this address section are incorporated into the conversion. This will provide the latter 4 segments of an IPv6 address, to be paired with the link-local IPv6 prefix of 4 segments.- Returns:
-
toEUI64IPv6
Converts to an Ipv6 address section. Any MAC prefix length is ignored. Other elements of this address section are incorporated into the conversion. This will provide the latter 4 segments of an IPv6 address, to be paired with an IPv6 prefix of 4 segments.- Returns:
-
isEUI64
public boolean isEUI64(boolean asMAC) Whether this section is consistent with an IPv6 EUI64 section, which means it came from an extended 8 byte address, and the corresponding segments in the middle match 0xff and 0xff/fe for MAC/not-MAC- Parameters:
asMAC-- Returns:
-
toEUI64
Convert to IPv6 EUI-64 section http://standards.ieee.org/develop/regauth/tut/eui64.pdf- Parameters:
asMAC- if true, this address is considered MAC and the EUI-64 is extended using ff-ff, otherwise this address is considered EUI-48 and extended using ff-fe Note that IPv6 treats MAC as EUI-48 and extends MAC to IPv6 addresses using ff-fe- Returns:
-
replace
public MACAddress replace(int startIndex, int endIndex, MACAddress replacement, int replacementIndex) Replaces segments starting from startIndex and ending before endIndex with the same number of segments starting at replacementStartIndex from the replacement section- Parameters:
startIndex-endIndex-replacement-replacementIndex-- Returns:
- Throws:
IndexOutOfBoundsException
-
replace
Replaces segments starting from startIndex with as many segments as possible from the replacement section- Parameters:
startIndex-replacement-- Returns:
- Throws:
IndexOutOfBoundsException
-
getDottedAddress
-
toAddressString
Description copied from class:AddressReturns a host identifier string representation for this address, which will be already validated.- Overrides:
toAddressStringin classAddress- Returns:
-
toNormalizedString
-
toDottedString
- Throws:
IncompatibleAddressException
-
toDashedString
-
toColonDelimitedString
-
toSpaceDelimitedString
-
toString
-
isUnicast
public boolean isUnicast() -
isMulticast
public boolean isMulticast()Multicast MAC addresses have the least significant bit of the first octet set to 1.- Specified by:
isMulticastin classAddress- See Also:
-
isUniversal
public boolean isUniversal()Universal MAC addresses have second the least significant bit of the first octet set to 0. -
isLocal
-