From: Anthony Minessale Date: Thu, 17 Nov 2011 22:21:43 +0000 (-0600) Subject: FS-3686 sigh X-Git-Tag: v1.2-rc1~27^2~162 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1bf80f050924f21c0eec1ec83d7fd130215c4532;p=thirdparty%2Ffreeswitch.git FS-3686 sigh --- diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 2fb1aa3fdf..a7539a7311 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -196,13 +196,34 @@ static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip, SWITCH_STANDARD_STREAM(stream); - for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) { - char *rr = sip_header_as_string(nh->nh_home, (void *) rrp); + if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { + char *tmp[128] = { 0 }; + int y = 0; - stream.write_function(&stream, x == 0 ? "%s" : ",%s", rr); - su_free(nh->nh_home, rr); + for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) { + char *rr = sip_header_as_string(nh->nh_home, (void *) rrp); + tmp[y++] = rr; + if (y == 127) break; + } - x++; + y--; + + while(y >= 0) { + stream.write_function(&stream, x == 0 ? "%s" : ",%s", tmp[y]); + su_free(nh->nh_home, tmp[y]); + y--; + x++; + } + + } else { + for(rrp = sip->sip_record_route; rrp; rrp = rrp->r_next) { + char *rr = sip_header_as_string(nh->nh_home, (void *) rrp); + + stream.write_function(&stream, x == 0 ? "%s" : ",%s", rr); + su_free(nh->nh_home, rr); + + x++; + } } switch_channel_set_variable(channel, "sip_invite_record_route", (char *)stream.data);