Hello Freeswitch-users! I'm currently writing a SIP middlebox that intercepts sip messages and changes their username. The reasons for this are complicated and somewhat outside of the scope of this discussion. However, I've come upon a very strange issue: when making a phone-to-phone call across freeswitch; it is connecting the wrong user. I'm fairly well convinced this is a bug, but I thought I'd send the issue here and see if it's anything I'm obviously doing wrong. Basically, FS sees a SIP message from a registered UA (call it A) inviting another registered user to a call (B). This is acked correctly (a TRYING message). FS then responds by inviting B into a call with some OTHER user C. C is not mentioned at any point in the initial SIP messages (as verified by wireshark). Even more strangely, if I remove user C from FS (by removing their config file) FS responds to the invite by inviting B into a call with itself. In each case, the appropriate from header in the invite should be the original caller A. It's worth noting that I am not monkeying with the RTP packets at all, but my understanding is that SIP signalling shouldn't be affected by that. My general guess is that I'm messing up the naming somehow, and FS is running an algorithm to guess at who the call originator is. However, the naming must be roughly correct; Asterisk is able to handle this call just fine. I've included a sip trace of the second situation (A calls B, FS invites B to a call with itself) For the record A:1300 B:1301 C:IMSI641104878332498 REGISTER MESSAGE (Which works fine) REGISTER sip:192.168.1.144 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.144:5063;branch=z9hG4bK13347 Via: SIP/2.0/UDP 192.168.1.144:5063;branch=z9hG4bK13347 From: 1300 <sip:1300@192.168.1.144>;tag=ftoui To: 1300 <sip:1300@192.168.1.144> Call-ID: 1032827938@192.168.1.144 CSeq: 91 REGISTER Contact: <sip:1300@192.168.1.144:5063>;expires=7200 Max-Forwards: 70 Content-Length: 0 SIP/2.0 200 OK Via: SIP/2.0/UDP 192.168.1.144:5063;branch=z9hG4bK13347 Via: SIP/2.0/UDP 192.168.1.144:5063;branch=z9hG4bK13347 From: 1300 <sip:1300@192.168.1.144>;tag=ftoui To: 1300 <sip:1300@192.168.1.144>;tag=jU64NXypQc57F Call-ID: 1032827938@192.168.1.144 CSeq: 91 REGISTER Contact: <sip:1300@192.168.1.144:5063>;expires=7200 Date: Wed, 08 Jun 2011 21:02:04 GMT User-Agent: FreeSWITCH-mod_sofia/1.0.head-git-71d64e6 2011-06-07 22-30-16 -0700 Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, UPDATE, INFO, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, precondition, path, replaces Content-Length: 0 SIP TRACE (A -> B, B -> B response) INITIAL INVITE INVITE sip:1301@192.168.1.144 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.144:5063;branch=z9hG4bK77974 From: 1300 <sip:1300@192.168.1.144>;tag=bgdqx To: <sip:1301@192.168.1.144> Call-ID: 1817795092@192.168.1.144 CSeq: 485 INVITE Contact: <sip:1300@192.168.1.144:5063>;expires=3600 Content-Type: application/sdp Max-Forwards: 70 Content-Length: 143 INVITE ACK SIP/2.0 100 Trying Via: SIP/2.0/UDP 192.168.1.144:5063;branch=z9hG4bK77974 From: 1300 <sip:1300@192.168.1.144>;tag=bgdqx To: <sip:1301@192.168.1.144> Call-ID: 1817795092@192.168.1.144 CSeq: 485 INVITE User-Agent: FreeSWITCH-mod_sofia/1.0.head-git-71d64e6 2011-06-07 22-30-16 -0700 Content-Length: 0 FS INVITE (Note the from address being wrong) INVITE sip:1301@192.168.1.144:5063 SIP/2.0 Via: SIP/2.0/UDP 192.168.1.144;rport;branch=z9hG4bKeeQvcyZ70SDUg Max-Forwards: 69 From: "1301" <sip:1301@192.168.1.144>;tag=rHyS0Z3B61arN To: <sip:1301@192.168.1.144:5063> Call-ID: 84df47f9-0cb7-122f-13b5-5cff350d9de5 CSeq: 13447852 INVITE Contact: <sip:mod_sofia@192.168.1.144:5060> User-Agent: FreeSWITCH-mod_sofia/1.0.head-git-71d64e6 2011-06-07 22-30-16 -0700 Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, UPDATE, INFO, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, precondition, path, replaces Allow-Events: talk, hold, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 315 X-FS-Support: update_display Remote-Party-ID: "1301" <sip:1301@192.168.1.144>;party=calling;screen=yes;privacy=off USER CONFIGURATIONS 1300.xml <include> <user id="1300" cidr="192.168.1.0/24,127.0.0.1/32"> <params> <param name="accept-blind-reg" value="true"/> <param name="accept-blind-auth" value="true"/> <param name="vm-password" value="1000"/> </params> <variables> <variable name="toll_allow" value="domestic,international,local"/> <variable name="accountcode" value="1300"/> <variable name="user_context" value="default"/> <variable name="effective_caller_id_name" value="1300"/> <variable name="effective_caller_id_number" value="1300"/> <variable name="outbound_caller_id_name" value="1300"/> <variable name="outbound_caller_id_number" value="1300"/> <variable name="callgroup" value="techsupport"/> </variables> </user> </include> 1301.xml <include> <user id="1301" cidr="192.168.1.0/24,127.0.0.1/32"> <params> <param name="accept-blind-reg" value="true"/> <param name="accept-blind-auth" value="true"/> <param name="vm-password" value="1000"/> </params> <variables> <variable name="toll_allow" value="domestic,international,local"/> <variable name="accountcode" value="1301"/> <variable name="user_context" value="default"/> <variable name="effective_caller_id_name" value="1301"/> <variable name="effective_caller_id_number" value="1301"/> <variable name="outbound_caller_id_name" value="1301"/> <variable name="outbound_caller_id_number" value="1301"/> <variable name="callgroup" value="techsupport"/> </variables> </user> </include> IMSI641104878332498.xml <include> <user id="IMSI641104878332498" cidr="192.168.1.0/24,127.0.0.1/32" number-alias="1302"> <params> <param name="accept-blind-reg" value="true"/> <param name="accept-blind-auth" value="true"/> <param name="vm-password" value="1000"/> </params> <variables> <variable name="toll_allow" value="domestic,international,local"/> <variable name="accountcode" value="1302"/> <variable name="user_context" value="default"/> <variable name="effective_caller_id_name" value="IMSI641104878332498"/> <variable name="effective_caller_id_number" value="1302"/> <variable name="outbound_caller_id_name" value="IMSI641104878332498"/> <variable name="outbound_caller_id_number" value="1302"/> <variable name="callgroup" value="techsupport"/> </variables> </user> </include> DIALPLAN <extension name="Local Numbers"> <condition field="destination_number" expression="^130[0-9]$"> <!--<action application="bridge" data="user/${user_data(${destination_number}@${domain_name} attr id)}"/> --> <action application="bridge" data="user/${destination_number}"/> </condition> </extension>