[asterisk-commits] kmoore: branch kmoore/pjsip_path_support r404948 - in /team/kmoore/pjsip_path...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 5 20:55:38 CST 2014


Author: kmoore
Date: Sun Jan  5 20:55:34 2014
New Revision: 404948

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404948
Log:
Fix merge conflicts and reenable automerge

Added:
    team/kmoore/pjsip_path_support/include/asterisk/res_pjsip_cli.h
      - copied unchanged from r404936, trunk/include/asterisk/res_pjsip_cli.h
    team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_cli.c
      - copied unchanged from r404936, trunk/res/res_pjsip/pjsip_cli.c
Modified:
    team/kmoore/pjsip_path_support/   (props changed)
    team/kmoore/pjsip_path_support/CHANGES
    team/kmoore/pjsip_path_support/CREDITS
    team/kmoore/pjsip_path_support/UPGRADE-12.txt
    team/kmoore/pjsip_path_support/apps/app_meetme.c
    team/kmoore/pjsip_path_support/cel/cel_pgsql.c
    team/kmoore/pjsip_path_support/channels/chan_dahdi.c
    team/kmoore/pjsip_path_support/channels/chan_pjsip.c
    team/kmoore/pjsip_path_support/configs/chan_dahdi.conf.sample
    team/kmoore/pjsip_path_support/configs/pjsip.conf.sample
    team/kmoore/pjsip_path_support/funcs/func_strings.c
    team/kmoore/pjsip_path_support/include/asterisk/config.h
    team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
    team/kmoore/pjsip_path_support/include/asterisk/sorcery.h
    team/kmoore/pjsip_path_support/main/asterisk.c
    team/kmoore/pjsip_path_support/main/channel.c
    team/kmoore/pjsip_path_support/main/config.c
    team/kmoore/pjsip_path_support/main/http.c
    team/kmoore/pjsip_path_support/main/manager.c
    team/kmoore/pjsip_path_support/main/sorcery.c
    team/kmoore/pjsip_path_support/res/ari/resource_channels.c
    team/kmoore/pjsip_path_support/res/ari/resource_channels.h
    team/kmoore/pjsip_path_support/res/res_ari_channels.c
    team/kmoore/pjsip_path_support/res/res_pjsip.c
    team/kmoore/pjsip_path_support/res/res_pjsip/config_auth.c
    team/kmoore/pjsip_path_support/res/res_pjsip/include/res_pjsip_private.h
    team/kmoore/pjsip_path_support/res/res_pjsip/location.c
    team/kmoore/pjsip_path_support/res/res_pjsip/pjsip_configuration.c
    team/kmoore/pjsip_path_support/res/res_pjsip_authenticator_digest.c
    team/kmoore/pjsip_path_support/res/res_pjsip_endpoint_identifier_ip.c
    team/kmoore/pjsip_path_support/res/res_pjsip_logger.c
    team/kmoore/pjsip_path_support/res/res_pjsip_outbound_registration.c
    team/kmoore/pjsip_path_support/res/res_pjsip_pubsub.c
    team/kmoore/pjsip_path_support/res/res_pjsip_registrar.c
    team/kmoore/pjsip_path_support/res/res_pjsip_session.c
    team/kmoore/pjsip_path_support/rest-api/api-docs/applications.json
    team/kmoore/pjsip_path_support/rest-api/api-docs/channels.json
    team/kmoore/pjsip_path_support/tests/test_stasis.c
    team/kmoore/pjsip_path_support/tests/test_utils.c

Propchange: team/kmoore/pjsip_path_support/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Propchange: team/kmoore/pjsip_path_support/
------------------------------------------------------------------------------
    svn:automerge = *

Propchange: team/kmoore/pjsip_path_support/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jan  5 20:55:34 2014
@@ -1,1 +1,1 @@
-/trunk:1-404464
+/trunk:1-404947

Modified: team/kmoore/pjsip_path_support/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/CHANGES?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/CHANGES (original)
+++ team/kmoore/pjsip_path_support/CHANGES Sun Jan  5 20:55:34 2014
@@ -1176,6 +1176,9 @@
    various SIP functionality in Asterisk. The majority of configuration for
    these modules is performed in pjsip.conf. Other modules may use their
    own configuration files.
+
+ * Added 'set_var' option for an endpoint. For each variable specified that
+   variable gets set upon creation of a channel involving the endpoint.
 
 res_rtp_asterisk
 ------------------

Modified: team/kmoore/pjsip_path_support/CREDITS
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/CREDITS?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/CREDITS (original)
+++ team/kmoore/pjsip_path_support/CREDITS Sun Jan  5 20:55:34 2014
@@ -276,6 +276,8 @@
 	* Andrew "lathama" Latham <lathama at gmail dot com>
 		Doxygen, HTTP-Static, Phoneprov, make update
 
+	* George Joseph - PJSIP CLI commands, PJSIP_HEADER dialplan function
+
 === OTHER CONTRIBUTIONS ===
 
  We'd like to thank the following for their listed contributions.

Modified: team/kmoore/pjsip_path_support/UPGRADE-12.txt
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/UPGRADE-12.txt?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/UPGRADE-12.txt (original)
+++ team/kmoore/pjsip_path_support/UPGRADE-12.txt Sun Jan  5 20:55:34 2014
@@ -219,6 +219,11 @@
    mailbox at context.
 
  - Added mwi_vm_boxes that also must be configured for ISDN MWI to be enabled.
+
+ - ignore_failed_channels now defaults to True: the channel will continue to
+   be configured even if configuring it has failed. This is generally a
+   better setup for systems with not more than one DAHDI device or with DAHDI
+   >= 2.8.0 .
 
 chan_local:
  - The /b option has been removed.
@@ -381,6 +386,8 @@
    direct file read/write functions are marked as dangerous. DB_DELETE() and
    REALTIME_DESTROY() are marked as dangerous for reads, but can now safely
    accept writes (which ignore the provided value).
+ - The default value for live_dangerously was changed from yes (in Asterisk 11
+   and earlier) to no (in Asterisk 12 and greater).
 
 Dialplan:
  - All channel and global variable names are evaluated in a case-sensitive

Modified: team/kmoore/pjsip_path_support/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/apps/app_meetme.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/apps/app_meetme.c (original)
+++ team/kmoore/pjsip_path_support/apps/app_meetme.c Sun Jan  5 20:55:34 2014
@@ -2959,7 +2959,8 @@
  * \param recordingtmp character buffer which may hold the name of the conference recording file
  * \param dahdic dahdi configuration info used by the main conference loop
  */
-static void meetme_menu_admin_extended(enum menu_modes *menu_mode, int *dtmf, struct ast_conference *conf, struct ast_flags64 *confflags, struct ast_channel *chan, struct ast_conf_user *user, char *recordingtmp, struct dahdi_confinfo *dahdic, struct ast_format_cap *cap_slin)
+
+static void meetme_menu_admin_extended(enum menu_modes *menu_mode, int *dtmf, struct ast_conference *conf, struct ast_flags64 *confflags, struct ast_channel *chan, struct ast_conf_user *user, char *recordingtmp, int recordingtmp_size, struct dahdi_confinfo *dahdic, struct ast_format_cap *cap_slin)
 {
 	int keepplaying;
 	int playednamerec;
@@ -3080,7 +3081,7 @@
 				}
 				ast_channel_unlock(chan);
 				if (!conf->recordingfilename) {
-					snprintf(recordingtmp, sizeof(recordingtmp), "meetme-conf-rec-%s-%s", conf->confno, ast_channel_uniqueid(chan));
+					snprintf(recordingtmp, recordingtmp_size, "meetme-conf-rec-%s-%s", conf->confno, ast_channel_uniqueid(chan));
 					conf->recordingfilename = ast_strdup(recordingtmp);
 				}
 				if (!conf->recordingformat) {
@@ -3143,7 +3144,7 @@
  * \param dahdic dahdi configuration info used by the main conference loop
  */
 
-static void meetme_menu(enum menu_modes *menu_mode, int *dtmf, struct ast_conference *conf, struct ast_flags64 *confflags, struct ast_channel *chan, struct ast_conf_user *user, char *recordingtmp, struct dahdi_confinfo *dahdic, struct ast_format_cap *cap_slin)
+static void meetme_menu(enum menu_modes *menu_mode, int *dtmf, struct ast_conference *conf, struct ast_flags64 *confflags, struct ast_channel *chan, struct ast_conf_user *user, char *recordingtmp, int recordingtmp_size, struct dahdi_confinfo *dahdic, struct ast_format_cap *cap_slin)
 {
 	switch (*menu_mode) {
 	case MENU_DISABLED:
@@ -3158,7 +3159,7 @@
 			break;
 		}
 	case MENU_ADMIN_EXTENDED:
-		meetme_menu_admin_extended(menu_mode, dtmf, conf, confflags, chan, user, recordingtmp, dahdic, cap_slin);
+		meetme_menu_admin_extended(menu_mode, dtmf, conf, confflags, chan, user, recordingtmp, recordingtmp_size, dahdic, cap_slin);
 		break;
 	}
 }
@@ -4209,7 +4210,7 @@
 					}
 
 					if (dtmf > 0) {
-						meetme_menu(&menu_mode, &dtmf, conf, confflags, chan, user, recordingtmp, &dahdic, cap_slin);
+						meetme_menu(&menu_mode, &dtmf, conf, confflags, chan, user, recordingtmp, sizeof(recordingtmp), &dahdic, cap_slin);
 					}
 
 					if (musiconhold && !menu_mode) {

Modified: team/kmoore/pjsip_path_support/cel/cel_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/cel/cel_pgsql.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/cel/cel_pgsql.c (original)
+++ team/kmoore/pjsip_path_support/cel/cel_pgsql.c Sun Jan  5 20:55:34 2014
@@ -346,8 +346,9 @@
 static int my_unload_module(void)
 {
 	struct columns *current;
+
+	ast_cel_backend_unregister(PGSQL_BACKEND_NAME);
 	AST_RWLIST_WRLOCK(&psql_columns);
-	ast_cel_backend_unregister(PGSQL_BACKEND_NAME);
 	if (conn) {
 		PQfinish(conn);
 		conn = NULL;
@@ -556,6 +557,10 @@
 		return AST_MODULE_LOAD_SUCCESS;
 	}
 
+	if (reload) {
+		my_unload_module();
+	}
+
 	process_my_load_module(cfg);
 	ast_config_destroy(cfg);
 
@@ -574,7 +579,6 @@
 
 static int reload(void)
 {
-	my_unload_module();
 	return my_load_module(1);
 }
 

Modified: team/kmoore/pjsip_path_support/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/channels/chan_dahdi.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/channels/chan_dahdi.c (original)
+++ team/kmoore/pjsip_path_support/channels/chan_dahdi.c Sun Jan  5 20:55:34 2014
@@ -961,6 +961,7 @@
 			.debouncetime = -1
 		},
 		.is_sig_auto = 1,
+		.ignore_failed_channels = 1,
 		.smdi_port = "/dev/ttyS0",
 	};
 
@@ -14929,8 +14930,8 @@
 
 static char *dahdi_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-#define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
-#define FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
+#define FORMAT "%7s %-15.15s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
+#define FORMAT2 "%7s %-15.15s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
 	ast_group_t targetnum = 0;
 	int filtertype = 0;
 	struct dahdi_pvt *tmp = NULL;

Modified: team/kmoore/pjsip_path_support/channels/chan_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/channels/chan_pjsip.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/channels/chan_pjsip.c (original)
+++ team/kmoore/pjsip_path_support/channels/chan_pjsip.c Sun Jan  5 20:55:34 2014
@@ -346,6 +346,7 @@
 	struct ast_format fmt;
 	RAII_VAR(struct chan_pjsip_pvt *, pvt, NULL, ao2_cleanup);
 	struct ast_sip_channel_pvt *channel;
+	struct ast_variable *var;
 
 	if (!(pvt = ao2_alloc(sizeof(*pvt), chan_pjsip_pvt_dtor))) {
 		return NULL;
@@ -364,6 +365,11 @@
 		return NULL;
 	}
 
+	for (var = session->endpoint->channel_vars; var; var = var->next) {
+		char buf[512];
+		pbx_builtin_setvar_helper(chan, var->name, ast_get_encoded_str(
+						  var->value, buf, sizeof(buf)));
+	}
 
 	ast_channel_stage_snapshot(chan);
 
@@ -1429,8 +1435,6 @@
 
 static int hangup(void *data)
 {
-	pj_status_t status;
-	pjsip_tx_data *packet = NULL;
 	struct hangup_data *h_data = data;
 	struct ast_channel *ast = h_data->chan;
 	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);
@@ -1438,12 +1442,19 @@
 	struct ast_sip_session *session = channel->session;
 	int cause = h_data->cause;
 
-	if (!session->defer_terminate &&
-		((status = pjsip_inv_end_session(session->inv_session, cause ? cause : 603, NULL, &packet)) == PJ_SUCCESS) && packet) {
-		if (packet->msg->type == PJSIP_RESPONSE_MSG) {
-			ast_sip_session_send_response(session, packet);
-		} else {
-			ast_sip_session_send_request(session, packet);
+	if (!session->defer_terminate) {
+		pj_status_t status;
+		pjsip_tx_data *packet = NULL;
+
+		if (session->inv_session->state == PJSIP_INV_STATE_NULL) {
+			pjsip_inv_terminate(session->inv_session, cause ? cause : 603, PJ_TRUE);
+		} else if (((status = pjsip_inv_end_session(session->inv_session, cause ? cause : 603, NULL, &packet)) == PJ_SUCCESS)
+			&& packet) {
+			if (packet->msg->type == PJSIP_RESPONSE_MSG) {
+				ast_sip_session_send_response(session, packet);
+			} else {
+				ast_sip_session_send_request(session, packet);
+			}
 		}
 	}
 

Modified: team/kmoore/pjsip_path_support/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/configs/chan_dahdi.conf.sample?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/configs/chan_dahdi.conf.sample (original)
+++ team/kmoore/pjsip_path_support/configs/chan_dahdi.conf.sample Sun Jan  5 20:55:34 2014
@@ -1167,12 +1167,11 @@
 ;
 ;
 ; ignore_failed_channels: Continue even if some channels failed to configure.
-; False by default, as if even a single channel failed to configure, it might
-; mean other channels are misplaced and having them work may not be a good
-; idea. If enabled (set to true), chan_dahdi will nevertheless attempt to
-; configure other channels rather than giving up. This normally makes sense
-; only if you use names (<subdir>!<number>) for DAHDI channels.
-;ignore_failed_channels = true
+; True by default. Disable this if you can guarantee that DAHDI starts before
+; Asterisk and want to be sure chan_dahdi will not start with broken
+; configuration.
+;
+;ignore_failed_channels = false
 ;
 ; Configure jitter buffers in DAHDI (each one is 20ms, default is 4)
 ; This is set globally, rather than per-channel.

Modified: team/kmoore/pjsip_path_support/configs/pjsip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/configs/pjsip.conf.sample?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/configs/pjsip.conf.sample (original)
+++ team/kmoore/pjsip_path_support/configs/pjsip.conf.sample Sun Jan  5 20:55:34 2014
@@ -539,7 +539,8 @@
                 ; other party or both (default: "")
 ;srtp_tag_32=no ; Determines whether 32 byte tags should be used instead of 80
                 ; byte tags (default: "no")
-
+;set_var=       ; Variable set on a channel involving the endpoint. For multiple
+		; channel variables specify multiple 'set_var'(s)
 
 ;==========================AUTH SECTION OPTIONS=========================
 ;[auth]

Modified: team/kmoore/pjsip_path_support/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/funcs/func_strings.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/funcs/func_strings.c (original)
+++ team/kmoore/pjsip_path_support/funcs/func_strings.c Sun Jan  5 20:55:34 2014
@@ -841,8 +841,7 @@
 		 * directly there */
 		if (strchr(find, *strptr)) {
 			if (ast_strlen_zero(replace)) {
-				/* Remove character */
-				strcpy(strptr, strptr + 1); /* SAFE */
+				memmove(strptr, strptr + 1, strlen(strptr + 1) + 1);
 				strptr--;
 			} else {
 				/* Replace character */
@@ -1726,6 +1725,76 @@
 	return res;
 }
 
+AST_TEST_DEFINE(test_REPLACE)
+{
+	int i, res = AST_TEST_PASS;
+	struct ast_channel *chan;
+	struct ast_str *str;
+	char expression[256];
+	struct {
+		const char *test_string;
+		const char *find_chars;
+		const char *replace_char;
+		const char *expected;
+	} test_args[] = {
+		{"abc,def", "\\,", "-", "abc-def"},
+		{"abc,abc", "bc",  "a", "aaa,aaa"},
+		{"abc,def", "x",   "?", "abc,def"},
+		{"abc,def", "\\,", "",  "abcdef"}
+	};
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "func_REPLACE_test";
+		info->category = "/funcs/func_strings/";
+		info->summary = "Test REPLACE function";
+		info->description = "Verify REPLACE behavior";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	if (!(chan = ast_dummy_channel_alloc())) {
+		ast_test_status_update(test, "Unable to allocate dummy channel\n");
+		return AST_TEST_FAIL;
+	}
+
+	if (!(str = ast_str_create(16))) {
+		ast_test_status_update(test, "Unable to allocate dynamic string buffer\n");
+		ast_channel_release(chan);
+		return AST_TEST_FAIL;
+	}
+
+	for (i = 0; i < ARRAY_LEN(test_args); i++) {
+		struct ast_var_t *var = ast_var_assign("TEST_STRING", test_args[i].test_string);
+		if (!var) {
+			ast_test_status_update(test, "Out of memory\n");
+			res = AST_TEST_FAIL;
+			break;
+		}
+
+		AST_LIST_INSERT_HEAD(ast_channel_varshead(chan), var, entries);
+
+		snprintf(expression, sizeof(expression), "${REPLACE(%s,%s,%s)}", var->name, test_args[i].find_chars, test_args[i].replace_char);
+		ast_str_substitute_variables(&str, 0, chan, expression);
+
+		AST_LIST_REMOVE(ast_channel_varshead(chan), var, entries);
+		ast_var_delete(var);
+
+		if (strcasecmp(ast_str_buffer(str), test_args[i].expected)) {
+			ast_test_status_update(test, "Evaluation of '%s' returned '%s' instead of the expected value '%s'\n",
+				expression, ast_str_buffer(str), test_args[i].expected);
+			res = AST_TEST_FAIL;
+			break;
+		}
+	}
+
+	ast_free(str);
+	ast_channel_release(chan);
+
+	return res;
+}
+
 AST_TEST_DEFINE(test_FILTER)
 {
 	int i, res = AST_TEST_PASS;
@@ -1843,6 +1912,7 @@
 	int res = 0;
 
 	AST_TEST_UNREGISTER(test_FIELDNUM);
+	AST_TEST_UNREGISTER(test_REPLACE);
 	AST_TEST_UNREGISTER(test_FILTER);
 	AST_TEST_UNREGISTER(test_STRREPLACE);
 	res |= ast_custom_function_unregister(&fieldqty_function);
@@ -1879,6 +1949,7 @@
 	int res = 0;
 
 	AST_TEST_REGISTER(test_FIELDNUM);
+	AST_TEST_REGISTER(test_REPLACE);
 	AST_TEST_REGISTER(test_FILTER);
 	AST_TEST_REGISTER(test_STRREPLACE);
 	res |= ast_custom_function_register(&fieldqty_function);

Modified: team/kmoore/pjsip_path_support/include/asterisk/config.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/config.h?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/config.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/config.h Sun Jan  5 20:55:34 2014
@@ -691,6 +691,7 @@
 void ast_variable_append(struct ast_category *category, struct ast_variable *variable);
 void ast_variable_insert(struct ast_category *category, struct ast_variable *variable, const char *line);
 int ast_variable_delete(struct ast_category *category, const char *variable, const char *match, const char *line);
+struct ast_variable *ast_variable_list_sort(struct ast_variable *start);
 
 /*!
  * \brief Update variable value within a config

Modified: team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/res_pjsip.h Sun Jan  5 20:55:34 2014
@@ -40,6 +40,9 @@
 #include "asterisk/rtp_engine.h"
 /* Needed for AST_VECTOR macro */
 #include "asterisk/vector.h"
+/* Needed for ast_sip_for_each_channel_snapshot struct */
+#include "asterisk/stasis_channels.h"
+#include "asterisk/stasis_endpoints.h"
 
 /* Forward declarations of PJSIP stuff */
 struct pjsip_rx_data;
@@ -215,6 +218,17 @@
 	struct ao2_container *permanent_contacts;
 	/*! Determines whether SIP Path headers are supported */
 	unsigned int support_path;
+};
+
+/*!
+ * \brief Aor/Contact pair used for ast_sip_for_each_contact callback.
+ */
+struct ast_sip_aor_contact_pair {
+	SORCERY_OBJECT(details);
+	/*! Aor */
+	struct ast_sip_aor *aor;
+	/*! Contact */
+	struct ast_sip_contact *contact;
 };
 
 /*!
@@ -579,6 +593,8 @@
 	unsigned int allowtransfer;
 	/*! Method used when handling redirects */
 	enum ast_sip_session_redirect redirect_method;
+	/*! Variables set on channel creation */
+	struct ast_variable *channel_vars;
 };
 
 /*!
@@ -1570,13 +1586,6 @@
 	mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
 
 /*!
- * \brief Function pointer for contact callbacks.
- */
-typedef int (*on_contact_t)(const struct ast_sip_aor *aor,
-			    const struct ast_sip_contact *contact,
-			    int last, void *arg);
-
-/*!
  * \brief For every contact on an AOR call the given 'on_contact' handler.
  *
  * \param aor the aor containing a list of contacts to iterate
@@ -1584,21 +1593,18 @@
  * \param arg user data passed to handler
  * \retval 0 Success, non-zero on failure
  */
-int ast_sip_for_each_contact(const struct ast_sip_aor *aor,
-			     on_contact_t on_contact, void *arg);
+int ast_sip_for_each_contact(struct ast_sip_aor *aor,
+		ao2_callback_fn on_contact, void *arg);
 
 /*!
  * \brief Handler used to convert a contact to a string.
  *
- * \param aor the aor containing a list of contacts to iterate
- * \param contact the contact to convert
- * \param last is this the last contact
+ * \param object the ast_sip_aor_contact_pair containing a list of contacts to iterate and the contact
  * \param arg user data passed to handler
+ * \param flags
  * \retval 0 Success, non-zero on failure
  */
-int ast_sip_contact_to_str(const struct ast_sip_aor *aor,
-			   const struct ast_sip_contact *contact,
-			   int last, void *arg);
+int ast_sip_contact_to_str(void *object, void *arg, int flags);
 
 /*!
  * \brief For every aor in the comma separated aors string call the
@@ -1718,6 +1724,49 @@
  */
 int ast_sip_format_auths_ami(const struct ast_sip_auth_vector *auths,
 			     struct ast_sip_ami *ami);
+
+/*!
+ * \brief Retrieve the endpoint snapshot for an endpoint
+ *
+ * \param endpoint The endpoint whose snapshot is to be retreieved.
+ * \retval The endpoint snapshot
+ */
+struct ast_endpoint_snapshot *ast_sip_get_endpoint_snapshot(
+	const struct ast_sip_endpoint *endpoint);
+
+/*!
+ * \brief Retrieve the device state for an endpoint.
+ *
+ * \param endpoint The endpoint whose state is to be retrieved.
+ * \retval The device state.
+ */
+const char *ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint);
+
+/*!
+ * \brief For every channel snapshot on an endpoint snapshot call the given
+ *        'on_channel_snapshot' handler.
+ *
+ * \param endpoint_snapshot snapshot of an endpoint
+ * \param on_channel_snapshot callback for each channel snapshot
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_for_each_channel_snapshot(const struct ast_endpoint_snapshot *endpoint_snapshot,
+		ao2_callback_fn on_channel_snapshot,
+				      void *arg);
+
+/*!
+ * \brief For every channel snapshot on an endpoint all the given
+ *        'on_channel_snapshot' handler.
+ *
+ * \param endpoint endpoint
+ * \param on_channel_snapshot callback for each channel snapshot
+ * \param arg user data passed to handler
+ * \retval 0 Success, non-zero on failure
+ */
+int ast_sip_for_each_channel(const struct ast_sip_endpoint *endpoint,
+		ao2_callback_fn on_channel_snapshot,
+				      void *arg);
 
 enum ast_sip_supplement_priority {
 	/*! Top priority. Supplements with this priority are those that need to run before any others */

Modified: team/kmoore/pjsip_path_support/include/asterisk/sorcery.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/include/asterisk/sorcery.h?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/include/asterisk/sorcery.h (original)
+++ team/kmoore/pjsip_path_support/include/asterisk/sorcery.h Sun Jan  5 20:55:34 2014
@@ -823,6 +823,12 @@
  */
 int ast_sorcery_object_set_extended(const void *object, const char *name, const char *value);
 
+/*!
+ * \brief Sorcery object comparator based on id.
+ */
+int ast_sorcery_object_id_compare(const void *obj_left, const void *obj_right, int flags);
+
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/kmoore/pjsip_path_support/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/asterisk.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/main/asterisk.c (original)
+++ team/kmoore/pjsip_path_support/main/asterisk.c Sun Jan  5 20:55:34 2014
@@ -3571,7 +3571,9 @@
 			live_dangerously = ast_true(v->value);
 		}
 	}
-	pbx_live_dangerously(live_dangerously);
+	if (!ast_opt_remote) {
+		pbx_live_dangerously(live_dangerously);
+	}
 	for (v = ast_variable_browse(cfg, "compat"); v; v = v->next) {
 		float version;
 		if (sscanf(v->value, "%30f", &version) != 1) {

Modified: team/kmoore/pjsip_path_support/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/channel.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/main/channel.c (original)
+++ team/kmoore/pjsip_path_support/main/channel.c Sun Jan  5 20:55:34 2014
@@ -275,7 +275,7 @@
 /*! \brief Show channel types - CLI command */
 static char *handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-#define FORMAT  "%-10.10s  %-40.40s %-12.12s %-12.12s %-12.12s\n"
+#define FORMAT  "%-15.15s  %-40.40s %-12.12s %-12.12s %-12.12s\n"
 	struct chanlist *cl;
 	int count_chan = 0;
 
@@ -295,7 +295,7 @@
 		return CLI_SHOWUSAGE;
 
 	ast_cli(a->fd, FORMAT, "Type", "Description",       "Devicestate", "Indications", "Transfer");
-	ast_cli(a->fd, FORMAT, "----------", "-----------", "-----------", "-----------", "--------");
+	ast_cli(a->fd, FORMAT, "-----------", "-----------", "-----------", "-----------", "-----------");
 
 	AST_RWLIST_RDLOCK(&backends);
 	AST_RWLIST_TRAVERSE(&backends, cl, list) {
@@ -733,6 +733,8 @@
 		return "Dialing Offhook";
 	case AST_STATE_PRERING:
 		return "Pre-ring";
+	case AST_STATE_MUTE:
+		return "Mute";
 	default:
 		if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE)))
 			return "Unknown";

Modified: team/kmoore/pjsip_path_support/main/config.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/config.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/main/config.c (original)
+++ team/kmoore/pjsip_path_support/main/config.c Sun Jan  5 20:55:34 2014
@@ -70,6 +70,7 @@
 
 static struct ao2_container *cfg_hooks;
 static void config_hook_exec(const char *filename, const char *module, struct ast_config *cfg);
+inline struct ast_variable *variable_list_switch(struct ast_variable *l1, struct ast_variable *l2);
 
 /*! \brief Structure to keep comments for rewriting configuration files */
 struct ast_comment {
@@ -579,6 +580,39 @@
 	}
 
 	return (cat) ? cat->root : NULL;
+}
+
+inline struct ast_variable *variable_list_switch(struct ast_variable *l1, struct ast_variable *l2)
+{
+    l1->next = l2->next;
+    l2->next = l1;
+    return l2;
+}
+
+struct ast_variable *ast_variable_list_sort(struct ast_variable *start)
+{
+	struct ast_variable *p, *q, *top;
+	int changed = 1;
+	top = ast_calloc(1, sizeof(struct ast_variable));
+	top->next = start;
+	if (start != NULL && start->next != NULL) {
+		while (changed) {
+			changed = 0;
+			q = top;
+			p = top->next;
+			while (p->next != NULL) {
+				if (p->next != NULL && strcmp(p->name, p->next->name) > 0) {
+					q->next = variable_list_switch(p, p->next);
+
+					changed = 1;
+				}
+				q = p;
+				if (p->next != NULL)
+					p = p->next;
+			}
+		}
+	}
+	return top->next;
 }
 
 const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var)

Modified: team/kmoore/pjsip_path_support/main/http.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/http.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/main/http.c (original)
+++ team/kmoore/pjsip_path_support/main/http.c Sun Jan  5 20:55:34 2014
@@ -609,6 +609,27 @@
 #define MAX_POST_CONTENT 1025
 
 /*!
+ * \brief Retrieves the header with the given field name.
+ *
+ * \param headers Headers to search.
+ * \param field_name Name of the header to find.
+ * \return Associated header value.
+ * \return \c NULL if header is not present.
+ */
+static const char *get_header(struct ast_variable *headers,
+	const char *field_name)
+{
+	struct ast_variable *v;
+
+	for (v = headers; v; v = v->next) {
+		if (!strcasecmp(v->name, field_name)) {
+			return v->value;
+		}
+	}
+	return NULL;
+}
+
+/*!
  * \brief Retrieves the content type specified in the "Content-Type" header.
  *
  * This function only returns the "type/subtype" and any trailing parameter is
@@ -620,32 +641,51 @@
  */
 static char *get_content_type(struct ast_variable *headers)
 {
-	struct ast_variable *v;
-
-	for (v = headers; v; v = v->next) {
-		if (strcasecmp(v->name, "Content-Type") == 0) {
-			const char *param = strchr(v->value, ';');
-			size_t size = (param ? param - v->value :
-				       strlen(v->value)) + 1;
-			return ast_strndup(v->value, size);
-		}
-	}
-
-	return NULL;
-}
-
+	const char *content_type = get_header(headers, "Content-Type");
+	const char *param;
+	size_t size;
+
+	if (!content_type) {
+		return NULL;
+	}
+
+	param = strchr(content_type, ';');
+	size = param ? param - content_type : strlen(content_type);
+
+	return ast_strndup(content_type, size);
+}
+
+/*!
+ * \brief Returns the value of the Content-Length header.
+ *
+ * \param headers HTTP headers.
+ * \return Value of the Content-Length header.
+ * \return 0 if header is not present, or is invalid.
+ */
 static int get_content_length(struct ast_variable *headers)
 {
-	struct ast_variable *v;
-
-	for (v = headers; v; v = v->next) {
-		if (!strcasecmp(v->name, "Content-Length")) {
-			return atoi(v->value);
-		}
-	}
-
-	/* Missing content length; assume zero */
-	return 0;
+	const char *content_length = get_header(headers, "Content-Length");
+
+	if (!content_length) {
+		/* Missing content length; assume zero */
+		return 0;
+	}
+
+	/* atoi() will return 0 for invalid inputs, which is good enough for
+	 * the HTTP parsing. */
+	return atoi(content_length);
+}
+
+/*!
+ * \brief Returns the value of the Transfer-Encoding header.
+ *
+ * \param headers HTTP headers.
+ * \return Value of the Transfer-Encoding header.
+ * \return 0 if header is not present, or is invalid.
+ */
+static const char *get_transfer_encoding(struct ast_variable *headers)
+{
+	return get_header(headers, "Transfer-Encoding");
 }
 
 struct ast_json *ast_http_get_json(
@@ -1068,6 +1108,7 @@
 	struct ast_variable *tail = headers;
 	char *uri, *method;
 	enum ast_http_method http_method = AST_HTTP_UNKNOWN;
+	const char *transfer_encoding;
 
 	if (ast_atomic_fetchadd_int(&session_count, +1) >= session_limit) {
 		goto done;
@@ -1138,6 +1179,22 @@
 			tail->next = ast_variable_new(name, value, __FILE__);
 			tail = tail->next;
 		}
+	}
+
+	transfer_encoding = get_transfer_encoding(headers);
+	/* Transfer encoding defaults to identity */
+	if (!transfer_encoding) {
+		transfer_encoding = "identity";
+	}
+
+	/*
+	 * RFC 2616, section 3.6, we should respond with a 501 for any transfer-
+	 * codings we don't understand.
+	 */
+	if (strcasecmp(transfer_encoding, "identity") != 0) {
+		/* Transfer encodings not supported */
+		ast_http_error(ser, 501, "Unimplemented", "Unsupported Transfer-Encoding.");
+		goto done;
 	}
 
 	if (!*uri) {

Modified: team/kmoore/pjsip_path_support/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/manager.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/main/manager.c (original)
+++ team/kmoore/pjsip_path_support/main/manager.c Sun Jan  5 20:55:34 2014
@@ -5170,7 +5170,7 @@
 
 	ast_str_reset(body);
 
-	for (x = 0; x < m->hdrcount; x++) {
+	for (x = 1; x < m->hdrcount; x++) {
 		if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) {
 			ast_str_append(&body, 0, "%s\r\n", m->headers[x]);
 		}

Modified: team/kmoore/pjsip_path_support/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/main/sorcery.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/main/sorcery.c (original)
+++ team/kmoore/pjsip_path_support/main/sorcery.c Sun Jan  5 20:55:34 2014
@@ -1583,3 +1583,11 @@
 	ao2_callback(object_type->observers, OBJ_NODATA | OBJ_UNLINK,
 		sorcery_observer_remove, cbs);
 }
+
+int ast_sorcery_object_id_compare(const void *obj_left, const void *obj_right, int flags)
+{
+	if (!obj_left || !obj_right) {
+		return 0;
+	}
+	return strcmp(ast_sorcery_object_get_id(obj_left), ast_sorcery_object_get_id(obj_right));
+}

Modified: team/kmoore/pjsip_path_support/res/ari/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/ari/resource_channels.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/res/ari/resource_channels.c (original)
+++ team/kmoore/pjsip_path_support/res/ari/resource_channels.c Sun Jan  5 20:55:34 2014
@@ -687,43 +687,6 @@
 	ast_ari_response_ok(response, ast_json_ref(json));
 }
 
-static int ari_channels_set_channel_var(struct ast_channel *chan,
-	const char *variable, const char *value, struct ast_ari_response *response)
-{
-	if (pbx_builtin_setvar_helper(chan, variable, value)) {
-		ast_ari_response_error(
-			response, 400, "Bad Request",
-			"Unable to set channel variable %s=%s", variable, value);
-		return -1;
-	}
-
-	return 0;
-}
-
-static int ari_channels_set_channel_vars(struct ast_channel *chan,
-	struct ast_json *variables, struct ast_ari_response *response)
-{
-	struct ast_json_iter *i;
-
-	if (!variables) {
-		/* nothing to do */
-		return 0;
-	}
-
-	for (i = ast_json_object_iter(variables); i;
-	     i = ast_json_object_iter_next(variables, i)) {
-		if (ari_channels_set_channel_var(
-			chan, ast_json_object_iter_key(i),
-			ast_json_string_get(ast_json_object_iter_value(i)),
-			response)) {
-			/* response filled in by called function */
-			return -1;
-		}
-	}
-
-	return 0;
-}
-
 void ast_ari_channels_originate(struct ast_variable *headers,
 	struct ast_ari_channels_originate_args *args,
 	struct ast_ari_response *response)
@@ -813,11 +776,6 @@
 		return;
 	}
 
-	if (ari_channels_set_channel_vars(chan, args->variables, response)) {
-		/* response filled in by called function */
-		return;
-	}
-
 	snapshot = ast_channel_snapshot_create(chan);
 	ast_channel_unlock(chan);
 

Modified: team/kmoore/pjsip_path_support/res/ari/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/ari/resource_channels.h?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/res/ari/resource_channels.h (original)
+++ team/kmoore/pjsip_path_support/res/ari/resource_channels.h Sun Jan  5 20:55:34 2014
@@ -68,8 +68,6 @@
 	const char *caller_id;
 	/*! \brief Timeout (in seconds) before giving up dialing, or -1 for no timeout. */
 	int timeout;
-	/*! \brief Variables to be set on the channel. */
-	struct ast_json *variables;
 };
 /*!
  * \brief Create a new channel (originate).

Modified: team/kmoore/pjsip_path_support/res/res_ari_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_ari_channels.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_ari_channels.c (original)
+++ team/kmoore/pjsip_path_support/res/res_ari_channels.c Sun Jan  5 20:55:34 2014
@@ -117,6 +117,7 @@
 	struct ast_ari_channels_originate_args args = {};
 	struct ast_variable *i;
 	RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
+	struct ast_json *field;
 #if defined(AST_DEVMODE)
 	int is_valid;
 	int code;
@@ -164,7 +165,39 @@
 			goto fin;
 		}
 	}
-	args.variables = ast_json_ref(body);
+	/* Parse query parameters out of it */
+	field = ast_json_object_get(body, "endpoint");
+	if (field) {
+		args.endpoint = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "extension");
+	if (field) {
+		args.extension = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "context");
+	if (field) {
+		args.context = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "priority");
+	if (field) {
+		args.priority = ast_json_integer_get(field);
+	}
+	field = ast_json_object_get(body, "app");
+	if (field) {
+		args.app = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "appArgs");
+	if (field) {
+		args.app_args = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "callerId");
+	if (field) {
+		args.caller_id = ast_json_string_get(field);
+	}
+	field = ast_json_object_get(body, "timeout");
+	if (field) {
+		args.timeout = ast_json_integer_get(field);
+	}
 	ast_ari_channels_originate(headers, &args, response);
 #if defined(AST_DEVMODE)
 	code = response->response_code;

Modified: team/kmoore/pjsip_path_support/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip.c?view=diff&rev=404948&r1=404947&r2=404948
==============================================================================
--- team/kmoore/pjsip_path_support/res/res_pjsip.c (original)
+++ team/kmoore/pjsip_path_support/res/res_pjsip.c Sun Jan  5 20:55:34 2014
@@ -663,6 +663,14 @@
 					<description><para>
 						This option only applies if <replaceable>media_encryption</replaceable> is
 						set to <literal>sdes</literal> or <literal>dtls</literal>.
+					</para></description>
+				</configOption>
+				<configOption name="set_var">
+					<synopsis>Variable set on a channel involving the endpoint.</synopsis>
+					<description><para>
+					        When a new channel is created using the endpoint set the specified
+						variable(s) on that channel. For multiple channel variables specify
+						multiple 'set_var'(s).
 					</para></description>
 				</configOption>
 			</configObject>

Modified: team/kmoore/pjsip_path_support/res/res_pjsip/config_auth.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_path_support/res/res_pjsip/config_auth.c?view=diff&rev=404948&r1=404947&r2=404948

[... 1575 lines stripped ...]



More information about the asterisk-commits mailing list