[asterisk-dev] Adding Required header to OK response will fail.

Dave WOOLLEY dave.woolley at bts.co.uk
Thu Nov 13 12:34:34 CST 2014


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:

        if (req->lines) {
               ast_log(LOG_WARNING, "Can't add more headers when lines have been added\n");
               return -1;
        }



In transmit_response_with_sdp:

        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);


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:


        if (ast_str_strlen(str) > 0) {

               add_header(req, "Require", ast_str_buffer(str));

        }


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.

BTS Holdings PLC - Registered office: BTS House, Manor Road, Wallington, SM6 0DD - Registered in England: 1517630
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141113/b5611251/attachment.html>


More information about the asterisk-dev mailing list