diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-09-02 16:34:01 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-09-02 16:34:01 +0100 |
commit | 10348322a960258043363e7c84e78c4821c90412 (patch) | |
tree | f68c5996d6a4a7bdc3ee4e2631d56f52788e9f2b | |
parent | abdab053af41068406caf95e80a64c512fd3db90 (diff) | |
parent | ab4ced5a46a7edba7cd49c0495bc41cd8fff7cc2 (diff) | |
download | libnice-10348322a960258043363e7c84e78c4821c90412.tar.gz |
ms-turn: don't wait for a reply to STUN_SEND request
Maniphest Tasks: T126
Reviewers: pwithnall
Projects: #libnice
Reviewed By: pwithnall
Subscribers: pwithnall
Differential Revision: https://phabricator.freedesktop.org/D223
-rw-r--r-- | socket/udp-turn.c | 3 | ||||
-rw-r--r-- | stun/stunagent.c | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/socket/udp-turn.c b/socket/udp-turn.c index 2b20142..12f90a0 100644 --- a/socket/udp-turn.c +++ b/socket/udp-turn.c @@ -816,7 +816,8 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to, /* Finish the message. */ msg_len = stun_agent_finish_message (&priv->agent, &msg, priv->password, priv->password_len); - if (msg_len > 0 && stun_message_get_class (&msg) == STUN_REQUEST) { + if (msg_len > 0 && stun_message_get_class (&msg) == STUN_REQUEST && + priv->compatibility != NICE_TURN_SOCKET_COMPATIBILITY_OC2007) { SendRequest *req = g_slice_new0 (SendRequest); req->priv = priv; diff --git a/stun/stunagent.c b/stun/stunagent.c index 2abcc29..bd243cb 100644 --- a/stun/stunagent.c +++ b/stun/stunagent.c @@ -513,8 +513,20 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, uint32_t fpr; int saved_id_idx = 0; uint8_t md5[16]; + bool remember_transaction; - if (stun_message_get_class (msg) == STUN_REQUEST) { + remember_transaction = (stun_message_get_class (msg) == STUN_REQUEST); + + if (agent->compatibility == STUN_COMPATIBILITY_OC2007 && + stun_message_get_method (msg) == STUN_SEND) { + /* As per [MS-TURN] Section 2.2.1, the TURN server doesn't send responses to + * STUN_SEND requests, so don't bother waiting for them. More details at + * https://msdn.microsoft.com/en-us/library/dd946797%28v=office.12%29.aspx. + */ + remember_transaction = FALSE; + } + + if (remember_transaction) { for (saved_id_idx = 0; saved_id_idx < STUN_AGENT_MAX_SAVED_IDS; saved_id_idx++) { if (agent->sent_ids[saved_id_idx].valid == FALSE) { break; @@ -620,7 +632,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, } - if (stun_message_get_class (msg) == STUN_REQUEST) { + if (remember_transaction) { stun_message_id (msg, agent->sent_ids[saved_id_idx].id); agent->sent_ids[saved_id_idx].method = stun_message_get_method (msg); agent->sent_ids[saved_id_idx].key = (uint8_t *) key; |