Kamailio: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
Kamailio 는 SIP 에 특화된 오픈 소스 라우터/방화벽 이다.
Kamailio 는 SIP 에 특화된 오픈 소스 라우터/방화벽 이다.


== kamailio.cfg ==
== Structure ==
Kamailio.cfg 는 다음의 파트로 이루어져 있다.
Kamailio 의 configuration file 은 크게 다음의 파트로 이루어져 있다.
* global parameters
* global parameters
* modules settings
* modules settings
Line 47: Line 47:
     route(NATMANAGE);
     route(NATMANAGE);
}
}
</pre>
== Generic elements ==
=== Comments ===
Line comments start with # or //. Block comments start with  /* and are ended by */.
<pre>
  # this is a line comment
 
  // this is another line comment
 
  /* this
    is
    a
    block
    comment */
</pre>
=== Values ===
There are three types of values.
* integer : number of 32bit size.
* boolean: aliases to 1 (true, on, yes) or 0(false, off, no).
* string: tokens enclosed in between double or single quotes.
<pre>
// next two are strings
  "this is a string value"
  'this is another string value"
// next is a boolean
  yes
// next is an integer
  64
</pre>
=== Identifiers ===
Identifiers are tokens which are not enclosed in single or double quotes and to match the rules for integer or boolean values.
For example, the identifiers are the core parameters and functions, module functions, core keywords and statements.
<pre>
return
</pre>
=== Variables ===
The variables start with $.
<pre>
$var(x) = $rU + "@" + $fd;
</pre>
=== Actions ===
An action is an element used inside routing blocks ended by ;. It can be an execution of a function from core or a module, a conditional or loop statement, an assignment expression.
<pre>
  sl_send_reply("404", "Not found");
  exit;
</pre>
=== Expressions ===
An expression is an association group of statements, variables, functions and operators.
<pre>
if(!t_relay())
if($var(x)>10)
"sip:" + $var(prefix) + $rU + "@" + $rd
</pre>
</pre>



Revision as of 15:23, 31 December 2018

Overview

SIP server Kamailio(former OpenSER) 내용 정리.

Basic

Kamailio 는 SIP 에 특화된 오픈 소스 라우터/방화벽 이다.

Structure

Kamailio 의 configuration file 은 크게 다음의 파트로 이루어져 있다.

  • global parameters
  • modules settings
  • routing blocks

Global parameters section

This is the first part of the configuration file, containing the parameters for the core of kamailio and custom global parameters.

Typically this is formed by directives of the form:

name=value

The name corresponds to a core parameters. If a name is not matching a core parameter, then Kamailio will not start, rising an error during startup.

Modules setting section

This is the second section of the configuration file, containing the directives to load modules and set their parameters.

It contains the directives loadmodule and modparam. In the default configuration file starts with the line setting the path to modules(the assignment to mpath core parameter).

loadmodule "debugger.so"
...
modparam("debugger", "cfgtrace", 1)

Routing blocks section

This is the last section of the configuration file, typically the biggest one, containing the routing blocks with the routing logic for SIP traffic handled by Kamailio. The only mandatory routing block is request_route, which contains the actions for deciding the routing for SIP requests.

request_route {
 
    # per request initial checks
    route(REQINIT);
 
    ...
}
 
branch_route[MANAGE_BRANCH] {
    xdbg("new branch [$T_branch_idx] to $ru\n");
    route(NATMANAGE);
}

Generic elements

Comments

Line comments start with # or //. Block comments start with /* and are ended by */.

  # this is a line comment
  
  // this is another line comment
  
  /* this
     is
     a
     block
     comment */

Values

There are three types of values.

  • integer : number of 32bit size.
  • boolean: aliases to 1 (true, on, yes) or 0(false, off, no).
  • string: tokens enclosed in between double or single quotes.
// next two are strings
  "this is a string value"
  'this is another string value"
 
// next is a boolean
  yes
 
// next is an integer
  64

Identifiers

Identifiers are tokens which are not enclosed in single or double quotes and to match the rules for integer or boolean values. For example, the identifiers are the core parameters and functions, module functions, core keywords and statements.

return

Variables

The variables start with $.

$var(x) = $rU + "@" + $fd;

Actions

An action is an element used inside routing blocks ended by ;. It can be an execution of a function from core or a module, a conditional or loop statement, an assignment expression.

  sl_send_reply("404", "Not found");
  exit;

Expressions

An expression is an association group of statements, variables, functions and operators.

if(!t_relay())
 
if($var(x)>10)
 
"sip:" + $var(prefix) + $rU + "@" + $rd

See also