#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"
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 = "88eaa8f5c1bd988bedd71113385e0886" , .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_info * | ast_module_info = &__mod_info |
struct { | |
pthread_t id | |
unsigned int stop:1 | |
} | dispatch_thread |
Definition in file res_ais.c.
const char* ais_err2str | ( | SaAisErrorT | error | ) |
Definition at line 103 of file res_ais.c.
References ais_errors, ARRAY_LEN, and ais_error::desc.
Referenced by add_subscribe_event(), ast_ais_clm_load_module(), ast_ais_clm_unload_module(), ast_ais_evt_load_module(), ast_ais_evt_unload_module(), ast_event_cb(), build_event_channel(), event_channel_destroy(), evt_event_deliver_cb(), and subscribe_event_destroy().
00104 { 00105 int x; 00106 00107 for (x = 0; x < ARRAY_LEN(ais_errors); x++) { 00108 if (ais_errors[x].error == error) 00109 return ais_errors[x].desc; 00110 } 00111 00112 return "Unknown"; 00113 }
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().
00116 { 00117 SaSelectionObjectT clm_fd, evt_fd; 00118 int res; 00119 struct pollfd pfd[2] = { { .events = POLLIN, }, { .events = POLLIN, } }; 00120 SaAisErrorT ais_res; 00121 00122 ais_res = saClmSelectionObjectGet(clm_handle, &clm_fd); 00123 if (ais_res != SA_AIS_OK) { 00124 ast_log(LOG_ERROR, "Failed to retrieve select fd for CLM service. " 00125 "This module will not operate.\n"); 00126 return NULL; 00127 } 00128 00129 ais_res = saEvtSelectionObjectGet(evt_handle, &evt_fd); 00130 if (ais_res != SA_AIS_OK) { 00131 ast_log(LOG_ERROR, "Failed to retrieve select fd for EVT service. " 00132 "This module will not operate.\n"); 00133 return NULL; 00134 } 00135 00136 pfd[0].fd = clm_fd; 00137 pfd[1].fd = evt_fd; 00138 00139 while (!dispatch_thread.stop) { 00140 pfd[0].revents = 0; 00141 pfd[1].revents = 0; 00142 00143 res = ast_poll(pfd, 2, -1); 00144 if (res == -1 && errno != EINTR && errno != EAGAIN) { 00145 ast_log(LOG_ERROR, "Select error (%s) dispatch thread going away now, " 00146 "and the module will no longer operate.\n", strerror(errno)); 00147 break; 00148 } 00149 00150 if (pfd[0].revents & POLLIN) { 00151 saClmDispatch(clm_handle, SA_DISPATCH_ALL); 00152 } 00153 if (pfd[1].revents & POLLIN) { 00154 saEvtDispatch(evt_handle, SA_DISPATCH_ALL); 00155 } 00156 } 00157 00158 return NULL; 00159 }
static int load_module | ( | void | ) | [static] |
Definition at line 161 of file res_ais.c.
References ast_ais_clm_load_module(), ast_ais_clm_unload_module(), ast_ais_evt_load_module(), ast_ais_evt_unload_module(), ast_log(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_pthread_create_background, dispatch_thread, dispatch_thread_handler(), and LOG_ERROR.
00162 { 00163 if (ast_ais_clm_load_module()) 00164 goto return_error; 00165 00166 if (ast_ais_evt_load_module()) 00167 goto evt_failed; 00168 00169 if (ast_pthread_create_background(&dispatch_thread.id, NULL, 00170 dispatch_thread_handler, NULL)) { 00171 ast_log(LOG_ERROR, "Error starting AIS dispatch thread.\n"); 00172 goto dispatch_failed; 00173 } 00174 00175 return AST_MODULE_LOAD_SUCCESS; 00176 00177 dispatch_failed: 00178 ast_ais_evt_unload_module(); 00179 evt_failed: 00180 ast_ais_clm_unload_module(); 00181 return_error: 00182 return AST_MODULE_LOAD_DECLINE; 00183 }
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.
00186 { 00187 ast_ais_clm_unload_module(); 00188 ast_ais_evt_unload_module(); 00189 00190 if (dispatch_thread.id != AST_PTHREADT_NULL) { 00191 dispatch_thread.stop = 1; 00192 pthread_kill(dispatch_thread.id, SIGURG); /* poke! */ 00193 pthread_join(dispatch_thread.id, NULL); 00194 } 00195 00196 return 0; 00197 }
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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
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().
struct ast_module_info* ast_module_info = &__mod_info [static] |
struct { ... } dispatch_thread [static] |
Referenced by dispatch_thread_handler(), load_module(), and unload_module().