Mon Mar 12 2012 21:44:07

Asterisk developer's documentation


res_ais.c File Reference

Usage of the SAForum AIS (Application Interface Specification) More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <pthread.h>
#include "ais/ais.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
Include dependency graph for res_ais.c:

Go to the source code of this file.

Data Structures

struct  ais_error

Functions

static void __reg_module (void)
static void __unreg_module (void)
const char * ais_err2str (SaAisErrorT error)
 ASTERISK_FILE_VERSION (__FILE__,"$Revision: 328209 $")
static void * dispatch_thread_handler (void *data)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "SAForum AIS" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static struct ais_error ais_errors []
SaVersionT ais_version = { 'B', 1, 1 }
static struct ast_module_infoast_module_info = &__mod_info
struct {
   pthread_t   id
   unsigned int   stop:1
dispatch_thread

Detailed Description

Usage of the SAForum AIS (Application Interface Specification)

Author:
Russell Bryant <russell@digium.com>

This file contains the common code between the uses of the different AIS services.

Note:
This module is still considered experimental, as it exposes the internal binary format of events between Asterisk servers over a network. However, this format is still subject to change between 1.6.X releases.

Definition in file res_ais.c.


Function Documentation

static void __reg_module ( void  ) [static]

Definition at line 199 of file res_ais.c.

static void __unreg_module ( void  ) [static]

Definition at line 199 of file res_ais.c.

const char* ais_err2str ( SaAisErrorT  error)
ASTERISK_FILE_VERSION ( __FILE__  ,
"$Revision: 328209 $"   
)
static void* dispatch_thread_handler ( void *  data) [static]

Definition at line 115 of file res_ais.c.

References ast_log(), ast_poll, clm_handle, dispatch_thread, errno, evt_handle, and LOG_ERROR.

Referenced by load_module().

{
   SaSelectionObjectT clm_fd, evt_fd;
   int res;
   struct pollfd pfd[2] = { { .events = POLLIN, }, { .events = POLLIN, } };
   SaAisErrorT ais_res;

   ais_res = saClmSelectionObjectGet(clm_handle, &clm_fd);
   if (ais_res != SA_AIS_OK) {
      ast_log(LOG_ERROR, "Failed to retrieve select fd for CLM service.  "
         "This module will not operate.\n");
      return NULL;
   }

   ais_res = saEvtSelectionObjectGet(evt_handle, &evt_fd);
   if (ais_res != SA_AIS_OK) {
      ast_log(LOG_ERROR, "Failed to retrieve select fd for EVT service.  "
         "This module will not operate.\n");
      return NULL;
   }

   pfd[0].fd = clm_fd;
   pfd[1].fd = evt_fd;

   while (!dispatch_thread.stop) {
      pfd[0].revents = 0;
      pfd[1].revents = 0;

      res = ast_poll(pfd, 2, -1);
      if (res == -1 && errno != EINTR && errno != EAGAIN) {
         ast_log(LOG_ERROR, "Select error (%s) dispatch thread going away now, "
            "and the module will no longer operate.\n", strerror(errno));
         break;
      }

      if (pfd[0].revents & POLLIN) {
         saClmDispatch(clm_handle,   SA_DISPATCH_ALL);
      }
      if (pfd[1].revents & POLLIN) {
         saEvtDispatch(evt_handle,   SA_DISPATCH_ALL);
      }
   }

   return NULL;
}
static int load_module ( void  ) [static]
static int unload_module ( void  ) [static]

Definition at line 185 of file res_ais.c.

References ast_ais_clm_unload_module(), ast_ais_evt_unload_module(), AST_PTHREADT_NULL, and dispatch_thread.

{
   ast_ais_clm_unload_module();
   ast_ais_evt_unload_module();

   if (dispatch_thread.id != AST_PTHREADT_NULL) {
      dispatch_thread.stop = 1;
      pthread_kill(dispatch_thread.id, SIGURG); /* poke! */
      pthread_join(dispatch_thread.id, NULL);
   }

   return 0;
}

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "SAForum AIS" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 199 of file res_ais.c.

struct ais_error ais_errors[] [static]

Referenced by ais_err2str().

SaVersionT ais_version = { 'B', 1, 1 }

Definition at line 68 of file res_ais.c.

Referenced by ast_ais_clm_load_module(), and ast_ais_evt_load_module().

Definition at line 199 of file res_ais.c.

struct { ... } dispatch_thread [static]
pthread_t id

Definition at line 62 of file res_ais.c.

unsigned int stop

Definition at line 63 of file res_ais.c.