Index: /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
===================================================================
--- /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 3215)
+++ /pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c	(revision 3216)
@@ -193,6 +193,10 @@
     puts  ("  --proxy=url         Optional URL of proxy server to visit");
     puts  ("                      May be specified multiple times");
-    puts  ("  --reg-timeout=SEC   Optional registration interval (default 55)");
-    puts  ("  --rereg-delay=SEC   Optional auto retry registration interval (default 300)");
+    printf("  --reg-timeout=SEC   Optional registration interval (default %d)\n",
+	    PJSUA_REG_INTERVAL);
+    printf("  --rereg-delay=SEC   Optional auto retry registration interval (default %d)\n",
+	    PJSUA_REG_RETRY_INTERVAL);
+    puts  ("  --reg-use-proxy=N   Control the use of proxy settings in REGISTER.");
+    puts  ("                      0=no proxy, 1=outbound only, 2=acc only, 3=all (default)");
     puts  ("  --realm=string      Set realm");
     puts  ("  --username=string   Set authentication username");
@@ -202,5 +206,6 @@
     puts  ("  --use-100rel        Require reliable provisional response (100rel)");
     puts  ("  --use-timer         Require SIP session timers");
-    puts  ("  --timer-se=N        Session timers expiration period, in secs (def:1800)");
+    printf("  --timer-se=N        Session timers expiration period, in secs (def:%d)\n",
+	    PJSIP_SESS_TIMER_DEF_SE);
     puts  ("  --timer-min-se=N    Session timers minimum expiration period, in secs (def:90)");
     puts  ("  --auto-update-nat=N Where N is 0 or 1 to enable/disable SIP traversal behind");
@@ -490,5 +495,5 @@
 	   OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS,
 	   OPT_100REL, OPT_USE_IMS, OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
-	   OPT_REG_RETRY_INTERVAL,
+	   OPT_REG_RETRY_INTERVAL, OPT_REG_USE_PROXY,
 	   OPT_MWI, OPT_NAMESERVER, OPT_STUN_SRV,
 	   OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
@@ -559,4 +564,5 @@
 	{ "password",	1, 0, OPT_PASSWORD},
 	{ "rereg-delay",1, 0, OPT_REG_RETRY_INTERVAL},
+	{ "reg-use-proxy", 1, 0, OPT_REG_USE_PROXY},
 	{ "nameserver", 1, 0, OPT_NAMESERVER},
 	{ "stun-srv",   1, 0, OPT_STUN_SRV},
@@ -976,4 +982,13 @@
 	    break;
 
+	case OPT_REG_USE_PROXY:
+	    cur_acc->reg_use_proxy = (unsigned)pj_strtoul(pj_cstr(&tmp, pj_optarg));
+	    if (cur_acc->reg_use_proxy > 3) {
+		PJ_LOG(1,(THIS_FILE, "Error: invalid --reg-use-proxy value '%s'",
+			  pj_optarg));
+		return PJ_EINVAL;
+	    }
+	    break;
+
 	case OPT_NEXT_CRED: /* next credential */
 	    cur_acc->cred_count++;
@@ -1570,4 +1585,18 @@
 	if (i != acc_cfg->cred_count - 1)
 	    pj_strcat2(result, "--next-cred\n");
+    }
+
+    /* reg-use-proxy */
+    if (acc_cfg->reg_use_proxy != 3) {
+	pj_ansi_sprintf(line, "--reg-use-proxy %d\n",
+			      acc_cfg->reg_use_proxy);
+	pj_strcat2(result, line);
+    }
+
+    /* rereg-delay */
+    if (acc_cfg->reg_retry_interval != PJSUA_REG_RETRY_INTERVAL) {
+	pj_ansi_sprintf(line, "--rereg-delay %d\n",
+		              acc_cfg->reg_retry_interval);
+	pj_strcat2(result, line);
     }
 
Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 3215)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 3216)
@@ -1925,4 +1925,18 @@
 
 /**
+ * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
+ * the global outbound proxy list should be added to the REGISTER request.
+ */
+#define PJSUA_REG_USE_OUTBOUND_PROXY		1
+
+
+/**
+ * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
+ * the account proxy list should be added to the REGISTER request.
+ */
+#define PJSUA_REG_USE_ACC_PROXY			2
+
+
+/**
  * This structure describes account configuration to be specified when
  * adding a new account with #pjsua_acc_add(). Application MUST initialize
@@ -2224,4 +2238,16 @@
      */
     pj_bool_t	     drop_calls_on_reg_fail;
+
+    /**
+     * Specify how the registration uses the outbound and account proxy
+     * settings. This controls if and what Route headers will appear in
+     * the REGISTER request of this account. The value is bitmask combination
+     * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
+     * If the value is set to 0, the REGISTER request will not use any proxy
+     * (i.e. it will not have any Route headers).
+     *
+     * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
+     */
+    unsigned	     reg_use_proxy;
 
 } pjsua_acc_config;
Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 3215)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 3216)
@@ -286,4 +286,7 @@
     pj_bool_t		 nat_in_progress; /**< Detection in progress	*/
 
+    /* List of outbound proxies: */
+    pjsip_route_hdr	 outbound_proxy;
+
     /* Account: */
     unsigned		 acc_cnt;	     /**< Number of accounts.	*/
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 3215)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 3216)
@@ -200,19 +200,13 @@
     pj_list_init(&acc->route_set);
 
-    for (i=0; i<pjsua_var.ua_cfg.outbound_proxy_cnt; ++i) {
-    	pj_str_t hname = { "Route", 5};
+    if (!pj_list_empty(&pjsua_var.outbound_proxy)) {
 	pjsip_route_hdr *r;
-	pj_str_t tmp;
-
-	pj_strdup_with_null(acc->pool, &tmp, 
-			    &pjsua_var.ua_cfg.outbound_proxy[i]);
-	r = (pjsip_route_hdr*)
-	    pjsip_parse_hdr(acc->pool, &hname, tmp.ptr, tmp.slen, NULL);
-	if (r == NULL) {
-	    pjsua_perror(THIS_FILE, "Invalid outbound proxy URI",
-			 PJSIP_EINVALIDURI);
-	    return PJSIP_EINVALIDURI;
-	}
-	pj_list_push_back(&acc->route_set, r);
+
+	r = pjsua_var.outbound_proxy.next;
+	while (r != &pjsua_var.outbound_proxy) {
+	    pj_list_push_back(&acc->route_set,
+			      pjsip_hdr_shallow_clone(acc->pool, r));
+	    r = r->next;
+	}
     }
 
@@ -603,22 +597,12 @@
     if (global_route_crc != acc->global_route_crc) {
 	pjsip_route_hdr *r;
-	unsigned i;
-
-	/* Validate the global route and save it to temporary var */
+
+	/* Copy from global outbound proxies */
 	pj_list_init(&global_route);
-	for (i=0; i < pjsua_var.ua_cfg.outbound_proxy_cnt; ++i) {
-    	    pj_str_t hname = { "Route", 5};
-	    pj_str_t tmp;
-
-	    pj_strdup_with_null(acc->pool, &tmp, 
-				&pjsua_var.ua_cfg.outbound_proxy[i]);
-	    r = (pjsip_route_hdr*)
-		pjsip_parse_hdr(acc->pool, &hname, tmp.ptr, tmp.slen, NULL);
-	    if (r == NULL) {
-		status = PJSIP_EINVALIDURI;
-		pjsua_perror(THIS_FILE, "Invalid outbound proxy URI", status);
-		goto on_return;
-	    }
-	    pj_list_push_back(&global_route, r);
+	r = pjsua_var.outbound_proxy.next;
+	while (r != &pjsua_var.outbound_proxy) {
+	    pj_list_push_back(&global_route,
+		              pjsip_hdr_shallow_clone(acc->pool, r));
+	    r = r->next;
 	}
     }
@@ -1611,6 +1595,34 @@
     /* Set route-set
      */
-    if (!pj_list_empty(&acc->route_set)) {
-	pjsip_regc_set_route_set( acc->regc, &acc->route_set );
+    if (acc->cfg.reg_use_proxy) {
+	pjsip_route_hdr route_set;
+	const pjsip_route_hdr *r;
+
+	pj_list_init(&route_set);
+
+	if (acc->cfg.reg_use_proxy & PJSUA_REG_USE_OUTBOUND_PROXY) {
+	    r = pjsua_var.outbound_proxy.next;
+	    while (r != &pjsua_var.outbound_proxy) {
+		pj_list_push_back(&route_set, pjsip_hdr_shallow_clone(pool, r));
+		r = r->next;
+	    }
+	}
+
+	if (acc->cfg.reg_use_proxy & PJSUA_REG_USE_ACC_PROXY &&
+	    acc->cfg.proxy_cnt)
+	{
+	    int cnt = acc->cfg.proxy_cnt;
+	    pjsip_route_hdr *pos = route_set.prev;
+	    int i;
+
+	    r = acc->route_set.prev;
+	    for (i=0; i<cnt; ++i) {
+		pj_list_push_front(pos, pjsip_hdr_shallow_clone(pool, r));
+		r = r->prev;
+	    }
+	}
+
+	if (!pj_list_empty(&route_set))
+	    pjsip_regc_set_route_set( acc->regc, &route_set );
     }
 
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 3215)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 3216)
@@ -65,4 +65,5 @@
     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);
@@ -180,4 +181,6 @@
     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;
 }
 
@@ -666,4 +669,5 @@
     const pj_str_t	 STR_OPTIONS = { "OPTIONS", 7 };
     pjsip_ua_init_param  ua_init_param;
+    unsigned i;
     pj_status_t status;
 
@@ -784,4 +788,34 @@
     }
 
+    /* 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);
+    }
     
 
