inet.ipaddr.mac

Class MACAddressSection

    • Field Detail

      • startIndex

        public final int startIndex
      • extended

        public final boolean extended
    • Constructor Detail

      • MACAddressSection

        public MACAddressSection(MACAddressSegment segment)
        Constructs a single segment section, the segment being the leading segment.
        Parameters:
        segment -
      • MACAddressSection

        public MACAddressSection(MACAddressSegment segment,
                                 int startIndex,
                                 boolean extended)
        Constructs a single segment section with the segment at the given index in the address.
        Parameters:
        segment -
      • MACAddressSection

        public MACAddressSection(MACAddressSegment[] segments)
        Use this constructor for any address section that includes the leading segment of a MAC address
      • MACAddressSection

        public MACAddressSection(MACAddressSegment[] segments,
                                 int startIndex,
                                 boolean extended)
      • MACAddressSection

        public MACAddressSection(MACAddressSegment[] segments,
                                 java.lang.Integer prefixLength)
      • MACAddressSection

        public MACAddressSection(MACAddressSegment[] segments,
                                 int startIndex,
                                 boolean extended,
                                 java.lang.Integer prefixLength)
      • MACAddressSection

        public MACAddressSection(byte[] bytes,
                                 int startIndex,
                                 boolean extended,
                                 java.lang.Integer prefixLength)
      • MACAddressSection

        public MACAddressSection(byte[] bytes,
                                 int startIndex,
                                 boolean extended)
      • MACAddressSection

        public MACAddressSection(byte[] bytes,
                                 java.lang.Integer prefixLength)
      • MACAddressSection

        public MACAddressSection(byte[] bytes)
      • MACAddressSection

        public MACAddressSection(long value,
                                 int startIndex,
                                 boolean extended,
                                 java.lang.Integer prefixLength)
      • MACAddressSection

        public MACAddressSection(long value,
                                 int startIndex,
                                 boolean extended)
      • MACAddressSection

        public MACAddressSection(long value,
                                 java.lang.Integer prefixLength)
      • MACAddressSection

        public MACAddressSection(long value)
    • Method Detail

      • isExtended

        public boolean isExtended()
        Returns:
        whether this section is part of a larger EUI-64 address.
      • isEntireAddress

        public boolean isEntireAddress(boolean extended)
      • getSegments

        public void getSegments(java.util.Collection<? super MACAddressSegment> segs)
      • getSegments

        public void getSegments(int start,
                                int end,
                                java.util.Collection<? super MACAddressSegment> segs)
      • getByteCount

        public int getByteCount()
        Description copied from interface: AddressComponent
        returns the number of bytes in each of the address components represented by this instance
        Specified by:
        getByteCount in interface AddressComponent
        Returns:
      • getOUISegmentCount

        public int getOUISegmentCount()
      • getODISegmentCount

        public int getODISegmentCount()
      • getPrefixLength

        public java.lang.Integer getPrefixLength()
        Description copied from interface: AddressDivisionSeries
        The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses. Typically this is the largest number of bits in the upper-most portion of the section for which the remaining bits assume all possible values. For IP addresses, this must be explicitly defined when the address is created. For example, 1.2.0.0/16 has a prefix length of 16, while 1.2.*.* has no prefix length, even though they both represent the same set of addresses and are considered equal. Prefixes can be considered variable for any given IP addresses and can depend on the routing table. The methods getMinPrefix and getEquivalentPrefix can help you to obtain or define a prefix length if one does not exist already. 1.2.0.0/16 and 1.2.*.* both the same equivalent and minimum prefix length of 16. For MAC addresses, the prefix is implicit, so 1:2:3:*:*:* has a prefix length of 24 by definition. Generally prefixes are not variable for a given address. Either an address has a prefix or not, the one assigned by the IEEE. There is no way to explicitly define the prefix in a representation of a MAC address. The prefix length is instead determined by the address itself when created.
        Specified by:
        getPrefixLength in interface AddressDivisionSeries
        Overrides:
        getPrefixLength in class AddressDivisionGrouping
        Returns:
        the number of bits in the prefix. The prefix is the smallest bit length x for which all possible values with the same first x bits are included in this range of sections, unless that value x matches the bit count of this section, in which case the prefix is null. If the prefix is the OUI bit length (24) then the ODI segments cover all possibly values.
      • isEUI64

        public boolean isEUI64(boolean asMAC)
        Equivalent to isEUI64(asMAC, false)
        Returns:
      • isEUI64

        public boolean isEUI64(boolean asMAC,
                               boolean partial)
        Whether this section is consistent with an 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:
        partial - whether missing segments are considered a match (this only has an effect if this section came from an extended 8 byte address), or in other words, we don't consider 6 byte addresses to be "missing" the bytes that would make it 8 byte.
        asMAC - whether to search for the ffff or fffe pattern
        Returns:
      • toEUI64

        public MACAddressSection toEUI64(boolean asMAC)
        If this section is part of a shorter 48 bit MAC or EUI-48 address see isExtended(), then the required sections are inserted (FF-FF for MAC, FF-FE for EUI-48) to extend it to EUI-64. However, if the section does not encompass the parts of the address where the new sections should be placed, then the section is unchanged. If the section is already part of an EUI-64 address, then it is checked to see if it has the segments that identify it as extended to EUI-64 (FF-FF for MAC, FF-FE for EUI-48), and if not, AddressTypeException is thrown.
        Parameters:
        asMAC -
        Returns:
      • contains

        public boolean contains(MACAddressSection other)
        Parameters:
        other -
        Returns:
        whether this section contains the given address section
      • toHexString

        public java.lang.String toHexString(boolean with0xPrefix)
        Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
        Specified by:
        toHexString in interface AddressComponent
      • toNormalizedString

        public java.lang.String toNormalizedString()
        The normalized string returned by this method is the most common representation of MAC addresses: xx:xx:xx:xx:xx:xx
        Specified by:
        toNormalizedString in interface AddressComponent
        Returns:
      • toCanonicalString

        public java.lang.String toCanonicalString()
        This produces a canonical string using the canonical standardized IEEE 802 MAC address representation of xx-xx-xx-xx-xx-xx For range segments, '..' is used: 11-22-33..44-55-66
        Specified by:
        toCanonicalString in interface AddressSegmentSeries
        Returns:
      • toCompressedString

        public java.lang.String toCompressedString()
        This produces a shorter string for the address that uses the canonical representation but not using leading zeroes. Each address has a unique compressed string.
        Specified by:
        toCompressedString in interface AddressSegmentSeries
        Returns:
      • toDottedString

        public java.lang.String toDottedString()
        This produces the dotted hexadecimal format aaaa.bbbb.cccc
      • toSpaceDelimitedString

        public java.lang.String toSpaceDelimitedString()
        This produces a string delimited by spaces: aa bb cc dd ee ff
      • toDashedString

        public java.lang.String toDashedString()
      • toColonDelimitedString

        public java.lang.String toColonDelimitedString()
      • contains

        public boolean contains(AddressSection other)
        Description copied from interface: AddressSection
        Determines if one section contains another. Sections must have the same number of segments to be comparable. For sections which are aware of their position in an address (IPv6 and MAC), their respective positions must match to be comparable.
        Specified by:
        contains in interface AddressSection
        Returns:
        whether this section contains the given address section