Commit d37b7097 authored by Simon Morlat's avatar Simon Morlat
Browse files

decode xor mapped address (there is no reason not to do it)

parent 930fac6f
...@@ -612,7 +612,11 @@ stunParseMessage( char* buf, unsigned int bufLen, StunMessage *msg) ...@@ -612,7 +612,11 @@ stunParseMessage( char* buf, unsigned int bufLen, StunMessage *msg)
} }
else else
{ {
ortp_debug("stun: SA_XORMAPPEDADDRESS = %s\n", ipaddr(&msg->xorMappedAddress.ipv4) ); uint32_t cookie = 0x2112A442;
uint16_t cookie16 = 0x2112A442 >> 16;
msg->xorMappedAddress.ipv4.port = msg->xorMappedAddress.ipv4.port^cookie16;
msg->xorMappedAddress.ipv4.addr = msg->xorMappedAddress.ipv4.addr^cookie;
ortp_debug("stun: SA_XORMAPPEDADDRESS = %s\n", ipaddr(&msg->xorMappedAddress.ipv4) );
} }
} }
else if (atrType == SA_XORONLY) else if (atrType == SA_XORONLY)
...@@ -2538,10 +2542,8 @@ stunOpenSocket( StunAddress4 *dest, StunAddress4* mapAddr, ...@@ -2538,10 +2542,8 @@ stunOpenSocket( StunAddress4 *dest, StunAddress4* mapAddr,
if (resp.hasXorMappedAddress==TRUE) if (resp.hasXorMappedAddress==TRUE)
{ {
uint32_t cookie = 0x2112A442; mappedAddr.port = resp.xorMappedAddress.ipv4.port;
uint16_t cookie16 = 0x2112A442 >> 16; mappedAddr.addr = resp.xorMappedAddress.ipv4.addr;
mappedAddr.port = resp.xorMappedAddress.ipv4.port^cookie16;
mappedAddr.addr = resp.xorMappedAddress.ipv4.addr^cookie;
} }
else else
mappedAddr = resp.mappedAddress.ipv4; mappedAddr = resp.mappedAddress.ipv4;
...@@ -2648,10 +2650,8 @@ stunOpenSocketPair(StunAddress4 *dest, ...@@ -2648,10 +2650,8 @@ stunOpenSocketPair(StunAddress4 *dest,
if (resp.hasXorMappedAddress==TRUE) if (resp.hasXorMappedAddress==TRUE)
{ {
uint32_t cookie = 0x2112A442; mappedAddr[i].port = resp.xorMappedAddress.ipv4.port;
uint16_t cookie16 = 0x2112A442 >> 16; mappedAddr[i].addr = resp.xorMappedAddress.ipv4.addr;
mappedAddr[i].port = resp.xorMappedAddress.ipv4.port^cookie16;
mappedAddr[i].addr = resp.xorMappedAddress.ipv4.addr^cookie;
} }
else else
mappedAddr[i] = resp.mappedAddress.ipv4; mappedAddr[i] = resp.mappedAddress.ipv4;
...@@ -2840,10 +2840,8 @@ turnAllocateSocketPair(StunAddress4 *dest, ...@@ -2840,10 +2840,8 @@ turnAllocateSocketPair(StunAddress4 *dest,
{ {
if (resp.hasXorRelayedAddress==TRUE) if (resp.hasXorRelayedAddress==TRUE)
{ {
uint32_t cookie = 0x2112A442; mappedAddr[i].port = resp.xorRelayedAddress.ipv4.port;
uint16_t cookie16 = 0x2112A442 >> 16; mappedAddr[i].addr = resp.xorRelayedAddress.ipv4.addr;
mappedAddr[i].port = resp.xorRelayedAddress.ipv4.port^cookie16;
mappedAddr[i].addr = resp.xorRelayedAddress.ipv4.addr^cookie;
} }
else else
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment