Following the recent new feature of #!ifexp based on snexpr, another preprocessor directive was added which allows defining IDs with a value computed from the evaluation of an expression, respectively:

#!defexp ID EXP

The EXP can be any expression supported by snexpr, including the previously defined IDs. For example:

#!define IPADDR 1.2.3.4
#!define PORT 5060
#!defexp SIPURI "sip:" + IPADDR + ":" + PORT

The result is that SIPURI is defined to sip:1.2.3.4:5060.

Another variant is available as #!defexps, which encloses the result of the expression in double quotes, making it suitable to be used further as string value:

#!defexps SIPURI "sip:" + IPADDR + ":" + PORT

The result is that SIPURI is defined to “sip:1.2.3.4:5060”.

More details at:

Enjoy!

Thanks for flying Kamailio!