I have to send a custom SIP response code (compliant to RFC3261) to the calling party on a specific condition (defined by a value of a dialplan variable). Do you know if there is any way to achieve it with dialplan functions?
For instance, something like this:
exten => s,n,Set(ResponseCode=<VALUE>)
If this is supported, could you provide the correct syntax?
Thank you.
You can only send the response codes that correspond to defined values of ${HANGUPCAUSE}. That value will be translated to the actual SIP response used.
Put the literal value of the desired hangup cause in the Hangup call. Note that the value is the ISDN cause code that corresponds to the SIP response, not the actual SIP response.
(Hangup() is equivalent to Hangup(${HANGUPCAUSE}), but I’m not sure that you can set that “variable”.
The HANGUPCAUSE dialplan variable is special, it gets the data from the channel when asked. While you may be able to set the variable it won’t do anything and can’t be retrieved afterwards.
@jcolp
So, what’s the conclusion? Is it possible to send a custom response code, not referring to HANGUPCAUSE variable?
For instance: exten => s,n,HangUp(<Q931 code>)
Yes, as @david551 mentioned you can specify an ISDN cause code there as a custom one and it will get translated into a SIP response code. You can’t specify a SIP one there. There is also a mapping[1] on the wiki for the translation. Oh, and the dialplan application is documented to work like this on there too[2].