[asterisk-bugs] [JIRA] (ASTERISK-25803) chan_sip: Optionally supply fromuser/fromdomain in SIP dial string
Walter Doekes (JIRA)
noreply at issues.asterisk.org
Fri Feb 19 03:56:57 CST 2016
Walter Doekes created ASTERISK-25803:
----------------------------------------
Summary: chan_sip: Optionally supply fromuser/fromdomain in SIP dial string
Key: ASTERISK-25803
URL: https://issues.asterisk.org/jira/browse/ASTERISK-25803
Project: Asterisk
Issue Type: New Feature
Security Level: None
Components: Channels/chan_sip/Interoperability
Reporter: Walter Doekes
Severity: Minor
Hidden deep inside chan_sip.c, there is a feature that allows you to specify the To-URI at Dial time:
{noformat}
* SIP Dial string syntax:
* SIP/devicename
* or SIP/username at domain (SIP uri)
...
* and there is an optional [!dnid] argument you can append to alter the
* To: header.
{noformat}
For example:
{noformat}
Dial(SIP/mydevice!touser at todomain.com)
{noformat}
will cause a SIP invite with {{To: <sip:touser at todomain.com>}} to be sent out.
*I suggest we add the possibility to also supply the From-URI through the Dial string, like this*:
{noformat}
* and there is an optional [!dnid] argument you can append to alter the
- * To: header.
+ * To: header. And after that, a [![fromuser][@fromdomain]] argument.
+ * Leave those blank to use the defaults.
{noformat}
For example:
{noformat}
Dial(SIP/mydevice!touser at todomain.com!fromuser at fromdomain.com)
{noformat}
causing a SIP invite with {{To: <sip:touser at todomain.com>}} and {{From: <sip:fromuser at fromdomain.com>}} to get sent.
*Why*? Because I need it. I don't think there is any way to specify the From-URI through the dialplan at this moment.
*Why here*? Because it fits there nicely along with the {{!dnid}} setting that has existed there.
All of the above settings after the first {{!}} are optional, except for: the todomain, but that was already the case before the suggested patch.
*Changes*: the patch changes that an exclamation mark in the To-URI -- if anyone uses that -- would not work anymore, since it's now a delimiter.
----
*Tests*: apart from using the feature, I also ran the following tests with {{channel originate}}.
{noformat}
for x in touser.txt touser-todomain.txt fromuser.txt fromuser-fromdomain.txt fromdomain.txt all.txt
do printf '*%s*\n{%s}\n' $x noformat; diff none.txt $x | grep '^[<>]'
printf '{%s}\n\n' noformat; done
{noformat}
*touser.txt*
{noformat}
< *CLI> channel originate SIP/1.2.3.4 application noop
> *CLI> channel originate SIP/1.2.3.4!touser application noop
< To: <sip:1.2.3.4>
> To: <sip:touser at 1.2.3.4>
{noformat}
*touser-todomain.txt*
{noformat}
< *CLI> channel originate SIP/1.2.3.4 application noop
> *CLI> channel originate SIP/1.2.3.4!touser at todomain application noop
< To: <sip:1.2.3.4>
> To: <sip:touser at todomain>
{noformat}
*fromuser.txt*
{noformat}
< *CLI> channel originate SIP/1.2.3.4 application noop
> *CLI> channel originate SIP/1.2.3.4!!fromuser application noop
< From: "Anonymous" <sip:anonymous at anonymous.invalid>;tag=TAG
> From: "Anonymous" <sip:fromuser at anonymous.invalid>;tag=TAG
< Contact: <sip:anonymous at 192.168.1.12:5060>
> Contact: <sip:fromuser at 192.168.1.12:5060>
{noformat}
*fromuser-fromdomain.txt*
{noformat}
< *CLI> channel originate SIP/1.2.3.4 application noop
> *CLI> channel originate SIP/1.2.3.4!!fromuser at fromdomain application noop
< From: "Anonymous" <sip:anonymous at anonymous.invalid>;tag=TAG
> From: "Anonymous" <sip:fromuser at fromdomain>;tag=TAG
< Contact: <sip:anonymous at 192.168.1.12:5060>
< Call-ID: RANDOM at 192.168.1.12:5060
> Contact: <sip:fromuser at 192.168.1.12:5060>
> Call-ID: RANDOM at fromdomain
{noformat}
*fromdomain.txt*
{noformat}
< *CLI> channel originate SIP/1.2.3.4 application noop
> *CLI> channel originate SIP/1.2.3.4!!@fromdomain application noop
< From: "Anonymous" <sip:anonymous at anonymous.invalid>;tag=TAG
> From: "Anonymous" <sip:anonymous at fromdomain>;tag=TAG
< Call-ID: RANDOM at 192.168.1.12:5060
> Call-ID: RANDOM at fromdomain
{noformat}
*all.txt*
{noformat}
< *CLI> channel originate SIP/1.2.3.4 application noop
> *CLI> channel originate SIP/1.2.3.4!touser at todomain!fromuser at fromdomain application noop
< From: "Anonymous" <sip:anonymous at anonymous.invalid>;tag=TAG
< To: <sip:1.2.3.4>
< Contact: <sip:anonymous at 192.168.1.12:5060>
< Call-ID: RANDOM at 192.168.1.12:5060
> From: "Anonymous" <sip:fromuser at fromdomain>;tag=TAG
> To: <sip:touser at todomain>
> Contact: <sip:fromuser at 192.168.1.12:5060>
> Call-ID: RANDOM at fromdomain
{noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list