]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Add support for exposing the received contact URI and also for setting the request...
authorJoshua Colp <jcolp@digium.com>
Mon, 9 Jul 2012 19:50:56 +0000 (19:50 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 9 Jul 2012 19:50:56 +0000 (19:50 +0000)
(closes issue AST-911)

git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.11@369845 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index dba896cbd68fb97a3ced3876ca01850f3b7c1036..5d05485d9265d4b9447e8a2ce0d3837e4aefb04e 100644 (file)
@@ -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) {