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:
@cfg_get.group_name.var_name
Example:
gateway.destination = "127.0.0.1" 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");
exit;
}
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 0Examples 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.)
http://kamailio.org/docs/modules/3.0.x/modules/cfg_db.html
http://kamailio.org/docs/modules/3.0.x/modules/cfg_rpc.html
Next episode will be about sercmd.
No comments:
Post a Comment