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
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@3216 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 888b3db..3d13f2e 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -64,6 +64,7 @@
pjsua_var.stun_status = PJ_EUNKNOWN;
pjsua_var.nat_status = PJ_EPENDING;
pj_list_init(&pjsua_var.stun_res);
+ pj_list_init(&pjsua_var.outbound_proxy);
pjsua_config_default(&pjsua_var.ua_cfg);
}
@@ -179,6 +180,8 @@
#endif
cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL;
cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD;
+ cfg->reg_use_proxy = PJSUA_REG_USE_OUTBOUND_PROXY |
+ PJSUA_REG_USE_ACC_PROXY;
}
PJ_DEF(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)
@@ -665,6 +668,7 @@
pjsua_media_config default_media_cfg;
const pj_str_t STR_OPTIONS = { "OPTIONS", 7 };
pjsip_ua_init_param ua_init_param;
+ unsigned i;
pj_status_t status;
@@ -783,6 +787,36 @@
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
}
+ /* Parse outbound proxies */
+ for (i=0; i<ua_cfg->outbound_proxy_cnt; ++i) {
+ pj_str_t tmp;
+ pj_str_t hname = { "Route", 5};
+ pjsip_route_hdr *r;
+
+ pj_strdup_with_null(pjsua_var.pool, &tmp, &ua_cfg->outbound_proxy[i]);
+
+ r = (pjsip_route_hdr*)
+ pjsip_parse_hdr(pjsua_var.pool, &hname, tmp.ptr,
+ (unsigned)tmp.slen, NULL);
+ if (r == NULL) {
+ pjsua_perror(THIS_FILE, "Invalid outbound proxy URI",
+ PJSIP_EINVALIDURI);
+ return PJSIP_EINVALIDURI;
+ }
+
+ if (pjsua_var.ua_cfg.force_lr) {
+ pjsip_sip_uri *sip_url;
+ if (!PJSIP_URI_SCHEME_IS_SIP(r->name_addr.uri) &&
+ !PJSIP_URI_SCHEME_IS_SIP(r->name_addr.uri))
+ {
+ return PJSIP_EINVALIDSCHEME;
+ }
+ sip_url = (pjsip_sip_uri*)r->name_addr.uri;
+ sip_url->lr_param = 1;
+ }
+
+ pj_list_push_back(&pjsua_var.outbound_proxy, r);
+ }
/* Initialize PJSUA call subsystem: */