Class MacAddress


  • public class MacAddress
    extends java.lang.Object
    The class representing MAC address.
    • Field Detail

      • ONOS

        public static final MacAddress ONOS
        First MAC address in ONOS OUI range.
      • NONE

        public static final MacAddress NONE
        Dummy MAC address. We use the first MAC address in ONOS OUI range as the dummy MAC address.
      • ONOS_LLDP

        public static final MacAddress ONOS_LLDP
        ONOS LLDP MAC address with slow protocol destination address.
      • ZERO

        public static final MacAddress ZERO
        All-zero MAC address.
      • BROADCAST

        public static final MacAddress BROADCAST
        Broadcast MAC address.
      • EXACT_MASK

        public static final MacAddress EXACT_MASK
        Mask that indicates exact match on the MacAddress.
      • IPV4_MULTICAST

        public static final MacAddress IPV4_MULTICAST
        IPv4 multicast MAC address.
      • IPV4_MULTICAST_MASK

        public static final MacAddress IPV4_MULTICAST_MASK
        IPv4 multicast MAC mask.
      • IPV6_MULTICAST

        public static final MacAddress IPV6_MULTICAST
        IPv6 multicast MAC address.
      • IPV6_MULTICAST_MASK

        public static final MacAddress IPV6_MULTICAST_MASK
        IPv6 multicast MAC mask.
      • LLDP

        public static final java.util.Set<MacAddress> LLDP
        A set of LLDP MAC addresses.
      • LACP

        public static final MacAddress LACP
        LACP MAC address.
    • Constructor Detail

      • MacAddress

        public MacAddress​(byte[] address)
    • Method Detail

      • valueOf

        public static MacAddress valueOf​(java.lang.String address)
        Returns a MAC address instance representing the value of the specified String.
        Parameters:
        address - the String representation of the MAC Address to be parsed.
        Returns:
        a MAC Address instance representing the value of the specified String.
        Throws:
        java.lang.IllegalArgumentException - if the string cannot be parsed as a MAC address.
      • valueOf

        public static MacAddress valueOf​(byte[] address)
        Returns a MAC address instance representing the specified byte array.
        Parameters:
        address - the byte array to be parsed.
        Returns:
        a MAC address instance representing the specified byte array.
        Throws:
        java.lang.IllegalArgumentException - if the byte array cannot be parsed as a MAC address.
      • valueOf

        public static MacAddress valueOf​(long address)
        Returns a MAC address instance representing the specified long value. The lower 48 bits of the long value are used to parse as a MAC address.
        Parameters:
        address - the long value to be parsed. The lower 48 bits are used for a MAC address.
        Returns:
        a MAC address instance representing the specified long value.
        Throws:
        java.lang.IllegalArgumentException - if the long value cannot be parsed as a MAC address.
      • length

        public int length()
        Returns the length of the MACAddress.
        Returns:
        the length of the MACAddress.
      • toBytes

        public byte[] toBytes()
        Returns the value of the MACAddress as a byte array.
        Returns:
        the numeric value represented by this object after conversion to type byte array.
      • toLong

        public long toLong()
        Returns the value of the MACAddress as a long.
        Returns:
        the numeric value represented by this object after conversion to type long.
      • isBroadcast

        public boolean isBroadcast()
        Returns true if the MAC address is the broadcast address.
        Returns:
        true if the MAC address is the broadcast address.
      • isMulticast

        public boolean isMulticast()
        Returns true if the MAC address is the multicast address.
        Returns:
        true if the MAC address is the multicast address.
      • isLldp

        public boolean isLldp()
        Returns true if this MAC address is used by link layer discovery protocol.
        Returns:
        true if this MAC is LLDP MAC.
      • isOnos

        public boolean isOnos()
        Returns true if the Organizationally Unique Identifier (OUI) of this MAC address matches ONOS OUI.
        Returns:
        true if the OUI of this MAC address matches ONOS OUI.
      • oui

        public byte[] oui()
        Returns the Organizationally Unique Identifier (OUI) of this MAC address.
        Returns:
        the OUI of this MAC address.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toStringNoColon

        public java.lang.String toStringNoColon()
        Returns:
        MAC address in string representation without colons (useful for radix tree storage)