Sat Apr 26 2014 22:03:19

Asterisk developer's documentation


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.
void ast_sip_api_provider_unregister (void)
 Unregister a SIP API provider.
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.

Variables

static struct ast_sip_api_techapi_provider

Function Documentation

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, and ast_sip_api_tech::version.

Referenced by load_module().

{
   if (api_provider) {
      ast_log(LOG_WARNING, "SIP provider %s has already registered. Not registering provider %s\n",
            api_provider->name, provider->name);
      return -1;
   }

   if (provider->version != AST_SIP_API_VERSION) {
      ast_log(LOG_WARNING, "SIP API provider version mismatch: Current version is %d but provider "
            "uses version %d\n", AST_SIP_API_VERSION, provider->version);
      return -1;
   }

   api_provider = provider;
   return 0;
}

Unregister a SIP API provider.

Definition at line 57 of file sip_api.c.

Referenced by load_module(), and unload_module().

{
   api_provider = NULL;
}
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:
headersThe headers to add to the INFO request
content_typeThe content type header to add
contenThe 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.

{
   if (!api_provider) {
      ast_log(LOG_WARNING, "Unable to send custom SIP INFO. No API provider registered\n");
      return -1;
   }

   return api_provider->sipinfo_send(chan, headers, content_type, content, useragent_filter);
}

Variable Documentation

struct ast_sip_api_tech* api_provider [static]

Definition at line 23 of file sip_api.c.