Asterisk - The Open Source Telephony Project  21.4.1
sip_api.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2012, Digium, Inc.
5  *
6  * Mark Michelson <mmichelson@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 #include "asterisk.h"
19 
20 #include "asterisk/sip_api.h"
21 #include "asterisk/logger.h"
22 
23 static const struct ast_sip_api_tech *api_provider;
24 
25 int ast_sipinfo_send(struct ast_channel *chan,
26  struct ast_variable *headers,
27  const char *content_type,
28  const char *content,
29  const char *useragent_filter)
30 {
31  if (!api_provider) {
32  ast_log(LOG_WARNING, "Unable to send custom SIP INFO. No API provider registered\n");
33  return -1;
34  }
35 
36  return api_provider->sipinfo_send(chan, headers, content_type, content, useragent_filter);
37 }
38 
39 int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider)
40 {
41  if (api_provider) {
42  ast_log(LOG_WARNING, "SIP provider %s has already registered. Not registering provider %s\n",
43  api_provider->name, provider->name);
44  return -1;
45  }
46 
47  if (provider->version != AST_SIP_API_VERSION) {
48  ast_log(LOG_WARNING, "SIP API provider version mismatch: Current version is %d but provider "
49  "uses version %d\n", AST_SIP_API_VERSION, provider->version);
50  return -1;
51  }
52 
53  api_provider = provider;
54  return 0;
55 }
56 
57 void ast_sip_api_provider_unregister(void)
58 {
59  api_provider = NULL;
60 }
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
Structure for variables, used for configurations and for channel variables.
Support for logging to various files, console and syslog Configuration in file logger.conf.