How to manage Diversion Header

Hi everyone,

I’m working on SIP headers with Asterisk 14 and i just would to know if Diversion header in INVITE is automatically generated when you transfer a call or if you have to add it in the dialplan with a SIPAddHeader function.

For now i use this:

exten => s,n,SIPAddHeader(Diversion: sip:${ARG1}\;reason=unconditional\;screen=no\;privacy=off\;counter=1)

In the case of multiple transfers, i guess i need to increment my counter ?

Thanks a lot for your help,

I believe you want to use the REDIRECTING dialplan function

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_REDIRECTING

 same => n,Set(REDIRECTING(to-num,i)=${CALLERID(dnid)})
 same => n,Set(REDIRECTING(to-num-pres)=allowed)
 same => n,Set(REDIRECTING(from-num,i)=${NUMBER})
 same => n,Set(REDIRECTING(from-num-pres,i)=allowed)
 same => n,Set(REDIRECTING(to-num,i)=${EXTEN})
 same => n,Set(REDIRECTING(count,i)=$[${REDIRECTING(count)} + 1])
 same => n,Set(REDIRECTING(reason,i)=${REDIRECTING(reason)})
2 Likes

Thank’s a lot for your help, it’s what i’m looking for.