Asterisk - The Open Source Telephony Project  18.5.0
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.

References ast_log, AST_SIP_API_VERSION, LOG_WARNING, ast_sip_api_tech::name, provider, and ast_sip_api_tech::version.

Referenced by load_module().

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 
54  return 0;
55 }
#define LOG_WARNING
Definition: logger.h:274
const int version
Definition: sip_api.h:31
#define ast_log
Definition: astobj2.c:42
#define AST_SIP_API_VERSION
Definition: sip_api.h:28
static struct prometheus_metrics_provider provider
Definition: bridges.c:178
static const struct ast_sip_api_tech * api_provider
Definition: sip_api.c:23
const char * name
Definition: sip_api.h:32

◆ 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.

References NULL.

Referenced by unload_module().

58 {
60 }
#define NULL
Definition: resample.c:96
static const struct ast_sip_api_tech * api_provider
Definition: sip_api.c:23

◆ 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.

References ast_log, LOG_WARNING, and ast_sip_api_tech::sipinfo_send.

Referenced by sip_sendcustominfo().

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
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
static const struct ast_sip_api_tech * api_provider
Definition: sip_api.c:23

Variable Documentation

◆ api_provider

const struct ast_sip_api_tech* api_provider
static

Definition at line 23 of file sip_api.c.