<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.14.3">
</HEAD>
<BODY>
On Tue, 2007-12-18 at 08:40 +0100, Olle E Johansson wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">18 dec 2007 kl. 06.50 skrev SVN commits to the Digium repositories:</FONT>
<FONT COLOR="#000000">> Author: murf</FONT>
<FONT COLOR="#000000">> Date: Mon Dec 17 23:50:15 2007</FONT>
<FONT COLOR="#000000">> New Revision: 93535</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> URL: <A HREF="http://svn.digium.com/view/asterisk?view=rev&rev=93535">http://svn.digium.com/view/asterisk?view=rev&rev=93535</A></FONT>
<FONT COLOR="#000000">> Log:</FONT>
<FONT COLOR="#000000">> Good. the dialog callids change, hadn't known that. Now I do. Unlink </FONT>
<FONT COLOR="#000000">> and relink in the hash table under new name. Sip works better now.</FONT>
<FONT COLOR="#000000">No, they don't.</FONT>
<FONT COLOR="#000000">You've ropably discovered a bug. When, exactly does this happen? Do </FONT>
<FONT COLOR="#000000">you have a call trace (sip debug) from Asterisk so we</FONT>
<FONT COLOR="#000000">can fix it ... ???</FONT>
<FONT COLOR="#000000">Guess we need to find each other on IRC :-)</FONT>
<FONT COLOR="#000000">/O</FONT>
</PRE>
</BLOCKQUOTE>
<BR>
It looks pretty purposeful to me. Albeit, I realize that some of these freshly create a new dialog, and then set the name; this still qualifies as a name change (to me)-- although it might not to you. Here's my enumeration of the places:<BR>
<BR>
In create_addr_from_peer() :<BR>
<BR>
        if (!ast_strlen_zero(peer->fromdomain)) {<BR>
                ast_string_field_set(dialog, fromdomain, peer->fromdomain);<BR>
                if (!dialog->initreq.headers) {<BR>
                        char *c;<BR>
                        char *tmpcall = ast_strdupa(dialog->callid);<BR>
                        /* this sure looks to me like we are going to change the callid on this dialog!! */<BR>
                        c = strchr(tmpcall, '@');<BR>
                        if (c) {<BR>
                                *c = '\0';<BR>
                                ao2_unlink(dialogs,dialog,"About to change the callid -- remove the old name");<BR>
                                <FONT COLOR="#ff0000">ast_string_field_build(dialog, callid, "%s@%s", tmpcall, peer->fromdomain);</FONT><BR>
                                ao2_link(dialogs,dialog,"New dialog callid -- inserted back into table");<BR>
                                ast_log(LOG_NOTICE,"=========Changed Dialog name to %s\n", dialog->callid);<BR>
                        }<BR>
                }<BR>
        }<BR>
Note: see the ast_string_field_build() call above?<BR>
<BR>
Note2: I'm showing "fixed" code, so in the original, there's no ao2_unlink, ao2_link calls (of course, since in the original,<BR>
astobj2 isn't being used!)<BR>
<BR>
<BR>
In sip_notify() :<BR>
<BR>
                /* Recalculate our side, and recalculate Call ID */<BR>
                ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);<BR>
                build_via(p);<BR>
                ast_log(LOG_NOTICE,"============About to build callid for %s\n", p->callid);<BR>
                ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");<BR>
                <FONT COLOR="#ff0000">build_callid_pvt(p);</FONT><BR>
                ao2_link(dialogs,p,"Linking in new name");<BR>
                ast_log(LOG_NOTICE,"================New callid: %s\n", p->callid);<BR>
                ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n", a->argv[2], a->argv[i]);<BR>
                dialog_ref(p,"bump the count of p, which transmit_sip_request will decrement.");<BR>
                transmit_sip_request(p, &req);<BR>
                sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);<BR>
                dialog_unref(p,"unref pvt at end of for loop in sip_notify");<BR>
<BR>
Note: see the call to build_callid_pvt() above...<BR>
<BR>
<BR>
<BR>
In sip_send_mwi_to_peer():<BR>
<BR>
        if (peer->mwipvt) {<BR>
                ...<BR>
        } else {<BR>
                /* Build temporary dialog for this message */<BR>
                if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY))) <BR>
                        return -1;<BR>
                if (create_addr_from_peer(p, peer)) {<BR>
...<BR>
                        return 0;<BR>
                }<BR>
                /* Recalculate our side, and recalculate Call ID */<BR>
                ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);<BR>
                ast_log(LOG_NOTICE,"=======================About to build callid for %s\n", p->callid);<BR>
                build_via(p);<BR>
                ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");<BR>
                <FONT COLOR="#ff0000">build_callid_pvt(p);</FONT><BR>
                ao2_link(dialogs,p,"Linking in under new name");<BR>
                ast_log(LOG_NOTICE,"====================New callid: %s\n", p->callid);<BR>
                /* Destroy this session after 32 secs */<BR>
                sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);<BR>
        }<BR>
<BR>
Note: this one is pretty active, as it generates a new dialog, which sets up a name, and then create_addr_from_peer might modify it, and then we do a build_callid_pvt to finish up the process!<BR>
<BR>
<BR>
sip_poke_peer():<BR>
        if (!(p = sip_alloc(NULL, NULL, 0, SIP_OPTIONS)))<BR>
                return -1;<BR>
        peer->call = dialog_ref(p,"copy sip alloc from p to peer->call");<BR>
        ...<BR>
<BR>
        /* Recalculate our side, and recalculate Call ID */<BR>
        ast_log(LOG_NOTICE,"===============About to build callid for %s\n", p->callid);<BR>
        ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);<BR>
        build_via(p);<BR>
        ao2_unlink(dialogs,p,"About to change the callid -- remove the old name");<BR>
        <FONT COLOR="#ff0000">build_callid_pvt(p);</FONT><BR>
        ao2_link(dialogs,p,"Linking in under new name");<BR>
        ast_log(LOG_NOTICE,"==============New callid: %s\n", p->callid);<BR>
<BR>
Note: again, this routine generates a new dialog via sip_alloc, which sets the dialog name, and then modifies it...<BR>
which in some places might not be classified as a name change, really, but **I** have consider it such.<BR>
<BR>
sip_alloc() is called in find_call(), transmit_register(), <FONT COLOR="#ff0000">sip_notify</FONT>(), <FONT COLOR="#ff0000">sip_send_mwi_to_peer</FONT>(), <FONT COLOR="#ff0000">sip_poke_peer</FONT>(), and sip_request_call(), (The names in red are mentioned above). So, the routines above are not the only ones to allocate a dialog, and not all functions that allocate a dialog reset the name.<BR>
<BR>
murf<BR>
<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
--
Steve Murphy
Software Developer
Digium
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>