Changeset 1412


Ignore:
Timestamp:
Aug 2, 2007 2:58:19 PM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #360: More support for strict routed requests in proxy sample (thanks Helmut Wolf)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/proxy.h

    r1411 r1412  
    422422     * this modified request. 
    423423     */ 
    424     /* Nah, we don't want to support this */ 
     424    if (is_uri_local(target)) { 
     425        pjsip_route_hdr *r; 
     426        pjsip_sip_uri *uri; 
     427 
     428        /* Find the first Route header */ 
     429        r = hroute = (pjsip_route_hdr*) 
     430                     pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ROUTE, NULL); 
     431        if (r == NULL) { 
     432            /* No Route header. This request is destined for this proxy. */ 
     433            return PJ_SUCCESS; 
     434        } 
     435 
     436        /* Find the last Route header */ 
     437        while ( (r=(pjsip_route_hdr*)pjsip_msg_find_hdr(tdata->msg,  
     438                                                        PJSIP_H_ROUTE,  
     439                                                        r->next)) != NULL ) 
     440        { 
     441            hroute = r; 
     442        } 
     443 
     444        /* If the last Route header doesn't have ";lr" parameter, then 
     445         * this is a strict-routed request indeed, and we follow the steps 
     446         * in processing strict-route requests above. 
     447         * 
     448         * But if it does contain ";lr" parameter, skip the strict-route 
     449         * processing. 
     450         */ 
     451        uri = (pjsip_sip_uri*) 
     452              pjsip_uri_get_uri(&hroute->name_addr); 
     453        if (uri->lr_param == 0) { 
     454            /* Yes this is strict route, so: 
     455             * - replace req URI with the URI in Route header, 
     456             * - remove the Route header, 
     457             * - proceed as if it received this modified request.  
     458            */ 
     459            tdata->msg->line.req.uri = hroute->name_addr.uri; 
     460            target = (pjsip_sip_uri*) tdata->msg->line.req.uri; 
     461            pj_list_erase(hroute); 
     462        } 
     463    } 
    425464 
    426465    /* If the Request-URI contains a maddr parameter, the proxy MUST check 
     
    476515        rr = pjsip_generic_string_hdr_create(tdata->pool, 
    477516                                             &H_RR, &uri); 
    478         pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)rr); 
     517        pjsip_msg_insert_first_hdr(tdata->msg, (pjsip_hdr*)rr); 
    479518    } 
    480519} 
Note: See TracChangeset for help on using the changeset viewer.