]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Improve accuracy of identifying information sent in dialog-info SIP NOTIFY requests.
authorMark Michelson <mmichelson@digium.com>
Thu, 29 Mar 2012 23:05:42 +0000 (23:05 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 29 Mar 2012 23:05:42 +0000 (23:05 +0000)
This change makes use of connected party information in addition to caller ID in order
to populate local and remote XML elements in the dialog-info NOTIFYs.

(closes issue ASTERISK-16735)
Reported by: Maciej Krajewski
Tested by: Maciej Krajewski
Patches:
    local_remote_hint2.diff uploaded by Mark Michelson (license 5049)
........

Merged revisions 360862 from http://svn.asterisk.org/svn/asterisk/branches/1.8

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

channels/chan_sip.c

index 4733a3131636126a2cee66f73fd857094a1a187d..3eba035d35680b3520ec5fe53b855498a23b5786 100644 (file)
@@ -12987,6 +12987,8 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
                if ((state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
                        const char *local_display = exten;
                        char *local_target = ast_strdupa(mto);
+                       const char *remote_display = exten;
+                       char *remote_target = ast_strdupa(mfrom);
 
                        /* There are some limitations to how this works.  The primary one is that the
                           callee must be dialing the same extension that is being monitored.  Simply dialing
@@ -12996,16 +12998,28 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
 
                                if ((caller = ast_channel_callback(find_calling_channel, NULL, p, 0))) {
                                        char *cid_num;
+                                       char *connected_num;
                                        int need;
 
                                        ast_channel_lock(caller);
                                        cid_num = S_COR(caller->caller.id.number.valid,
                                                caller->caller.id.number.str, "");
                                        need = strlen(cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
-                                       local_target = alloca(need);
-                                       snprintf(local_target, need, "sip:%s@%s", cid_num, p->fromdomain);
-                                       local_display = ast_strdupa(S_COR(caller->caller.id.name.valid,
+                                       remote_target = alloca(need);
+                                       snprintf(remote_target, need, "sip:%s@%s", cid_num, p->fromdomain);
+
+                                       remote_display = ast_strdupa(S_COR(caller->caller.id.name.valid,
                                                caller->caller.id.name.str, ""));
+
+                                       connected_num = S_COR(caller->connected.id.number.valid,
+                                               caller->connected.id.number.str, "");
+                                       need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@");
+                                       local_target = alloca(need);
+                                       snprintf(local_target, need, "sip:%s@%s", connected_num, p->fromdomain);
+
+                                       local_display = ast_strdupa(S_COR(caller->connected.id.name.valid,
+                                               caller->connected.id.name.str, ""));
+
                                        ast_channel_unlock(caller);
                                        caller = ast_channel_unref(caller);
                                }
@@ -13027,10 +13041,10 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
                                                "<target uri=\"%s\"/>\n"
                                                "</remote>\n"
                                                "<local>\n"
-                                               "<identity>%s</identity>\n"
+                                               "<identity display=\"%s\">%s</identity>\n"
                                                "<target uri=\"%s\"/>\n"
                                                "</local>\n",
-                                               local_display, local_target, local_target, mto, mto);
+                                               remote_display, remote_target, remote_target, local_display, local_target, local_target);
                        } else {
                                ast_str_append(tmp, 0, "<dialog id=\"%s\" direction=\"recipient\">\n", exten);
                        }