Changeset 3216 for pjproject/trunk
- Timestamp:
- Jun 22, 2010 6:02:13 AM (14 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r3212 r3216 193 193 puts (" --proxy=url Optional URL of proxy server to visit"); 194 194 puts (" May be specified multiple times"); 195 puts (" --reg-timeout=SEC Optional registration interval (default 55)"); 196 puts (" --rereg-delay=SEC Optional auto retry registration interval (default 300)"); 195 printf(" --reg-timeout=SEC Optional registration interval (default %d)\n", 196 PJSUA_REG_INTERVAL); 197 printf(" --rereg-delay=SEC Optional auto retry registration interval (default %d)\n", 198 PJSUA_REG_RETRY_INTERVAL); 199 puts (" --reg-use-proxy=N Control the use of proxy settings in REGISTER."); 200 puts (" 0=no proxy, 1=outbound only, 2=acc only, 3=all (default)"); 197 201 puts (" --realm=string Set realm"); 198 202 puts (" --username=string Set authentication username"); … … 202 206 puts (" --use-100rel Require reliable provisional response (100rel)"); 203 207 puts (" --use-timer Require SIP session timers"); 204 puts (" --timer-se=N Session timers expiration period, in secs (def:1800)"); 208 printf(" --timer-se=N Session timers expiration period, in secs (def:%d)\n", 209 PJSIP_SESS_TIMER_DEF_SE); 205 210 puts (" --timer-min-se=N Session timers minimum expiration period, in secs (def:90)"); 206 211 puts (" --auto-update-nat=N Where N is 0 or 1 to enable/disable SIP traversal behind"); … … 490 495 OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS, 491 496 OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 492 OPT_REG_RETRY_INTERVAL, 497 OPT_REG_RETRY_INTERVAL, OPT_REG_USE_PROXY, 493 498 OPT_MWI, OPT_NAMESERVER, OPT_STUN_SRV, 494 499 OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, … … 559 564 { "password", 1, 0, OPT_PASSWORD}, 560 565 { "rereg-delay",1, 0, OPT_REG_RETRY_INTERVAL}, 566 { "reg-use-proxy", 1, 0, OPT_REG_USE_PROXY}, 561 567 { "nameserver", 1, 0, OPT_NAMESERVER}, 562 568 { "stun-srv", 1, 0, OPT_STUN_SRV}, … … 976 982 break; 977 983 984 case OPT_REG_USE_PROXY: 985 cur_acc->reg_use_proxy = (unsigned)pj_strtoul(pj_cstr(&tmp, pj_optarg)); 986 if (cur_acc->reg_use_proxy > 3) { 987 PJ_LOG(1,(THIS_FILE, "Error: invalid --reg-use-proxy value '%s'", 988 pj_optarg)); 989 return PJ_EINVAL; 990 } 991 break; 992 978 993 case OPT_NEXT_CRED: /* next credential */ 979 994 cur_acc->cred_count++; … … 1570 1585 if (i != acc_cfg->cred_count - 1) 1571 1586 pj_strcat2(result, "--next-cred\n"); 1587 } 1588 1589 /* reg-use-proxy */ 1590 if (acc_cfg->reg_use_proxy != 3) { 1591 pj_ansi_sprintf(line, "--reg-use-proxy %d\n", 1592 acc_cfg->reg_use_proxy); 1593 pj_strcat2(result, line); 1594 } 1595 1596 /* rereg-delay */ 1597 if (acc_cfg->reg_retry_interval != PJSUA_REG_RETRY_INTERVAL) { 1598 pj_ansi_sprintf(line, "--rereg-delay %d\n", 1599 acc_cfg->reg_retry_interval); 1600 pj_strcat2(result, line); 1572 1601 } 1573 1602 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r3213 r3216 1925 1925 1926 1926 /** 1927 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that 1928 * the global outbound proxy list should be added to the REGISTER request. 1929 */ 1930 #define PJSUA_REG_USE_OUTBOUND_PROXY 1 1931 1932 1933 /** 1934 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that 1935 * the account proxy list should be added to the REGISTER request. 1936 */ 1937 #define PJSUA_REG_USE_ACC_PROXY 2 1938 1939 1940 /** 1927 1941 * This structure describes account configuration to be specified when 1928 1942 * adding a new account with #pjsua_acc_add(). Application MUST initialize … … 2224 2238 */ 2225 2239 pj_bool_t drop_calls_on_reg_fail; 2240 2241 /** 2242 * Specify how the registration uses the outbound and account proxy 2243 * settings. This controls if and what Route headers will appear in 2244 * the REGISTER request of this account. The value is bitmask combination 2245 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits. 2246 * If the value is set to 0, the REGISTER request will not use any proxy 2247 * (i.e. it will not have any Route headers). 2248 * 2249 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY) 2250 */ 2251 unsigned reg_use_proxy; 2226 2252 2227 2253 } pjsua_acc_config; -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r3206 r3216 286 286 pj_bool_t nat_in_progress; /**< Detection in progress */ 287 287 288 /* List of outbound proxies: */ 289 pjsip_route_hdr outbound_proxy; 290 288 291 /* Account: */ 289 292 unsigned acc_cnt; /**< Number of accounts. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r3213 r3216 200 200 pj_list_init(&acc->route_set); 201 201 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)) { 204 203 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 } 217 211 } 218 212 … … 603 597 if (global_route_crc != acc->global_route_crc) { 604 598 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 */ 608 601 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; 623 607 } 624 608 } … … 1611 1595 /* Set route-set 1612 1596 */ 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 ); 1615 1627 } 1616 1628 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r3213 r3216 65 65 pjsua_var.nat_status = PJ_EPENDING; 66 66 pj_list_init(&pjsua_var.stun_res); 67 pj_list_init(&pjsua_var.outbound_proxy); 67 68 68 69 pjsua_config_default(&pjsua_var.ua_cfg); … … 180 181 cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL; 181 182 cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD; 183 cfg->reg_use_proxy = PJSUA_REG_USE_OUTBOUND_PROXY | 184 PJSUA_REG_USE_ACC_PROXY; 182 185 } 183 186 … … 666 669 const pj_str_t STR_OPTIONS = { "OPTIONS", 7 }; 667 670 pjsip_ua_init_param ua_init_param; 671 unsigned i; 668 672 pj_status_t status; 669 673 … … 784 788 } 785 789 790 /* Parse outbound proxies */ 791 for (i=0; i<ua_cfg->outbound_proxy_cnt; ++i) { 792 pj_str_t tmp; 793 pj_str_t hname = { "Route", 5}; 794 pjsip_route_hdr *r; 795 796 pj_strdup_with_null(pjsua_var.pool, &tmp, &ua_cfg->outbound_proxy[i]); 797 798 r = (pjsip_route_hdr*) 799 pjsip_parse_hdr(pjsua_var.pool, &hname, tmp.ptr, 800 (unsigned)tmp.slen, NULL); 801 if (r == NULL) { 802 pjsua_perror(THIS_FILE, "Invalid outbound proxy URI", 803 PJSIP_EINVALIDURI); 804 return PJSIP_EINVALIDURI; 805 } 806 807 if (pjsua_var.ua_cfg.force_lr) { 808 pjsip_sip_uri *sip_url; 809 if (!PJSIP_URI_SCHEME_IS_SIP(r->name_addr.uri) && 810 !PJSIP_URI_SCHEME_IS_SIP(r->name_addr.uri)) 811 { 812 return PJSIP_EINVALIDSCHEME; 813 } 814 sip_url = (pjsip_sip_uri*)r->name_addr.uri; 815 sip_url->lr_param = 1; 816 } 817 818 pj_list_push_back(&pjsua_var.outbound_proxy, r); 819 } 786 820 787 821
Note: See TracChangeset
for help on using the changeset viewer.