With chan_sip there is the variable SIP_MAX_FORWARDS to set Max-Forwards. This counter is persistant after a redirect. I can't find the equivalent for PJSIP, so I went the way of header manipulation. Only to find out that any headers added to the outbound leg are lost after a redirect (with redirect_method=uri_core (didn't try any other since in the past they didn't work for me)).
Am I missing something? Or is this a PJSIP feature? chan_sip example: [macro-maxforwards] exten => s,1,NoOp() exten => s,n,Set(mf=${SIP_HEADER(Max-Forwards)}) exten => s,n,Set(mf=$[ ${mf} - 1 ]) exten => s,n,ExecIf($[ ${mf} < 1 ]?Hangup(19)) exten => s,n,Set(__SIP_MAX_FORWARDS=${mf}) exten => s,n,SipAddHeader(X-Foo: bar) exten => s,n,MacroExit() [route] ... exten => _+.,n,Macro(maxforwards) exten => _+.,n,Dial(SIP/${EXTEN}@redirector) An incomig INVITE will look like: > INVITE sip:+number@asterisk;user=phone SIP/2.0 > Max-Forwards: 70 To the redirector: > INVITE sip:+number@asterisk;user=phone SIP/2.0 > Max-Forwards: 69 > X-Foo: bar < SIP/2.0 302 Redirect < Contact: <sip:+number@somewhereelse:5060;transport=udp> To somewhereelse: > INVITE sip:+number@somewhereelse;user=phone SIP/2.0 > Max-Forwards: 69 > X-Foo: bar PJSIP example (where the add strangely overrides the default Max-Forwards: 70). [setoutgoinglegvars] exten => add,1,Set(PJSIP_HEADER(add,Max-Forwards)=60) exten => add,1,Set(PJSIP_HEADER(add,X-Foo)=bar) exten => add,n,Return() [route] ... exten => _+.,n,Macro(maxforwards) exten => _+.,n,Dial(PJSIP/${EXTEN}@redirector,,b(setoutgoinglegvars,add,1)) > INVITE sip:+number@asterisk;user=phone SIP/2.0 > Max-Forwards: 70 To the redirector: > INVITE sip:+number@asterisk;user=phone SIP/2.0 > Max-Forwards: 60 > X-Foo: bar < SIP/2.0 302 Redirect < Contact: <sip:+number@somewhereelse:5060;transport=udp> To somewhereelse: > INVITE sip:+number@somewhereelse;user=phone SIP/2.0 > Max-Forwards: 70
signature.asc
Description: PGP signature
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- Check out the new Asterisk community forum at: https://community.asterisk.org/ New to Asterisk? Start here: https://wiki.asterisk.org/wiki/display/AST/Getting+Started asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users