[asterisk-dev] Defining new section type in sip.conf - question about syntax

Jared Smith jsmith at digium.com
Wed Apr 15 16:51:56 CDT 2009


On Wed, 2009-04-15 at 16:17 -0500, John Todd wrote:
> I'm not in favor of overloading the names to have separate meanings by  
> construction of the name itself in a place where the name is otherwise  
> free-form.  XML starts to look appealing after staring at these  
> problems for too long.

Well, from somebody sick and twisted enough to write books in XML, I'll
add my 2 centi-dollars (with a nod to our metric friends). And no, I
don't think XML would help us any here.  :-)

> I'd like to see either a separate config file (not my favorite idea)  
> or type= or perhaps even some separate value definition.  (domain=  
> would be good, but we've already used that for other purposes, sort-of.)

The problem here is that you wouldn't ever have a section that had both
type= and this new setting (let's call it domaintemplate for lack of a
better term).  The sections with this new setting are going to look very
much like the [general] section in sip.conf already does... 

So, in a nutshell, I think the question comes down to this: how do we
differentiate between different kinds of *sections* within a config
file.  In rough pseudo-config files, I imagine the choices come down to
one of the following (and I apologize in advance for the length). 

(Oh, and one more thing... Olle, if I've totally messed this up, please
forgive me!)

=== Option #1 ===
Use a separate config file

sip_domains.conf
--
[jaredsmith.net]
bindaddr=10.1.2.3
bindport=5060
domain=jaredsmith.net
pedantic=yes
context=verysecure

[astrinomicon.com]
bindaddr=192.168.123.222
bindport=5070
domain=astrinomicon.com
autodomain=yes
pedantic=no
context=notdefault

sip.conf
--
[general]
; snip

[authentication]
; snip

[george]
domaintemplate=general
type=friend
context=blah
username=georgejones
secret=n0tnum3r1c
disallow=all
allow=ulaw

[fred]
domaintemplate=jaredsmith.net
type=user
context=blah
secret=supersecret_955

=== Option #2 ===
Try to combine both domaintemplate and user/peer/friend sections into
the same configuration file, and use something other than type= to set
them apart.

sip.conf
--
[general]
; snip

[authentication]
; snip

[jaredsmith.net]
thissectionisadomain=yes; and not a user/peer/friend
bindaddr=10.1.2.3
bindport=5060
domain=jaredsmith.net
pedantic=yes
context=verysecure

[astrinomicon.com]
thissectionisadomain=yes; and not a user/peer/friend
bindaddr=192.168.123.222
bindport=5070
domain=astrinomicon.com
autodomain=yes
pedantic=no
context=notdefault


[george]
domaintemplate=general
type=friend
context=blah
username=georgejones
secret=n0tnum3r1c
disallow=all
allow=ulaw

[fred]
domaintemplate=jaredsmith.net
type=user
context=blah
secret=supersecret_955

=== Option #3 ===
Overload type= to use it for domain sections as well:

[general]
; snip

[authentication]
; snip

[jaredsmith.net]
type=domaintemplate ; and not a user/peer/friend
bindaddr=10.1.2.3
bindport=5060
domain=jaredsmith.net
pedantic=yes
context=verysecure

[astrinomicon.com]
type=domaintemplate ; and not a user/peer/friend
bindaddr=192.168.123.222
bindport=5070
domain=astrinomicon.com
autodomain=yes
pedantic=no
context=notdefault


[george]
domaintemplate=general
type=friend
context=blah
username=georgejones
secret=n0tnum3r1c
disallow=all
allow=ulaw

[fred]
domaintemplate=jaredsmith.net
type=user
context=blah
secret=supersecret_955



-- 
Jared Smith
Training Manager
Digium, Inc.




More information about the asterisk-dev mailing list