Understanding dialplan parameters

What is the difference between EXTEN_ and $(EXTEN)?

If I have a dialplan with a line that looks like this: Set(EXTEN_=${EXTEN}) what is happening here and what is the difference between the two EXTENS. I realize $(EXTEN) is a variable that I think is filled in earlier in the dialplan.

But I do not understand how there can be EXTEN as a variable and then EXTEN_.

Thanks for any input.

As far as I know, EXTEN cannot be set, as it isn’t a real shell variable, but rather a (read-only) function that reads the value of a property of the channel data structure. To set EXTEN, you have to use Goto.

I don’t believe VARIABLE_ is valid syntax.

In “Set(VARIABLE=${VARIABLE})”, the first occurrence of VARIABLE is the name of the destination (left value). The ${...} operator takes the current value (right value) of the variable.

In “Set(_VARIABLE...” and “Set(__VARIABLE...”, the underscores are operators that set attributes of the variable which cause that variable to be set in any channel created directly from the current channel, or in all channels created, directly or indirectly, from the current channel.

EXTEN_ with the trailing underscore is a valid variable name, just confirmed with Asterisk 18

-- Executing [100@from-internal:1] Set("PJSIP/6006-00000002", "EXTEN_=100") in new stack
-- Executing [100@from-internal:2] NoOp("PJSIP/6006-00000002", "Value of EXTEN_ is 100") in new stack

So the dialplan is just preserving the value of ${EXTEN} with the channel variable named EXTEN_. Presumably EXTEN_ is referenced later in the call flow.

If you have to ask, this implies you are not the original author, and the OA should have chosen a more meaningful name like INITIAL-EXTEN or PRODUCT-FAMILY or …

A search through the dialplan should yield clues as to it’s use. Fortunately, it will be easy to search for. Imagine if the OA had named it E. :slight_smile:

Maybe a little refactoring is in order?

EXTEN_ is variable , you can set it to anything you want , example EXTEN_=1, EXTEN=2

${EXTEN} is equal to extension in dialplan command, example: exten => 1000,1,NoOP(${EXTEN}) , you will get 1000

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.