[svn-commits] kmoore: trunk r424267 - in /trunk: ./ configs/samples/ res/ res/res_pjsip/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 1 07:28:08 CDT 2014


Author: kmoore
Date: Wed Oct  1 07:28:05 2014
New Revision: 424267

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=424267
Log:
PJSIP: Handle defaults properly

This updates the code behind PJSIP configuration options with custom
handlers to deal with the assigned default values properly where it
makes sense and adjusting the default value where it doesn't. Before
applying this patch, there were several cases where the default value
for an option would prevent that config section from loading properly.

Reported by: Thomas Thompson
Review: https://reviewboard.asterisk.org/r/4019/
........

Merged revisions 424263 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 424266 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/configs/samples/pjsip.conf.sample
    trunk/res/res_pjsip/config_transport.c
    trunk/res/res_pjsip/location.c
    trunk/res/res_pjsip/pjsip_configuration.c
    trunk/res/res_pjsip_endpoint_identifier_ip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/configs/samples/pjsip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/samples/pjsip.conf.sample?view=diff&rev=424267&r1=424266&r2=424267
==============================================================================
--- trunk/configs/samples/pjsip.conf.sample (original)
+++ trunk/configs/samples/pjsip.conf.sample Wed Oct  1 07:28:05 2014
@@ -490,7 +490,7 @@
 ;aors=  ; AoR s to be used with the endpoint (default: "")
 ;auth=  ; Authentication Object s associated with the endpoint (default: "")
 ;callerid=      ; CallerID information for the endpoint (default: "")
-;callerid_privacy=      ; Default privacy level (default: "")
+;callerid_privacy=allowed      ; Default privacy level (default: "allowed")
 ;callerid_tag=  ; Internal id_tag for the endpoint (default: "")
 ;context=default        ; Dialplan context for inbound sessions (default:
                         ; "default")
@@ -596,10 +596,10 @@
                 ; this endpoint (default: "")
 ;from_domain=   ; Domain to user in From header for requests to this endpoint
                 ; (default: "")
-;dtls_verify=   ; Verify that the provided peer certificate is valid (default:
-                ; "")
-;dtls_rekey=    ; Interval at which to renegotiate the TLS session and rekey
-                ; the SRTP session (default: "")
+;dtls_verify=no ; Verify that the provided peer certificate is valid (default:
+                ; "no")
+;dtls_rekey=0   ; Interval at which to renegotiate the TLS session and rekey
+                ; the SRTP session (default: "0")
 ;dtls_cert_file=        ; Path to certificate file to present to peer (default:
                         ; "")
 ;dtls_private_key=      ; Path to private key for certificate file (default:

Modified: trunk/res/res_pjsip/config_transport.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/config_transport.c?view=diff&rev=424267&r1=424266&r2=424267
==============================================================================
--- trunk/res/res_pjsip/config_transport.c (original)
+++ trunk/res/res_pjsip/config_transport.c Wed Oct  1 07:28:05 2014
@@ -349,7 +349,7 @@
 {
 	struct ast_sip_transport *transport = obj;
 
-	if (!strcasecmp(var->value, "default")) {
+	if (ast_strlen_zero(var->value) || !strcasecmp(var->value, "default")) {
 		transport->tls.method = PJSIP_SSL_DEFAULT_METHOD;
 	} else if (!strcasecmp(var->value, "unspecified")) {
 		transport->tls.method = PJSIP_SSL_UNSPECIFIED_METHOD;
@@ -416,6 +416,10 @@
 	struct ast_sip_transport *transport = obj;
 	pj_ssl_cipher cipher;
 
+	if (ast_strlen_zero(var->value)) {
+		return 0;
+	}
+
 	if (transport->tls.ciphers_num == (SIP_TLS_MAX_CIPHERS - 1)) {
 		return -1;
 	}
@@ -467,6 +471,12 @@
 {
 	struct ast_sip_transport *transport = obj;
 	int error = 0;
+
+	if (ast_strlen_zero(var->value)) {
+		ast_free_ha(transport->localnet);
+		transport->localnet = NULL;
+		return 0;
+	}
 
 	if (!(transport->localnet = ast_append_ha("d", var->value, transport->localnet, &error))) {
 		return -1;

Modified: trunk/res/res_pjsip/location.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/location.c?view=diff&rev=424267&r1=424266&r2=424267
==============================================================================
--- trunk/res/res_pjsip/location.c (original)
+++ trunk/res/res_pjsip/location.c Wed Oct  1 07:28:05 2014
@@ -290,9 +290,14 @@
 {
 	struct ast_sip_aor *aor = obj;
 	const char *aor_id = ast_sorcery_object_get_id(aor);
-	char *contacts = ast_strdupa(var->value);
+	char *contacts;
 	char *contact_uri;
 
+	if (ast_strlen_zero(var->value)) {
+		return 0;
+	}
+
+	contacts = ast_strdupa(var->value);
 	while ((contact_uri = strsep(&contacts, ","))) {
 		struct ast_sip_contact *contact;
 		char contact_id[strlen(aor_id) + strlen(contact_uri) + 2 + 1];

Modified: trunk/res/res_pjsip/pjsip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip/pjsip_configuration.c?view=diff&rev=424267&r1=424266&r2=424267
==============================================================================
--- trunk/res/res_pjsip/pjsip_configuration.c (original)
+++ trunk/res/res_pjsip/pjsip_configuration.c Wed Oct  1 07:28:05 2014
@@ -559,13 +559,9 @@
 	struct ast_sip_endpoint *endpoint = obj;
 
 	if (!strncmp(var->name, "call_group", 10)) {
-		if (!(endpoint->pickup.callgroup = ast_get_group(var->value))) {
-			return -1;
-		}
+		endpoint->pickup.callgroup = ast_get_group(var->value);
 	} else if (!strncmp(var->name, "pickup_group", 12)) {
-		if (!(endpoint->pickup.pickupgroup = ast_get_group(var->value))) {
-			return -1;
-		}
+		endpoint->pickup.pickupgroup = ast_get_group(var->value);
 	} else {
 		return -1;
 	}
@@ -603,12 +599,18 @@
 	struct ast_sip_endpoint *endpoint = obj;
 
 	if (!strncmp(var->name, "named_call_group", 16)) {
-		if (!(endpoint->pickup.named_callgroups =
+		if (ast_strlen_zero(var->value)) {
+			endpoint->pickup.named_callgroups =
+				ast_unref_namedgroups(endpoint->pickup.named_callgroups);
+		} else if (!(endpoint->pickup.named_callgroups =
 		      ast_get_namedgroups(var->value))) {
 			return -1;
 		}
 	} else if (!strncmp(var->name, "named_pickup_group", 18)) {
-		if (!(endpoint->pickup.named_pickupgroups =
+		if (ast_strlen_zero(var->value)) {
+			endpoint->pickup.named_pickupgroups =
+				ast_unref_namedgroups(endpoint->pickup.named_pickupgroups);
+		} else if (!(endpoint->pickup.named_pickupgroups =
 		      ast_get_namedgroups(var->value))) {
 			return -1;
 		}
@@ -808,7 +810,15 @@
 {
 	struct ast_sip_endpoint *endpoint = obj;
 	struct ast_variable *new_var;
-	char *name = ast_strdupa(var->value), *val = strchr(name, '=');
+	char *name;
+	char *val;
+
+	if (ast_strlen_zero(var->value)) {
+		return 0;
+	}
+
+	name = ast_strdupa(var->value);
+	val = strchr(name, '=');
 
 	if (!val) {
 		return -1;
@@ -1677,7 +1687,7 @@
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "direct_media_glare_mitigation", "none", direct_media_glare_mitigation_handler, direct_media_glare_mitigation_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "disable_direct_media_on_nat", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.direct_media.disable_on_nat));
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid", "", caller_id_handler, caller_id_to_str, NULL, 0, 0);
-	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "", caller_id_privacy_handler, caller_id_privacy_to_str, NULL, 0, 0);
+	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "allowed", caller_id_privacy_handler, caller_id_privacy_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_tag", "", caller_id_tag_handler, caller_id_tag_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_inbound));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, id.trust_outbound));
@@ -1720,8 +1730,8 @@
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "from_domain", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, fromdomain));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "mwi_from_user", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, subscription.mwi.fromuser));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "rtp_engine", "asterisk", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_endpoint, media.rtp.engine));
-	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_verify", "", dtls_handler, dtlsverify_to_str, NULL, 0, 0);
-	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_rekey", "", dtls_handler, dtlsrekey_to_str, NULL, 0, 0);
+	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_verify", "no", dtls_handler, dtlsverify_to_str, NULL, 0, 0);
+	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_rekey", "0", dtls_handler, dtlsrekey_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_cert_file", "", dtls_handler, dtlscertfile_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_private_key", "", dtls_handler, dtlsprivatekey_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "dtls_cipher", "", dtls_handler, dtlscipher_to_str, NULL, 0, 0);

Modified: trunk/res/res_pjsip_endpoint_identifier_ip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_endpoint_identifier_ip.c?view=diff&rev=424267&r1=424266&r2=424267
==============================================================================
--- trunk/res/res_pjsip_endpoint_identifier_ip.c (original)
+++ trunk/res/res_pjsip_endpoint_identifier_ip.c Wed Oct  1 07:28:05 2014
@@ -160,6 +160,10 @@
 	char *input_string = ast_strdupa(var->value);
 	char *current_string;
 
+	if (ast_strlen_zero(var->value)) {
+		return 0;
+	}
+
 	while ((current_string = strsep(&input_string, ","))) {
 		struct ast_sockaddr *addrs;
 		int num_addrs = 0, error = 0, i;




More information about the svn-commits mailing list