Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
sip_api.c File Reference
#include "asterisk.h"
#include "asterisk/sip_api.h"
#include "asterisk/logger.h"
Include dependency graph for sip_api.c:

Go to the source code of this file.

Functions

int ast_sip_api_provider_register (const struct ast_sip_api_tech *provider)
 Register a SIP API provider. More...
 
void ast_sip_api_provider_unregister (void)
 Unregister a SIP API provider. More...
 
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. More...
 

Variables

static const struct ast_sip_api_techapi_provider
 

Function Documentation

◆ ast_sip_api_provider_register()

int ast_sip_api_provider_register ( const struct ast_sip_api_tech provider)

Register a SIP API provider.

This will fail if a provider has already registered or if the provider is using an incorrect version.

Parameters
providerThe provider to register
Return values
0Success
-1Failure

Definition at line 39 of file sip_api.c.

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}
#define ast_log
Definition: astobj2.c:42
static struct prometheus_metrics_provider provider
Definition: bridges.c:201
#define LOG_WARNING
static const struct ast_sip_api_tech * api_provider
Definition: sip_api.c:23
#define AST_SIP_API_VERSION
Definition: sip_api.h:28
const char * name
Definition: sip_api.h:32
const char * name
Handy name of the provider for debugging purposes.

References api_provider, ast_log, AST_SIP_API_VERSION, LOG_WARNING, prometheus_metrics_provider::name, ast_sip_api_tech::name, and provider.

◆ ast_sip_api_provider_unregister()

void ast_sip_api_provider_unregister ( void  )

Unregister a SIP API provider.

Definition at line 57 of file sip_api.c.

58{
60}
#define NULL
Definition: resample.c:96

References api_provider, and NULL.

◆ ast_sipinfo_send()

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.

Parameters
chanChannel
headersThe headers to add to the INFO request
content_typeThe content type header to add
contentThe body of the INFO request
useragent_filterIf non-NULL, only send the INFO if the recipient's User-Agent contains useragent_filter as a substring
Return values
0Success
non-zeroFailure

Definition at line 25 of file sip_api.c.

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}
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

References api_provider, ast_log, LOG_WARNING, and ast_sip_api_tech::sipinfo_send.

Variable Documentation

◆ api_provider

const struct ast_sip_api_tech* api_provider
static