[asterisk-dev] Transfer cmd (PJSIP not sending Referred-By but chan_sip does)

Dan Cropp dan at amtelco.com
Tue Aug 25 12:35:47 CDT 2015


In doing a little research, it seems the Referred-By header could be added after the pjsip_xfer_initiate.

This is the approach PJSIP did for some code as far back as PJSIP 1.6.



    /*

     * Create REFER request.

     */

    status = pjsip_xfer_initiate(sub, dest, &tdata);

    if (status != PJ_SUCCESS) {

                pjsua_perror(THIS_FILE, "Unable to create REFER request", status);

                pjsip_dlg_dec_lock(dlg);

                return status;

    }



    /* Add Referred-By header */

    gs_hdr = pjsip_generic_string_hdr_create(tdata->pool, &str_ref_by,

                                                                                     &dlg->local.info_str);

    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)gs_hdr);





    /* Add additional headers etc */

    pjsua_process_msg_data( tdata, msg_data);



    /* Send. */

    status = pjsip_xfer_send_request(sub, tdata);

    if (status != PJ_SUCCESS) {

                pjsua_perror(THIS_FILE, "Unable to send REFER request", status);

                pjsip_dlg_dec_lock(dlg);

                return status;

    }



Could anyone provider some insight into how difficult this might be for me to add and submit for approval?  Depending on the answer, my manager may be willing to let me work on this.

I've developed in C/C++ for over 25 years so I'm plenty familiar with the language.

I'm less familiar with the syntax and coding standards of Asterisk.  I know the group is very good at letting people know about their mistakes and how to fix them.



Have a great day!
Dan

From: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Dan Cropp
Sent: Tuesday, August 25, 2015 10:50 AM
To: Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] Transfer cmd (PJSIP not sending Referred-By but chan_sip does)

Thank you Mark

From: asterisk-dev-bounces at lists.digium.com<mailto:asterisk-dev-bounces at lists.digium.com> [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Mark Michelson
Sent: Tuesday, August 25, 2015 10:30 AM
To: Asterisk Developers Mailing List
Subject: Re: [asterisk-dev] Transfer cmd (PJSIP not sending Referred-By but chan_sip does)

The answer to this is actually pretty simple: adding Referred-By in outgoing SIP REFERs is simply not implemented in chan_pjsip's chan_pjsip_transfer() function.

As far as the syntax required for the Transfer() application, that's probably a case where that needs to be clarified in documentation. There are lots of places in PJSIP configuration where we require full SIP URIs rather than just IP addresses or bare URIs (user at domain).

On 08/25/2015 10:00 AM, Dan Cropp wrote:
I asked the question on asterisk-users but did not receive a response, so I am sending the question here.

I am running Asterisk 13.5.0.

A call comes in, Asterisk answers it.  After some actions, the call needs to be Transferred (SIP REFER) to another number.  The other switch is responsible for accepting the Transfer and tromboning the lines internally.  It will also send a BYE so Asterisk no longer has the call.

The behavior works when I have the endpoint configured at chan_sip.  It does not work when the endpoint is configured as PJSIP.  I worked with the other switch vendor and he determined chan_sip includes the Referred-By header.  PJSIP does not include the Referred-By header.  The other switch requires the Referred-By header to be present.

I tried setting the channel's SIPREFERREDBYHDR variable before the Transfer command and that still did not force the Referred-By header to be part of the REFER packet.
I tried the PJSIP_HEADER add and it still did not add the Referred-By header to the REFER packet.

Is there a PJSIP setting to force the Referred-By to be part of the REFER packet?

chan_sip (succeeds)
19:27:32.512123 IP (tos 0x0, ttl 64, id 11492, offset 0, flags [none], proto UDP (17), length 630)
    192.168.xxx.xxx.sip > 192.168.yyy.yyy.sip: SIP, length: 602
        REFER sip:3400 at 192.168.yyy.yyy:5060 SIP/2.0
        Via: SIP/2.0/UDP 192.168.xxx.xxx:5060;branch=z9hG4bK58f4bd1d
        Max-Forwards: 70
        From: <sip:3344 at 192.168.xxx.xxx>;tag=as44000cf4
        To: <sip:3400 at 192.168.yyy.yyy>;tag=7Iy0JkwDC
        Contact: <sip:3344 at 192.168.xxx.xxx:5060>
        Call-ID: jdEuqpAK-0002- at 192.168.yyy.yyy<mailto:jdEuqpAK-0002- at 192.168.yyy.yyy>
        CSeq: 102 REFER
        User-Agent: Asterisk PBX 13.5.0
        Date: Thu, 20 Aug 2015 19:27:32 GMT
        Refer-To: <sip:370 at 192.168.yyy.yyy>
        Referred-By: <sip:3344 at 192.168.xxx.xxx:5060>
        Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
        Supported: replaces, timer
        Content-Length: 0

Pjsip
18:46:58.386372 IP (tos 0x0, ttl 64, id 38690, offset 0, flags [DF], proto UDP (17), length 654)
    192.168.xxx.xxx.sip > 192.168.yyy.yyy.sip: SIP, length: 626
        REFER sip:3400 at 192.168.yyy.yyy:5060 SIP/2.0
        Via: SIP/2.0/UDP 192.168.xxx.xxx:5060;rport;branch=z9hG4bKPjec41c3b9-d734-482d-82c1-2a6f8d9452a3
        From: <sip:3344 at 192.168.xxx.xxx>;tag=3c10f423-e468-42ea-87a1-658ae106581c
        To: <sip:3400 at 192.168.yyy.yyy>;tag=WITKDakt
        Contact: <sip:192.168.xxx.xxx:5060>
        Call-ID: s6Wk6l6Q-0001- at 192.168.yyy.yyy<mailto:s6Wk6l6Q-0001- at 192.168.yyy.yyy>
        CSeq: 981 REFER
        Event: refer
        Expires: 600
        Supported: 100rel, timer, replaces, norefersub
        Accept: message/sipfrag;version=2.0
        Allow-Events: message-summary, presence, dialog, refer
        Refer-To: <sip:370 at 192.168.yyy.yyy>
        Max-Forwards: 70
        User-Agent: Asterisk PBX 13.5.0
        Content-Length:  0



One other slight oddity.
To get chan_sip to Transfer
370 at 192.168.yyy.yyy<mailto:370 at 192.168.yyy.yyy>

To get PJSIP to Transfer with the correct Refer-To header, I had to include the <> and sip:
<sip:370 at 192.168.yyy.yyy>


Have a great day!
Dan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150825/dd04cb51/attachment.html>


More information about the asterisk-dev mailing list