Is there any way in Asterisk to get a list of channel variables?
The reason I ask is that there a few scenarios where I need to split the call and I need to retain all the channel variables on the caller side of the call. And by split, I mean an entirely new call that is created through a call file. Here’s an example:
[regeneratecall] ; ARG1 = local channel, ARG2 = context, ARG3 = in/out, ARG4 = called #
exten => s,1,System(echo Channel: Local/{ARG1} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Context: {ARG2} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Extension: {callednumber} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Priority: 1 >> /tmp/{UNIQUEID}.call)
same => n,System(echo CallerID: "{CALLERID(name)} <{CALLERID(num)}>" >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: calldirection={ARG3} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: __channel={channel} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: __clidverif={clidverif} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: pres={CALLERID(pres)} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: __autovonprioritydigit={autovonprioritydigit} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: __forcesecurechannel={forcesecurechannel} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: __dtlocation={dtlocation} >> /tmp/{UNIQUEID}.call)
same => n,System(echo Setvar: __isup-oli={isup-oli} >> /tmp/{UNIQUEID}.call)
same => n,System(mv /tmp/{UNIQUEID}.call /var/spool/asterisk/outgoing/)
same => n,Return({CUT(ARG1,@,1)})
(Some of the stuff above didn’t paste right. There really are $ signs before the { for variables, the editor ate it up.)
This works good for some use cases of mine where the # of variables is relatively small.
I’m now in a different use case where I have a much larger # of channel variables. Is there any way to get an array of channel variables so I can do this dynamically, rather than hardcoding them into a subroutine? I simply want all current channel variables to get written into the call file, so that when the call is split, all existing channel variables are automatically in the new call, which would be much more flexible.
My first thought was ${CHANNEL}, but that’s actually just another channel variable, so I’m a bit stumped on where/how I could access these. Does Asterisk provide this kind of access to memory? I’d need the variable names and values.
Any thoughts or ideas appreciated! If it’s not possible, I’ll simply hardcode again, but potentially that might become large and unwieldy.