From d06773e931d0268ff829588bab60263bdc07d204 Mon Sep 17 00:00:00 2001 From: "Michael L. Young" Date: Fri, 4 Jan 2013 21:12:38 +0000 Subject: [PATCH] Fix SIP Notify Messages To Have The Proper IP Address In The FROM Field On a multihomed server when sending a NOTIFY message, we were not figuring out which network should be used to contact the peer. This patch fixes the problem by calling ast_sip_ouraddrfor() and then build_via() so that our NOTIFY message contains the correct IP address. Also, a debug message is being added to help follow the call-id changes that occur. This was helpful for confirming that the IP address was set properly since the call-id contains the IP address. It also will be helpful for troubleshooting purposes when following a call in the debug logs. (closes issue ASTERISK-20805) Reported by: Bryan Hunt Tested by: Bryan Hunt, Michael L. Young Patches: asterisk-20805-notify-ip-v2.diff uploaded by Michael L. Young (license 5026) Review: https://reviewboard.asterisk.org/r/2255/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@378554 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 4687f87b99..b11817ce4b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -7997,6 +7997,7 @@ static void build_callid_pvt(struct sip_pvt *pvt) static void change_callid_pvt(struct sip_pvt *pvt, const char *callid) { int in_dialog_container; + char *oldid = ast_strdupa(pvt->callid); ao2_lock(dialogs); in_dialog_container = CONTAINER_UNLINK(dialogs, pvt, @@ -8010,6 +8011,10 @@ static void change_callid_pvt(struct sip_pvt *pvt, const char *callid) ao2_t_link(dialogs, pvt, "New dialog callid -- inserted back into table"); } ao2_unlock(dialogs); + + if (strcmp(oldid, pvt->callid)) { + ast_debug(1, "SIP call-id changed from '%s' to '%s'\n", oldid, pvt->callid); + } } /*! \brief Build SIP Call-ID value for a REGISTER transaction */ @@ -19616,7 +19621,12 @@ static char *sip_cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_arg } } - /* Recalculate our side, and recalculate Call ID */ + /* Now that we have the peer's address, set our ip and change callid */ + ast_sip_ouraddrfor(&p->sa, &p->ourip, p); + build_via(p); + + change_callid_pvt(p, NULL); + ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n", a->argv[2], a->argv[i]); sip_scheddestroy(p, SIP_TRANS_TIMEOUT); transmit_invite(p, SIP_NOTIFY, 0, 2, NULL); -- 2.47.3