Package 

Class Attribute

  • All Implemented Interfaces:

    
    public abstract class Attribute
    
                        

    After the header are 0 or more attributes. Each attribute is TLV encoded, with a 16 bit type, 16 bit length, and variable value:

        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
    
    • Constructor Detail

    • Method Detail

      • setAttributeType

         void setAttributeType(char type)

        Sets the attribute's type.

        Parameters:
        type - the new type of this attribute
      • getLocationInMessage

         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.

      • setLocationInMessage

         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.

        Parameters:
        index - the original location of this attribute in the datagram we got off the wire
      • getDataLength

         abstract char getDataLength()

        Returns the length of this attribute's body.

      • getName

         abstract String getName()

        Returns the human readable name of this attribute. Attribute names do not really matter from the protocol point of view. They are only used for debugging and readability.

      • equals

         abstract boolean equals(Object obj)

        Compares two STUN Attributes. Two attributes are considered equal when they have the same type length and value.

        Parameters:
        obj - the object to compare this attribute with.
      • encode

         abstract Array<byte> encode()

        Returns a binary representation of this attribute.