[asterisk-commits] file: branch mjordan/pjsip-cli r404453 - in /team/mjordan/pjsip-cli: include/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 20 14:34:35 CST 2013


Author: file
Date: Fri Dec 20 14:34:31 2013
New Revision: 404453

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404453
Log:
res_pjsip_endpoint_identifier_ip: Remove CLI functionality.

This change introduced a hard dependency on res_pjsip_endpoint_identifier_ip
in certain situations, potentially circular depending on resolution.

Removed:
    team/mjordan/pjsip-cli/include/asterisk/res_pjsip_endpoint_identifier_ip.h
    team/mjordan/pjsip-cli/res/res_pjsip_endpoint_identifier_ip.exports.in
Modified:
    team/mjordan/pjsip-cli/res/res_pjsip/pjsip_cli.c
    team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c
    team/mjordan/pjsip-cli/res/res_pjsip_endpoint_identifier_ip.c

Modified: team/mjordan/pjsip-cli/res/res_pjsip/pjsip_cli.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/pjsip-cli/res/res_pjsip/pjsip_cli.c?view=diff&rev=404453&r1=404452&r2=404453
==============================================================================
--- team/mjordan/pjsip-cli/res/res_pjsip/pjsip_cli.c (original)
+++ team/mjordan/pjsip-cli/res/res_pjsip/pjsip_cli.c Fri Dec 20 14:34:31 2013
@@ -21,7 +21,6 @@
 #include <pjsip.h>
 #include <pjsip_ua.h>
 #include "asterisk/res_pjsip.h"
-#include "asterisk/res_pjsip_endpoint_identifier_ip.h"
 #include "include/res_pjsip_private.h"
 #include "asterisk/res_pjsip_cli.h"
 #include "asterisk/acl.h"

Modified: team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c?view=diff&rev=404453&r1=404452&r2=404453
==============================================================================
--- team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c (original)
+++ team/mjordan/pjsip-cli/res/res_pjsip/pjsip_configuration.c Fri Dec 20 14:34:31 2013
@@ -11,7 +11,6 @@
 #include <pjsip_ua.h>
 
 #include "asterisk/res_pjsip.h"
-#include "asterisk/res_pjsip_endpoint_identifier_ip.h"
 #include "include/res_pjsip_private.h"
 #include "asterisk/res_pjsip_cli.h"
 #include "asterisk/acl.h"
@@ -1328,10 +1327,6 @@
 		formatter_entry = ast_sip_lookup_cli_formatter("aor");
 		if (formatter_entry) {
 			ast_sip_for_each_aor(endpoint->aors, formatter_entry->print_body, context);
-		}
-		formatter_entry = ast_sip_lookup_cli_formatter("identify");
-		if (formatter_entry) {
-			ast_sip_for_each_identify(endpoint, formatter_entry->print_body, context);
 		}
 		formatter_entry = ast_sip_lookup_cli_formatter("channel");
 		if (formatter_entry) {

Modified: team/mjordan/pjsip-cli/res/res_pjsip_endpoint_identifier_ip.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/pjsip-cli/res/res_pjsip_endpoint_identifier_ip.c?view=diff&rev=404453&r1=404452&r2=404453
==============================================================================
--- team/mjordan/pjsip-cli/res/res_pjsip_endpoint_identifier_ip.c (original)
+++ team/mjordan/pjsip-cli/res/res_pjsip_endpoint_identifier_ip.c Fri Dec 20 14:34:31 2013
@@ -27,11 +27,10 @@
 #include <pjsip.h>
 
 #include "asterisk/res_pjsip.h"
-#include "asterisk/res_pjsip_endpoint_identifier_ip.h"
-#include "asterisk/res_pjsip_cli.h"
 #include "asterisk/module.h"
 #include "asterisk/acl.h"
 #include "asterisk/manager.h"
+#include "res_pjsip/include/res_pjsip_private.h"
 
 /*** DOCUMENTATION
 	<configInfo name="res_pjsip_endpoint_identifier_ip" language="en_US">
@@ -59,10 +58,23 @@
 	</configInfo>
  ***/
 
+/*! \brief Structure for an IP identification matching object */
+struct ip_identify_match {
+	/*! \brief Sorcery object details */
+	SORCERY_OBJECT(details);
+	/*! \brief Stringfields */
+	AST_DECLARE_STRING_FIELDS(
+		/*! The name of the endpoint */
+		AST_STRING_FIELD(endpoint_name);
+	);
+	/*! \brief Networks or addresses that should match this */
+	struct ast_ha *matches;
+};
+
 /*! \brief Destructor function for a matching object */
 static void ip_identify_destroy(void *obj)
 {
-	struct ast_sip_ip_identify_match *identify = obj;
+	struct ip_identify_match *identify = obj;
 
 	ast_string_field_free_memory(identify);
 	ast_free_ha(identify->matches);
@@ -71,7 +83,7 @@
 /*! \brief Allocator function for a matching object */
 static void *ip_identify_alloc(const char *name)
 {
-	struct ast_sip_ip_identify_match *identify = ast_sorcery_generic_alloc(sizeof(*identify), ip_identify_destroy);
+	struct ip_identify_match *identify = ast_sorcery_generic_alloc(sizeof(*identify), ip_identify_destroy);
 
 	if (!identify || ast_string_field_init(identify, 256)) {
 		ao2_cleanup(identify);
@@ -84,7 +96,7 @@
 /*! \brief Comparator function for a matching object */
 static int ip_identify_match_check(void *obj, void *arg, int flags)
 {
-	struct ast_sip_ip_identify_match *identify = obj;
+	struct ip_identify_match *identify = obj;
 	struct ast_sockaddr *addr = arg;
 	int sense;
 
@@ -106,7 +118,7 @@
 {
 	struct ast_sockaddr addr = { { 0, } };
 	RAII_VAR(struct ao2_container *, candidates, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_sip_ip_identify_match *, match, NULL, ao2_cleanup);
+	RAII_VAR(struct ip_identify_match *, match, NULL, ao2_cleanup);
 	struct ast_sip_endpoint *endpoint;
 
 	/* If no possibilities exist return early to save some time */
@@ -143,7 +155,7 @@
 /*! \brief Custom handler for match field */
 static int ip_identify_match_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
 {
-	struct ast_sip_ip_identify_match *identify = obj;
+	struct ip_identify_match *identify = obj;
 	int error = 0;
 
 	/* We deny what we actually want to match because there is an implicit permit all rule for ACLs */
@@ -157,14 +169,14 @@
 static int ip_identify_match_to_str(const void *obj, const intptr_t *args, char **buf)
 {
 	RAII_VAR(struct ast_str *, str, ast_str_create(MAX_OBJECT_FIELD), ast_free);
-	const struct ast_sip_ip_identify_match *identify = obj;
+	const struct ip_identify_match *identify = obj;
 
 	ast_ha_join(identify->matches, &str);
 	*buf = ast_strdup(ast_str_buffer(str));
 	return 0;
 }
 
-static int sip_identify_to_ami(const struct ast_sip_ip_identify_match *identify,
+static int sip_identify_to_ami(const struct ip_identify_match *identify,
 			       struct ast_str **buf)
 {
 	return ast_sip_sorcery_object_to_ami(identify, buf);
@@ -172,37 +184,17 @@
 
 static int find_identify_by_endpoint(void *obj, void *arg, int flags)
 {
-	struct ast_sip_ip_identify_match *identify = obj;
+	struct ip_identify_match *identify = obj;
 	const char *endpoint_name = arg;
 
 	return strcmp(identify->endpoint_name, endpoint_name) ? 0 : CMP_MATCH | CMP_STOP;
-}
-
-int ast_sip_for_each_identify(const struct ast_sip_endpoint *endpoint,
-	ao2_callback_fn on_identify, void *arg)
-{
-	RAII_VAR(struct ao2_container *, identifies, NULL, ao2_cleanup);
-
-	struct ast_variable *fields = ast_calloc(1, sizeof(struct ast_variable));
-	fields->name = "endpoint";
-	fields->value = ast_sorcery_object_get_id(endpoint);
-	fields->next = NULL;
-
-	if (!(identifies = ast_sorcery_retrieve_by_fields(
-		      ast_sip_get_sorcery(), "identify", AST_RETRIEVE_FLAG_MULTIPLE, fields))) {
-		return -1;
-	}
-
-	ao2_callback(identifies, OBJ_NOLOCK, on_identify, arg);
-
-	return 0;
 }
 
 static int format_ami_endpoint_identify(const struct ast_sip_endpoint *endpoint,
 					struct ast_sip_ami *ami)
 {
 	RAII_VAR(struct ao2_container *, identifies, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_sip_ip_identify_match *, identify, NULL, ao2_cleanup);
+	RAII_VAR(struct ip_identify_match *, identify, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_str *, buf, NULL, ast_free);
 
 	if (!(identifies = ast_sorcery_retrieve_by_fields(
@@ -236,84 +228,6 @@
 	.format_ami = format_ami_endpoint_identify
 };
 
-static int populate_identify_container(void *obj, void *arg, int flags) {
-	struct ast_sip_ip_identify_match *ident = obj;
-	struct ao2_container *container = arg;
-	ao2_link(container, ident);
-	return 0;
-}
-
-static int gather_endpoint_identifies(void *obj, void *arg, int flags) {
-	struct ast_sip_endpoint *endpoint = obj;
-	struct ao2_container *container = arg;
-	ast_sip_for_each_identify(endpoint, populate_identify_container, container);
-	return 0;
-}
-
-static struct ao2_container *cli_get_identify_container(struct ast_sorcery *sip_sorcery)
-{
-	RAII_VAR(struct ao2_container *, parent_container, NULL, ao2_cleanup);
-	RAII_VAR(struct ao2_container *, s_parent_container, NULL, ao2_cleanup);
-	RAII_VAR(struct ao2_container *, child_container, NULL, ao2_cleanup);
-
-	parent_container =  ast_sorcery_retrieve_by_fields(sip_sorcery, "endpoint",
-				AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL);
-
-	s_parent_container = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, &ast_sorcery_object_id_compare, NULL);
-
-	ao2_container_dup(s_parent_container, parent_container, OBJ_ORDER_ASCENDING);
-
-	child_container = ao2_t_container_alloc_hash(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, 1, NULL,
-		NULL, NULL, 0);
-
-	ao2_callback(s_parent_container, OBJ_NODATA, gather_endpoint_identifies, child_container);
-
-	return child_container;
-}
-
-
-
-static int cli_print_identify_header(void *obj, void *arg, int flags)
-{
-	struct ast_sip_cli_context *context = arg;
-	int indent = CLI_INDENT_TO_SPACES(context->indent_level);
-	int filler = CLI_MAX_WIDTH - indent - 14;
-
-	if (!context->output_buffer) {
-		return -1;
-	}
-
-	ast_str_append(&context->output_buffer, 0,
-		"%*s:  <MatchList%*.*s>\n",
-		indent, "Identify", filler, filler, CLI_HEADER_FILLER);
-
-	return 0;
-}
-
-static int cli_print_identify_body(void *obj, void *arg, int flags) {
-	RAII_VAR(struct ast_str *, str, ast_str_create(MAX_OBJECT_FIELD), ast_free);
-	struct ast_sip_ip_identify_match *ident = obj;
-	struct ast_sip_cli_context *context = arg;
-
-	if (!context->output_buffer) {
-		return -1;
-	}
-
-	ast_str_append(&context->output_buffer, 0, "%*s: ",
-		CLI_INDENT_TO_SPACES(context->indent_level), "Identify");
-	ast_ha_join(ident->matches, &str);
-	ast_str_append(&context->output_buffer, 0, "%s\n", ast_str_buffer(str));
-
-	return 0;
-}
-
-static struct ast_sip_cli_formatter_entry  cli_identify_formatter = {
-	.name = "identify",
-	.print_header = cli_print_identify_header,
-	.print_body = cli_print_identify_body,
-	.get_container = cli_get_identify_container,
-};
-
 static int load_module(void)
 {
 	ast_sorcery_apply_default(ast_sip_get_sorcery(), "identify", "config", "pjsip.conf,criteria=type=identify");
@@ -323,13 +237,12 @@
 	}
 
 	ast_sorcery_object_field_register(ast_sip_get_sorcery(), "identify", "type", "", OPT_NOOP_T, 0, 0);
-	ast_sorcery_object_field_register(ast_sip_get_sorcery(), "identify", "endpoint", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_ip_identify_match, endpoint_name));
+	ast_sorcery_object_field_register(ast_sip_get_sorcery(), "identify", "endpoint", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ip_identify_match, endpoint_name));
 	ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "identify", "match", "", ip_identify_match_handler, ip_identify_match_to_str, 0, 0);
 	ast_sorcery_reload_object(ast_sip_get_sorcery(), "identify");
 
 	ast_sip_register_endpoint_identifier(&ip_identifier);
 	ast_sip_register_endpoint_formatter(&endpoint_identify_formatter);
-	ast_sip_register_cli_formatter(&cli_identify_formatter);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }
@@ -346,7 +259,7 @@
 	return 0;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "PJSIP IP endpoint identifier",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP IP endpoint identifier",
 		.load = load_module,
 		.reload = reload_module,
 		.unload = unload_module,




More information about the asterisk-commits mailing list