Skip to main content

Routing with directory parameters

Click here to expand Table of Contents

All the text below was last edited in 2008, it is therefore likely out-of-date, inaccurate and in dire need of a refresh

Problem: You need to apply a different set of routing rules to a set of endpoints‚Äč

Solution: Add a <variables> section to the directory entries. These parameters will be passed into the dialplan, and can be tested against just like other variables.

Note: You must force per-call authentication in your sofia.xml.conf for <variables> to be passed through to the dialplan.

directory.xml:

<domain name="$${domain}">
<user id="phone1">
<params>
<param name="password" value="password1" />
</params>
<variables>
<variable name="ruleset" value="internal" />
<variable name="arbitrary" value="whatever" />
</variables>
</user>
<user id="NoName2">
<params>
<param name="password" value="33451" />
</params>
<variables>
<variable name="ruleset" value="courtesy" />
</variables>
</user>
</domain>

default_context.xml:

<context name="default">

<extension name="internal_phones">
<condition field="${ruleset}" value="internal" />
<condition field="destination_number" expression="^(1?\d{10})"> <!-- LD and Local calls allowed -->
<action application="bridge" data="sofia/gateway/[gateway_name]/$1" />
</condition>
</extension>

<extension name="internal_phones">
<condition field="${ruleset}" value="courtesy" />
<condition field="destination_number" expression="^(\d{10})"> <!-- NO LD calls for you! -->
<action application="bridge" data="sofia/gateway/[gateway_name]/$1" />
</condition>
</extension>

</context>