Changeset 3069


Ignore:
Timestamp:
Jan 21, 2010 5:07:28 PM (15 years ago)
Author:
bennylp
Message:

Fixed ticket #1030: Missing To tag in out-of-dialog response (thanks Rui Macedo for the report)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_util.c

    r2932 r3069  
    486486    pjsip_msg *msg, *req_msg; 
    487487    pjsip_hdr *hdr; 
    488     pjsip_via_hdr *via; 
     488    pjsip_to_hdr *to_hdr; 
     489    pjsip_via_hdr *top_via = NULL, *via; 
    489490    pjsip_rr_hdr *rr; 
    490491    pj_status_t status; 
     
    528529    via = rdata->msg_info.via; 
    529530    while (via) { 
    530         pjsip_msg_add_hdr( msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, via)); 
     531        pjsip_via_hdr *new_via; 
     532 
     533        new_via = (pjsip_via_hdr*)pjsip_hdr_clone(tdata->pool, via); 
     534        if (top_via == NULL) 
     535            top_via = new_via; 
     536 
     537        pjsip_msg_add_hdr( msg, (pjsip_hdr*)new_via); 
    531538        via = via->next; 
    532539        if (via != (void*)&req_msg->hdr) 
     
    559566 
    560567    /* Copy To header. */ 
    561     hdr = (pjsip_hdr*) pjsip_hdr_clone(tdata->pool, rdata->msg_info.to); 
    562     pjsip_msg_add_hdr( msg, hdr); 
     568    to_hdr = (pjsip_to_hdr*) pjsip_hdr_clone(tdata->pool, rdata->msg_info.to); 
     569    pjsip_msg_add_hdr( msg, (pjsip_hdr*)to_hdr); 
     570 
     571    /* Must add To tag in the response (Section 8.2.6.2), except if this is 
     572     * 100 (Trying) response. Same tag must be created for the same request 
     573     * (e.g. same tag in provisional and final response). The easiest way 
     574     * to do this is to derive the tag from Via branch parameter (or to 
     575     * use it directly). 
     576     */ 
     577    if (st_code > 100 && top_via) { 
     578        to_hdr->tag = top_via->branch_param; 
     579    } 
    563580 
    564581    /* Copy CSeq header. */ 
Note: See TracChangeset for help on using the changeset viewer.