[Freeswitch-dev] store message thread for handling extra register.

ThanhTruong ngoc217thanh at yahoo.com
Thu Jun 20 08:39:13 MSD 2013


Hi all,

I have small issue when i am trying to handle extra register with another server. 

Let me explain my idea.

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).

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). 

Then I can do the same when i get REGISTER message (with password in md5) from xlite and forwarding to asterisk server for authen.

So, I have try to store message in to msg_t variable but i get error 500 - Responding to a Non-Existing Request when try to send back 401 with realm, nonce to xlite.

I have used this function to store msg to one variable:

(in  function sofia.c/sofia_event_callback )
if(event == nua_i_register){
                msg1 = de->data->e_msg ;
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "tnt: done store msg1 into catche \n");
        }
        if (event == nua_r_register){
                msg2 = de->data->e_msg ;
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "tnt: done store msg2 into catche \n");
        }

and send back 401 like:

case nua_r_register:
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "nua_r_register : process handler ===========>>>>> \n ");
                if (status == 401 || status == 407){
                        sip_www_authenticate_t const* www_auth = sip->sip_www_authenticate;
                        char const* scheme = www_auth->au_scheme;
                        const char* realm = msg_params_find( www_auth->au_params, "realm=" );
                        const char* nonce = msg_params_find( www_auth->au_params, "nonce=" );
                        char *auth_str;
                        auth_str = switch_mprintf("%s realm=\"%q\", nonce=\"%q\",%s algorithm=MD5, qop=\"auth\"", scheme,realm, nonce," stale=true,");
                        nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS_MSG(msg2), SIPTAG_WWW_AUTHENTICATE_STR(auth_str), TAG_END());

                        break;
                }
                break;


I am new in this and need your help, please suggest or reference some link that i can get it work,

thank all in advance.
 
ThanhTruong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20130619/dd2dc178/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list