Thanks @miconda, here you go.

####### Global Parameters #########
debug = 2
log_stderror = no
log_facility = LOG_LOCAL6
listen = eth0

####### Modules Section ########
# mpath="/usr/lib64/kamailio/modules/"

loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "debugger.so"
loadmodule "htable.so"

# ----- tm params -----
modparam("tm", "failure_reply_mode", 3)
modparam("tm", "remap_503_500", 0)
modparam("tm", "contacts_avp", "tm_contacts")
modparam("tm", "contact_flows_avp", "tm_contact_flows")

# ----- rr params -----
modparam("rr", "enable_full_lr", 0)
modparam("rr", "append_fromtag", 1)

# ----- htable params -----
modparam("htable", "htable", "gateways=>size=4")

request_route
{
    if (!is_method("ACK")) {
        if(t_precheck_trans()) {
            t_check_trans();
            exit;
        }
        t_check_trans();
    }

    if (!sanity_check("1535", "7")) {
        exit;
    }

    if ( msg:len >= 8192 ) {
        send_reply("513", "Message too big");
        exit;
    }

    if (!mf_process_maxfwd_header("10")) {
        send_reply("483", "Too Many Hops");
        exit;
    }

    if (is_method("OPTIONS")) {
        send_reply("200","OK");
        exit;
    }

    if (has_totag()) {
        if (is_method("INVITE")) {
            record_route();
        }
        if (loose_route()) {
            route(RELAY);
        }
        if (is_method("ACK")) {
            if (t_check_trans()) {
                route(RELAY);
            }
            exit;
        }
        send_reply("481", "Call Leg/Transaction Does Not Exist");
        exit;
    }

    if (is_method("CANCEL")) {
        if (t_check_trans()) {
            route(RELAY);
        } else {
            send_reply("481", "Call leg/transaction does not exist");
        }
        exit;
    } else if (is_method("ACK")) {
        if (t_check_trans()) {
            route(RELAY);
        }
        exit;
    }

    remove_hf("Route");
    record_route();

    $var(i) = 1;
    while ($var(i) < 10) {
        $sht(gateways=>$var(i)) = "host=" + $_s($var(i).$var(i).$var(i).$var(i)) + ";priority=" + $var(i);
        xlog ("==== Storing: $sht(gateways=>$var(i))\n");
        $var(i) = $var(i) + 1;
    }

    sht_iterator_start("i", "gateways");
    while(sht_iterator_next("i")) {
        append_branch("sip:$rU@$(shtitval(i){param.value,host})", "$_s(0.$(shtitval(i){param.value,priority}))");
    }
    sht_iterator_end("i");
    t_load_contacts();
    xlog ("Route order:\n");
    while (t_next_contacts()) {
        xlog ("==== $rd\n");
    }
    route(RELAY);
}

route[RELAY] {
    xlog ("L_INFO", "Routing to $rd/$du\n");
    t_on_failure("OB_FAILURE");
    if (!t_relay()) {
        sl_reply_error();
    }
    exit;
}

failure_route[OB_FAILURE] {
    if (t_is_canceled()) {
        xlog("L_INFO", "Transaction cancelled\n");
        exit;
    }
    if (!t_next_contacts() && $ru==$ou) {
        send_reply("503", "Service Unavailable");
        exit;
    }
    t_on_failure("OB_FAILURE");
    route(RELAY);
    exit;
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.