summaryrefslogtreecommitdiff
path: root/stun/usages
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2016-02-07 19:48:07 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2016-05-26 15:28:30 -0400
commitc129b05a469b59b576f4700fe9bfe3adca0a48dc (patch)
tree7259ca22332e699f50763129430710d9c73ea536 /stun/usages
parent501f9a82e47076cda0deab8cf54758b608e899aa (diff)
downloadlibnice-c129b05a469b59b576f4700fe9bfe3adca0a48dc.tar.gz
stun turn usage: Only send the username if short term creds or nonce present
This is recommended by the STUN RFC 5389.
Diffstat (limited to 'stun/usages')
-rw-r--r--stun/usages/turn.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/stun/usages/turn.c b/stun/usages/turn.c
index f242650..3b94959 100644
--- a/stun/usages/turn.c
+++ b/stun/usages/turn.c
@@ -152,7 +152,9 @@ size_t stun_usage_turn_create (StunAgent *agent, StunMessage *msg,
}
}
- if (username != NULL && username_len > 0) {
+ if (username != NULL && username_len > 0 &&
+ (agent->usage_flags & STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS ||
+ previous_response)) {
if (stun_message_append_bytes (msg, STUN_ATTRIBUTE_USERNAME,
username, username_len) != STUN_MESSAGE_RETURN_SUCCESS)
return 0;
@@ -205,7 +207,9 @@ size_t stun_usage_turn_create_refresh (StunAgent *agent, StunMessage *msg,
}
- if (username != NULL && username_len > 0) {
+ if (username != NULL && username_len > 0 &&
+ (agent->usage_flags & STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS ||
+ previous_response)) {
if (stun_message_append_bytes (msg, STUN_ATTRIBUTE_USERNAME,
username, username_len) != STUN_MESSAGE_RETURN_SUCCESS)
return 0;
@@ -251,7 +255,9 @@ size_t stun_usage_turn_create_permission (StunAgent *agent, StunMessage *msg,
}
/* username */
- if (username != NULL) {
+ if (username != NULL &&
+ (agent->usage_flags & STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS ||
+ (nonce != NULL && realm != NULL))) {
if (stun_message_append_bytes (msg, STUN_ATTRIBUTE_USERNAME,
username, username_len) != STUN_MESSAGE_RETURN_SUCCESS)
return 0;