PJSIP and call forwarding

I am trying to figure out the PJSIP way how to forward calls from extern A via B to to extern C. I am following Manipulating Party ID Information and created

[cfu-test]        
       exten=>s,1,Noop()
        same =>n,SET(A=${CALLERID(num)})
        same =>n,SET(B=+4961...........)
        same =>n,SET(C=+4915.........)

        same => n,Set(REDIRECTING(orig-num,i)=${A})  
        same => n,Set(REDIRECTING(from-num,i)=${B})
        same => n,Set(REDIRECTING(from-num-pres,i)=allowed)

        same => n,Set(REDIRECTING(to-num,i)=${C})
        same => n,Set(REDIRECTING(to-num-pres,i)=allowed)

        same => n,Set(REDIRECTING(count,i)=$[${REDIRECTING(count)} + 1])
        same => n,Set(REDIRECTING(reason,i)=cfu)

        same => n,Dial(PJSIP/${C}@my-sbc)  
        same => n,Hangup()

[default]
        exten => +4961... ,1,Gosub(cfu-test,s,1( ))

Incoming calls are diverted to C and everything is fine except the outgoing TO: header, which is C, not B. In my understanding, FROM: and TO: should be fixed along the call chain. And my provider wants the diverted INVITE look like this:

A= From, B = To und B = Diversion , C only in request URI

With chan_sip, i could achieve [Edit: To=C was wrong] To=B by replacing Dial with

       same => n,DIAL(SIP/${C}@my-sbc!${B}@my-sbc)

but with PJSIP I found no such syntax. I read about header manipulation using a predial handler, but I wonder if there is a simpler solution using my REDIRECTING parameters.

Best regards

1 Like

Asterisk is intended to work at a higher level and there might be subtle differences in the support of different techs. A simple call to the Transfer() application might solve your problem, provided the channel has not been answered, or you answer, which would have other advantages and disadvantages. If you want to have fine grained control, Kamailio might be the better choice.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.