Package org.onlab.packet
Class MacAddress
- java.lang.Object
-
- org.onlab.packet.MacAddress
-
public class MacAddress extends Object
The class representing MAC address.
-
-
Field Summary
Fields Modifier and Type Field Description static MacAddressBROADCASTBroadcast MAC address.static MacAddressEXACT_MASKMask that indicates exact match on the MacAddress.static MacAddressIPV4_MULTICASTIPv4 multicast MAC address.static MacAddressIPV4_MULTICAST_MASKIPv4 multicast MAC mask.static MacAddressIPV6_MULTICASTIPv6 multicast MAC address.static MacAddressIPV6_MULTICAST_MASKIPv6 multicast MAC mask.static MacAddressLACPLACP MAC address.static Set<MacAddress>LLDPA set of LLDP MAC addresses.static intMAC_ADDRESS_LENGTHstatic MacAddressNONEDummy MAC address.static MacAddressONOSFirst MAC address in ONOS OUI range.static MacAddressONOS_LLDPONOS LLDP MAC address with slow protocol destination address.static MacAddressZEROAll-zero MAC address.
-
Constructor Summary
Constructors Constructor Description MacAddress(byte[] address)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)inthashCode()booleaninRange(MacAddress macAddr, MacAddress maskAddr)Checks if the Mac Address is inside a range defined by macAddr and mask.booleanisBroadcast()Returnstrueif the MAC address is the broadcast address.booleanisLldp()Returns true if this MAC address is used by link layer discovery protocol.booleanisMulticast()Returnstrueif the MAC address is the multicast address.booleanisOnos()Returns true if the Organizationally Unique Identifier (OUI) of this MAC address matches ONOS OUI.intlength()Returns the length of theMACAddress.byte[]oui()Returns the Organizationally Unique Identifier (OUI) of this MAC address.byte[]toBytes()Returns the value of theMACAddressas abytearray.longtoLong()Returns the value of theMACAddressas along.StringtoString()StringtoStringNoColon()static MacAddressvalueOf(byte[] address)Returns a MAC address instance representing the specifiedbytearray.static MacAddressvalueOf(long address)Returns a MAC address instance representing the specifiedlongvalue.static MacAddressvalueOf(String address)Returns a MAC address instance representing the value of the specifiedString.
-
-
-
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 Set<MacAddress> LLDP
A set of LLDP MAC addresses.
-
LACP
public static final MacAddress LACP
LACP MAC address.
-
MAC_ADDRESS_LENGTH
public static final int MAC_ADDRESS_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
valueOf
public static MacAddress valueOf(String address)
Returns a MAC address instance representing the value of the specifiedString.- 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:
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 specifiedbytearray.- Parameters:
address- the byte array to be parsed.- Returns:
- a MAC address instance representing the specified
bytearray. - Throws:
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 specifiedlongvalue. 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
longvalue. - Throws:
IllegalArgumentException- if the long value cannot be parsed as a MAC address.
-
length
public int length()
Returns the length of theMACAddress.- Returns:
- the length of the
MACAddress.
-
toBytes
public byte[] toBytes()
Returns the value of theMACAddressas abytearray.- Returns:
- the numeric value represented by this object after conversion to
type
bytearray.
-
toLong
public long toLong()
Returns the value of theMACAddressas along.- Returns:
- the numeric value represented by this object after conversion to
type
long.
-
isBroadcast
public boolean isBroadcast()
Returnstrueif the MAC address is the broadcast address.- Returns:
trueif the MAC address is the broadcast address.
-
isMulticast
public boolean isMulticast()
Returnstrueif the MAC address is the multicast address.- Returns:
trueif 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.
-
toStringNoColon
public String toStringNoColon()
- Returns:
- MAC address in string representation without colons (useful for radix tree storage)
-
inRange
public boolean inRange(MacAddress macAddr, MacAddress maskAddr)
Checks if the Mac Address is inside a range defined by macAddr and mask.- Parameters:
macAddr- the mac addressmaskAddr- the mask- Returns:
- true if in range, false otherwise.
-
-