summaryrefslogtreecommitdiff
path: root/main/stun.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2012-07-09 22:38:25 +0000
committerJoshua Colp <jcolp@digium.com>2012-07-09 22:38:25 +0000
commit8f162be802fbadea7d1551202f1297cacf10a2e9 (patch)
treefa33e010bc5926cadab47e8f57a06d52664e5ae3 /main/stun.c
parent7baa8bf43de107cec6c172cd30d93d20961a5d12 (diff)
When receiving a STUN binding request send one out as the Google Talk client uses this as a method to determine if the remote party is still reachable or not.
Failure to do this results in the Google Talk client ignoring RTP packets after a specific period of time. This is also done as a result of receiving a STUN binding request so that the username information can be used from the inbound request, thus not requiring it to be stored on a per candidate basis. (closes issue ASTERISK-20107) Reported by: Malcolm Davenport git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369858 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/stun.c')
-rw-r--r--main/stun.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/stun.c b/main/stun.c
index ca3183839..a41dbac10 100644
--- a/main/stun.c
+++ b/main/stun.c
@@ -328,6 +328,7 @@ int ast_stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *data,
struct stun_header *resp = (struct stun_header *)respdata;
int resplen = 0; /* len excluding header */
int respleft = sizeof(respdata) - sizeof(struct stun_header);
+ char combined[33];
resp->id = hdr->id;
resp->msgtype = 0;
@@ -338,12 +339,16 @@ int ast_stun_handle_packet(int s, struct sockaddr_in *src, unsigned char *data,
if (stundebug)
ast_verbose("STUN Bind Request, username: %s\n",
st.username ? st.username : "<none>");
- if (st.username)
+ if (st.username) {
append_attr_string(&attr, STUN_USERNAME, st.username, &resplen, &respleft);
+ snprintf(combined, sizeof(combined), "%16s%16s", st.username + 16, st.username);
+ }
+
append_attr_address(&attr, STUN_MAPPED_ADDRESS, src, &resplen, &respleft);
resp->msglen = htons(resplen);
resp->msgtype = htons(STUN_BINDRESP);
stun_send(s, src, resp);
+ ast_stun_request(s, src, combined, NULL);
ret = AST_STUN_ACCEPT;
break;
default: