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.49k stars 1.4k forks source link

wrong format sip header of "Reason" to send 18x. #1571

Open jkkj1630 opened 2 years ago

jkkj1630 commented 2 years ago

i try to send a 183 message with nua_respond,i want push a reason header there,like this

               nua_respond(tech_pvt->nh,
                      send_sip_code, p_send_sip_msg,
                      NUTAG_AUTOANSWER(0),
                      TAG_IF(sticky, NUTAG_PROXY(tech_pvt->record_route)),
                      TAG_IF(cid, SIPTAG_HEADER_STR(cid)),
                      SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
                      SOATAG_REUSE_REJECTED(1),
                      SOATAG_RTP_SELECT(1),
                      SOATAG_ADDRESS(tech_pvt->mparams.adv_sdp_audio_ip),
                      TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
                      TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
                      TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
                             SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)),

                      TAG_IF(reason, SIPTAG_REASON_STR("SIP;cause=486;text=\"user busy\",Q.850;cause=17")),      // <----- this reason

                      TAG_IF(!zstr(session_id_header), SIPTAG_HEADER_STR(session_id_header)),
                      TAG_END());

This is what i'm hoping for: SIP/2.0 183 Session Progress Via: SIP/2.0/UDP 0.0.0.0;branch=z9hG4bKmc088272DFSSg;received=0.0.0.0;rport=5060 <sip:0.0.0.0;lr;vsf=AAAAABoNBQAGAgkKCAENeQwachsfBBwfBwAXMTI5;vst=AAAAABoPAQAHBAcCAQ4BcgkDbgAEHh8FBB4fBQIdCwcDNjA7dmlkZW8-> Call-ID: bccf3d78-1bc0-123b-4f8e-286ed488c9b2 From: sip:+xxxxxxx@0.0.0.0;tag=2U6peQZFH138a To: sip:+xxxxxxx@0.0.0.0;tag=0012-126431-90ee161f42fec754 CSeq: 48941723 INVITE Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,UPDATE,PRACK,REFER,SUBSCRIBE,NOTIFY,MESSAGE Contact: Require: 100rel RSeq: 2 Reason: SIP;cause=486;text="user busy",Q.850;cause=17 <---------------Reason header style P-Early-Media: sendrecv P-Asserted-Service-Info: vrbt=10 Content-Length: 0

But that's what happened: SIP/2.0 183 Session Progress Via: SIP/2.0/UDP 0.0.0.0;branch=z9hG4bKmc088272DFSSg;received=0.0.0.0;rport=5060 <sip:0.0.0.0;lr;vsf=AAAAABoNBQAGAgkKCAENeQwachsfBBwfBwAXMTI5;vst=AAAAABoPAQAHBAcCAQ4BcgkDbgAEHh8FBB4fBQIdCwcDNjA7dmlkZW8-> Call-ID: bccf3d78-1bc0-123b-4f8e-286ed488c9b2 From: sip:+xxxxxxx@0.0.0.0;tag=2U6peQZFH138a To: sip:+xxxxxxx@0.0.0.0;tag=0012-126431-90ee161f42fec754 CSeq: 48941723 INVITE Allow: INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,UPDATE,PRACK,REFER,SUBSCRIBE,NOTIFY,MESSAGE Contact: Require: 100rel RSeq: 2 Reason: SIP;cause=486;text="user busy" <-----------------Reason header style Reason: Q.850;cause=17 <-----------------Reason header style P-Early-Media: sendrecv P-Asserted-Service-Info: vrbt=10 Content-Length: 0

I tried different approaches, but the effect was always the same: SIPTAG_HEADER_STR("Reason: SIP;cause=486;text=\"user busy\",Q.850;cause=17") SIPTAG_REASON_STR("SIP;cause=486;text=\"user busy\",Q.850;cause=17") SIPTAG_REASON_STR("SIP;cause=486;text=\"user busy\"\x2cQ.850;cause=17") SIPTAG_REASON(sip_reason_make(nua_handle_get_home(tech_pvt->nh), "SIP;cause=486;text=\"user busy\",Q.850;cause=17"))

They sliced up my string,two reason were sent separately,whether sofia can achieve the effect I want?

nttranbao commented 2 years ago

I think FS is doing correctly here, as per rfc3326 -> section 2.

https://datatracker.ietf.org/doc/html/rfc3326 A SIP message MAY contain more than one Reason value (i.e., multiple Reason lines), but all of them MUST have different protocol values (e.g., one SIP and another Q.850). An implementation is free to ignore Reason values that it does not understand.