System information

We could also advertise a full or partial range of extensions using pattern matches:
[RegisteredDevices]
exten => _1[1-3]XX,1,NoOp() ; extensions 1100->1399
exten => _1[7-9]XX,1,NoOp() ; extensions 1700->1999
Pattern matches are a good way of adding ranges of numbers, but these are still static.
In the next section we’ll explore how we can add some fluidity to the
RegisteredDevices context.
Dynamically adding extension numbers
In some cases, you might want to only advertise extensions at your location that are
currently registered to the system. Perhaps we have a salesperson who flies between the
Toronto and Vancouver offices, and plugs her laptop into the network and registers at
whichever location she is currently at. In that case, we would want to make sure that
calls to that person are routed to the appropriate office in order to avoid sending calls
across the country unnecessarily.
The regcontext and regexten options in iax.conf and sip.conf are useful for this. When
a peer registers the value associated with regexten for that peer, an extension of that
value will be created in the context defined by regcontext. So, for example, if we define
regcontext in the [general] section of sip.conf to contain RegisteredDevices, and we
define the regexten for each peer to contain the extension number of that peer, when
the peers register the RegisteredDevices context will be populated automatically for
us. We’ll modify our sip.conf to look like this:
[general]
regcontext=RegisteredDevices
[0000FFFF0001](office-phone)
regexten=1001
and then reload chan_sip.so.
Now, we’ll register our device to the system and look at the RegisteredDevices context:
*CLI> dialplan show RegisteredDevices
[ Context 'RegisteredDevices' created by 'SIP' ]
'1001' => 1. Noop(0000FFFF0001) [SIP]
'1002' => 1. Noop(0000FFFF0002) [SIP]
With our devices registered and the context used for determining when to respond
populated, the only task left is to include the LocalSets context within the
DUNDi_Incoming context in order to permit routing of calls to the endpoints.
Using dialplan functions in mappings
Sometimes it’s useful to utilize a dialplan function within the mappings to control what
a peer responds with. Throughout this book we’ve been touting the advantages of
decoupling the user’s extension number from the device in order to permit hot-desking.
Configuring Asterisk for Use with DUNDi | 517