Changeset 1077


Ignore:
Timestamp:
Mar 17, 2007 10:21:58 PM (13 years ago)
Author:
bennylp
Message:

Fixed ticket #186: Major bug with destination address calculation for strict route set (thanks Hoi-Ho Chan)

Location:
pjproject/branches/pjproject-0.5-stable/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjsip/include/pjsip/sip_util.h

    r974 r1077  
    173173 * chapter 8.1.2. 
    174174 * 
    175  * This function may modify the message (request line and Route headers), 
    176  * if the Route information specifies strict routing and the request 
    177  * URI in the message is different than the calculated target URI. In that 
    178  * case, the target URI will be put as the request URI of the request and 
    179  * current request URI will be put as the last entry of the Route headers. 
     175 * Note there was a change in the behavior of this function since version 
     176 * 0.5.10.2. Previously this function may modify the request when strict 
     177 * route is present (to update request URI and route-set). This is no 
     178 * longer the case now, and this process is done in separate function 
     179 * (see #pjsip_process_route_set()). 
    180180 * 
    181181 * @param tdata     The transmit data containing the request message. 
     
    187187 * 
    188188 * @return          PJ_SUCCESS, or the appropriate error code. 
    189  */ 
    190 PJ_DECL(pj_status_t) pjsip_get_request_addr( pjsip_tx_data *tdata, 
     189 * 
     190 * @see pjsip_process_route_set 
     191 */ 
     192PJ_DECL(pj_status_t) pjsip_get_request_dest(const pjsip_tx_data *tdata, 
     193                                            pjsip_host_info *dest_info ); 
     194 
     195 
     196/** 
     197 * Process route-set found in the request and calculate destination to be 
     198 * used to send the request message, based on the request URI and Route  
     199 * headers in the message. The procedure used here follows the guidelines 
     200 * on sending the request in RFC 3261 chapter 8.1.2. 
     201 * 
     202 * This function may modify the message (request line and Route headers), 
     203 * if the Route information specifies strict routing and the request 
     204 * URI in the message is different than the calculated target URI. In that 
     205 * case, the target URI will be put as the request URI of the request and 
     206 * current request URI will be put as the last entry of the Route headers. 
     207 * 
     208 * @param tdata     The transmit data containing the request message. 
     209 * @param dest_info On return, it contains information about destination 
     210 *                  host to contact, along with the preferable transport 
     211 *                  type, if any. Caller will then normally proceed with 
     212 *                  resolving this host with server resolution procedure 
     213 *                  described in RFC 3263. 
     214 * 
     215 * @return          PJ_SUCCESS, or the appropriate error code. 
     216 * 
     217 * @see pjsip_get_request_addr 
     218 */ 
     219PJ_DECL(pj_status_t) pjsip_process_route_set(pjsip_tx_data *tdata, 
    191220                                             pjsip_host_info *dest_info ); 
    192221 
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsip/sip_transaction.c

    r974 r1077  
    12001200     * This will be updated whenever transport has changed. 
    12011201     */ 
    1202     status = pjsip_get_request_addr(tdata, &dst_info); 
     1202    status = pjsip_get_request_dest(tdata, &dst_info); 
    12031203    if (status != PJ_SUCCESS) { 
    12041204        tsx_destroy(tsx); 
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsip/sip_util.c

    r974 r1077  
    626626 * chapter 8.1.2. 
    627627 */ 
    628 PJ_DEF(pj_status_t) pjsip_get_request_addr( pjsip_tx_data *tdata, 
     628PJ_DEF(pj_status_t) pjsip_get_request_dest(const pjsip_tx_data *tdata, 
     629                                           pjsip_host_info *dest_info ) 
     630{ 
     631    const pjsip_uri *target_uri; 
     632    const pjsip_route_hdr *first_route_hdr; 
     633     
     634    PJ_ASSERT_RETURN(tdata->msg->type == PJSIP_REQUEST_MSG,  
     635                     PJSIP_ENOTREQUESTMSG); 
     636    PJ_ASSERT_RETURN(dest_info != NULL, PJ_EINVAL); 
     637 
     638    /* Get the first "Route" header from the message. 
     639     */ 
     640    first_route_hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ROUTE, NULL); 
     641    if (first_route_hdr) { 
     642        target_uri = (const pjsip_uri*)&first_route_hdr->name_addr; 
     643    } else { 
     644        target_uri = tdata->msg->line.req.uri; 
     645    } 
     646 
     647 
     648    /* The target URI must be a SIP/SIPS URL so we can resolve it's address. 
     649     * Otherwise we're in trouble (i.e. there's no host part in tel: URL). 
     650     */ 
     651    pj_bzero(dest_info, sizeof(*dest_info)); 
     652 
     653    if (PJSIP_URI_SCHEME_IS_SIPS(target_uri)) { 
     654        pjsip_uri *uri = (pjsip_uri*) target_uri; 
     655        const pjsip_sip_uri *url=(const pjsip_sip_uri*)pjsip_uri_get_uri(uri); 
     656        dest_info->flag |= (PJSIP_TRANSPORT_SECURE | PJSIP_TRANSPORT_RELIABLE); 
     657        pj_strdup(tdata->pool, &dest_info->addr.host, &url->host); 
     658        dest_info->addr.port = url->port; 
     659        dest_info->type =  
     660            pjsip_transport_get_type_from_name(&url->transport_param); 
     661 
     662    } else if (PJSIP_URI_SCHEME_IS_SIP(target_uri)) { 
     663        pjsip_uri *uri = (pjsip_uri*) target_uri; 
     664        const pjsip_sip_uri *url=(const pjsip_sip_uri*)pjsip_uri_get_uri(uri); 
     665        pj_strdup(tdata->pool, &dest_info->addr.host, &url->host); 
     666        dest_info->addr.port = url->port; 
     667        dest_info->type =  
     668            pjsip_transport_get_type_from_name(&url->transport_param); 
     669        dest_info->flag =  
     670            pjsip_transport_get_flag_from_type(dest_info->type); 
     671    } else { 
     672        pj_assert(!"Unsupported URI scheme!"); 
     673        PJ_TODO(SUPPORT_REQUEST_ADDR_RESOLUTION_FOR_TEL_URI); 
     674        return PJSIP_EINVALIDSCHEME; 
     675    } 
     676 
     677    return PJ_SUCCESS; 
     678} 
     679 
     680 
     681/* 
     682 * Process route-set found in the request and calculate 
     683 * the destination to be used to send the request message, based 
     684 * on the request URI and Route headers in the message. The procedure 
     685 * used here follows the guidelines on sending the request in RFC 3261 
     686 * chapter 8.1.2. 
     687 */ 
     688PJ_DEF(pj_status_t) pjsip_process_route_set(pjsip_tx_data *tdata, 
    629689                                            pjsip_host_info *dest_info ) 
    630690{ 
     
    637697    PJ_ASSERT_RETURN(dest_info != NULL, PJ_EINVAL); 
    638698 
    639     /* Get the first "Route" header from the message. If the message doesn't 
    640      * have any "Route" headers but the endpoint has, then copy the "Route" 
    641      * headers from the endpoint first. 
    642      */ 
     699    /* Find the first and last "Route" headers from the message. */ 
    643700    last_route_hdr = first_route_hdr =  
    644701        pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ROUTE, NULL); 
     
    9471004 
    9481005    /* Get destination name to contact. */ 
    949     status = pjsip_get_request_addr(tdata, &dest_info); 
     1006    status = pjsip_process_route_set(tdata, &dest_info); 
    9501007    if (status != PJ_SUCCESS) 
    9511008        return status; 
Note: See TracChangeset for help on using the changeset viewer.