MacAddress
class MacAddress : Parcelable
Representation of a MAC address. This class only supports 48 bits long addresses and does not support 64 bits long addresses. Instances of this class are immutable.
Summary
Constants
|
| static Int |
Indicates a MAC address is the broadcast address.
|
| static Int |
Indicates a MAC address is a multicast address.
|
| static Int |
Indicates a MAC address is a unicast address.
|
Inherited constants
|
From class Parcelable
Int |
CONTENTS_FILE_DESCRIPTOR
Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.
|
Int |
PARCELABLE_WRITE_RETURN_VALUE
Flag for use with writeToParcel: the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)". Some implementations may want to release resources at this point.
|
|
Public methods
|
| Int |
|
| Boolean |
|
| static MacAddress |
Creates a MacAddress from the given byte array representation.
|
| static MacAddress |
Creates a MacAddress from the given String representation.
|
| Int |
Returns the type of this address.
|
| Inet6Address? |
Create a link-local Inet6Address from the MAC address.
|
| Int |
|
| Boolean |
|
| Boolean |
Checks if this MAC Address matches the provided range.
|
| ByteArray |
|
| String |
|
| String |
Returns a string representation of the object.
|
| Unit |
|
Constants
TYPE_BROADCAST
static val TYPE_BROADCAST: Int
Indicates a MAC address is the broadcast address.
Value: 3
TYPE_MULTICAST
static val TYPE_MULTICAST: Int
Indicates a MAC address is a multicast address.
Value: 2
TYPE_UNICAST
static val TYPE_UNICAST: Int
Indicates a MAC address is a unicast address.
Value: 1
Public methods
describeContents
fun describeContents(): Int
equals
fun equals(other: Any?): Boolean
| Parameters |
obj |
the reference object with which to compare. |
| Return |
Boolean |
true if this object is the same as the obj argument; false otherwise. |
fromBytes
static fun fromBytes(addr: ByteArray): MacAddress
Creates a MacAddress from the given byte array representation. A valid byte array representation for a MacAddress is a non-null array of length 6.
| Parameters |
addr |
ByteArray: a byte array representation of a MAC address. This value cannot be null. |
| Return |
MacAddress |
the MacAddress corresponding to the given byte array representation. |
| Exceptions |
java.lang.IllegalArgumentException |
if the given byte array is not a valid representation. |
fromString
static fun fromString(addr: String): MacAddress
Creates a MacAddress from the given String representation. A valid String representation for a MacAddress is a series of 6 values in the range [0,ff] printed in hexadecimal and joined by ':' characters.
| Parameters |
addr |
String: a String representation of a MAC address. This value cannot be null. |
| Return |
MacAddress |
the MacAddress corresponding to the given String representation. This value cannot be null. |
| Exceptions |
java.lang.IllegalArgumentException |
if the given String is not a valid representation. |
getAddressType
fun getAddressType(): Int
Returns the type of this address.
getLinkLocalIpv6FromEui48Mac
fun getLinkLocalIpv6FromEui48Mac(): Inet6Address?
Create a link-local Inet6Address from the MAC address. The EUI-48 MAC address is converted to an EUI-64 MAC address per RFC 4291. The resulting EUI-64 is used to construct a link-local IPv6 address per RFC 4862.
| Return |
Inet6Address? |
A link-local Inet6Address constructed from the MAC address. This value may be null. |
hashCode
fun hashCode(): Int
| Return |
Int |
a hash code value for this object. |
isLocallyAssigned
fun isLocallyAssigned(): Boolean
| Return |
Boolean |
true if this MacAddress is a locally assigned address. |
matches
fun matches(
baseAddress: MacAddress,
mask: MacAddress
): Boolean
Checks if this MAC Address matches the provided range.
| Parameters |
baseAddress |
MacAddress: MacAddress representing the base address to compare with. This value cannot be null. |
mask |
MacAddress: MacAddress representing the mask to use during comparison. This value cannot be null. |
| Return |
Boolean |
true if this MAC Address matches the given range. |
toByteArray
fun toByteArray(): ByteArray
| Return |
ByteArray |
a byte array representation of this MacAddress. This value cannot be null. |
toOuiString
fun toOuiString(): String
| Return |
String |
a String representation of the OUI part of this MacAddress made of 3 hexadecimal numbers in [0,ff] joined by ':' characters. This value cannot be null. |
toString
fun toString(): String
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
| Return |
String |
This value cannot be null. |
Properties
BROADCAST_ADDRESS
static val BROADCAST_ADDRESS: MacAddress!
The MacAddress representing the unique broadcast MAC address.