[SR-Users] uac +kamailio + dispatcher + asterisk

Жан Базаров chiefkeeft at gmail.com
Thu Aug 31 12:40:55 CEST 2017


Hello! provider trunks registration on kamailio UAC?! it's clear.
but how does asterisk find out through which trunk the call should be made?
I tried to set the header from asterisk dialplan.
for example:



 if (is_method("INVITE")) {
                                 #record_route_preset("109.195.102.122");




        route(DIRECTION);


        setflag(FLT_ACC); # do accounting
        }



#        ------ LOADBALANCE ROUTE ------------ #
if(!ds_is_from_list()) {
route(DISPATCH);
}

route[DISPATCH] {
        #round robin dispatching on gateways group '1'
        if(!ds_select_dst("1", "4"))
                {






                send_reply("404", "No destination");
                exit;
        }
        xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
        t_on_failure("RTF_DISPATCH");

route(NATMANAGE);
route(DRELAY);
        exit;
}


route[DIRECTION] {

                 if ($hdr(x-trunk)  != $null) {

                 if (!is_method("BYE")){
                                        $fu="";
                                        t_on_failure("MANAGE_FAILURE");
                                        $dlg_ctx(timeout_route) =
"DIALOG_END";
                                        $avp(i:10)=43200;
                                        $dlg_ctx(timeout_bye) = 0;
        sql_pvquery("ca", "select l_uuid, auth_username, auth_password,
realm, l_domain, r_domain  from uacreg where id='$hdr(x-trunk)'",
"$avp(uuid), $avp(uname), $avp(passwd), $avp(realm), $avp(src_ipaddr),
$avp(dst_ipaddr)");
                                        t_on_failure("MANAGE_FAILURE");
                                        $dlg_ctx(timeout_route) =
"DIALOG_END";
                                        $avp(i:10)=43200;
                                        $dlg_ctx(timeout_bye) = 0;

                $fu="";
                uac_replace_from("sip:$avp(uname)@$avp(dst_ipaddr)");
                $tu="sip:"+$tU+"@"+$avp(dst_ipaddr);
                $ru="sip:"+$tU+"@"+$avp(dst_ipaddr);
                remove_hf("Contact");
                $var(contact)="sip:"+$avp(uname)+"@10.49.9.2:5060";
                insert_hf("Contact: <$var(contact)>\r\n");
                #insert_hf("Contact:  ");
                msg_apply_changes();
                fix_nated_register();
                xlog("L_INFO","Contact header $var(contact)
111111111111111111111111111111111111111 is $ct {$ct}\n");
                route(RELAY);
 }      #### BYE

}       ### XTRUNK

But in this configuration I do not come bye
but when I register providers trunks on asterisk - problem with BYE not
visible.
but I can not register provider-trunks on all the asterisks, because
incoming invite arrives at the link + address, and all the asteriscs ring.
All my asterisk's behind nat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20170831/0ff6b801/attachment.html>


More information about the sr-users mailing list