[asterisk-bugs] [JIRA] (ASTERISK-24541) Code that adds Required: timers to a 200 OK response will not work

David Woolley (JIRA) noreply at issues.asterisk.org
Thu Nov 20 11:11:29 CST 2014


    [ https://issues.asterisk.org/jira/browse/ASTERISK-24541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=223645#comment-223645 ] 

David Woolley commented on ASTERISK-24541:
------------------------------------------

Although I checked this on the branch 13 SVN, this appears to exist in all supported versions.

This is the original email to asterisk-dev, and Mark Michelson's response <[http://lists.digium.com/pipermail/asterisk-dev/2014-November/071396.html]>:

{quote}I don’t believe that the code that adds Required: timers to a 200 OK response will work, even in Asterisk 13, current branch version.
 
In my back port, it produces an error saying headers cannot be added after lines have been added.  The same conditions for this seem to apply in version 13:
 
In add_header:
 
{code}
        if (req->lines) {
               ast_log(LOG_WARNING, "Can't add more headers when lines have been added\n");
               return -1;
        }
{code} 
 
 
In transmit_response_with_sdp:
 
{code}
        if (p->rtp) {
...
               if (p->t38.state == T38_ENABLED) {
                       add_sdp(&resp, p, oldsdp, TRUE, TRUE);
               } else {
                       add_sdp(&resp, p, oldsdp, TRUE, FALSE);
               }
        } else
               ast_log(LOG_ERROR, "Can't add SDP to response, since we have no RTP session allocated. Call-ID %s\n", p->callid);
        if (reliable && !p->pendinginvite)
               p->pendinginvite = seqno;             /* Buggy clients sends ACK on RINGING too */
            add_required_respheader(&resp);
{code} 
 
Note that SDP is added, and therefore “req->lines” becomes non-zero, as the response now has a body, before add_required_respheader is called.
 
In add_required_respheader:
 
{code}
        if (ast_str_strlen(str) > 0) {
               add_header(req, "Require", ast_str_buffer(str));
        }
{code} 
 
For information, the test setup for this was two Asterisk instances in tandem.  The first one uses session-timers=originate.  The second one uses sendrpid=true, session-timers=accept and session-refresher=uas.  The dialplan (after a delay) sets the connected line, to force a re-invite against the call setup direction (then goes into a long wait).  As the first Asterisk is UAS for the re-invite, but is in session timer originate mode, it is forced to use Require.  The test was trying to confirm that session timer role reversals worked.

---------

{color:green}
Agreed that this looks like a bug. Probably should be doing the add_required_respheader() call before adding the SDP.
{color}
{quote}

> Code that adds Required: timers to a 200 OK response will not work
> ------------------------------------------------------------------
>
>                 Key: ASTERISK-24541
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-24541
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Channels/chan_sip/General
>    Affects Versions: SVN
>            Reporter: David Woolley
>            Severity: Minor
>
> "Required:" headers fail to be added for UAS mode handling of session-timers=originate.  Instead "WARNING: Can't add more headers when lines have been added" is generated.
> This is because transmit_response_with_sdp calls add_required_respheader after it has called add_sdp.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list