Hello everybody,

My SIP vendor request me to replace FROM before sending the traffic. In order to achieve this I use uac_replace_from.

UAC module is setup in restore_mode = auto.

In my insfrastructure I have an Asterisk and then a Kamailio that connects to vendor via internet.

Softphone -> Asterisk -> Kamailio -> Internet -> SIP vendor

If caller ID is setup in Asterisk using CALLERID(num)=34888888888 and then INVITE is forwarded to Kamailio, the call is established and finished correctly but the URI in TO field in BYE request from Kamailio to Asterisk contains garbage. In the scenario the callee hangs up the call.

Example of TO Field with garbage: 34888888888 <sip:50026896@no{soy,ns^^>

What I do see is that the number "50026896" that is part of the URI is the same I use in:
uac_replace_from("50026896", "sip:50026896@sip.vendor.es");

Something else that I have found is that vsf field is the same in the INVITE and in the BYE.

----------------------------------------------------------------------------------------------------------------
2015/06/23 17:48:38.552442 192.168.0.2:5060 -> 192.168.0.1:5060
BYE sip:34888888888@192.168.0.1:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2;branch=z9hG4bKfb49.73c6517609cdb6f7ec00b1f40a05dbe9.0
Via: SIP/2.0/UDP 8.8.8.8.8;rport=5060;branch=z9hG4bKfcdf.3767c59c2d0e3d8ab695669845ce4cea.0
branch=z9hG4bK04boo6104o5hcso0c2a1sd0000g00.1
Call-ID: 4bf8effb45b0ae8e049366297924cbba@192.168.0.1:5060
From: <sip:28999999999@192.168.0.2;tag=k0eci3x3-CC-30
To: 34888888888 <sip:50026896@no{soy,ns^^>;tag=as041b7d84
CSeq: 1 BYE
Reason: Q.850;cause=16;text="normal call clearing"
Max-Forwards: 67
Content-Length: 0

------------------------------------------------------------------------------------------------------------------
DEBUG: uac [replace.c:525]: restore_uri(): getting 'vsf' Route param
DEBUG: uac [replace.c:533]: restore_uri(): route param is 'AAAAAAEECQkCAgsNAXBeL0NGQUsfVl02Ni44Mw--' (len=40)
DEBUG: uac [replace.c:607]: restore_uri(): decoded uris are: new=[sip:50026896@no{soy,ns#005#007] old=[sip:34888888888@8.8.8.8]
DEBUG: uac [replace.c:525]: restore_uri(): getting 'vst' Route param
DEBUG: uac [replace.c:533]: restore_uri(): route param is 'AAAAAAQPAw8MDgsAAHZBKRVdAhoVHQ4XH1BdYWJhbnRlLmVz' (len=48)
DEBUG: uac [replace.c:607]: restore_uri(): decoded uris are: new=[sip:28999999999@192.168.0.1] old=[sip:999999999@sip.vendor.es]
-----------------------------------------------------------------------------------------------------------------------------------