public class FingerprintAttribute extends Attribute implements ContentDependentAttribute
The FINGERPRINT attribute can aid in distinguishing STUN packets from packets of other protocols. See Section 8.
As with MESSAGE-INTEGRITY, the CRC used in the FINGERPRINT attribute covers the length field from the STUN message header. Therefore, this value must be correct and include the CRC attribute as part of the message length, prior to computation of the CRC. When using the FINGERPRINT attribute in a message, the attribute is first placed into the message with a dummy value, then the CRC is computed, and then the value of the attribute is updated. If the MESSAGE-INTEGRITY attribute is also present, then it must be present with the correct message-integrity value before the CRC is computed, since the CRC is done over the value of the MESSAGE-INTEGRITY attribute as well.
Modifier and Type | Field and Description |
---|---|
private byte[] |
crc
The CRC32 checksum that this attribute is carrying.
|
static String |
NAME
Attribute name.
|
static byte[] |
XOR_MASK
The value that we need to XOR the CRC with.
|
ALTERNATE_SERVER, attributeType, CHANGE_REQUEST, CHANGED_ADDRESS, CHANNEL_NUMBER, CONNECTION_ID, 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_ADDRESS_FAMILY, 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
Constructor and Description |
---|
FingerprintAttribute()
Creates a FingerPrintAttribute instance.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
calculateXorCRC32(byte[] message,
int offset,
int len)
Calculates and returns the CRC32 checksum for message after
applying the XOR_MASK specified by RFC 5389.
|
void |
decodeAttributeBody(byte[] attributeValue,
char offset,
char length)
Sets this attribute's fields according to the message and attributeValue
arrays.
|
byte[] |
encode()
Returns a binary representation of this attribute.
|
byte[] |
encode(StunStack stunStack,
byte[] content,
int offset,
int length)
Returns a binary representation of this attribute.
|
boolean |
equals(Object obj)
Compares two STUN Attributes.
|
byte[] |
getChecksum()
Returns the CRC32 checksum that this attribute is carrying.
|
char |
getDataLength()
Returns the length of this attribute's body.
|
String |
getName()
Returns the human readable name of this attribute.
|
getAttributeType, getLocationInMessage, setAttributeType, setLocationInMessage
public static final String NAME
public static final byte[] XOR_MASK
private byte[] crc
FingerprintAttribute()
public byte[] getChecksum()
public char getDataLength()
getDataLength
in class Attribute
public String getName()
public boolean equals(Object obj)
public byte[] encode() throws UnsupportedOperationException
encode
in class Attribute
UnsupportedOperationException
- since ContentDependentAttribute
s should be encoded through the content
dependent encode method.public byte[] encode(StunStack stunStack, byte[] content, int offset, int length)
encode
in interface ContentDependentAttribute
stunStack
- the StunStack in the context of which the
request to encode this ContentDependentAttribute is being madecontent
- the content of the message that this attribute will be
transported inoffset
- the content-related offset where the actual
content starts.length
- the length of the content in the content array.public void decodeAttributeBody(byte[] attributeValue, char offset, char length) throws StunException
decodeAttributeBody
in class Attribute
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.
the start of this attribute.StunException
- if attrubteValue contains invalid data.public static byte[] calculateXorCRC32(byte[] message, int offset, int len)
message
- the message whose checksum we'd like to haveoffset
- the location in message where the actual message
starts.len
- the number of message bytes in messageCopyright © 2018. All rights reserved.