[asterisk-commits] mmichelson: trunk r374849 - in /trunk: ./ channels/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 11 10:49:06 CDT 2012


Author: mmichelson
Date: Thu Oct 11 10:49:02 2012
New Revision: 374849

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=374849
Log:
Don't make chan_sip export global symbols.

During testing, it was discovered that having chan_sip
export global symbols was problematic.

The biggest problem was that load order was affected.
Trying to use realtime could be problematic since in
all likelihood the necessary realtime driver(s) would
not be loaded before chan_sip.

In addition, it was found that it was impossible to
use the Digium Phone Module for Asterisk since it
must be loaded before chan_sip since it must hook
into chan_sip's configuration parsing.

The solution is to use a virtual table in the same
manner that other modules in Asterisk do, like
app_voicemail.
........

Merged revisions 374842 from http://svn.asterisk.org/svn/asterisk/branches/11

Added:
    trunk/main/sip_api.c
      - copied unchanged from r374842, branches/11/main/sip_api.c
Removed:
    trunk/channels/chan_sip.exports.in
Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/include/asterisk/sip_api.h

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

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=374849&r1=374848&r2=374849
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Oct 11 10:49:02 2012
@@ -7342,7 +7342,8 @@
 	return 0;
 }
 
-int ast_sipinfo_send(
+
+static int sipinfo_send(
 		struct ast_channel *chan,
 		struct ast_variable *headers,
 		const char *content_type,
@@ -33298,6 +33299,12 @@
 	AST_DATA_ENTRY("asterisk/channel/sip/peers", &peers_data_provider),
 };
 
+static const struct ast_sip_api_tech chan_sip_api_provider = {
+	.version = AST_SIP_API_VERSION,
+	.name = "chan_sip",
+	.sipinfo_send = sipinfo_send,
+};
+
 /*!
  * \brief Load the module
  *
@@ -33313,6 +33320,10 @@
 	ast_verbose("SIP channel loading...\n");
 
 	if (!(sip_tech.capabilities = ast_format_cap_alloc())) {
+		return AST_MODULE_LOAD_FAILURE;
+	}
+
+	if (ast_sip_api_provider_register(&chan_sip_api_provider)) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
@@ -33477,6 +33488,8 @@
 	struct ao2_iterator i;
 	int wait_count;
 
+	ast_sip_api_provider_unregister();
+
 	ast_websocket_remove_protocol("sip", sip_websocket_callback);
 
 	network_change_event_unsubscribe();
@@ -33652,7 +33665,7 @@
 	return 0;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Session Initiation Protocol (SIP)",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Session Initiation Protocol (SIP)",
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload,

Modified: trunk/include/asterisk/sip_api.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/sip_api.h?view=diff&rev=374849&r1=374848&r2=374849
==============================================================================
--- trunk/include/asterisk/sip_api.h (original)
+++ trunk/include/asterisk/sip_api.h Thu Oct 11 10:49:02 2012
@@ -26,6 +26,16 @@
 #include "asterisk/optional_api.h"
 #include "asterisk/config.h"
 
+#define AST_SIP_API_VERSION 1
+
+struct ast_sip_api_tech {
+	const int version;
+	const char *name;
+	int (*sipinfo_send)(struct ast_channel *chan,
+			struct ast_variable *headers, const char *content_type,
+			const char *content, const char *useragent_filter);
+};
+
 /*!
  * \brief Send a customized SIP INFO request
  *
@@ -45,6 +55,23 @@
 		const char *content,
 		const char *useragent_filter);
 
+/*!
+ * \brief Register a SIP API provider
+ *
+ * This will fail if a provider has already registered or if the
+ * provider is using an incorrect version.
+ *
+ * \param provider The provider to register
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider);
+
+/*!
+ * \brief Unregister a SIP API provider
+ */
+void ast_sip_api_provider_unregister(void);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif




More information about the asterisk-commits mailing list