Friday, December 18, 2009

Best of New in Kamailio 3.0.0 - #4: cfg variables reload framework

Inherited from SIP Express Router (SER) via project, the cfg variables framework can be used by Kamailio 3.0.0 core and by the modules, to get and set internal variables on-the-fly, eliminating Kamailio restarts whenever it is possible. Such variables can be global or module parameters.

The operations with cfg variables can be done at any time without performance overhead. The framework makes sure that the variables do not change during the SIP message processing, the child processes see a snapshot of the variables with constant values. The variable that is changed will be automatically replaced by the framework the next time a SIP message is started to be processed.

The drivers can change the values of all the variables by names with or without the need of commit. That means a kind of transaction support, the framework can keep track of the changes (per driver) until they are committed or rolled-back.

New configuration values can be declared in the script, with following syntax :

group_name.var_name = value ['descr' description]

The values can be accessed via select calls:



gateway.destination = "" descr "IP addr of the gateway"
gateway.enabled = 1 descr "enable/disable the gateway"

route {
if (@cfg_get.gateway.enabled == 1) {
$du = "sip:"+ $sel(cfg_get.gateway.destination);
} else {
send_reply("404", "No gateway");

The cfg variables can be changed via control interface (e.g., xmlrpc) or using the new command line interface application (cli): sercmd.
sercmd cfg.set_now_int gateway enabled 0
Examples of what can be tuned via cfg variables framework:
  • tcp parameters (connect_timeout, send_timeout, connection_lifetime, asynchronous mode, keepalive, ...)
  • sctp parameters (autoclose, send_ttl, send_retries, ...)
  • dns parameters (dns_retr_time, dns_retr_no, ...)
  • other global parameters (debug, log_facility, memlog, force_rport, udp_mtu, ...) - see the cookbook for all tcp, sctp, dns and other global parameters
  • TM module parameters (fr_timer, fr_inv_timer, fr_inv_timer_next, auto_inv_100, auto_inv_100_reason, a.s.o.)
By using the cfg_db or cfg_rpc modules, values for those variables can be loaded from database or set via RPC control interface:

Next episode will be about sercmd.

No comments:

Post a Comment