Changeset 1026


Ignore:
Timestamp:
Mar 1, 2007 6:39:37 PM (18 years ago)
Author:
bennylp
Message:

Fixed ticket #153: UAC dialog doesn't update route_set when calling RFC 2543 UAS (thanks Binu K S)

File:
1 edited

Legend:

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

    r995 r1026  
    15161516} 
    15171517 
     1518/* Update route-set from incoming message */ 
     1519static void dlg_update_routeset(pjsip_dialog *dlg, const pjsip_msg *msg) 
     1520{ 
     1521    const pjsip_hdr *hdr, *end_hdr; 
     1522 
     1523    pj_list_init(&dlg->route_set); 
     1524 
     1525    end_hdr = &msg->hdr; 
     1526    for (hdr=msg->hdr.prev; hdr!=end_hdr; hdr=hdr->prev) { 
     1527        if (hdr->type == PJSIP_H_RECORD_ROUTE) { 
     1528            pjsip_route_hdr *r; 
     1529            r = pjsip_hdr_clone(dlg->pool, hdr); 
     1530            pjsip_routing_hdr_set_route(r); 
     1531            pj_list_push_back(&dlg->route_set, r); 
     1532        } 
     1533    } 
     1534} 
     1535 
    15181536/* This function is called by user agent upon receiving incoming response 
    15191537 * message. 
     
    15221540{ 
    15231541    unsigned i; 
     1542    pj_bool_t routeset_updated = PJ_FALSE; 
    15241543    int res_code; 
    15251544 
     
    15591578         pj_strcmp(&dlg->remote.info->tag, &rdata->msg_info.to->tag))) 
    15601579    { 
    1561         pjsip_hdr *hdr, *end_hdr; 
    15621580        pjsip_contact_hdr *contact; 
    15631581 
     
    15751593         * route set for future requests in this dialog. 
    15761594         */ 
    1577         pj_list_init(&dlg->route_set); 
    1578  
    1579         end_hdr = &rdata->msg_info.msg->hdr; 
    1580         for (hdr=rdata->msg_info.msg->hdr.prev; hdr!=end_hdr; hdr=hdr->prev) { 
    1581             if (hdr->type == PJSIP_H_RECORD_ROUTE) { 
    1582                 pjsip_route_hdr *r; 
    1583                 r = pjsip_hdr_clone(dlg->pool, hdr); 
    1584                 pjsip_routing_hdr_set_route(r); 
    1585                 pj_list_push_back(&dlg->route_set, r); 
    1586             } 
    1587         } 
     1595        dlg_update_routeset(dlg, rdata->msg_info.msg); 
     1596        routeset_updated = PJ_TRUE; 
    15881597 
    15891598        /* The remote target MUST be set to the URI from the Contact header  
     
    16111620    /* Update remote target (again) when receiving 2xx response messages 
    16121621     * that's defined as target refresh.  
     1622     * 
     1623     * Also upon receiving 2xx response, recheck again the route set. 
     1624     * This is for compatibility with RFC 2543, as described in Section 
     1625     * 13.2.2.4 of RFC 3261: 
     1626 
     1627        If the dialog identifier in the 2xx response matches the dialog 
     1628        identifier of an existing dialog, the dialog MUST be transitioned to 
     1629        the "confirmed" state, and the route set for the dialog MUST be 
     1630        recomputed based on the 2xx response using the procedures of Section 
     1631        12.2.1.2.  
     1632 
     1633        Note that the only piece of state that is recomputed is the route 
     1634        set.  Other pieces of state such as the highest sequence numbers 
     1635        (remote and local) sent within the dialog are not recomputed.  The 
     1636        route set only is recomputed for backwards compatibility.  RFC 
     1637        2543 did not mandate mirroring of the Record-Route header field in 
     1638        a 1xx, only 2xx. 
    16131639     */ 
    16141640    if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) && 
     
    16231649            dlg->target = dlg->remote.contact->uri; 
    16241650        } 
     1651 
     1652        if (!routeset_updated) { 
     1653            dlg_update_routeset(dlg, rdata->msg_info.msg); 
     1654            routeset_updated = PJ_TRUE; 
     1655        } 
    16251656    } 
    16261657 
Note: See TracChangeset for help on using the changeset viewer.