Saturday, May 1, 2010

Kamailio 3.0.x - DYK-09 - cancel and invite

Access INVITE attributes while processing the CANCEL

See also: Kamailio 3.0.x - DYK - Table of Content

Another enhancements brought by Kamailio 3.0.0 is the possibility of accessing the attributes of INVITE while processing the CANCEL. By loading the tmx module, you can use in your config file the pseudo-variable $T_inv(pv).

Instead of returning the values of pseudo-variables bound to CANCEL, $T_inv(pv) will return the value of pseudo-variables bound to INVITE. For example:

$T_inv($si) returns the source IP of INVITE, therefore checking if the CANCEL comes from same IP address as INVITE is:
if (is_method("CANCEL"))
{
if (t_check_trans())
{
$var(ip) = $T_inv($si);
if($si != $var(ip))
{
send_reply("403", "CANCEL from a different IP than INVITE");
exit;
}
t_relay();
}
exit;
}

No comments:

Post a Comment