diff options
author | Youness Alaoui <kakaroto@kakaroto.(none)> | 2008-09-10 16:13:04 -0400 |
---|---|---|
committer | Youness Alaoui <kakaroto@kakaroto.(none)> | 2008-09-10 16:13:04 -0400 |
commit | 6f631ec6284a6fbec2a7a55bb6ae0712ea7dff98 (patch) | |
tree | 9af031ec74b05c879621dcb82b4aa944c35939e9 /stun | |
parent | 6c5580755060cacdc08a4ec706523e1702c7da62 (diff) | |
download | libnice-6f631ec6284a6fbec2a7a55bb6ae0712ea7dff98.tar.gz |
Let the turn usage tell us if a mapped address was also found
Diffstat (limited to 'stun')
-rw-r--r-- | stun/usages/turn.c | 16 | ||||
-rw-r--r-- | stun/usages/turn.h | 3 |
2 files changed, 14 insertions, 5 deletions
diff --git a/stun/usages/turn.c b/stun/usages/turn.c index 247e21e..e24a68d 100644 --- a/stun/usages/turn.c +++ b/stun/usages/turn.c @@ -205,6 +205,7 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg, StunUsageTurnCompatibility compatibility) { int val, code = -1; + StunUsageTurnReturn ret = STUN_USAGE_TURN_RETURN_RELAY_SUCCESS; switch (stun_message_get_class (msg)) { @@ -250,15 +251,18 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg, stun_debug ("Received %u-bytes STUN message\n", stun_message_length (msg)); if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_TD9) { - stun_message_find_xor_addr (msg, + val = stun_message_find_xor_addr (msg, STUN_ATTRIBUTE_XOR_MAPPED_ADDRESS, addr, addrlen); + + if (val == 0) + ret = STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS; val = stun_message_find_xor_addr (msg, STUN_ATTRIBUTE_RELAY_ADDRESS, relay_addr, relay_addrlen); if (val) { stun_debug (" No RELAYED-ADDRESS: %s\n", strerror (val)); return STUN_USAGE_TURN_RETURN_ERROR; } - } else if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_TD9) { + } else if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_GOOGLE) { val = stun_message_find_addr (msg, STUN_ATTRIBUTE_MAPPED_ADDRESS, relay_addr, relay_addrlen); if (val) { @@ -266,8 +270,12 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg, return STUN_USAGE_TURN_RETURN_ERROR; } }else if (compatibility == STUN_USAGE_TURN_COMPATIBILITY_MSN) { - stun_message_find_xor_addr (msg, + val = stun_message_find_xor_addr (msg, STUN_ATTRIBUTE_MSN_MAPPED_ADDRESS, addr, addrlen); + + if (val == 0) + ret = STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS; + val = stun_message_find_addr (msg, STUN_ATTRIBUTE_MAPPED_ADDRESS, relay_addr, relay_addrlen); if (val) { @@ -277,6 +285,6 @@ StunUsageTurnReturn stun_usage_turn_process (StunMessage *msg, } stun_debug (" Mapped address found!\n"); - return STUN_USAGE_TURN_RETURN_SUCCESS; + return ret; } diff --git a/stun/usages/turn.h b/stun/usages/turn.h index a4598f8..ed2d6c4 100644 --- a/stun/usages/turn.h +++ b/stun/usages/turn.h @@ -63,7 +63,8 @@ typedef enum { } StunUsageTurnCompatibility; typedef enum { - STUN_USAGE_TURN_RETURN_SUCCESS, + STUN_USAGE_TURN_RETURN_RELAY_SUCCESS, + STUN_USAGE_TURN_RETURN_MAPPED_SUCCESS, STUN_USAGE_TURN_RETURN_ERROR, STUN_USAGE_TURN_RETURN_RETRY, STUN_USAGE_TURN_RETURN_ALTERNATE_SERVER, |