From aafa57cf4b2aef5a3961e10f86dbec3069c84c4d Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichelson@digium.com>
Date: Fri, 10 Jul 2009 15:56:45 +0000
Subject: [PATCH] Merged revisions 205775 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r205775 | mmichelson | 2009-07-10 10:51:36 -0500 (Fri, 10 Jul 2009) | 10 lines

  Ensure that outbound NOTIFY requests are properly routed through stateful proxies.

  With this change, we make note of Record-Route headers present in any SUBSCRIBE
  request that we receive so that our outbound NOTIFY requests will have the proper
  Route headers in them.

  (closes issue #14725)
  Reported by: ibc
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@205776 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_sip.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 6d6078efd9..ed12bf282d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -10592,8 +10592,11 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
 
 	add_header(req, "Via", p->via);
 	add_header(req, "Max-Forwards", DEFAULT_MAX_FORWARDS);
-	/* SLD: FIXME?: do Route: here too?  I think not cos this is the first request.
-	 * OTOH, then we won't have anything in p->route anyway */
+	/* This will be a no-op most of the time. However, under certain circumstances,
+	 * NOTIFY messages will use this function for preparing the request and should
+	 * have Route headers present.
+	 */
+	add_route(req, p->route);
 
 	add_header(req, "From", from);
 	add_header(req, "To", to);
@@ -21585,6 +21588,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
 		if (sipdebug)
 			ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
 		check_via(p, req);
+		build_route(p, req, 0);
 	} else if (req->debug && req->ignore)
 		ast_verbose("Ignoring this SUBSCRIBE request\n");
 
-- 
GitLab