Hi,
Thanks for the replies! The first thing I looked at was the encode/decode.hexa transformations but it only transforms between ASCII characters and Hex numbers. Then I used exec_avp to call a bash command (for example, 'echo $((0x123))' gives you 291) which works. But calling something external may not be optimal I thought?
I found OpenSIPS has hex2dec and dec2hex transformations and wonder if we could have these in Kamailio as well?
Cheers, Yufei
Hello,
On 16/09/15 10:59, Yufei Tao wrote:
Hi,
Thanks for the replies! The first thing I looked at was the encode/decode.hexa transformations but it only transforms between ASCII characters and Hex numbers. Then I used exec_avp to call a bash command (for example, 'echo $((0x123))' gives you 291) which works. But calling something external may not be optimal I thought?
an embedded script like lua (see app_lua module) could be the alternative for anything that is not available as config function. Exec might not be the most performat option that can be used, but it won't have any relevant impact if you don't execute any long time taking application.
Anyhow, I looked at the code and found an easy way to get this working so, I pushed a patch that makes the cast operator (int) to detect and convert hex:
* https://github.com/kamailio/kamailio/commit/33f159121193b3ed09e2ec7aa7b55aa5...
You should be able to cherry pick that commit in your branch.
It can be used like:
$var(x) = "0x10"; $var(y) = (int)$var(x); xlog("hex x = $var(x); dec y = $var(y)\n");
Adding transformations would be another option to be done when time allows.
Cheers, Daniel