From dd1275912720f7caaa4053ccbe0f8b42028440c8 Mon Sep 17 00:00:00 2001 From: Olle Johansson Date: Mon, 19 Sep 2011 13:38:53 +0000 Subject: [PATCH] Merged revisions 336501 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ........ r336501 | oej | 2011-09-19 15:33:50 +0200 (Mån, 19 Sep 2011) | 5 lines Add diversion header to a 302 redirect response if we have diversion data (closes issue ASTERISK-18143) patch by oej ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@336502 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- Makefile | 2 +- channels/chan_sip.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a653bcf0a7..96a85de34c 100644 --- a/Makefile +++ b/Makefile @@ -286,7 +286,7 @@ MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree) ifneq ($(findstring darwin,$(OSARCH)),) _ASTCFLAGS+=-D__Darwin__ SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace - ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6) + ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.7) SOLINK+=/usr/lib/bundle1.o endif _ASTLDFLAGS+=-L/usr/local/lib diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 6474d2dceb..312f1dac60 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1339,6 +1339,7 @@ static struct sip_auth *find_realm_authentication(struct sip_auth_container *cre /*--- Misc functions */ static void check_rtp_timeout(struct sip_pvt *dialog, time_t t); static int reload_config(enum channelreloadreason reason); +static void add_diversion_header(struct sip_request *req, struct sip_pvt *pvt); static int expire_register(const void *data); static void *do_monitor(void *data); static int restart_monitor(void); @@ -10363,6 +10364,11 @@ static int __transmit_response(struct sip_pvt *p, const char *msg, const struct add_cc_call_info_to_response(p, &resp); } + /* If we are sending a 302 Redirect we can add a diversion header if the redirect information is set */ + if (!strncmp(msg, "302", 3)) { + add_diversion_header(&resp, p); + } + /* If we are cancelling an incoming invite for some reason, add information about the reason why we are doing this in clear text */ if (p->method == SIP_INVITE && msg[0] != '1') {