Asterisk - The Open Source Telephony Project GIT-master-f36a736
sip_api.c
Go to the documentation of this file.
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
23static const struct ast_sip_api_tech *api_provider;
24
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
40{
41 if (api_provider) {
42 ast_log(LOG_WARNING, "SIP provider %s has already registered. Not registering provider %s\n",
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
54 return 0;
55}
56
58{
60}
Asterisk main include file. File version handling, generic pbx functions.
#define ast_log
Definition: astobj2.c:42
static struct prometheus_metrics_provider provider
Definition: bridges.c:201
Support for logging to various files, console and syslog Configuration in file logger....
#define LOG_WARNING
#define NULL
Definition: resample.c:96
int ast_sip_api_provider_register(const struct ast_sip_api_tech *provider)
Register a SIP API provider.
Definition: sip_api.c:39
void ast_sip_api_provider_unregister(void)
Unregister a SIP API provider.
Definition: sip_api.c:57
static const struct ast_sip_api_tech * api_provider
Definition: sip_api.c:23
int ast_sipinfo_send(struct ast_channel *chan, struct ast_variable *headers, const char *content_type, const char *content, const char *useragent_filter)
Send a customized SIP INFO request.
Definition: sip_api.c:25
#define AST_SIP_API_VERSION
Definition: sip_api.h:28
Main Channel structure associated with a channel.
int(* sipinfo_send)(struct ast_channel *chan, struct ast_variable *headers, const char *content_type, const char *content, const char *useragent_filter)
Definition: sip_api.h:33
const char * name
Definition: sip_api.h:32
Structure for variables, used for configurations and for channel variables.
const char * name
Handy name of the provider for debugging purposes.