Discussion:
[asterisk-dev] [Code Review] Add EXPORT dialplan function: set variable on another channel
t***@gmail.com
2010-06-23 23:06:06 UTC
Permalink
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/742/
-----------------------------------------------------------

Review request for Asterisk Developers.


Summary
-------

Adds a dialplan function named EXPORT that lets you set channel variables on other channels. It is based on IMPORT. Originally it was ExportVar based on ImportVar, but while porting to 1.8 I noticed ImportVar was depreciated.

You can set either a simple variable or a function.
Example dialplan that sets a function (you would 'console dial ***@test-local'):

[test]
exten => _X.,1,NoOp()
exten => _X.,n,Set(EXPORT(${TEST},CDR(userfield))=blah)
exten => _X.,n,Dial(SIP/sometrunk/${EXTEN})

[test-local]
exten => _X.,1,NoOp()
exten => _X.,n,Set(__TEST=${CHANNEL})
exten => _X.,n,Dial(Local/${EXTEN}@test/n)


Diffs
-----

http://svn.asterisk.org/svn/asterisk/trunk/funcs/func_logic.c 272331

Diff: https://reviewboard.asterisk.org/r/742/diff


Testing
-------

I tested it by dialing on the console, using variations of the simple dialplan above, testing setting both variables and functions, and using 'core show channel' to verify everything was set correctly.


Thanks,

tim_ringenbach
Tilghman Lesher
2010-06-24 06:45:31 UTC
Permalink
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/742/#review2262
-----------------------------------------------------------


We intentionally refused the ExportVar/EXPORT() dialplan function, because altering an execution environment of another channel could occur at very weird times, causing dialplan bugs that are very difficult to diagnose. As a compromise, we created the SHARED() dialplan function that allows a user to set a variable on another channel ONLY in a "special space" that the channel then has to access in order to retrieve. This avoids the problem of altering dialplan variables while logic is running within a channel.

- Tilghman
Post by t***@gmail.com
-----------------------------------------------------------
https://reviewboard.asterisk.org/r/742/
-----------------------------------------------------------
(Updated 2010-06-23 18:06:06)
Review request for Asterisk Developers.
Summary
-------
Adds a dialplan function named EXPORT that lets you set channel variables on other channels. It is based on IMPORT. Originally it was ExportVar based on ImportVar, but while porting to 1.8 I noticed ImportVar was depreciated.
You can set either a simple variable or a function.
[test]
exten => _X.,1,NoOp()
exten => _X.,n,Set(EXPORT(${TEST},CDR(userfield))=blah)
exten => _X.,n,Dial(SIP/sometrunk/${EXTEN})
[test-local]
exten => _X.,1,NoOp()
exten => _X.,n,Set(__TEST=${CHANNEL})
Diffs
-----
http://svn.asterisk.org/svn/asterisk/trunk/funcs/func_logic.c 272331
Diff: https://reviewboard.asterisk.org/r/742/diff
Testing
-------
I tested it by dialing on the console, using variations of the simple dialplan above, testing setting both variables and functions, and using 'core show channel' to verify everything was set correctly.
Thanks,
tim_ringenbach
Tilghman Lesher
2010-06-24 15:06:54 UTC
Permalink
Post by t***@gmail.com
Post by Tilghman Lesher
We intentionally refused the ExportVar/EXPORT() dialplan function, because altering an execution environment of another channel could occur at very weird times, causing dialplan bugs that are very difficult to diagnose. As a compromise, we created the SHARED() dialplan function that allows a user to set a variable on another channel ONLY in a "special space" that the channel then has to access in order to retrieve. This avoids the problem of altering dialplan variables while logic is running within a channel.
Additionally, for the direction in your example, we have MASTER_CHANNEL(), for accessing variables in the first channel of a series.


- Tilghman


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/742/#review2262
-----------------------------------------------------------
Post by t***@gmail.com
-----------------------------------------------------------
https://reviewboard.asterisk.org/r/742/
-----------------------------------------------------------
(Updated 2010-06-23 18:06:06)
Review request for Asterisk Developers.
Summary
-------
Adds a dialplan function named EXPORT that lets you set channel variables on other channels. It is based on IMPORT. Originally it was ExportVar based on ImportVar, but while porting to 1.8 I noticed ImportVar was depreciated.
You can set either a simple variable or a function.
[test]
exten => _X.,1,NoOp()
exten => _X.,n,Set(EXPORT(${TEST},CDR(userfield))=blah)
exten => _X.,n,Dial(SIP/sometrunk/${EXTEN})
[test-local]
exten => _X.,1,NoOp()
exten => _X.,n,Set(__TEST=${CHANNEL})
Diffs
-----
http://svn.asterisk.org/svn/asterisk/trunk/funcs/func_logic.c 272331
Diff: https://reviewboard.asterisk.org/r/742/diff
Testing
-------
I tested it by dialing on the console, using variations of the simple dialplan above, testing setting both variables and functions, and using 'core show channel' to verify everything was set correctly.
Thanks,
tim_ringenbach
t***@gmail.com
2010-06-24 15:34:22 UTC
Permalink
Post by Tilghman Lesher
Post by Tilghman Lesher
We intentionally refused the ExportVar/EXPORT() dialplan function, because altering an execution environment of another channel could occur at very weird times, causing dialplan bugs that are very difficult to diagnose. As a compromise, we created the SHARED() dialplan function that allows a user to set a variable on another channel ONLY in a "special space" that the channel then has to access in order to retrieve. This avoids the problem of altering dialplan variables while logic is running within a channel.
Additionally, for the direction in your example, we have MASTER_CHANNEL(), for accessing variables in the first channel of a series.
Alright then, SHARED() will do what I wanted EXPORT() for anyway.

Perhaps MASTER_CHANNEL(), and the manager's SetVar should carry the same warning as SHARED?


- tim_ringenbach


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/742/#review2262
-----------------------------------------------------------
Post by Tilghman Lesher
-----------------------------------------------------------
https://reviewboard.asterisk.org/r/742/
-----------------------------------------------------------
(Updated 2010-06-23 18:06:06)
Review request for Asterisk Developers.
Summary
-------
Adds a dialplan function named EXPORT that lets you set channel variables on other channels. It is based on IMPORT. Originally it was ExportVar based on ImportVar, but while porting to 1.8 I noticed ImportVar was depreciated.
You can set either a simple variable or a function.
[test]
exten => _X.,1,NoOp()
exten => _X.,n,Set(EXPORT(${TEST},CDR(userfield))=blah)
exten => _X.,n,Dial(SIP/sometrunk/${EXTEN})
[test-local]
exten => _X.,1,NoOp()
exten => _X.,n,Set(__TEST=${CHANNEL})
Diffs
-----
http://svn.asterisk.org/svn/asterisk/trunk/funcs/func_logic.c 272331
Diff: https://reviewboard.asterisk.org/r/742/diff
Testing
-------
I tested it by dialing on the console, using variations of the simple dialplan above, testing setting both variables and functions, and using 'core show channel' to verify everything was set correctly.
Thanks,
tim_ringenbach
Loading...