From: Joshua Colp Date: Mon, 9 Jul 2012 19:50:56 +0000 (+0000) Subject: Add support for exposing the received contact URI and also for setting the request... X-Git-Tag: certified/1.8.11-cert5-rc1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e276789669debb08d3d8a9a6af647e43e414fdc3;p=thirdparty%2Fasterisk.git Add support for exposing the received contact URI and also for setting the request URI in messages. (closes issue AST-911) git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369845 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index dba896cbd6..5d05485d92 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -13521,6 +13521,17 @@ static int transmit_message_with_msg(struct sip_pvt *p, const struct ast_msg *ms struct ast_msg_var_iterator *i; const char *var, *val; + i = ast_msg_var_iterator_init(msg); + while (ast_msg_var_iterator_next(msg, i, &var, &val)) { + if (!strcasecmp(var, "Request-URI")) { + ast_string_field_set(p, fullcontact, val); + ast_msg_var_unref_current(i); + break; + } + ast_msg_var_unref_current(i); + } + ast_msg_var_iterator_destroy(i); + build_via(p); initreqprep(&req, p, SIP_MESSAGE, NULL); ast_string_field_set(p, msg_body, ast_msg_get_body(msg)); @@ -13528,7 +13539,9 @@ static int transmit_message_with_msg(struct sip_pvt *p, const struct ast_msg *ms i = ast_msg_var_iterator_init(msg); while (ast_msg_var_iterator_next(msg, i, &var, &val)) { - add_header(&req, var, val); + if (strcasecmp(var, "Request-URI")) { + add_header(&req, var, val); + } ast_msg_var_unref_current(i); } ast_msg_var_iterator_destroy(i); @@ -16459,7 +16472,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a const char *content_type = get_header(req, "Content-Type"); struct ast_msg *msg; int res; - char *from, *to; + char *from, *to, stripped[SIPBUFSIZE]; if (strncmp(content_type, "text/plain", strlen("text/plain"))) { /* No text/plain attachment */ transmit_response(p, "415 Unsupported Media Type", req); /* Good enough, or? */ @@ -16597,6 +16610,9 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req, struct a res |= ast_msg_set_var(msg, "SIP_PEERNAME", p->peername); } + ast_copy_string(stripped, get_header(req, "Contact"), sizeof(stripped)); + res |= ast_msg_set_var(msg, "SIP_FULLCONTACT", get_in_brackets(stripped)); + res |= ast_msg_set_exten(msg, "%s", p->exten); if (res) {