User Tools

Site Tools


cookbooks:4.0.x:core:cfg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cookbooks:4.0.x:core:cfg [2013/06/18 10:05]
poing [Comments]
cookbooks:4.0.x:core:cfg [2013/06/26 09:39] (current)
poing [Configuration Directives]
Line 1: Line 1:
-<fc #FF0000>**This is a work in progress**</fc> 
- 
 ====== The Configuration File ====== ====== The Configuration File ======
  
 ===== Configuration Elements ===== ===== Configuration Elements =====
  
-For the sake and sanity of the user of this software, we need to cover the basic elements of the configuration before getting to the meat and potatoes.+For the sake and sanity of the user of this software, we should cover the basic elements of the configuration before getting to the meat and potatoes.  There are three basic configuration elements to be concerned about.
  
 +  * Configuration Directives
   * Comments   * Comments
-  * Configuration Directives 
   * Instruction Separator   * Instruction Separator
  
-==== Comments ==== 
- 
-<fc #FF0000>**The first thing you should understand is the comment syntax used in the configuration file.\\ \\ **</fc> 
-Comments in the configuration file are a mixture of C-Style (**not C++**) and scripting language syntax.\\  
-It closely resembles the PHP style, **//except//** you **can not use** double-slash ( ⁄ ⁄ ), and only hash (#) may be used for line comments.\\ \\  
-It can be confusing seeing the C-Style Control Directives ([[cfg#c-style_control_directives|explained later]]) that begin with a hash-bang (#!) mixed with line comments begin with a hash (#). 
  
-<code> +----- 
-/* block comment +-----
-   block comment */ +
-// this is NOT a line comment +
-# this is a line comment +
-#!c_style_directive  <-- VALID CONFIGURATION DIRECTIVE +
-</code>+
  
 ==== Configuration Directives ==== ==== Configuration Directives ====
  
-There are five (5) types of configuration directives used with Kamailio.+There are five (5) types of configuration directives used with Kamailio.\\  
 +^  <fc #800000>**Each type of configuration directive uses its own syntax!**</fc>  |
  
-  - [[cfg#c-style_control_directives|C-Style Control Directives]] +  - C-Style Control Directives 
-  - [[cfg#apache_namevalue_pairs|Apache Name/Value Pairs]] +  - Apache-Like Name/Value Pairs 
-  - [[cfg#normal_namevalue_pairs|Normal Name/Value Pairs]] +  - Normal Name/Value Pairs 
-  - [[cfg#modify_parameter_procedure|Modify Parameter Procedure]] +  - Modify Parameter Procedure 
-  - [[cfg#route_functions|Route Functions]]+  - Route Functions 
 + 
 +----- 
 + 
 +==== Comments ==== 
 + 
 +^  <fc #800000>**The first thing you should understand is the comment syntax used in the configuration file.**</fc> 
 + 
 +Comments in the configuration file are a mixture of C-Style (**not C++**) and scripting language syntaxes.\\  
 +It closely resembles the PHP style, **//except//** you **can not use** double-slash ( ⁄ ⁄ ) for line comments.  Only the hash (#) may be used for line comments.\\ \\  
 +It can be confusing seeing the C-Style Control Directives ([[cfg#c-style_control_directives|explained later]]) that begin with a hash-bang (#!) mixed with line comments beginning with a hash (#). 
 + 
 +^ Examples: 
 +|Block Comment:<code c> 
 +/* This is a ... 
 +   block comment */</code> 
 +|<fc #800000>**Not a Comment:**</fc><code> // this is NOT a line comment </code>
 +|Line Comment:<code c># this is a line comment </code>
 +|**<fc #800000>Valid Configuration Directive:</fc>**<code>#!c_style_directive</code>
 + 
 +-----
  
 ==== Instruction Separator ==== ==== Instruction Separator ====
  
-The semicolon works with all forms of configuration directives as an instruction separator.  Allowing for comments or additional configuration directives on the same line.+<fc #438D80>Just getting this out of the way before covering the Configuration Directives.</fc>
  
-<code> +The semicolon (;) is **//not required//** and **//may//** be used as an instruction separator for all configuration directives **//except//** Route Functions((Route Functions use scripting language syntax and **must** be terminated with a semicolon at the end of each statement.)).\\  
-configuration_directive_aconfiguration_directive_b + 
-configuration_directive; # comment about the configuration directive +The general use is to allow for comments or additional configuration directives be placed on the same line. 
-</code>+ 
 +^ Examples: 
 +|<code> 
 +configuration_directive_a 
 +configuration_directive_b; 
 +configuration_directive_c; configuration_directive_d 
 +configuration_directive_e; # comment about the configuration directive 
 +</code>
 + 
 +----- 
 +-----
  
 ===== Configuration Directives ===== ===== Configuration Directives =====
 +
 +^ Type ^ Format ^ Comment ^
 +| C-Style Control Directives | #!directive [ NAME [ VALUE ] ] | Begins with hash-bang (#!) |
 +| Apache-Like Name/Value Pairs | name "value" | Delimited by a space & Value within quotes |
 +| Normal Name/Value Pairs | name=value | Delimited by an equals sign |
 +| Modify Parameter Procedure | modparam("MODULE", "PARAMETER", "VALUE") | |
 +| Route Functions | route {...} | Scripting Language |
 ==== C-Style Control Directives ==== ==== C-Style Control Directives ====
  
Line 61: Line 86:
   * #!substdef   * #!substdef
  
-<code>+^ Example: 
 +|<code c>
 #!define MODULE_NAME #!define MODULE_NAME
  
 #!ifdef MODULE_NAME #!ifdef MODULE_NAME
- .. set directives ..+ ".. set directives .."
 #!else #!else
- .. set alternate directives .. + ".. set alternate directives ..
 #!endif #!endif
-</code>+</code>|
  
 +-----
 ==== Apache Name/Value Pairs ==== ==== Apache Name/Value Pairs ====
  
-  name "value"+^ Syntax 
 +| <code c>name "value"</code>  |
  
 <fc #FF0000>//The value MUST be enclosed in quotes.//</fc> <fc #FF0000>//The value MUST be enclosed in quotes.//</fc>
  
-  loadmodule "module_name.so" +^ Examples 
-  loadmodule "another_module.so" +|<code> 
-  include_file "file_to_include.cfg" +loadmodule "module_name.so" 
-  import_file "/path/to/file_to_import.cfg"+loadmodule "another_module.so" 
 +include_file "file_to_include.cfg" 
 +import_file "/path/to/file_to_import.cfg" 
 +</code>|
  
-  +-------
 ==== Normal Name/Value Pairs ==== ==== Normal Name/Value Pairs ====
  
-  name=value +These name/value pairs are normally delimited by an equal sign.
- (delimited by an equals sign+
  
-[[../core#core_parameters|core_parameters]]+^ Syntax: | 
 +|<code c>name=value</code>|
  
-<code>+<fc #FF0000>There are a couple situations where the value needs to be enclosed in quotes.</fc>\\  
 +Check the [[../core#core_parameters|core parameters]] for the required syntax. 
 + 
 +^ Examples: 
 +|<code>
 memdbg=5 memdbg=5
 memlog=5 memlog=5
Line 99: Line 134:
 auto_aliases=no auto_aliases=no
 alias="sip.mydomain.com" alias="sip.mydomain.com"
-</code>+</code>|
  
 +------
 ==== Modify Parameter Procedure ==== ==== Modify Parameter Procedure ====
  
-<code>+The modify parameter is similar to other types programming procedure.\\ 
 +You call the procedure and it modifies the defined modules parameter. 
 + 
 +^ Syntax: 
 +| <code c>modparam ( string "$module" , string "$parameter" , mixed "$value" )</code>
 +   
 +<fc #800000>Strings should be enclosed in quotes.</fc> 
 + 
 +See the [[http://www.kamailio.org/docs/modules/4.0.x/|module documentation]] for support parameter settings. 
 + 
 +^ Examples:  |   
 +|<code>
 modparam("first_module", "module_parameter_text", "new_value");  # Set Text Value modparam("first_module", "module_parameter_text", "new_value");  # Set Text Value
 modparam("second_module", "module_parameter_number", 10000);      # Set Numeric Value modparam("second_module", "module_parameter_number", 10000);      # Set Numeric Value
 modparam("second_module", "module_parameter_on", 1);              # Enable Parameter modparam("second_module", "module_parameter_on", 1);              # Enable Parameter
 modparam("third_module", "module_parameter_on", 0);             # Disable Parameter modparam("third_module", "module_parameter_on", 0);             # Disable Parameter
-</code>+</code>|
  
 +-----
 ==== Route Functions ==== ==== Route Functions ====
 +
 +I will not go into too much detail here, the scripting methods, functions, and procdedures should be covered elsewhere in this wiki.\\ 
 +
 +
 +^ Example:  |
 +|<code c>request_route {
 +        route(REQINIT); # Request Initial
 +        route(NATDETECT); # NAT Detection
 +
 +        # CANCEL ??
 +        if (is_method("CANCEL")) {
 +         exit;
 +        }
 +
 +        # OTHER SCRIPT CODE HERE
 +}</code>|
cookbooks/4.0.x/core/cfg.1371542747.txt.gz · Last modified: 2013/06/18 10:05 by poing