<div dir="ltr"><div><div><div>Hello. At first- I think header of my message doesn't explain my porblem but I can not say about it with different terms)</div><div><br></div><div>So. I have construction Asterisk --> Kamailio --> Providers</div>
<div><br></div><div>My provisers registered with UAC modure and stored at UACREG table.</div><div><br></div><div>Problem scenario is:</div><div><br></div><div>I ring from asterisk to provider</div><div><br></div><div>Asterisk --> Kamailio --> Providers</div>
<div><br></div><div>Call from asterisk come to kamailio with </div><div>furi(Asterisk_clinet_local_number@asterisk)</div><div>turi(external_number@kamailio)</div><div><br></div><div>Then, to forward INVITE to provider that Needed I use some manipulations to choose provider (it does not matter, it is only sql_queryes to some tables), and then modify invite with this code:</div>
<div><br></div><div>#$var(prov) - my.provider.ip</div><div>#$var(trunk) - name_of_trunk </div><div><br></div><div>$rd=$var(prov);</div><div>$rp="5060";</div><div><span class="" style="white-space:pre">                        </span></div>
<div>$fU=$var(trunk);</div><div>$fd=$var(prov);</div><div>$td=$var(prov);</div><div><br></div><div>remove_hf("Contact");</div><div>append_hf("Contact:<$var(trunk)@my.kamailio.domain:5068>\n","Contact");</div>
<div><br></div><div><br></div><div>So -after this manipulation I have write packet, that goues to my provider.</div><div><br></div><div>Then Provier sends me 407 answer and packet goes to failure_route</div><div><br></div>
<div>if (t_check_status("401|407")){</div><div>        xlog("L_INFO", "Reply from provider on failure: $rs");</div><div>        </div><div>        if  (uac_auth()){</div><div>                     #my query to get avp for uac</div>
<div>                     #modparam("uac","auth_realm_avp","$avp(s:realm)")</div><div>                     #modparam("uac","auth_username_avp","avp(s:uname)")</div>
<div>                     #modparam("uac","auth_password_avp","$avp(s:passwd))") </div><div><span class="" style="white-space:pre">                                       </span> </div><div><span class="" style="white-space:pre">                                 </span> sql_pvquery("ca","select auth_username, auth_password, realm from uacreg where auth_username='$fU'","$var(uname), $var(passwd), $var(realm)");        </div>
<div><span class="" style="white-space:pre">    </span>                 xlog("L_INFO", "username=$var(uname), password=$var(passwd), realm=$var(realm) for {$fU}");</div><div><br></div><div><span class="" style="white-space:pre">                </span>pv_printf("$avp(s:uname)","$var(uname)");</div>
<div>                      pv_printf("$avp(s:passwd)","$var(passwd)");</div><div>                      pv_printf("$avp(s:realm)","$var(realm)");</div><div><span class="" style="white-space:pre">                                        </span> </div>
<div><br></div><div>                      xlog("L_INFO", "UAC_AUTH(): $rs"); </div><div>                       append_branch();</div><div>                       t_relay();</div><div>        </div><div>
            }</div><div>        }</div><div><span class="" style="white-space:pre"> </span>if (t_is_canceled()) {</div><div><span class="" style="white-space:pre">             </span>exit;</div><div><span class="" style="white-space:pre">      </span>}</div>
<div><span class="" style="white-space:pre">    </span></div><div><span class="" style="white-space:pre">   </span>So After changes Before Provider answer 407 my $fU = name_of_trunk, but at failure route my fU is Asterisk_clinet_local_number and it so strange because I see this packet at TCPDUMP and it have trunkname at fU</div>
<div>Because of It I can not take from table needed vars for auth and avp`s Have 0.</div><div><br></div><div>So packet for Auth (407) goes to Asterisk (with trunkname!!!! at fU), but t must stops at kamailio and must be ralayed to provider.</div>
<div><br></div><div>So this my problem- I can not understand: Why fU at reply 407 have old parameters?</div><br><br></div></div></div>