[asterisk-bugs] [JIRA] (ASTERISK-26779) No Call transfer Possible using PJSIP and Compact SIP Headers
Peter Sokolov (JIRA)
noreply at issues.asterisk.org
Thu Feb 9 09:43:10 CST 2017
[ https://issues.asterisk.org/jira/browse/ASTERISK-26779?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Sokolov updated ASTERISK-26779:
-------------------------------------
Description:
When an endpoint using compact SIP headers tries to transfer a call using REFER, Asterisk/PJSIP rejects the request with 400 and shows the following DEBUG info although the "r:" header is present in the REFER request:
[Feb 9 13:15:44] DEBUG[2212]: res_pjsip_refer.c:1031 refer_incoming_refer_request: Received a REFER without Refer-To on channel 'PJSIP/132-00000003' from endpoint '132'
The same request works perfectly using chan_SIP. It turns out that Asterisk uses pjsip_msg_find_hdr_by_name function from sip_msg.c on many places to read SIP headers. However this function does not find headers which use compact names. In the case of call transfer using REFER, both "r:" and "b:" headers (Refer-To and Referred-By) are not found, causing the rejection of REFER. Call transfer fails.
The problem with REFER can be resolved easily by modifying the file /res/res_pjsip_refer.c in the following way (add lines with ++, remove those with --):
{code}
static const pj_str_t str_referred_by = { "Referred-By", 11 };
++ static const pj_str_t str_referred_by_short = { "b", 1 };
-- referred_by = pjsip_msg_find_hdr_by_name(refer->rdata->msg_info.msg, &str_referred_by, NULL);
++ referred_by = pjsip_msg_find_hdr_by_names(refer->rdata->msg_info.msg, &str_referred_by, &str_referred_by_short, NULL);
static const pj_str_t str_refer_to = { "Refer-To", 8 };
++ static const pj_str_t str_refer_to_short = { "r", 1 };
static const pj_str_t str_replaces = { "Replaces", 8 };
-- refer_to = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL);
++ refer_to = pjsip_msg_find_hdr_by_names(rdata->msg_info.msg, &str_refer_to, &str_refer_to_short, NULL);
{code}
Even though the call transfer problem is solved this way, the question remains, whether there are other places in Asterisk that need to be corrected in order to handle correctly SIP compact names, for example:
- Will reading a SIP header from dialplan return correct result when using long/compact name in the query while the received headers use the other type or even mixed long/compact types of the same header? For example reading the second Via: header in the case one of the proxies inserted a compact v: header.
- Will adding a header to a request overwrite an existing header with the same name in the case such one is present, but uses the opposite long/compact form?
- Are there other places using pjsip_msg_find_hdr_by_name thet read headers which can use compact form?
The list of IANA registered compact headers is available here:
http://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml
was:
When an endpoint using compact SIP headers tries to transfer a call using REFER, Asterisk/PJSIP rejects the request with 400 and shows the following DEBUG info although the "r:" header is present in the REFER request:
[Feb 9 13:15:44] DEBUG[2212]: res_pjsip_refer.c:1031 refer_incoming_refer_request: Received a REFER without Refer-To on channel 'PJSIP/132-00000003' from endpoint '132'
The same request works perfectly using chan_SIP. It turns out that Asterisk uses pjsip_msg_find_hdr_by_name function from sip_msg.c on many places to read SIP headers. However this function does not find headers which use compact names. In the case of call transfer using REFER, both "r:" and "b:" headers (Refer-To and Referred-By) are not found, causing the rejection of REFER. Call transfer fails.
The problem with REFER can be resolved easily by modifying the file /res/res_pjsip_refer.c in the following way (add lines with ++, remove those with --):
static const pj_str_t str_referred_by = { "Referred-By", 11 };
++ static const pj_str_t str_referred_by_short = { "b", 1 };
-- referred_by = pjsip_msg_find_hdr_by_name(refer->rdata->msg_info.msg, &str_referred_by, NULL);
++ referred_by = pjsip_msg_find_hdr_by_names(refer->rdata->msg_info.msg, &str_referred_by, &str_referred_by_short, NULL);
static const pj_str_t str_refer_to = { "Refer-To", 8 };
++ static const pj_str_t str_refer_to_short = { "r", 1 };
static const pj_str_t str_replaces = { "Replaces", 8 };
-- refer_to = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL);
++ refer_to = pjsip_msg_find_hdr_by_names(rdata->msg_info.msg, &str_refer_to, &str_refer_to_short, NULL);
Even though the call transfer problem is solved this way, the question remains, whether there are other places in Asterisk that need to be corrected in order to handle correctly SIP compact names, for example:
- Will reading a SIP header from dialplan return correct result when using long/compact name in the query while the received headers use the other type or even mixed long/compact types of the same header? For example reading the second Via: header in the case one of the proxies inserted a compact v: header.
- Will adding a header to a request overwrite an existing header with the same name in the case such one is present, but uses the opposite long/compact form?
- Are there other places using pjsip_msg_find_hdr_by_name thet read headers which can use compact form?
The list of IANA registered compact headers is available here:
http://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml
> No Call transfer Possible using PJSIP and Compact SIP Headers
> -------------------------------------------------------------
>
> Key: ASTERISK-26779
> URL: https://issues.asterisk.org/jira/browse/ASTERISK-26779
> Project: Asterisk
> Issue Type: Bug
> Security Level: None
> Components: Channels/chan_pjsip
> Affects Versions: 14.2.1
> Reporter: Peter Sokolov
>
> When an endpoint using compact SIP headers tries to transfer a call using REFER, Asterisk/PJSIP rejects the request with 400 and shows the following DEBUG info although the "r:" header is present in the REFER request:
>
> [Feb 9 13:15:44] DEBUG[2212]: res_pjsip_refer.c:1031 refer_incoming_refer_request: Received a REFER without Refer-To on channel 'PJSIP/132-00000003' from endpoint '132'
>
> The same request works perfectly using chan_SIP. It turns out that Asterisk uses pjsip_msg_find_hdr_by_name function from sip_msg.c on many places to read SIP headers. However this function does not find headers which use compact names. In the case of call transfer using REFER, both "r:" and "b:" headers (Refer-To and Referred-By) are not found, causing the rejection of REFER. Call transfer fails.
>
> The problem with REFER can be resolved easily by modifying the file /res/res_pjsip_refer.c in the following way (add lines with ++, remove those with --):
> {code}
> static const pj_str_t str_referred_by = { "Referred-By", 11 };
> ++ static const pj_str_t str_referred_by_short = { "b", 1 };
>
> -- referred_by = pjsip_msg_find_hdr_by_name(refer->rdata->msg_info.msg, &str_referred_by, NULL);
> ++ referred_by = pjsip_msg_find_hdr_by_names(refer->rdata->msg_info.msg, &str_referred_by, &str_referred_by_short, NULL);
>
> static const pj_str_t str_refer_to = { "Refer-To", 8 };
> ++ static const pj_str_t str_refer_to_short = { "r", 1 };
> static const pj_str_t str_replaces = { "Replaces", 8 };
>
> -- refer_to = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL);
> ++ refer_to = pjsip_msg_find_hdr_by_names(rdata->msg_info.msg, &str_refer_to, &str_refer_to_short, NULL);
> {code}
>
> Even though the call transfer problem is solved this way, the question remains, whether there are other places in Asterisk that need to be corrected in order to handle correctly SIP compact names, for example:
>
> - Will reading a SIP header from dialplan return correct result when using long/compact name in the query while the received headers use the other type or even mixed long/compact types of the same header? For example reading the second Via: header in the case one of the proxies inserted a compact v: header.
>
> - Will adding a header to a request overwrite an existing header with the same name in the case such one is present, but uses the opposite long/compact form?
>
> - Are there other places using pjsip_msg_find_hdr_by_name thet read headers which can use compact form?
>
> The list of IANA registered compact headers is available here:
> http://www.iana.org/assignments/sip-parameters/sip-parameters.xhtml
--
This message was sent by Atlassian JIRA
(v6.2#6252)
More information about the asterisk-bugs
mailing list