[asterisk-users] How does Asterisk parse extensions.conf file?

Tzafrir Cohen tzafrir.cohen at xorcom.com
Tue Oct 18 04:42:49 CDT 2011


On Tue, Oct 18, 2011 at 12:08:04AM -0700, Sazzad Kamal wrote:
> Hello,
> 
> I want to know the way Asterisk parses configuration files. So that I can find out, what Asterisk does when I write, 'allow=g711' in extensions.conf file.
> 
> As I've come to know, Asterisk configuration files are kind of DSLs.

AEL is. Calling the configuration files a DSL (Domain-Specific Language)
is a bit streching it. The format of the file itself is very simple. The
dialplan can be more complex, though.

> I thought it must have a parser to know the values in those conf files, i.e., the value of 'allow' parameter.

Let's see:

In the shell:
# echo allow=g711 >>/etc/asterisk/extensions.conf

In the CLI:

sweetmorn*CLI> dialplan reload
Dialplan reloaded.
[Oct 18 11:33:38] WARNING[31241]: pbx_config.c:1595 pbx_load_config: ==!!== Unknown directive: allow at line 941 -- IGNORING!!!

Are you sure you're after that file? This is indeed an invalind
configuration. Can you give us a hint as to what you're after?

> 
> Can anyone please tell me what functions/files are used to parse these configuration files?

pbx/pbx_config.c , main/config.c

Hint: grep '"extensions\.conf"' */*.c

Also, if you don't have the source:

$ grep 'extensions\.conf' /usr/sbin/asterisk /usr/lib/asterisk/modules/*.so
Binary file /usr/lib/asterisk/modules/pbx_config.so matches
Binary file /usr/lib/asterisk/modules/res_ael_share.so matches

$ strings /usr/lib/asterisk/modules/res_ael_share.so  | grep 'extensions\.conf'
 (You may ignore this warning if '%s' exists in extensions.conf, or is created by another module. I cannot check for those.)

This is only a simple message, not the one we're looking for.

$ strings /usr/lib/asterisk/modules/res_ael_share.so  | grep 'extensions\.conf'

does give the expected output.

-- 
               Tzafrir Cohen
icq#16849755              jabber:tzafrir.cohen at xorcom.com
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir



More information about the asterisk-users mailing list