The sip-router.org has now improved switch and while statements that can be used in config file.
The ‘break‘ statement can be used to break out from a ‘while‘ loop or from a ‘case‘ in ‘switch‘. Kamailio (openser) didn’t have it, the exit from a case or while being possible using IF statements, making the config a bit heavier. Now the break acts as in C language.
Moreover, the switch statement can match strings based on regular expression. SIP being a text-based protocol, the new addition brings a powerful tool in hands of administrators:
switch($var(x)){ case / "^[abc]" : log(1, "case a:a\n"); break; case "x": log(1, "case a:b\n"); break; }
If the case values are integers, the switch is optimized at startup, providing fast localization of the matching case branch, resulting in lower execution time.