summaryrefslogtreecommitdiff
path: root/main/sip_api.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2012-10-11 15:49:02 +0000
committerMark Michelson <mmichelson@digium.com>2012-10-11 15:49:02 +0000
commit825607e09b022ce56f7b5ccac03cd0dbf042396c (patch)
treedeec60920ba118bd06d2fdcd18f84853900e15c6 /main/sip_api.c
parent5ac43a08ad199d25d50198c0bb15826c346db9d2 (diff)
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. (closes issue ASTERISK-20545) Reported by: kmoore ........ Merged revisions 374842 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374849 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/sip_api.c')
-rw-r--r--main/sip_api.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/main/sip_api.c b/main/sip_api.c
new file mode 100644
index 000000000..b87a7fdbb
--- /dev/null
+++ b/main/sip_api.c
@@ -0,0 +1,60 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson@digium.com>
+ *
+ * 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.
+ */
+#include "asterisk.h"
+
+#include "asterisk/sip_api.h"
+#include "asterisk/logger.h"
+
+static const struct ast_sip_api_tech *api_provider;
+
+int ast_sipinfo_send(struct ast_channel *chan,
+ struct ast_variable *headers,
+ const char *content_type,
+ const char *content,
+ const char *useragent_filter)
+{
+ if (!api_provider) {
+ ast_log(LOG_WARNING, "Unable to send custom SIP INFO. No API provider registered\n");
+ return -1;
+ }
+
+ return api_provider->sipinfo_send(chan, headers, content_type, content, useragent_filter);
+}
+
+int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider)
+{
+ if (api_provider) {
+ ast_log(LOG_WARNING, "SIP provider %s has already registered. Not registering provider %s\n",
+ api_provider->name, provider->name);
+ return -1;
+ }
+
+ if (provider->version != AST_SIP_API_VERSION) {
+ ast_log(LOG_WARNING, "SIP API provider version mismatch: Current version is %d but provider "
+ "uses version %d\n", AST_SIP_API_VERSION, provider->version);
+ return -1;
+ }
+
+ api_provider = provider;
+ return 0;
+}
+
+void ast_sip_api_provider_unregister(void)
+{
+ api_provider = NULL;
+}