public abstract class AddressAttribute extends StunAttribute
MAPPED-ADDRESS
RESPONSE-ADDRESS
SOURCE-ADDRESS
CHANGED-ADDRESS
REFLECTED-FROM
ALTERNATE-SERVER
XOR-PEER-ADDRESS
XOR-RELAYED-ADDRESS
The different attributes are distinguished by the attributeType of org.ice4j.attribute.Attribute.
Address attributes indicate the mapped IP address and
port. They consist of an eight bit address family, and a sixteen bit
port, followed by a fixed length value representing the IP address.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|x x x x x x x x| Family | Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The port is a network byte ordered representation of the mapped port. The address family is always 0x01, corresponding to IPv4. The first 8 bits of the MAPPED-ADDRESS are ignored, for the purposes of aligning parameters on natural boundaries. The IPv4 address is 32 bits.
| Modifier and Type | Field and Description |
|---|---|
protected static byte |
ADDRESS_FAMILY_IPV4 |
protected static byte |
ADDRESS_FAMILY_IPV6 |
protected TransportAddress |
transportAddress |
ALTERNATE_SERVER, attributeType, CHANGE_REQUEST, CHANGED_ADDRESS, CHANNEL_NUMBER, DATA, DESTINATION_ADDRESS, DONT_FRAGMENT, ERROR_CODE, EVEN_PORT, FINGERPRINT, HEADER_LENGTH, ICE_CONTROLLED, ICE_CONTROLLING, LIFETIME, MAGIC_COOKIE, MAPPED_ADDRESS, MESSAGE_INTEGRITY, NONCE, PASSWORD, PRIORITY, REALM, REFLECTED_FROM, REMOTE_ADDRESS, REQUESTED_TRANSPORT, RESERVATION_TOKEN, RESPONSE_ADDRESS, SOFTWARE, SOURCE_ADDRESS, UNKNOWN_ATTRIBUTES, UNKNOWN_OPTIONAL_ATTRIBUTE, USE_CANDIDATE, USERNAME, XOR_MAPPED_ADDRESS, XOR_ONLY, XOR_PEER_ADDRESS, XOR_RELAYED_ADDRESS| Modifier | Constructor and Description |
|---|---|
protected |
AddressAttribute(char attributeType) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
decodeAttributeBody(byte[] attributeValue,
char offset,
char length)
Sets this attribute's fields according to attributeValue array.
|
byte[] |
encode()
Returns a binary representation of this attribute.
|
boolean |
equals(Object other)
Compares two STUN Attributes.
|
TransportAddress |
getAddress() |
byte[] |
getAddressBytes()
Returns the bytes of the address.
|
char |
getDataLength()
Returns the length of this attribute's body.
|
byte |
getFamily()
Returns the family that the this.address belongs to.
|
int |
getPort() |
void |
setAddress(TransportAddress address) |
protected void |
setAttributeType(char type)
Sets the attribute's type.
|
getAttributeType, getLocationInMessage, getName, setLocationInMessageprotected static final byte ADDRESS_FAMILY_IPV4
protected static final byte ADDRESS_FAMILY_IPV6
protected TransportAddress transportAddress
protected void setAttributeType(char type)
StunAttributesetAttributeType in class StunAttributetype - the new type of this attributepublic TransportAddress getAddress()
public void setAddress(TransportAddress address)
public int getPort()
public byte[] getAddressBytes()
public byte getFamily()
public char getDataLength()
StunAttributegetDataLength in class StunAttributepublic byte[] encode()
StunAttributeencode in class StunAttributeprotected void decodeAttributeBody(byte[] attributeValue,
char offset,
char length)
throws StunException
StunAttributedecodeAttributeBody in class StunAttributeattributeValue - a binary array containing this attribute's field values and
NOT containing the attribute header.offset - the position where attribute values begin (most often offset
is equal to the index of the first byte after length)length - the length of the binary array.StunException - if attrubteValue contains invalid data.public boolean equals(Object other)
equals in class StunAttributeother - the object to compare this attribute with.Copyright © 2017 TeleStax, Inc.. All Rights Reserved.