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"
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_info * | ast_module_info = &__mod_info |
| struct { | |
| pthread_t id | |
| unsigned int stop:1 | |
| } | dispatch_thread |
Usage of the SAForum AIS (Application Interface Specification)
This file contains the common code between the uses of the different AIS services.
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().
{
int x;
for (x = 0; x < ARRAY_LEN(ais_errors); x++) {
if (ais_errors[x].error == error)
return ais_errors[x].desc;
}
return "Unknown";
}
| 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] |
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.
{
if (ast_ais_clm_load_module())
goto return_error;
if (ast_ais_evt_load_module())
goto evt_failed;
if (ast_pthread_create_background(&dispatch_thread.id, NULL,
dispatch_thread_handler, NULL)) {
ast_log(LOG_ERROR, "Error starting AIS dispatch thread.\n");
goto dispatch_failed;
}
return AST_MODULE_LOAD_SUCCESS;
dispatch_failed:
ast_ais_evt_unload_module();
evt_failed:
ast_ais_clm_unload_module();
return_error:
return AST_MODULE_LOAD_DECLINE;
}
| 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;
}
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[] [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().