signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.62k stars 1.43k forks source link

unexpected Route header formatting #756

Open sergey-safarov opened 4 years ago

sergey-safarov commented 4 years ago

I want to specify Route: header in originate command. Do this I execute the command:

originate {sip_invite_route_uri='sip:192.184.122.216;transport=tcp'}sofia/internal/sip:+12053782561@192.184.122.216 &park()

Here sip:192.184.122.216;transport=tcp is valid SIP URI. According to RFC3261 Route: header notation: 1) Route = "Route" HCOLON route-param (COMMA route-param) 2) route-param = name-addr ( SEMI rr-param ) 3) name-addr = [ display-name ] LAQUOT addr-spec RAQUOT 4) addr-spec = SIP-URI / SIPS-URI / absoluteURI

So RFC allow use Route header like

Route: sip:192.184.122.216;transport=tcp

When executes originate command (example above) FreeSwitch send INVITE like

send 1737 bytes to udp/[192.184.122.216]:5060 at 15:48:50.207158:
   ------------------------------------------------------------------------
   INVITE sip:+12053782561@192.184.122.216 SIP/2.0
   Via: SIP/2.0/UDP 192.168.2.10:5090;rport;branch=z9hG4bKryceZN0295rDB
   Route: <sip:192.184.122.216>;transport=tcp
   Max-Forwards: 70
   From: "" <sip:0000000000@192.168.2.10>;tag=rXt77HprtUcKQ
   To: <sip:+12053782561@192.184.122.216>
   Call-ID: 2ccaad43-4931-1239-cd93-94b86deaeed5
   CSeq: 23292273 INVITE
   Contact: <sip:mod_sofia@192.168.2.10:5090>
   User-Agent: FreeSWITCH-mod_sofia/1.8.5+git~20200708T015131Z~c01af08f60~64bit
   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
   Supported: timer, path, replaces
   Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
   Content-Type: application/sdp
   Content-Disposition: session
   Content-Length: 742
   X-FS-Support: update_display,send_info
   Remote-Party-ID: <sip:0000000000@192.168.2.10>;party=calling;screen=yes;privacy=off

So looks as FreeSwitch not properly format SIP URI. FreeSwitch format SIP URI from

sip:192.184.122.216;transport=tcp

To

<sip:192.184.122.216>;transport=tcp

And now string transport=tcp means rr-param instead of uri-parameter.

Why this important Router header we use to specify Kamailio which transport need use during SIP message routing. As FreeSwitch now lose uri-parameter (transport=tcp), then Kamailio not able set required transport for next hop.

Work around As workaround need to use name-addr instead of addr-spec. Example

originate {sip_invite_route_uri='<sip:192.184.122.216;transport=tcp>'}sofia/internal/sip:+12053782561@192.184.122.216 &park()
sergey-safarov commented 3 years ago

Example how maybe set multiple Route headers

originate {^^|sip_invite_route_uri='<sip:sbc-a0.nga911.com;lr;transport=tcp>,<sip:sbc-a1.nga911.com;lr;transport=tcp>'}sofia/sipinterface_1/sip:911@sbc-a1.nga911.com &park()