Ignore:
Timestamp:
Jun 22, 2010 6:02:13 AM (14 years ago)
Author:
bennylp
Message:

Fixed #1095 (New option to control the Route headers in REGISTER request). Details:

  • added new account config setting: reg_use_proxy. This contains bitmask values to indicate whether outbound proxies and account proxies are to be added in the REGISTER request. Default value is to add both.
  • added new pjsua cmdline option to control this: --reg-use-proxy
  • miscellaneous minor fixes in other pjsua cmdline arguments
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r3213 r3216  
    200200    pj_list_init(&acc->route_set); 
    201201 
    202     for (i=0; i<pjsua_var.ua_cfg.outbound_proxy_cnt; ++i) { 
    203         pj_str_t hname = { "Route", 5}; 
     202    if (!pj_list_empty(&pjsua_var.outbound_proxy)) { 
    204203        pjsip_route_hdr *r; 
    205         pj_str_t tmp; 
    206  
    207         pj_strdup_with_null(acc->pool, &tmp,  
    208                             &pjsua_var.ua_cfg.outbound_proxy[i]); 
    209         r = (pjsip_route_hdr*) 
    210             pjsip_parse_hdr(acc->pool, &hname, tmp.ptr, tmp.slen, NULL); 
    211         if (r == NULL) { 
    212             pjsua_perror(THIS_FILE, "Invalid outbound proxy URI", 
    213                          PJSIP_EINVALIDURI); 
    214             return PJSIP_EINVALIDURI; 
    215         } 
    216         pj_list_push_back(&acc->route_set, r); 
     204 
     205        r = pjsua_var.outbound_proxy.next; 
     206        while (r != &pjsua_var.outbound_proxy) { 
     207            pj_list_push_back(&acc->route_set, 
     208                              pjsip_hdr_shallow_clone(acc->pool, r)); 
     209            r = r->next; 
     210        } 
    217211    } 
    218212 
     
    603597    if (global_route_crc != acc->global_route_crc) { 
    604598        pjsip_route_hdr *r; 
    605         unsigned i; 
    606  
    607         /* Validate the global route and save it to temporary var */ 
     599 
     600        /* Copy from global outbound proxies */ 
    608601        pj_list_init(&global_route); 
    609         for (i=0; i < pjsua_var.ua_cfg.outbound_proxy_cnt; ++i) { 
    610             pj_str_t hname = { "Route", 5}; 
    611             pj_str_t tmp; 
    612  
    613             pj_strdup_with_null(acc->pool, &tmp,  
    614                                 &pjsua_var.ua_cfg.outbound_proxy[i]); 
    615             r = (pjsip_route_hdr*) 
    616                 pjsip_parse_hdr(acc->pool, &hname, tmp.ptr, tmp.slen, NULL); 
    617             if (r == NULL) { 
    618                 status = PJSIP_EINVALIDURI; 
    619                 pjsua_perror(THIS_FILE, "Invalid outbound proxy URI", status); 
    620                 goto on_return; 
    621             } 
    622             pj_list_push_back(&global_route, r); 
     602        r = pjsua_var.outbound_proxy.next; 
     603        while (r != &pjsua_var.outbound_proxy) { 
     604            pj_list_push_back(&global_route, 
     605                              pjsip_hdr_shallow_clone(acc->pool, r)); 
     606            r = r->next; 
    623607        } 
    624608    } 
     
    16111595    /* Set route-set 
    16121596     */ 
    1613     if (!pj_list_empty(&acc->route_set)) { 
    1614         pjsip_regc_set_route_set( acc->regc, &acc->route_set ); 
     1597    if (acc->cfg.reg_use_proxy) { 
     1598        pjsip_route_hdr route_set; 
     1599        const pjsip_route_hdr *r; 
     1600 
     1601        pj_list_init(&route_set); 
     1602 
     1603        if (acc->cfg.reg_use_proxy & PJSUA_REG_USE_OUTBOUND_PROXY) { 
     1604            r = pjsua_var.outbound_proxy.next; 
     1605            while (r != &pjsua_var.outbound_proxy) { 
     1606                pj_list_push_back(&route_set, pjsip_hdr_shallow_clone(pool, r)); 
     1607                r = r->next; 
     1608            } 
     1609        } 
     1610 
     1611        if (acc->cfg.reg_use_proxy & PJSUA_REG_USE_ACC_PROXY && 
     1612            acc->cfg.proxy_cnt) 
     1613        { 
     1614            int cnt = acc->cfg.proxy_cnt; 
     1615            pjsip_route_hdr *pos = route_set.prev; 
     1616            int i; 
     1617 
     1618            r = acc->route_set.prev; 
     1619            for (i=0; i<cnt; ++i) { 
     1620                pj_list_push_front(pos, pjsip_hdr_shallow_clone(pool, r)); 
     1621                r = r->prev; 
     1622            } 
     1623        } 
     1624 
     1625        if (!pj_list_empty(&route_set)) 
     1626            pjsip_regc_set_route_set( acc->regc, &route_set ); 
    16151627    } 
    16161628 
Note: See TracChangeset for help on using the changeset viewer.