#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: 179166 $") | |
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_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
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 102 of file res_ais.c.
References ais_errors, ARRAY_LEN, and ais_error::desc.
00103 { 00104 int x; 00105 00106 for (x = 0; x < ARRAY_LEN(ais_errors); x++) { 00107 if (ais_errors[x].error == error) 00108 return ais_errors[x].desc; 00109 } 00110 00111 return "Unknown"; 00112 }
ASTERISK_FILE_VERSION | ( | __FILE__ | , | |
"$Revision: 179166 $" | ||||
) |
static void* dispatch_thread_handler | ( | void * | data | ) | [static] |
Definition at line 114 of file res_ais.c.
References ast_log(), ast_select(), dispatch_thread, errno, and LOG_ERROR.
Referenced by load_module().
00115 { 00116 SaSelectionObjectT clm_fd, evt_fd, max_fd; 00117 int res; 00118 fd_set read_fds; 00119 SaAisErrorT ais_res; 00120 00121 ais_res = saClmSelectionObjectGet(clm_handle, &clm_fd); 00122 if (ais_res != SA_AIS_OK) { 00123 ast_log(LOG_ERROR, "Failed to retrieve select fd for CLM service. " 00124 "This module will not operate.\n"); 00125 return NULL; 00126 } 00127 00128 ais_res = saEvtSelectionObjectGet(evt_handle, &evt_fd); 00129 if (ais_res != SA_AIS_OK) { 00130 ast_log(LOG_ERROR, "Failed to retrieve select fd for EVT service. " 00131 "This module will not operate.\n"); 00132 return NULL; 00133 } 00134 00135 max_fd = clm_fd > evt_fd ? clm_fd : evt_fd; 00136 00137 while (!dispatch_thread.stop) { 00138 FD_ZERO(&read_fds); 00139 FD_SET(clm_fd, &read_fds); 00140 FD_SET(evt_fd, &read_fds); 00141 00142 res = ast_select(max_fd + 1, &read_fds, NULL, NULL, NULL); 00143 if (res == -1 && errno != EINTR && errno != EAGAIN) { 00144 ast_log(LOG_ERROR, "Select error (%s) dispatch thread going away now, " 00145 "and the module will no longer operate.\n", strerror(errno)); 00146 break; 00147 } 00148 00149 if (FD_ISSET(clm_fd, &read_fds)) 00150 saClmDispatch(clm_handle, SA_DISPATCH_ALL); 00151 if (FD_ISSET(evt_fd, &read_fds)) 00152 saEvtDispatch(evt_handle, SA_DISPATCH_ALL); 00153 } 00154 00155 return NULL; 00156 }
static int load_module | ( | void | ) | [static] |
Definition at line 158 of file res_ais.c.
References ast_log(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_pthread_create_background, dispatch_thread, dispatch_thread_handler(), and LOG_ERROR.
00159 { 00160 if (ast_ais_clm_load_module()) 00161 goto return_error; 00162 00163 if (ast_ais_evt_load_module()) 00164 goto evt_failed; 00165 00166 if (ast_pthread_create_background(&dispatch_thread.id, NULL, 00167 dispatch_thread_handler, NULL)) { 00168 ast_log(LOG_ERROR, "Error starting AIS dispatch thread.\n"); 00169 goto dispatch_failed; 00170 } 00171 00172 return AST_MODULE_LOAD_SUCCESS; 00173 00174 dispatch_failed: 00175 ast_ais_evt_unload_module(); 00176 evt_failed: 00177 ast_ais_clm_unload_module(); 00178 return_error: 00179 return AST_MODULE_LOAD_DECLINE; 00180 }
static int unload_module | ( | void | ) | [static] |
Definition at line 182 of file res_ais.c.
References AST_PTHREADT_NULL, and dispatch_thread.
00183 { 00184 ast_ais_clm_unload_module(); 00185 ast_ais_evt_unload_module(); 00186 00187 if (dispatch_thread.id != AST_PTHREADT_NULL) { 00188 dispatch_thread.stop = 1; 00189 pthread_kill(dispatch_thread.id, SIGURG); /* poke! */ 00190 pthread_join(dispatch_thread.id, NULL); 00191 } 00192 00193 return 0; 00194 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
struct ais_error ais_errors[] [static] |
Referenced by ais_err2str().
SaVersionT ais_version = { 'B', 1, 1 } |
struct ast_module_info* ast_module_info = &__mod_info [static] |
struct { ... } dispatch_thread [static] |
Referenced by dispatch_thread_handler(), load_module(), and unload_module().