Hi all,

I’m trying to implement following routing behaviour:

- ingress INVITE is sequentially forked to 1 or more endpoints
- under certain conditions sequential forking may be stopped and pre-defined error returned to the caller

Here’s is part of the config responsible for handling errors:

failure_route[ROUTE_ELEMENT_FINAL_FAILURE_HELPER] {
route(ROUTE_ELEMENT_FINAL_FAILURE);
}

route[ROUTE_ELEMENT_FINAL_FAILURE] {
# We need to check if the error happens before the first egress, because T-state is not defined yet so we can not use t_reply
if ($var(before_first_egress) == 0) {
t_reply("$var(sipCode)", "$var(sipMessage)");
} else {
sl_send_reply("$var(sipCode)", "$var(sipMessage)");
}
}



Here is a simple scenario where delivering call to first endpoint times out after receiving 180 Ringing (using custom fr_inv_timer value) where:
- .33 is caller
- .208 is Kamailio
- .138 is callee


Notice that 504 is retransmitted by Kamailio. Here is a comparison of 180 and 504 returned by Kamailio:


As can be seen, 180 was proxied from the callee and has callee’s to-tag (tag=CALLEE1), however 504 that was generated by Kamailio using t_reply() has a different to-tag (presumably generated by Kamailio).

How can I tell Kamailio not to generate new to-tag but to use the last one that proxied back to the caller?

Thanks in advance for any help!

Regards,
Ivan