Hello,

try without restore_mode auto if you want that restore_dlg to be 1.

Cheers,
Daniel

On 05/11/15 18:00, Efelin Novak wrote:
Hi Folks,

I have a problem with To and From headers in 200 OK to BYE request. Their URI is doubled when leaving Kamailio.

Incoming 200 OK:
  From : <sip:00421111@IP_ADDRESS>;tag=as017a2986
  To : <sip:00421222@IP_ADDRESS0>;tag=K7ryDgH2g7gFm
Outgoing 200 OK:
  From : <sip:+421111@IP_ADDRESS><sip:+421111@IP_ADDRESS>;tag=as017a2986
  To : <sip:+421222@IP_ADDRESS><sip:+421222@IP_ADDRESS>;tag=K7ryDgH2g7gFm

I'm using uac module to replace these headers in auto and dialog mode:

modparam("uac", "restore_mode", "auto")
modparam("uac", "restore_dlg", 1)

append_fromtag is also set:

modparam("rr", "append_fromtag", 1)

When I run kamailio in debug mode I can see the function restore_uri_reply() is called twice:

.
.
.
 0(3133) DEBUG: <core> [parser/parse_via.c:1284]: parse_via_param(): Found param type 234, <received> = <IP_ADDRESS>; state=6
 0(3133) DEBUG: <core> [parser/parse_via.c:1284]: parse_via_param(): Found param type 232, <branch> = <z9hG4bK0bb8c5b2>; state=6
 0(3133) DEBUG: <core> [parser/parse_via.c:1284]: parse_via_param(): Found param type 235, <rport> = <5060>; state=16
 0(3133) DEBUG: <core> [parser/parse_via.c:2672]: parse_via(): end of header reached, state=5
 0(3133) DEBUG: <core> [parser/msg_parser.c:513]: parse_headers(): parse_headers: Via found, flags=62
 0(3133) DEBUG: <core> [parser/msg_parser.c:526]: parse_headers(): parse_headers: this is the second via
 0(3133) DEBUG: <core> [parser/parse_addr_spec.c:176]: parse_to_param(): DEBUG: add_param: tag=teHD72X67aQUm
 0(3133) DEBUG: <core> [parser/parse_addr_spec.c:898]: parse_addr_spec(): end of header reached, state=29
 0(3133) DEBUG: <core> [parser/msg_parser.c:190]: get_hdr_field(): DEBUG: get_hdr_field: <To> [60]; uri=[sip:421222@IP_ADDRESS:5060
 0(3133) DEBUG: <core> [parser/msg_parser.c:192]: get_hdr_field(): DEBUG: to body [<sip:421222@IP_ADDRESS:5060>]
 0(3133) DEBUG: <core> [parser/msg_parser.c:170]: get_hdr_field(): get_hdr_field: cseq <CSeq>: <103> <BYE>
 0(3133) DEBUG: tm [t_lookup.c:949]: t_reply_matching(): DEBUG: t_reply_matching: hash 10806 label 0 branch 0
 0(3133) DEBUG: tm [t_lookup.c:1004]: t_reply_matching(): DEBUG: t_reply_matching: reply matched (T=0x220071b4)!
 0(3133) DEBUG: tm [t_hooks.c:288]: run_trans_callbacks_internal(): DBG: trans=0x220071b4, callback type 2, id 0 entered
 0(3133) DEBUG: <core> [parser/parse_addr_spec.c:176]: parse_to_param(): DEBUG: add_param: tag=as46bccb83
 0(3133) DEBUG: <core> [parser/parse_addr_spec.c:898]: parse_addr_spec(): end of header reached, state=29
 0(3133) DEBUG: uac [replace.c:705]: restore_uri_reply(): removing <<sip:00421111@IP_ADDRESS>>
 0(3133) DEBUG: uac [replace.c:714]: restore_uri_reply(): inserting <<sip:+421111@IP_ADDRESS>>
 0(3133) DEBUG: uac [replace.c:705]: restore_uri_reply(): removing <<sip:00421222@IP_ADDRESS>>
 0(3133) DEBUG: uac [replace.c:714]: restore_uri_reply(): inserting <<sip:+421222@IP_ADDRESS>>
 0(3133) DEBUG: tm [t_hooks.c:288]: run_trans_callbacks_internal(): DBG: trans=0x220071b4, callback type 2, id 0 entered
 0(3133) DEBUG: uac [replace.c:705]: restore_uri_reply(): removing <<sip:00421111@IP_ADDRESS>>
 0(3133) DEBUG: uac [replace.c:714]: restore_uri_reply(): inserting <<sip:+421111@IP_ADDRESS>>
 0(3133) DEBUG: uac [replace.c:705]: restore_uri_reply(): removing <<sip:00421222@IP_ADDRESS>>
 0(3133) DEBUG: uac [replace.c:714]: restore_uri_reply(): inserting <<sip:+421222@IP_ADDRESS>>
.
.
.

I think the problem is in registering a function restore_uris_reply() in callbacks in functions (both in replace.c of uac module)
* void rr_checker(struct sip_msg *msg, str *r_param, void *cb_param)
* static void replace_callback(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params)

Both of these callbacks are registered for BYE and ACK requests (INVITE request is using different callback), therefore running restore_uri_reply() twice.
For testing purposes after I have removed the callback in rr_checker and recompile the uac module, To and From headers were OK.

In my configuration I'm calling uac_replace_to in RELAY route:
route[RELAY]
{

        if ( !has_totag() ) {
                dlg_manage();
                uac_replace_to("$ru");  
        }

        if (!t_relay())
        {
                sl_reply_error();
        }
}

So I think there is a bug in uac module, when one function is registered twice in callbacks for NON-INVITE requests. 

Or is there a problem with my configuration script?

Can anyone point me to the direction how to solve this issue?

Thank you

Efelin

Kamailio version: kamailio 4.4.0-dev6 (i386/linux) a66e22-dirty







_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com
Kamailio Advanced Training, Nov 30-Dec 2, Berlin - http://asipto.com/kat