[sr-dev] question about SWITCH statement

Klaus Feichtinger klaus.feichtinger at gmx.net
Wed Feb 24 09:35:02 CET 2010


Hello,

I have a question regarding the "SWITCH" statement from the core of
sip-router / kamailio.

In the news publication
(http://www.kamailio.org/dokuwiki/doku.php/features:new-in-3.0.x) I found a
description that the switch statement now supports "regular expression for
matching string".

However, when I try the example (as displayed on the wiki page) I get
different error messages. The example that I've tested looks like:

switch($rU) {
	case /^123/:
		sl_send_reply("200", "yippie - ^123 works");
	case /^124.*/:
		sl_send_reply("200", "yippie - ^124.* works");
	break;
}

Worst case was using the first case with the case label "/^123/".
That resulted in a segmentation fault (!) with following error messages:

loading modules under /usr/lib/kamailio/
 0(23229) : <core> [cfg.y:3329]: parse error in config file
/usr/local/etc/kamailio/kamailio.cfg, line 374, column 16: syntax error
 0(23229) : <core> [cfg.y:3329]: parse error in config file
/usr/local/etc/kamailio/kamailio.cfg, line 374, column 16: bad expression
Segmentation fault

When I added ".*" to /^123/ as in case "/^124.*/" the error message was:
loading modules under /usr/lib/kamailio/
 0(23256) : <core> [cfg.y:3329]: parse error in config file
/usr/local/etc/kamailio/kamailio.cfg, line 374, column 15: syntax error
 0(23256) : <core> [cfg.y:3329]: parse error in config file
/usr/local/etc/kamailio/kamailio.cfg, line 374, column 15: bad case label
 0(23256) : <core> [cfg.y:3329]: parse error in config file
/usr/local/etc/kamailio/kamailio.cfg, line 374, column 15: bad case
 0(23256) : <core> [cfg.y:3329]: parse error in config file
/usr/local/etc/kamailio/kamailio.cfg, line 379, column 5: bad switch body

What does sip-router / kamailio now REALLY support? Is the information about RegEx a mistake on the web page or is only the syntax wrong? However, in the CoreCookbook no entry can be found regarding RegEx for switch statement......

Regards,

Klaus

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



More information about the sr-dev mailing list