Skip to content

Instantly share code, notes, and snippets.

@ctaloi
Last active November 14, 2016 18:05
Show Gist options
  • Save ctaloi/5861727 to your computer and use it in GitHub Desktop.
Save ctaloi/5861727 to your computer and use it in GitHub Desktop.
Asterisk - Pass SIP Diversion if exists on the way in
exten => s,1,Set(TG_FULLNAME=${ARG2})
exten => s,n,Set(TRUNK=${CUT(TG_FULLNAME,/,2)})
exten => s,n,Set(ORIG_ANI=${CALLERID(rdnis)})
exten => s,n,Set(SIP_DOMAIN=${SIPDOMAIN})
exten => s,n,Set(ROUTE_STRIP=${ARG1})
exten => s,n,Set(DIALED=${DIALED_NUMBER:${ROUTE_STRIP}}
exten => s,n,GotoIf($[${LEN(${ORIG_ANI})} > 0]?100:101)
exten => s,100,SIPAddHeader(Diversion: <sip:${CALLERID(rdnis)}@${SIP_DOMAIN}>\;Reason=unconditional)
exten => s,101,Dial(SIP/${DIALED}@${TRUNK},,tT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment