Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions
sip_api.h File Reference
#include "asterisk/config.h"
Include dependency graph for sip_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_sip_api_tech
 

Macros

#define AST_SIP_API_VERSION   1
 

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

Macro Definition Documentation

◆ AST_SIP_API_VERSION

#define AST_SIP_API_VERSION   1

Definition at line 28 of file sip_api.h.

Referenced by ast_sip_api_provider_register().

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