[asterisk-commits] mmichelson: branch group/pimp_my_sip r379386 - in /team/group/pimp_my_sip: in...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 17 12:19:42 CST 2013


Author: mmichelson
Date: Thu Jan 17 12:19:38 2013
New Revision: 379386

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379386
Log:
Add an endpoint identifier that always just returns the same endpoint.


Added:
    team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c   (with props)
Modified:
    team/group/pimp_my_sip/include/asterisk/res_sip.h
    team/group/pimp_my_sip/res/res_sip.c

Modified: team/group/pimp_my_sip/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/include/asterisk/res_sip.h?view=diff&rev=379386&r1=379385&r2=379386
==============================================================================
--- team/group/pimp_my_sip/include/asterisk/res_sip.h (original)
+++ team/group/pimp_my_sip/include/asterisk/res_sip.h Thu Jan 17 12:19:38 2013
@@ -339,6 +339,18 @@
 void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier);
 
 /*!
+ * \brief Allocate a new SIP endpoint
+ *
+ * This will return an endpoint with its refcount increased by one. This reference
+ * can be released using ao2_ref().
+ *
+ * \param name The name of the endpoint.
+ * \retval NULL Endpoint allocation failed
+ * \retval non-NULL The newly allocated endpoint
+ */
+struct ast_sip_endpoint *ast_sip_endpoint_alloc(const char *name);
+
+/*!
  * \brief Get a pointer to the PJSIP endpoint.
  *
  * This is useful when modules have specific information they need

Modified: team/group/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip.c?view=diff&rev=379386&r1=379385&r2=379386
==============================================================================
--- team/group/pimp_my_sip/res/res_sip.c (original)
+++ team/group/pimp_my_sip/res/res_sip.c Thu Jan 17 12:19:38 2013
@@ -194,6 +194,29 @@
 	return endpoint;
 }
 
+static void endpoint_destructor(void* obj)
+{
+	struct ast_sip_endpoint *endpoint = obj;
+	ast_string_field_free_memory(endpoint);
+	/* XXX Will likely need to destroy a bunch
+	 * more other endpoint data too.
+	 */
+}
+
+struct ast_sip_endpoint *ast_sip_endpoint_alloc(const char *name)
+{
+	struct ast_sip_endpoint *endpoint = ao2_alloc(sizeof(*endpoint), endpoint_destructor);
+	if (!endpoint) {
+		return NULL;
+	}
+	if (ast_string_field_init(endpoint, 64)) {
+		ao2_cleanup(endpoint);
+		return NULL;
+	}
+	ast_string_field_set(endpoint, name, name);
+	return endpoint;
+}
+
 pjsip_endpoint *ast_sip_get_pjsip_endpoint(void)
 {
 	return ast_pjsip_endpoint;

Added: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c?view=auto&rev=379386
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c (added)
+++ team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c Thu Jan 17 12:19:38 2013
@@ -1,0 +1,71 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson at digium.com>
+ *
+ * Includes code and algorithms from the Zapata library.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*** MODULEINFO
+	<support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+#undef bzero
+#define bzero bzero
+#include <pjsip.h>
+
+#include "asterisk/res_sip.h"
+#include "asterisk/module.h"
+
+static struct ast_sip_endpoint *constant_identify(pjsip_rx_data *rdata)
+{
+	/* This endpoint identifier always returns the same endpoint. It's used
+	 * simply for testing. Most endpoint traits will not be filled in. Mostly
+	 * what we'll have are the location of the endpoint.
+	 *
+	 * Typically, endpoint identifiers would pick an endpoint already allocated
+	 * from a list and return that. Since we don't yet read allocation parameters
+	 * and create endpoints in advance, we'll create one on the fly instead.
+	 */
+	struct ast_sip_endpoint *endpoint = ast_sip_endpoint_alloc("constant");
+	if (!endpoint) {
+		return NULL;
+	}
+	ast_string_field_set(endpoint, context, "default");
+	return endpoint;
+}
+
+static struct ast_sip_endpoint_identifier constant_identifier = {
+	.identify_endpoint = constant_identify,
+};
+
+static int load_module(void)
+{
+	ast_sip_register_endpoint_identifier(&constant_identifier);
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "ADSI Resource",
+		.load = load_module,
+		.unload = unload_module,
+		.load_pri = AST_MODPRI_APP_DEPEND,
+	       );

Propchange: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/group/pimp_my_sip/res/res_sip_endpoint_identifier_constant.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list