Sat Apr 26 2014 22:01:42

Asterisk developer's documentation


sip_api.c
Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2012, Digium, Inc.
00005  *
00006  * Mark Michelson <mmichelson@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 #include "asterisk.h"
00019 
00020 #include "asterisk/sip_api.h"
00021 #include "asterisk/logger.h"
00022 
00023 static const struct ast_sip_api_tech *api_provider;
00024 
00025 int ast_sipinfo_send(struct ast_channel *chan,
00026       struct ast_variable *headers,
00027       const char *content_type,
00028       const char *content,
00029       const char *useragent_filter)
00030 {
00031    if (!api_provider) {
00032       ast_log(LOG_WARNING, "Unable to send custom SIP INFO. No API provider registered\n");
00033       return -1;
00034    }
00035 
00036    return api_provider->sipinfo_send(chan, headers, content_type, content, useragent_filter);
00037 }
00038 
00039 int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider)
00040 {
00041    if (api_provider) {
00042       ast_log(LOG_WARNING, "SIP provider %s has already registered. Not registering provider %s\n",
00043             api_provider->name, provider->name);
00044       return -1;
00045    }
00046 
00047    if (provider->version != AST_SIP_API_VERSION) {
00048       ast_log(LOG_WARNING, "SIP API provider version mismatch: Current version is %d but provider "
00049             "uses version %d\n", AST_SIP_API_VERSION, provider->version);
00050       return -1;
00051    }
00052 
00053    api_provider = provider;
00054    return 0;
00055 }
00056 
00057 void ast_sip_api_provider_unregister(void)
00058 {
00059    api_provider = NULL;
00060 }