<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16575] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16575">16575</a></dd>
<dt>Author</dt> <dd>mrene</dd>
<dt>Date</dt> <dd>2010-02-05 01:05:33 -0600 (Fri, 05 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/MODSOFIA-46">MODSOFIA-46</a> with some NULL-proofing</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_regc">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (16574 => 16575)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-02-05 02:46:45 UTC (rev 16574)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-02-05 07:05:33 UTC (rev 16575)
</span><span class="lines">@@ -888,24 +888,63 @@
</span><span class="cx"> void event_handler(switch_event_t *event)
</span><span class="cx"> {
</span><span class="cx">         char *subclass, *sql;
</span><ins>+        char *class;
+        switch_event_t *pevent;
</ins><span class="cx"> 
</span><del>-        if ((subclass = switch_event_get_header(event, &quot;orig-event-subclass&quot;)) &amp;&amp; !strcasecmp(subclass, MY_EVENT_REGISTER)) {
-                char *from_user = switch_event_get_header(event, &quot;orig-from-user&quot;);
-                char *from_host = switch_event_get_header(event, &quot;orig-from-host&quot;);
-                char *to_host = switch_event_get_header(event, &quot;orig-to-host&quot;);
-                char *contact_str = switch_event_get_header(event, &quot;orig-contact&quot;);
-                char *exp_str = switch_event_get_header(event, &quot;orig-expires&quot;);
-                char *rpid = switch_event_get_header(event, &quot;orig-rpid&quot;);
-                char *call_id = switch_event_get_header(event, &quot;orig-call-id&quot;);
-                char *user_agent = switch_event_get_header(event, &quot;orig-user-agent&quot;);
</del><ins>+        /* Get Original Event Name */
+        class = switch_event_get_header_nil(event, &quot;orig-event-name&quot;);
+        if (!strcasecmp(class, &quot;PRESENCE_IN&quot;)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;\nGot Presence IN event via MultiCast\n&quot;);
+                if (switch_event_create(&amp;pevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+                                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;proto&quot;, switch_event_get_header_nil(event, &quot;orig-proto&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;login&quot;, switch_event_get_header_nil(event, &quot;orig-login&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;from&quot;, switch_event_get_header_nil(event, &quot;orig-from&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;rpid&quot;, switch_event_get_header_nil(event, &quot;orig-rpid&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;status&quot;, switch_event_get_header_nil(event, &quot;orig-status&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;answer-state&quot;, switch_event_get_header_nil(event, &quot;orig-answer-state&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;alt_event_type&quot;, switch_event_get_header_nil(event, &quot;orig-alt_event_type&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;presence-call-direction&quot;, switch_event_get_header_nil(event, &quot;orig-presence-call-direction&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;channel-state&quot;, switch_event_get_header_nil(event, &quot;orig-channel-state&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;call-direction&quot;, switch_event_get_header_nil(event, &quot;orig-call-direction&quot;));
+                        /* we cannot use switch_event_fire, or otherwise we'll start an endless loop */
+                        sofia_presence_event_handler(pevent);
+                        return;
+                } else {                
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;\nCannot inject PRESENCE_IN event\n&quot;);
+                        return;
+                }
+        } else if (!strcasecmp(class, &quot;MESSAGE_WAITING&quot;)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;\nGot MWI event via MultiCast\n&quot;);
+                if (switch_event_create(&amp;pevent, SWITCH_EVENT_MESSAGE_WAITING) == SWITCH_STATUS_SUCCESS) {
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;MWI-Messages-Waiting&quot;, switch_event_get_header_nil(event, &quot;orig-MWI-Messages-Waiting&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;MWI-Message-Account&quot;, switch_event_get_header_nil(event, &quot;orig-MWI-Message-Account&quot;));
+                        switch_event_add_header_string(pevent, SWITCH_STACK_BOTTOM, &quot;MWI-Voice-Message&quot;, switch_event_get_header_nil(event, &quot;orig-MWI-Voice-Message&quot;));
+                        /* we cannot use switch_event_fire, or otherwise we'll start an endless loop */
+                        sofia_presence_mwi_event_handler(pevent);
+                        return;
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;\nCannot inject MWI event\n&quot;);
+                        return;
+                }
+        } else if ((subclass = switch_event_get_header_nil(event, &quot;orig-event-subclass&quot;)) &amp;&amp; !strcasecmp(subclass, MY_EVENT_REGISTER)) {
+                char *from_user = switch_event_get_header_nil(event, &quot;orig-from-user&quot;);
+                char *from_host = switch_event_get_header_nil(event, &quot;orig-from-host&quot;);
+                char *to_host = switch_event_get_header_nil(event, &quot;orig-to-host&quot;);
+                char *contact_str = switch_event_get_header_nil(event, &quot;orig-contact&quot;);
+                char *exp_str = switch_event_get_header_nil(event, &quot;orig-expires&quot;);
+                char *rpid = switch_event_get_header_nil(event, &quot;orig-rpid&quot;);
+                char *call_id = switch_event_get_header_nil(event, &quot;orig-call-id&quot;);
+                char *user_agent = switch_event_get_header_nil(event, &quot;orig-user-agent&quot;);
</ins><span class="cx">                 long expires = (long) switch_epoch_time_now(NULL);
</span><del>-                char *profile_name = switch_event_get_header(event, &quot;orig-profile-name&quot;);
-                char *to_user = switch_event_get_header(event, &quot;orig-to-user&quot;);
-                char *presence_hosts = switch_event_get_header(event, &quot;orig-presence-hosts&quot;);
-                char *network_ip = switch_event_get_header(event, &quot;orig-network-ip&quot;);
-                char *network_port = switch_event_get_header(event, &quot;orig-network-port&quot;);
-                char *username = switch_event_get_header(event, &quot;orig-username&quot;);
-                char *realm = switch_event_get_header(event, &quot;orig-realm&quot;);
</del><ins>+                char *profile_name = switch_event_get_header_nil(event, &quot;orig-profile-name&quot;);
+                char *to_user = switch_event_get_header_nil(event, &quot;orig-to-user&quot;);
+                char *presence_hosts = switch_event_get_header_nil(event, &quot;orig-presence-hosts&quot;);
+                char *network_ip = switch_event_get_header_nil(event, &quot;orig-network-ip&quot;);
+                char *network_port = switch_event_get_header_nil(event, &quot;orig-network-port&quot;);
+                char *username = switch_event_get_header_nil(event, &quot;orig-username&quot;);
+                char *realm = switch_event_get_header_nil(event, &quot;orig-realm&quot;);
+                char *orig_server_host = switch_event_get_header_nil(event, &quot;orig-FreeSWITCH-IPv4&quot;);
+                char *orig_hostname = switch_event_get_header_nil(event, &quot;orig-FreeSWITCH-Hostname&quot;);
</ins><span class="cx">                 char *fixed_contact_str = NULL;
</span><span class="cx"> 
</span><span class="cx">                 sofia_profile_t *profile = NULL;
</span><span class="lines">@@ -916,7 +955,7 @@
</span><span class="cx">                 char *mwi_user = NULL;
</span><span class="cx">                 char *mwi_host = NULL;
</span><span class="cx"> 
</span><del>-                if ((mwi_account = switch_event_get_header(event, &quot;orig-mwi-account&quot;))) {
</del><ins>+                if ((mwi_account = switch_event_get_header_nil(event, &quot;orig-mwi-account&quot;))) {
</ins><span class="cx">                         dup_mwi_account = strdup(mwi_account);
</span><span class="cx">                         switch_assert(dup_mwi_account != NULL);
</span><span class="cx">                         sofia_glue_get_user_host(dup_mwi_account, &amp;mwi_user, &amp;mwi_host);
</span><span class="lines">@@ -963,7 +1002,20 @@
</span><span class="cx">                                 sptr = strchr(fixed_contact_str, '\0') - 1;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        switch_snprintf(sptr, len - (sptr - fixed_contact_str), &quot;;fs_path=sip:%s%s&quot;, to_host, eptr ? eptr : &quot;&gt;&quot;);
</del><ins>+                        switch (mod_sofia_globals.rewrite_multicasted_fs_path) {
+                                case 1:
+                                        switch_snprintf(sptr, len - (sptr - fixed_contact_str), &quot;;fs_path=sip:%s%s&quot;, to_host, eptr ? eptr : &quot;&gt;&quot;);
+                                break;
+                                case 2:
+                                        switch_snprintf(sptr, len - (sptr - fixed_contact_str), &quot;;fs_path=sip:%s%s&quot;, orig_server_host, eptr ? eptr : &quot;&gt;&quot;);
+                                break;
+                                case 3:
+                                        switch_snprintf(sptr, len - (sptr - fixed_contact_str), &quot;;fs_path=sip:%s%s&quot;, orig_hostname, eptr ? eptr : &quot;&gt;&quot;);
+                                break;
+                                default:
+                                        switch_snprintf(sptr, len - (sptr - fixed_contact_str), &quot;;fs_path=sip:%s%s&quot;, to_host, eptr ? eptr : &quot;&gt;&quot;);
+                                break;
+                        }
</ins><span class="cx"> 
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Rewrote contact string from '%s' to '%s'\n&quot;, contact_str, fixed_contact_str);
</span><span class="cx">                         contact_str = fixed_contact_str;
</span><span class="lines">@@ -975,10 +1027,12 @@
</span><span class="cx">                 switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
</span><span class="cx">                 sql = switch_mprintf(&quot;insert into sip_registrations &quot;
</span><span class="cx">                                                          &quot;(call_id, sip_user, sip_host, presence_hosts, contact, status, rpid, expires,&quot;
</span><del>-                                                         &quot;user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm, mwi_user, mwi_host) &quot;
-                                                         &quot;values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</del><ins>+                                                         &quot;user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm,&quot; 
+                                                         &quot;mwi_user, mwi_host, orig_server_host, orig_hostname) &quot;
+                                                         &quot;values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')&quot;,
</ins><span class="cx">                                                          call_id, from_user, from_host, presence_hosts, contact_str, rpid, expires, user_agent, to_user, guess_ip4, 
</span><del>-                                                         profile_name, mod_sofia_globals.hostname, network_ip, network_port, username, realm, mwi_user, mwi_host);
</del><ins>+                                                         profile_name, mod_sofia_globals.hostname, network_ip, network_port, username, realm, mwi_user, mwi_host,
+                                                         orig_server_host, orig_hostname);
</ins><span class="cx"> 
</span><span class="cx">                 if (sql) {
</span><span class="cx">                         sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span><span class="lines">@@ -2526,7 +2580,16 @@
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;auto-restart&quot;)) {
</span><span class="cx">                                 mod_sofia_globals.auto_restart = switch_true(val);
</span><span class="cx">                         } else if (!strcasecmp(var, &quot;rewrite-multicasted-fs-path&quot;)) {
</span><del>-                                mod_sofia_globals.rewrite_multicasted_fs_path = switch_true(val);
</del><ins>+                                if( (!strcasecmp(val, &quot;to_host&quot;)) || (!strcasecmp(val, &quot;1&quot;)) ) {
+                                        /* old behaviour */
+                                        mod_sofia_globals.rewrite_multicasted_fs_path = 1;
+                                } else if (!strcasecmp(val, &quot;original_server_host&quot;)) {
+                                        mod_sofia_globals.rewrite_multicasted_fs_path = 2;
+                                } else if (!strcasecmp(val, &quot;original_hostname&quot;)) {
+                                        mod_sofia_globals.rewrite_multicasted_fs_path = 3;
+                                } else {
+                                        mod_sofia_globals.rewrite_multicasted_fs_path = SWITCH_FALSE;
+                                }
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (16574 => 16575)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-02-05 02:46:45 UTC (rev 16574)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-02-05 07:05:33 UTC (rev 16575)
</span><span class="lines">@@ -3835,25 +3835,27 @@
</span><span class="cx"> 
</span><span class="cx">         char reg_sql[] =
</span><span class="cx">                 &quot;CREATE TABLE sip_registrations (\n&quot;
</span><del>-                &quot;   call_id         VARCHAR(255),\n&quot;
-                &quot;   sip_user        VARCHAR(255),\n&quot;
-                &quot;   sip_host        VARCHAR(255),\n&quot;
-                &quot;   presence_hosts  VARCHAR(255),\n&quot;
-                &quot;   contact         VARCHAR(1024),\n&quot;
-                &quot;   status          VARCHAR(255),\n&quot;
-                &quot;   rpid            VARCHAR(255),\n&quot; 
-                &quot;   expires         INTEGER,\n&quot; 
-                &quot;   user_agent      VARCHAR(255),\n&quot; 
-                &quot;   server_user     VARCHAR(255),\n&quot;
-                &quot;   server_host     VARCHAR(255),\n&quot; 
-                &quot;   profile_name    VARCHAR(255),\n&quot; 
-                &quot;   hostname        VARCHAR(255),\n&quot; 
-                &quot;   network_ip      VARCHAR(255),\n&quot; 
-                &quot;   network_port    VARCHAR(6),\n&quot; 
-                &quot;   sip_username    VARCHAR(255),\n&quot; 
-                &quot;   sip_realm       VARCHAR(255),\n&quot;
-                &quot;   mwi_user        VARCHAR(255),\n&quot;
-                &quot;   mwi_host        VARCHAR(255)\n&quot;
</del><ins>+                &quot;   call_id          VARCHAR(255),\n&quot;
+                &quot;   sip_user         VARCHAR(255),\n&quot;
+                &quot;   sip_host         VARCHAR(255),\n&quot;
+                &quot;   presence_hosts   VARCHAR(255),\n&quot;
+                &quot;   contact          VARCHAR(1024),\n&quot;
+                &quot;   status           VARCHAR(255),\n&quot;
+                &quot;   rpid             VARCHAR(255),\n&quot; 
+                &quot;   expires          INTEGER,\n&quot; 
+                &quot;   user_agent       VARCHAR(255),\n&quot; 
+                &quot;   server_user      VARCHAR(255),\n&quot;
+                &quot;   server_host      VARCHAR(255),\n&quot; 
+                &quot;   profile_name     VARCHAR(255),\n&quot; 
+                &quot;   hostname         VARCHAR(255),\n&quot; 
+                &quot;   network_ip       VARCHAR(255),\n&quot; 
+                &quot;   network_port     VARCHAR(6),\n&quot; 
+                &quot;   sip_username     VARCHAR(255),\n&quot; 
+                &quot;   sip_realm        VARCHAR(255),\n&quot;
+                &quot;   mwi_user         VARCHAR(255),\n&quot;
+                &quot;   mwi_host         VARCHAR(255),\n&quot;
+                &quot;   orig_server_host VARCHAR(255),\n&quot;
+                &quot;   orig_hostname    VARCHAR(255)\n&quot;
</ins><span class="cx">                 &quot;);\n&quot;;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3963,6 +3965,8 @@
</span><span class="cx">                         &quot;create index sr_network_port on sip_registrations (network_port)&quot;,
</span><span class="cx">                         &quot;create index sr_sip_username on sip_registrations (sip_username)&quot;,
</span><span class="cx">                         &quot;create index sr_sip_realm on sip_registrations (sip_realm)&quot;,
</span><ins>+                        &quot;create index sr_orig_server_host on sip_registrations (orig_server_host)&quot;,
+                        &quot;create index sr_orig_hostname on sip_registrations (orig_hostname)&quot;,
</ins><span class="cx">                         &quot;create index ss_call_id on sip_subscriptions (call_id)&quot;,
</span><span class="cx">                         &quot;create index ss_hostname on sip_subscriptions (hostname)&quot;,
</span><span class="cx">                         &quot;create index ss_network_ip on sip_subscriptions (network_ip)&quot;,
</span><span class="lines">@@ -4011,7 +4015,8 @@
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_registrations where (contact like '%%TCP%%' &quot;
</span><span class="cx">                                                                   &quot;or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' &quot;
</span><span class="cx">                                                                   &quot;and network_ip like '%%' and network_port like '%%' and sip_username &quot;
</span><del>-                                                                  &quot;like '%%' and mwi_user  like '%%' and mwi_host like '%%'&quot;, 
</del><ins>+                                                                  &quot;like '%%' and mwi_user  like '%%' and mwi_host like '%%' &quot;
+                                                                  &quot;and orig_server_host like '%%' and orig_hostname like '%%'&quot;, 
</ins><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx"> 
</span><span class="cx">                 if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="lines">@@ -4101,7 +4106,8 @@
</span><span class="cx">                 test_sql = switch_mprintf(&quot;delete from sip_registrations where (contact like '%%TCP%%' &quot;
</span><span class="cx">                                                                   &quot;or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' &quot;
</span><span class="cx">                                                                   &quot;and network_ip like '%%' and network_port like '%%' and sip_username &quot;
</span><del>-                                                                  &quot;like '%%' and mwi_user like '%%' and mwi_host like '%%'&quot;,
</del><ins>+                                                                  &quot;like '%%' and mwi_user like '%%' and mwi_host like '%%'&quot;
+                                                                  &quot;and orig_server_host like '%%' and orig_hostname like '%%'&quot;, 
</ins><span class="cx">                                                                   mod_sofia_globals.hostname);
</span><span class="cx">                 
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, &quot;DROP TABLE sip_registrations&quot;, reg_sql);
</span><span class="lines">@@ -4171,6 +4177,8 @@
</span><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists sr_network_port on sip_registrations (network_port)&quot;, NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists sr_sip_username on sip_registrations (sip_username)&quot;, NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists sr_sip_realm on sip_registrations (sip_realm)&quot;, NULL, NULL, NULL);
</span><ins>+                switch_core_db_exec(db, &quot;create index if not exists sr_orig_server_host on sip_registrations (orig_server_host)&quot;, NULL, NULL, NULL);
+                switch_core_db_exec(db, &quot;create index if not exists sr_orig_hostname on sip_registrations (orig_hostname)&quot;, NULL, NULL, NULL);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                 switch_core_db_exec(db, &quot;create index if not exists ss_call_id on sip_subscriptions (call_id)&quot;, NULL, NULL, NULL);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_regc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (16574 => 16575)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-02-05 02:46:45 UTC (rev 16574)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-02-05 07:05:33 UTC (rev 16575)
</span><span class="lines">@@ -1136,11 +1136,13 @@
</span><span class="cx">                 switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
</span><span class="cx">                 sql = switch_mprintf(&quot;insert into sip_registrations &quot;
</span><span class="cx">                                                          &quot;(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,&quot;
</span><del>-                                                         &quot;user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host) &quot;
-                                                         &quot;values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q')&quot;, 
</del><ins>+                                                         &quot;user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,&quot;
+                                                         &quot;mwi_user,mwi_host, orig_server_host, orig_hostname) &quot;
+                                                         &quot;values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q')&quot;, 
</ins><span class="cx">                                                          call_id, to_user, reg_host, profile-&gt;presence_hosts ? profile-&gt;presence_hosts : reg_host, 
</span><span class="cx">                                                          contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2, 
</span><del>-                                                         agent, from_user, guess_ip4, profile-&gt;name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, mwi_user, mwi_host);
</del><ins>+                                                         agent, from_user, guess_ip4, profile-&gt;name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, 
+                                                         mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname);
</ins><span class="cx">                                                          
</span><span class="cx">                 if (sql) {
</span><span class="cx">                         sofia_glue_execute_sql(profile, &amp;sql, SWITCH_TRUE);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>