Continuing ticket #400: Only process Service-Route header if enable_service_route (--service-route option in pjsua) is set

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1520 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 31281af..51438ee 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -128,6 +128,7 @@
     puts  ("  --password=string   Set authentication password");
     puts  ("  --publish           Send presence PUBLISH for this account");
     puts  ("  --use-100rel        Require reliable provisional response (100rel)");
+    puts  ("  --service-route     Enable Service-Route processing");
     puts  ("  --next-cred         Add another credentials");
     puts  ("");
     puts  ("SIP Account Control:");
@@ -371,7 +372,7 @@
 	   OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, 
 	   OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY, 
 	   OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT,
-	   OPT_100REL, OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
+	   OPT_100REL, OPT_SERVICE_ROUTE, OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
 	   OPT_NAMESERVER, OPT_STUN_DOMAIN, OPT_STUN_SRV,
 	   OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
 	   OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP,
@@ -408,6 +409,7 @@
 	{ "reg-timeout",1, 0, OPT_REG_TIMEOUT},
 	{ "publish",    0, 0, OPT_PUBLISH},
 	{ "use-100rel", 0, 0, OPT_100REL},
+	{ "service-route", 0, 0, OPT_SERVICE_ROUTE},
 	{ "id",		1, 0, OPT_ID},
 	{ "contact",	1, 0, OPT_CONTACT},
 	{ "realm",	1, 0, OPT_REALM},
@@ -634,6 +636,10 @@
 	    cfg->cfg.require_100rel = PJ_TRUE;
 	    break;
 
+	case OPT_SERVICE_ROUTE: /* Service-Route processing */
+	    cur_acc->enable_service_route = PJ_TRUE;
+	    break;
+
 	case OPT_ID:   /* id */
 	    if (pjsua_verify_sip_url(pj_optarg) != 0) {
 		PJ_LOG(1,(THIS_FILE, 
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index df5aa25..d076c66 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1888,6 +1888,11 @@
      */
     pj_str_t	    proxy[PJSUA_ACC_MAX_PROXIES];
 
+    /**
+     * Enable Service-Route processing for this account.
+     */
+    pj_bool_t	    enable_service_route;
+
     /** 
      * Optional interval for registration, in seconds. If the value is zero, 
      * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index a1cab41..012832c 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -541,6 +541,10 @@
     pjsip_uri *uri[PJSUA_ACC_MAX_PROXIES];
     unsigned i, uri_cnt = 0, rcnt;
 
+    /* Skip processing is enable_service_route is not set */
+    if (!acc->cfg.enable_service_route)
+	return;
+
     /* Find and parse Service-Route headers */
     for (;;) {
 	char saved;