[Asterisk-code-review] res pjsip config wizard: Add 2 new parameters to help with p... (asterisk[14])

George Joseph asteriskteam at digium.com
Tue Mar 28 16:48:10 CDT 2017


George Joseph has uploaded a new change for review. ( https://gerrit.asterisk.org/5352 )

Change subject: res_pjsip_config_wizard: Add 2 new parameters to help with proxy config
......................................................................

res_pjsip_config_wizard: Add 2 new parameters to help with proxy config

Two new parameters have been added to the pjsip config wizard.

 * Setting 'sends_line_with_registrations' to true will cause the wizard
   to skip the creation of an identify object to match incoming request
   to the endpoint and instead add the line and endpoint parameters to
   the outbound registration object.

 * Setting 'outbound_proxy' is a shortcut for adding individual
   endpoint/outbound_proxy, aor/outbound_proxy and
   registration/outbound_proxy parameters.

Change-Id: I678e5f80765734c056620528a6d40d82736ceeb0
(cherry picked from commit a827892ff77cd37912b528d9c45b446be091bbc0)
---
M CHANGES
M configs/samples/pjsip_wizard.conf.sample
M res/res_pjsip_config_wizard.c
3 files changed, 63 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/52/5352/1

diff --git a/CHANGES b/CHANGES
index 848b777..9a4e0b1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,21 @@
 ==============================================================================
 
 ------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 14.4.0 to Asterisk 14.5.0 ------------
+------------------------------------------------------------------------------
+
+res_pjsip_config_wizard
+------------------
+ * Two new parameters have been added to the pjsip config wizard.
+   Setting 'sends_line_with_registrations' to true will cause the wizard
+   to skip the creation of an identify object to match incoming requests
+   to the endpoint and instead add the line and endpoint parameters to
+   the outbound registration object.
+   Setting 'outbound_proxy' is a shortcut for adding individual
+   endpoint/outbound_proxy, aor/outbound_proxy and registration/outbound_proxy
+   parameters.
+
+------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 14.3.0 to Asterisk 14.4.0 ------------
 ------------------------------------------------------------------------------
 
diff --git a/configs/samples/pjsip_wizard.conf.sample b/configs/samples/pjsip_wizard.conf.sample
index 0f46083..8c8572e 100644
--- a/configs/samples/pjsip_wizard.conf.sample
+++ b/configs/samples/pjsip_wizard.conf.sample
@@ -79,6 +79,13 @@
                          ; sends_auth must also be specified.
                          ; (default: "no")
 
+;sends_line_with_registrations=  ; Setting this to true will cause the wizard to
+                         ; skip the creation of an identify object to match
+                         ; incoming requests to the endpoint and instead add the
+                         ; line and endpoint parameters to the outbound
+                         ; registration object.
+                         ; (default: "no")
+
 ;accepts_registrations=  ; Will create an aor with dynamic contacts which will
                          ; accept registrations.
                          ; accepts_auth must also be specified.
@@ -96,6 +103,11 @@
                  ; SRV records are not currently supported.
                  ; (default: "")
 
+;outbound_proxy= ; Setting this is a shortcut for setting
+                 ; endpoint/outbound_proxy
+                 ; aor/outbound_proxy
+                 ; registration/outbound_proxy
+
 ;transport=      ; The transport to use for the endpoint and registrations
                  ; (default: the pjsip default)
 
diff --git a/res/res_pjsip_config_wizard.c b/res/res_pjsip_config_wizard.c
index aec923d..1241b15 100644
--- a/res/res_pjsip_config_wizard.c
+++ b/res/res_pjsip_config_wizard.c
@@ -141,6 +141,12 @@
 					entry in the list.  If send_registrations is also set, a registration will
 					also be created for each.</para></description>
 				</configOption>
+				<configOption name="outbound_proxy">
+					<synopsis>Shortcut for specifying proxy on individual objects.</synopsis>
+					<description><para>Shortcut for specifying endpoint/outbound_proxy,
+					aor/outbound_proxy, and registration/outbound_proxy individually.
+					</para></description>
+				</configOption>
 				<configOption name="sends_auth" default="no">
 					<synopsis>Send outbound authentication to remote hosts.</synopsis>
 					<description><para>At least outbound_auth/username is required.</para></description>
@@ -154,6 +160,13 @@
 					<description><para>remote_hosts is required and a registration object will
 					be created for each host in the remote _hosts string.  If authentication is required,
 					sends_auth and an outbound_auth/username must also be supplied.</para></description>
+				</configOption>
+				<configOption name="sends_line_with_registrations" default="no">
+					<synopsis>Sets "line" and "endpoint parameters on registrations.</synopsis>
+					<description><para>Setting this to true will cause the wizard to skip the
+					creation of an identify object to match incoming requests to the endpoint and
+					instead add the line and endpoint parameters to the outbound registration object.
+					</para></description>
 				</configOption>
 				<configOption name="accepts_registrations" default="no">
 					<synopsis>Accept inbound registration from remote hosts.</synopsis>
@@ -597,10 +610,15 @@
 	struct ast_sorcery_object *obj = NULL;
 	const char *id = ast_category_get_name(wiz);
 	const char *contact_pattern;
+	const char *outbound_proxy = ast_variable_find_last_in_list(wizvars, "outbound_proxy");
 	int host_count = AST_VECTOR_SIZE(remote_hosts_vector);
 	RAII_VAR(struct ast_variable *, vars, get_object_variables(wizvars, "aor/"), ast_variables_destroy);
 
 	variable_list_append(&vars, "@pjsip_wizard", id);
+
+	if (!ast_strlen_zero(outbound_proxy)) {
+		variable_list_append_return(&vars, "outbound_proxy", outbound_proxy);
+	}
 
 	/* If the user explicitly specified an aor/contact, don't use remote hosts. */
 	if (!ast_variable_find_last_in_list(vars, "contact")) {
@@ -649,6 +667,7 @@
 	struct ast_variable *wizvars = ast_category_first(wiz);
 	struct ast_sorcery_object *obj = NULL;
 	const char *id = ast_category_get_name(wiz);
+	const char *outbound_proxy = ast_variable_find_last_in_list(wizvars, "outbound_proxy");
 	const char *transport = ast_variable_find_last_in_list(wizvars, "transport");
 	const char *hint_context = hint_context = ast_variable_find_last_in_list(wizvars, "hint_context");
 	const char *hint_exten = ast_variable_find_last_in_list(wizvars, "hint_exten");
@@ -658,6 +677,10 @@
 
 	variable_list_append_return(&vars, "@pjsip_wizard", id);
 	variable_list_append_return(&vars, "aors", id);
+
+	if (!ast_strlen_zero(outbound_proxy)) {
+		variable_list_append_return(&vars, "outbound_proxy", outbound_proxy);
+	}
 
 	if (ast_strlen_zero(hint_context)) {
 		hint_context = ast_variable_find_last_in_list(vars, "context");
@@ -721,8 +744,9 @@
 
 	snprintf(new_id, sizeof(new_id), "%s-identify", id);
 
-	/* If accepting registrations, we don't need an identify. */
-	if (is_variable_true(wizvars, "accepts_registrations")) {
+	/* If accepting registrations or we're sending line, we don't need an identify. */
+	if (is_variable_true(wizvars, "accepts_registrations")
+		|| is_variable_true(wizvars, "sends_line_with_registrations")) {
 		/* If one exists, delete it. */
 		obj = otw->wizard->retrieve_id(sorcery, otw->wizard_data, "identify", new_id);
 		if (obj) {
@@ -838,6 +862,7 @@
 	const char *id = ast_category_get_name(wiz);
 	const char *server_uri_pattern;
 	const char *client_uri_pattern;
+	const char *outbound_proxy = ast_variable_find_last_in_list(wizvars, "outbound_proxy");
 	const char *transport = ast_variable_find_last_in_list(wizvars, "transport");
 	const char *username;
 	char new_id[strlen(id) + MAX_ID_SUFFIX];
@@ -855,6 +880,10 @@
 	search = ast_variable_new("@pjsip_wizard", id, "");
 	if (!search) {
 		return -1;
+	}
+
+	if (!ast_strlen_zero(outbound_proxy)) {
+		variable_list_append_return(&vars, "outbound_proxy", outbound_proxy);
 	}
 
 	otw->wizard->retrieve_multiple(sorcery, otw->wizard_data, "registration", existing, search);
@@ -927,6 +956,11 @@
 			variable_list_append_return(&registration_vars, "transport", transport);
 		}
 
+		if (is_variable_true(wizvars, "sends_line_with_registrations")) {
+			variable_list_append_return(&registration_vars, "line", "yes");
+			variable_list_append_return(&registration_vars, "endpoint", id);
+		}
+
 		snprintf(new_id, sizeof(new_id), "%s-reg-%d", id, host_counter);
 
 		obj = create_object(sorcery, new_id, "registration", registration_vars);

-- 
To view, visit https://gerrit.asterisk.org/5352
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I678e5f80765734c056620528a6d40d82736ceeb0
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: George Joseph <gjoseph at digium.com>



More information about the asterisk-code-review mailing list