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);
}