-
- All Implemented Interfaces:
public class XorMappedAddressAttribute extends AddressAttributeThe XOR-MAPPED-ADDRESS attribute is only present in Binding Responses. It provides the same information that is present in the MAPPED-ADDRESS attribute. However, the information is encoded by performing an exclusive or (XOR) operation between the mapped address and the transaction ID. Unfortunately, some NAT devices have been found to rewrite binary encoded IP addresses and ports that are present in protocol payloads. This behavior interferes with the operation of STUN. By providing the mapped address in an obfuscated form, STUN can continue to operate through these devices. The format of the XOR-MAPPED-ADDRESS is: 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 | X-Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | X-Address (Variable) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ The Family represents the IP address family, and is encoded identically to the Family in MAPPED-ADDRESS. X-Port is equal to the port in MAPPED-ADDRESS, exclusive or'ed with most significant 16 bits of the transaction ID. If the IP address family is IPv4, X-Address is equal to the IP address in MAPPED- ADDRESS, exclusive or'ed with the most significant 32 bits of the transaction ID. If the IP address family is IPv6, the X-Address is equal to the IP address in MAPPED-ADDRESS, exclusive or'ed with the entire 128 bit transaction ID.
-
-
Method Summary
Modifier and Type Method Description static TransportAddressapplyXor(TransportAddress address, Array<byte> transactionID)Returns the result of applying XOR on the specified attribute's address. TransportAddressgetAddress(Array<byte> transactionID)Returns the result of applying XOR on this attribute's address, using the specified transaction ID when converting IPv6 addresses. TransportAddressapplyXor(Array<byte> xorMask)Returns the result of applying XOR on this attribute's address, using the specified XOR mask. voidsetAddress(TransportAddress address, Array<byte> transactionID)Applies a XOR mask to the specified address and then sets it as the value transported by this attribute. -
Methods inherited from class org.ice4j.attribute.AddressAttribute
encode, equals, getAddress, getAddressBytes, getDataLength, getFamily, getName, getPort, setAddress -
Methods inherited from class org.ice4j.attribute.Attribute
getAttributeType, getLocationInMessage, setLocationInMessage -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
applyXor
static TransportAddress applyXor(TransportAddress address, Array<byte> transactionID)
Returns the result of applying XOR on the specified attribute's address. The method may be used for both encoding and decoding XorMappedAddresses.
- Parameters:
address- the address on which XOR should be appliedtransactionID- the transaction id to use for the XOR
-
getAddress
TransportAddress getAddress(Array<byte> transactionID)
Returns the result of applying XOR on this attribute's address, using the specified transaction ID when converting IPv6 addresses.
- Parameters:
transactionID- the transaction ID to use in case this attribute is encapsulating an IPv6 address.
-
applyXor
TransportAddress applyXor(Array<byte> xorMask)
Returns the result of applying XOR on this attribute's address, using the specified XOR mask. The method may be used for both encoding and decoding XorMappedAddresses.
- Parameters:
xorMask- the XOR mask to use when obtaining the original address.
-
setAddress
void setAddress(TransportAddress address, Array<byte> transactionID)
Applies a XOR mask to the specified address and then sets it as the value transported by this attribute.
- Parameters:
address- the address that we should xor and then record in this attribute.transactionID- the transaction identifier that we should use when creating the XOR mask.
-
-
-
-