Hello,

in this case, you have to perform the update of To header only in branch_route.

Cheers,
Daniel

On 03.04.23 14:58, Serdar GUCLUER wrote:

Hello all,

In my situation, it is possible to call forwarding to registered users multiple times on same leg. For each forward i have to update To uri and i am using uac_replace_to to do that.

But on second relaying, To uri was malformed. On below, Im attaching configuration to illustrate my problem. (version-5.4.9)

First relay - To: sip:xyz@192.168.0.51

Second relay - To: sip:xyz@192.168.0.51sip:abc@192.168.0.51

Thanks in advance.

Serdar


loadmodule "uac.so"
modparam("uac","restore_mode","auto")


request_route {
    ...
    $avp(x) = "abc";
    $avp(x) = "xyz";
    $avp(myip) = "192.168.0.51";
    $avp(i) = 0;
    route(SERDAR);
    ...
}

route[SERDAR] {
    if ($(avp(x)[$avp(i)])!=$null) {
        $avp(destination) = $(avp(x)[$avp(i)]);
        $avp(i) = $avp(i) + 1;
        $rU=$_s($avp(destination));
        uac_replace_to("$_s(sip:$avp(destination)@$avp(myip))");
        route(LOCATION);
    } else {
        send_reply("403", "Opps!");
        exit;
    }
}

route[LOCATION] {
    $avp(oexten) = $rU;
    if (!lookup("location") ) {
        t_newtran();
        switch ($var(rc)) {
            case -1:
            case -3:
                send_reply("480", "Temporarily Unavailable");
                exit;
            case -2:
                send_reply("405", "Method Not Allowed");
                exit;
        }
    }
    t_on_failure("SERDAR_FAILURE");
    if(!t_relay()) sl_reply_error();
    exit;
}

failure_route[SERDAR_FAILURE] {
    route(NATMANAGE);
    if (t_is_canceled()) exit;
    route(SERDAR);
}


__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - June 5-7, 2023 - www.kamailioworld.com