| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Introduction} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | The Asterisk configuration parser in the 1.2 version | 
					
						
							|  |  |  | and beyond series has been improved in a number of ways. In | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | addition to the realtime architecture, we now have the ability to create | 
					
						
							|  |  |  | templates in configuration files, and use these as templates when we | 
					
						
							|  |  |  | configure phones, voicemail accounts and queues. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-09 00:11:32 +00:00
										 |  |  | These changes are general to the configuration parser, and works in | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | all configuration files. | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{General syntax} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | Asterisk configuration files are defined as follows: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 	[section] | 
					
						
							|  |  |  | 	label = value | 
					
						
							|  |  |  | 	label2 = value | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | In some files, (e.g. mgcp.conf, dahdi.conf and agents.conf), the syntax | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | is a bit different. In these files the syntax is as follows: | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 	[section] | 
					
						
							|  |  |  | 	label1 = value1 | 
					
						
							|  |  |  | 	label2 = value2 | 
					
						
							|  |  |  | 	object => name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	label3 = value3 | 
					
						
							|  |  |  | 	label2 = value4 | 
					
						
							|  |  |  | 	object2 => name2 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | In this syntax, we create objects with the settings defined above the object | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | creation. Note that settings are inherited from the top, so in the example | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | above object2 has inherited the setting for "label1" from the first object. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For template configurations, the syntax for defining a section is changed | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | to: | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 	[section](options) | 
					
						
							|  |  |  | 	label = value | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The options field is used to define templates, refer to templates and hide | 
					
						
							|  |  |  | templates. Any object can be used as a template. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | No whitespace is allowed between the closing "]" and the parenthesis "(". | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Comments} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | All lines that starts with semi-colon ";" is treated as comments | 
					
						
							|  |  |  | and is not parsed. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The "\verb!;--!" is a marker for a multi-line comment. Everything after | 
					
						
							|  |  |  | that marker will be treated as a comment until the end-marker "\verb!--;!" | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | is found. Parsing begins directly after the end-marker. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 	;This is a comment | 
					
						
							|  |  |  | 	label = value | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | 	;-- This is | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 	a comment --; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	;-- Comment --; exten=> 1000,1,dial(SIP/lisa)	 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Including other files} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | In all of the configuration files, you may include the content of another | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | file with the \#include statement. The content of the other file will be | 
					
						
							|  |  |  | included at the row that the \#include statement occurred. | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 	#include myusers.conf | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | You may also include the output of a program with the \#exec directive, | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | if you enable it in asterisk.conf | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | In asterisk.conf, add the execincludes = yes statement in the options | 
					
						
							|  |  |  | section: | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 	[options] | 
					
						
							|  |  |  | 	execincludes=yes | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The exec directive is used like this: | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting}	 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 	#exec /usr/local/bin/myasteriskconfigurator.sh | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-10 07:21:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Adding to an existing section} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | 	[section] | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 	label = value | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	[section](+) | 
					
						
							|  |  |  | 	label2 = value2	 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim}	 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | In this case, the plus sign indicates that the second section (with the | 
					
						
							|  |  |  | same name) is an addition to the first section. The second section can | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | be in another file (by using the \#include statement). If the section | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | name referred to before the plus is missing, the configuration will fail | 
					
						
							|  |  |  | to load. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Defining a template-only section} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 	[section](!) | 
					
						
							|  |  |  | 	label = value | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The exclamation mark indicates to the config parser that this is a only | 
					
						
							|  |  |  | a template and should not itself be used by the Asterisk module for | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | configuration. The section can be inherited by other sections (see | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | section "Using templates" below) but is not used by itself. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Using templates (or other configuration sections)} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 	[section](name[,name]) | 
					
						
							|  |  |  | 	label = value | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The name within the parenthesis refers to other sections, either | 
					
						
							|  |  |  | templates or standard sections. The referred sections are included | 
					
						
							|  |  |  | before the configuration engine parses the local settings within the | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | section as though their entire contents (and anything they were | 
					
						
							|  |  |  | previously based upon) were included in the new section.  For example | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | consider the following: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | [foo] | 
					
						
							|  |  |  | permit=192.168.0.2 | 
					
						
							|  |  |  | host=asdf | 
					
						
							|  |  |  | deny=192.168.0.1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [bar] | 
					
						
							|  |  |  | permit=192.168.1.2 | 
					
						
							|  |  |  | host=jkl | 
					
						
							|  |  |  | deny=192.168.1.1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [baz](foo,bar) | 
					
						
							|  |  |  | permit=192.168.3.1 | 
					
						
							|  |  |  | host=bnm | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | The [baz] section will be processed as though it had been written in the | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | following way: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | [baz] | 
					
						
							|  |  |  | permit=192.168.0.2 | 
					
						
							|  |  |  | host=asdf | 
					
						
							|  |  |  | deny=192.168.0.1 | 
					
						
							|  |  |  | permit=192.168.1.2 | 
					
						
							|  |  |  | host=jkl | 
					
						
							|  |  |  | deny=192.168.1.1 | 
					
						
							|  |  |  | permit=192.168.3.1 | 
					
						
							|  |  |  | host=bnm | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \subsubsection{Additional Examples} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | (in top-level sip.conf) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | [defaults](!) | 
					
						
							|  |  |  | type=friend | 
					
						
							|  |  |  | nat=yes | 
					
						
							|  |  |  | qualify=on | 
					
						
							|  |  |  | dtmfmode=rfc2833 | 
					
						
							|  |  |  | disallow=all | 
					
						
							|  |  |  | allow=alaw | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include accounts/*/sip.conf | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | (in \path{accounts/customer1/sip.conf}) | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \begin{astlisting} | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \begin{verbatim} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | [def-customer1](!,defaults) | 
					
						
							|  |  |  | secret=this_is_not_secret | 
					
						
							|  |  |  | context=from-customer1 | 
					
						
							|  |  |  | callerid=Customer 1 <300> | 
					
						
							|  |  |  | accountcode=0001 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [phone1](def-customer1) | 
					
						
							|  |  |  | mailbox=phone1@customer1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [phone2](def-customer1) | 
					
						
							|  |  |  | mailbox=phone2@customer1 | 
					
						
							| 
									
										
										
										
											2007-03-15 22:29:45 +00:00
										 |  |  | \end{verbatim} | 
					
						
							| 
									
										
										
										
											2007-10-15 13:12:51 +00:00
										 |  |  | \end{astlisting} | 
					
						
							| 
									
										
										
										
											2005-02-07 22:38:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | This example defines two phones - phone1 and phone2 with settings | 
					
						
							|  |  |  | inherited from "def-customer1".  The "def-customer1" is a template that | 
					
						
							|  |  |  | inherits from "defaults", which also is a template. |