[Kamailio-Users] Kamailio 3.0.0: configuration request regarding VARIABLES usage (custom variables + $var(x))

Klaus Feichtinger klaus.feichtinger at gmx.net
Mon Feb 22 11:47:13 CET 2010


Hello Kamailio-3 users,

I have two questions regarding usage of variables within the config file (as published in the NEW FEATURES of Kamailio 3.0.0). 

The reason why I want to use variables instead of standard configuration
lines is the maintainability of my SIP servers. I have a group of about 20
sip servers distributed over a wide area. Especially routing rules might
change during operation of the servers and must be adapted on all servers.
Therefore I want to use variables, defined at the beginning of each config
file. Within the config file / the different routing blocks I want to
reference to these variables. That would be much easier for automatic config script adaptation with a linux script (e.g.) than parsing the whole config file for special text phrases.


QUESTION 1:
==========
Is it impossible using a variable for requesting a SRC_IP address? With my
current configuration I always see an entry in the SYSLOG that looks as
follows:  "<core> [route.c:1531]: BUG: comp_ip: invalid type for  src_ip or dst_ip (20)"

The configuration lines look like:

$var(lst_gwIpRange) = "10.16.48.6[0-2]";
[...]
if (src_ip=~$var(lst_gwIpRange)) {
	[...]
}

Is maybe a transformation missing/necessary to avoid the error message (which causes a malfunction)? Can anybody give me a hint?


QUESTION 2:
==========
The second problem I found is, that the config variables can be configured
within a route block only and not - as expected - e.g. at the top of the
config file (in the same way as the custom variables). I can't use the custom variables as they are, because I will use more complex variables, which are a mixture of up to three custom variables. These "complex" variables will be used in more than one routing block. Therefore I have to define these variables in every routing block...... Is an alternative (easier) solution with a single definition available, too?

An example of my problem is as follows:

# custom variables defined on top of the kamailio.cfg file
tst.loc_ipaddr 	= "10.10.1.1" 	desc "IP addr of the local SIP Server"
tst.loc_prefix 	= "11" 		desc "prefix of this SRV"
tst.distRu1 	= "51[0-9].*" 	desc "variable representing ID1"

# the final variable should look like "sip:1151[0-9].*@10.10.1.1"
# and is used in 3 routing blocks

route[]
$var(test) = "sip:" + $sel(cfg_get.tst.loc_prefix) +
$sel(cfg_get.tst.distRu1) + "@" + $sel(cfg_get.tst.loc_ipaddr);
[...]

route[TEST1]
$var(test) = "sip:" + $sel(cfg_get.tst.loc_prefix) +
$sel(cfg_get.tst.distRu1) + "@" + $sel(cfg_get.tst.loc_ipaddr);
[...]

route[TEST2]
$var(test) = "sip:" + $sel(cfg_get.tst.loc_prefix) +
$sel(cfg_get.tst.distRu1) + "@" + $sel(cfg_get.tst.loc_ipaddr);
[...]


Thanks in advance for any hints!

Regards,
Klaus Feichtinger

-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser



More information about the Users mailing list