public abstract class Attribute extends Object
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Value .... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The following types are defined: STUN attributes: 0x0001: MAPPED-ADDRESS 0x0002: RESPONSE-ADDRESS 0x0003: CHANGE-REQUEST 0x0004: SOURCE-ADDRESS 0x0005: CHANGED-ADDRESS 0x0006: USERNAME 0x0007: PASSWORD 0x0008: MESSAGE-INTEGRITY 0x0009: ERROR-CODE 0x000a: UNKNOWN-ATTRIBUTES 0x000b: REFLECTED-FROM 0x0014: REALM 0x0015: NONCE 0x0020: XOR-MAPPED-ADDRESS 0x8022: SOFTWARE 0x8023: ALTERNATE-SERVER 0x8028: FINGERPRINT TURN attributes: 0x000C: CHANNEL-NUMBER 0x000D: LIFETIME 0x0012: XOR-PEER-ADDRESS 0x0013: DATA 0x0016: XOR-RELAYED-ADDRESS 0x0018: EVEN-PORT 0x0019: REQUESTED-TRANSPORT 0x001A: DONT-FRAGMENT 0x0022: RESERVATION-TOKEN ICE attributes: 0x0024: PRIORITY 0x0025: USE-CANDIDATE 0x8029: ICE-CONTROLLED 0x802A: ICE-CONTROLLING
Modifier and Type | Field and Description |
---|---|
static char |
ALTERNATE_SERVER
Alternate server attribute.
|
protected char |
attributeType
The type of the attribute.
|
static char |
CHANGE_REQUEST
Change request attribute.
|
static char |
CHANGED_ADDRESS
Changed address attribute.
|
static char |
CHANNEL_NUMBER
Channel number attribute.
|
static char |
CONNECTION_ID
Connection Id attribute.
|
static char |
DATA
Data attribute.
|
static char |
DESTINATION_ADDRESS
Destination address attribute.
|
static char |
DONT_FRAGMENT
Don't fragment attribute.
|
static char |
ERROR_CODE
Error code attribute.
|
static char |
EVEN_PORT
Even port attribute.
|
static char |
FINGERPRINT
Fingerprint attribute.
|
static char |
HEADER_LENGTH
The size of an attribute header in bytes = len(TYPE) + len(LENGTH) = 4
|
static char |
ICE_CONTROLLED
ICE controlled attribute.
|
static char |
ICE_CONTROLLING
ICE controlling attribute.
|
static char |
LIFETIME
Lifetime attribute.
|
private int |
locationInMessage
For attributes that have arriving in incoming messages, this fiels
contains their original location in the binary array so that we could
later more easily verify attributes like MESSAGE-INTEGRITY.
|
static char |
MAGIC_COOKIE
Magic cookie attribute.
|
static char |
MAPPED_ADDRESS
Mapped address attribute.
|
static char |
MESSAGE_INTEGRITY
Message integrity attribute.
|
static char |
NONCE
Nonce attribute.
|
static char |
PASSWORD
Password attribute.
|
static char |
PRIORITY
Priority attribute.
|
static char |
REALM
Realm attribute.
|
static char |
REFLECTED_FROM
Reflected from attribute.
|
static char |
REMOTE_ADDRESS
Destination address attribute.
|
static char |
REQUESTED_ADDRESS_FAMILY
Requested Address Family attribute.
|
static char |
REQUESTED_TRANSPORT
Requested transport attribute.
|
static char |
RESERVATION_TOKEN
Reservation token attribute.
|
static char |
RESPONSE_ADDRESS
Response address attribute.
|
static char |
SOFTWARE
Software attribute.
|
static char |
SOURCE_ADDRESS
Source address attribute.
|
static char |
UNKNOWN_ATTRIBUTES
Unknown attributes attribute.
|
static char |
UNKNOWN_OPTIONAL_ATTRIBUTE
Unknown optional attribute.
|
static char |
USE_CANDIDATE
Use candidate attribute.
|
static char |
USERNAME
Username attribute.
|
static char |
XOR_MAPPED_ADDRESS
XOR Mapped address attribute.
|
static char |
XOR_ONLY
XOR only attribute.
|
static char |
XOR_PEER_ADDRESS
XOR peer address attribute.
|
static char |
XOR_RELAYED_ADDRESS
XOR relayed address attribute.
|
Modifier | Constructor and Description |
---|---|
protected |
Attribute(char attributeType)
Creates an empty STUN message attribute.
|
Modifier and Type | Method and Description |
---|---|
(package private) abstract void |
decodeAttributeBody(byte[] attributeValue,
char offset,
char length)
Sets this attribute's fields according to attributeValue array.
|
abstract byte[] |
encode()
Returns a binary representation of this attribute.
|
abstract boolean |
equals(Object obj)
Compares two STUN Attributes.
|
char |
getAttributeType()
Returns the attribute's type.
|
abstract char |
getDataLength()
Returns the length of this attribute's body.
|
int |
getLocationInMessage()
For attributes that have arriving in incoming messages, this method
returns their original location in the binary array so that we could
later more easily verify attributes like MESSAGE-INTEGRITY.
|
abstract String |
getName()
Returns the human readable name of this attribute.
|
protected void |
setAttributeType(char type)
Sets the attribute's type.
|
void |
setLocationInMessage(int index)
For attributes that have arriving in incoming messages, this method
stores their original location in the binary array so that we could
later more easily verify attributes like MESSAGE-INTEGRITY.
|
public static final char MAPPED_ADDRESS
public static final char RESPONSE_ADDRESS
public static final char CHANGE_REQUEST
public static final char SOURCE_ADDRESS
public static final char CHANGED_ADDRESS
public static final char USERNAME
public static final char PASSWORD
public static final char MESSAGE_INTEGRITY
public static final char ERROR_CODE
public static final char UNKNOWN_ATTRIBUTES
public static final char REFLECTED_FROM
public static final char REALM
public static final char NONCE
public static final char XOR_MAPPED_ADDRESS
public static final char XOR_ONLY
public static final char SOFTWARE
public static final char ALTERNATE_SERVER
public static final char FINGERPRINT
public static final char UNKNOWN_OPTIONAL_ATTRIBUTE
public static final char CHANNEL_NUMBER
public static final char LIFETIME
public static final char XOR_PEER_ADDRESS
public static final char DATA
public static final char XOR_RELAYED_ADDRESS
public static final char REQUESTED_ADDRESS_FAMILY
public static final char EVEN_PORT
public static final char REQUESTED_TRANSPORT
public static final char DONT_FRAGMENT
public static final char RESERVATION_TOKEN
public static final char CONNECTION_ID
public static final char MAGIC_COOKIE
public static final char DESTINATION_ADDRESS
public static final char REMOTE_ADDRESS
public static final char PRIORITY
public static final char USE_CANDIDATE
public static final char ICE_CONTROLLED
public static final char ICE_CONTROLLING
protected char attributeType
public static final char HEADER_LENGTH
private int locationInMessage
protected Attribute(char attributeType)
attributeType
- the type of the attribute.public abstract char getDataLength()
public abstract String getName()
public char getAttributeType()
protected void setAttributeType(char type)
type
- the new type of this attributepublic abstract boolean equals(Object obj)
public abstract byte[] encode()
public void setLocationInMessage(int index)
index
- the original location of this attribute in the datagram
we got off the wirepublic int getLocationInMessage()
Attribute
abstract void decodeAttributeBody(byte[] attributeValue, char offset, char length) throws StunException
attributeValue
- 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.Copyright © 2018. All rights reserved.