<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"><span>Hi all,</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>I have small issue when i am trying to handle extra register with another server.&nbsp;</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color:
 rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>Let me explain my idea.</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span>First : when xlite(192.168.1.158) send REGISTER message to FS, it will store message (or something like that to recognize thread from xlite, but I dont know exactly which value will be stored in msg1).</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0);
 background-color: transparent; font-style: normal;"><span>Then, I will send one REGISTER message to another server (like asterisk (192.168.1.174)), and when asterisk server return(100 first, then 401 include realm, nonce, auth_params), I need to store message thread like the first one (to reused like msg2), then, i will use nua_response to transfer 401 message to xlite(with realm, nonce).&nbsp;</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Then I can do the same when i get REGISTER message (with password in md5) from xlite and forwarding to asterisk server for authen.</div><div style="font-family: 'times new roman', 'new york', times, serif;
 font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">So, I have try to store message in to msg_t variable but i get error 500 -&nbsp;Responding to a Non-Existing Request when try to send back 401 with realm, nonce to xlite.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">I have used this function to store msg to one variable:</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent;
 font-style: normal;"><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">(in &nbsp;function sofia.c/sofia_event_callback )</div><div style="background-color: transparent;"><div style="background-color: transparent;">if(event == nua_i_register){</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg1 = de-&gt;data-&gt;e_msg ;</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "tnt: done store msg1 into catche \n");</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; if (event == nua_r_register){</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; msg2 = de-&gt;data-&gt;e_msg ;</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "tnt: done store msg2 into catche \n");</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;">and send back 401 like:</div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;"><br></div><div><div>case nua_r_register:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "nua_r_register : process
 handler ===========&gt;&gt;&gt;&gt;&gt; \n ");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (status == 401 || status == 407){</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sip_www_authenticate_t const* www_auth = sip-&gt;sip_www_authenticate;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char const* scheme = www_auth-&gt;au_scheme;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const char* realm = msg_params_find( www_auth-&gt;au_params, "realm=" );</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const char* nonce = msg_params_find( www_auth-&gt;au_params, "nonce=" );</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char *auth_str;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; auth_str = switch_mprintf("%s realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", scheme,realm, nonce," stale=true,");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS_MSG(msg2), SIPTAG_WWW_AUTHENTICATE_STR(auth_str), TAG_END());</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-family: 'times new
 roman', 'new york', times, serif; font-size: 16px; font-style: normal;">I am new in this and need your help, please suggest or reference some link that i can get it work,</div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal;">thank all in advance.</div></div></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">&nbsp;</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;">ThanhTruong</div></div></body></html>