Mon Jun 27 16:51:13 2011

Asterisk developer's documentation


evt.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 "ais.h"
#include "asterisk/module.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
#include "asterisk/logger.h"
#include "asterisk/event.h"
#include "asterisk/config.h"
#include "asterisk/linkedlists.h"
#include "asterisk/devicestate.h"

Go to the source code of this file.

Data Structures

struct  event_channel
struct  event_channels
struct  publish_event
struct  subscribe_event

Defines

#define AST_MODULE   "res_ais"

Functions

static void add_publish_event (struct event_channel *event_channel, const char *event_type)
static void add_subscribe_event (struct event_channel *event_channel, const char *event_type)
static char * ais_evt_show_event_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_ais_evt_load_module (void)
int ast_ais_evt_unload_module (void)
static void ast_event_cb (const struct ast_event *ast_event, void *data)
 ASTERISK_FILE_VERSION (__FILE__,"$Revision: 294535 $")
static void build_event_channel (struct ast_config *cfg, const char *cat)
static void destroy_event_channels (void)
static void event_channel_destroy (struct event_channel *event_channel)
void evt_channel_open_cb (SaInvocationT invocation, SaEvtChannelHandleT channel_handle, SaAisErrorT error)
void evt_event_deliver_cb (SaEvtSubscriptionIdT subscription_id, const SaEvtEventHandleT event_handle, const SaSizeT event_datalen)
static void load_config (void)
static void publish_event_destroy (struct publish_event *publish_event)
static void queue_event (struct ast_event *ast_event)
static SaAisErrorT set_egress_subscription (struct event_channel *event_channel, struct subscribe_event *subscribe_event)
static void subscribe_event_destroy (const struct event_channel *event_channel, struct subscribe_event *subscribe_event)
static const char * type_to_filter_str (enum ast_event_type type)

Variables

static struct ast_cli_entry ais_cli []
static const SaEvtCallbacksT evt_callbacks
SaEvtHandleT evt_handle
static SaAisErrorT evt_init_res
struct {
   const char *   str
   enum ast_event_type   type
supported_event_types []
static int unique_id


Detailed Description

Usage of the SAForum AIS (Application Interface Specification).

Author:
Russell Bryant <russell@digium.com>
This file contains the code specific to the use of the EVT (Event) Service.

Definition in file evt.c.


Define Documentation

#define AST_MODULE   "res_ais"

Definition at line 54 of file evt.c.


Function Documentation

static void add_publish_event ( struct event_channel event_channel,
const char *  event_type 
) [static]

Definition at line 301 of file evt.c.

References ARRAY_LEN, ast_calloc, ast_enable_distributed_devstate(), ast_event_cb(), AST_EVENT_DEVICE_STATE_CHANGE, ast_event_dump_cache(), AST_EVENT_IE_END, ast_event_subscribe(), AST_LIST_INSERT_TAIL, ast_log(), subscribe_event::entry, LOG_DEBUG, LOG_WARNING, event_channel::publish_events, str, and supported_event_types.

Referenced by build_event_channel().

00302 {
00303    int i;
00304    enum ast_event_type type = -1;
00305    struct publish_event *publish_event;
00306 
00307    for (i = 0; i < ARRAY_LEN(supported_event_types); i++) {
00308       if (!strcasecmp(event_type, supported_event_types[i].str)) {
00309          type = supported_event_types[i].type;
00310          break;
00311       }
00312    }
00313 
00314    if (type == -1) {
00315       ast_log(LOG_WARNING, "publish_event option given with invalid value '%s'\n", event_type);
00316       return;
00317    }
00318 
00319    if (type == AST_EVENT_DEVICE_STATE_CHANGE && ast_enable_distributed_devstate()) {
00320       return;
00321    }
00322 
00323    if (!(publish_event = ast_calloc(1, sizeof(*publish_event)))) {
00324       return;
00325    }
00326 
00327    publish_event->type = type;
00328    ast_log(LOG_DEBUG, "Subscribing to event type %d\n", type);
00329    publish_event->sub = ast_event_subscribe(type, ast_event_cb, "AIS", event_channel,
00330       AST_EVENT_IE_END);
00331    ast_event_dump_cache(publish_event->sub);
00332 
00333    AST_LIST_INSERT_TAIL(&event_channel->publish_events, publish_event, entry);
00334 }

static void add_subscribe_event ( struct event_channel event_channel,
const char *  event_type 
) [static]

Definition at line 363 of file evt.c.

References ais_err2str(), ARRAY_LEN, ast_atomic_fetchadd_int(), ast_calloc, ast_enable_distributed_devstate(), AST_EVENT_DEVICE_STATE_CHANGE, AST_LIST_INSERT_TAIL, ast_log(), subscribe_event::entry, free, LOG_ERROR, LOG_WARNING, set_egress_subscription(), str, event_channel::subscribe_events, supported_event_types, and unique_id.

00364 {
00365    int i;
00366    enum ast_event_type type = -1;
00367    struct subscribe_event *subscribe_event;
00368    SaAisErrorT ais_res;
00369 
00370    for (i = 0; i < ARRAY_LEN(supported_event_types); i++) {
00371       if (!strcasecmp(event_type, supported_event_types[i].str)) {
00372          type = supported_event_types[i].type;
00373          break;
00374       }
00375    }
00376 
00377    if (type == -1) {
00378       ast_log(LOG_WARNING, "subscribe_event option given with invalid value '%s'\n", event_type);
00379       return;
00380    }
00381 
00382    if (type == AST_EVENT_DEVICE_STATE_CHANGE && ast_enable_distributed_devstate()) {
00383       return;
00384    }
00385 
00386    if (!(subscribe_event = ast_calloc(1, sizeof(*subscribe_event)))) {
00387       return;
00388    }
00389 
00390    subscribe_event->type = type;
00391    subscribe_event->id = ast_atomic_fetchadd_int(&unique_id, +1);
00392 
00393    ais_res = set_egress_subscription(event_channel, subscribe_event);
00394    if (ais_res != SA_AIS_OK) {
00395       ast_log(LOG_ERROR, "Error setting up egress subscription: %s\n",
00396          ais_err2str(ais_res));
00397       free(subscribe_event);
00398       return;
00399    }
00400 
00401    AST_LIST_INSERT_TAIL(&event_channel->subscribe_events, subscribe_event, entry);
00402 }

static char* ais_evt_show_event_channels ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 243 of file evt.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli(), AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, subscribe_event::entry, ast_cli_args::fd, event_channel::name, event_channel::publish_events, event_channel::subscribe_events, subscribe_event::type, publish_event::type, type_to_filter_str(), and ast_cli_entry::usage.

00244 {
00245    struct event_channel *event_channel;
00246 
00247    switch (cmd) {
00248    case CLI_INIT:
00249       e->command = "ais evt show event channels";
00250       e->usage =
00251          "Usage: ais evt show event channels\n"
00252          "       List configured event channels for the (EVT) Eventing service.\n";
00253       return NULL;
00254 
00255    case CLI_GENERATE:
00256       return NULL;   /* no completion */
00257    }
00258 
00259    if (a->argc != e->args)
00260       return CLI_SHOWUSAGE;
00261 
00262    ast_cli(a->fd, "\n"
00263                "=============================================================\n"
00264                "=== Event Channels ==========================================\n"
00265                "=============================================================\n"
00266                "===\n");
00267 
00268    AST_RWLIST_RDLOCK(&event_channels);
00269    AST_RWLIST_TRAVERSE(&event_channels, event_channel, entry) {
00270       struct publish_event *publish_event;
00271       struct subscribe_event *subscribe_event;
00272 
00273       ast_cli(a->fd, "=== ---------------------------------------------------------\n"
00274                      "=== Event Channel Name: %s\n", event_channel->name);
00275 
00276       AST_LIST_TRAVERSE(&event_channel->publish_events, publish_event, entry) {
00277          ast_cli(a->fd, "=== ==> Publishing Event Type: %s\n",
00278             type_to_filter_str(publish_event->type));
00279       }
00280 
00281       AST_LIST_TRAVERSE(&event_channel->subscribe_events, subscribe_event, entry) {
00282          ast_cli(a->fd, "=== ==> Subscribing to Event Type: %s\n",
00283             type_to_filter_str(subscribe_event->type));
00284       }
00285 
00286       ast_cli(a->fd, "=== ---------------------------------------------------------\n"
00287                      "===\n");
00288    }
00289    AST_RWLIST_UNLOCK(&event_channels);
00290 
00291    ast_cli(a->fd, "=============================================================\n"
00292                   "\n");
00293 
00294    return CLI_SUCCESS;
00295 }

int ast_ais_evt_load_module ( void   ) 

Definition at line 542 of file evt.c.

References ais_cli, ais_err2str(), ais_version, ARRAY_LEN, ast_cli_register_multiple(), ast_log(), evt_callbacks, evt_handle, evt_init_res, load_config(), and LOG_ERROR.

Referenced by load_module().

00543 {
00544    evt_init_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
00545    if (evt_init_res != SA_AIS_OK) {
00546       ast_log(LOG_ERROR, "Could not initialize eventing service: %s\n",
00547          ais_err2str(evt_init_res));
00548       return -1;
00549    }
00550 
00551    load_config();
00552 
00553    ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli));
00554 
00555    return 0;
00556 }

int ast_ais_evt_unload_module ( void   ) 

Definition at line 558 of file evt.c.

References ais_err2str(), ast_log(), destroy_event_channels(), evt_handle, evt_init_res, and LOG_ERROR.

Referenced by load_module(), and unload_module().

00559 {
00560    SaAisErrorT ais_res;
00561 
00562    if (evt_init_res != SA_AIS_OK) {
00563       return 0;
00564    }
00565 
00566    destroy_event_channels();
00567 
00568    ais_res = saEvtFinalize(evt_handle);
00569    if (ais_res != SA_AIS_OK) {
00570       ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n",
00571          ais_err2str(ais_res));
00572       return -1;
00573    }
00574 
00575    return 0;
00576 }

static void ast_event_cb ( const struct ast_event ast_event,
void *  data 
) [static]

Definition at line 173 of file evt.c.

References ais_err2str(), ast_eid_cmp(), ast_eid_default, ast_event_get_ie_raw(), ast_event_get_size(), ast_event_get_type(), AST_EVENT_IE_EID, ast_log(), clm_handle, event_channel::handle, len(), LOG_DEBUG, LOG_ERROR, and type_to_filter_str().

Referenced by add_publish_event().

00174 {
00175    SaEvtEventHandleT event_handle;
00176    SaAisErrorT ais_res;
00177    struct event_channel *event_channel = data;
00178    SaClmClusterNodeT local_node;
00179    SaEvtEventPatternArrayT pattern_array;
00180    SaEvtEventPatternT pattern;
00181    SaSizeT len;
00182    const char *filter_str;
00183    SaEvtEventIdT event_id;
00184 
00185    ast_log(LOG_DEBUG, "Got an event to forward\n");
00186 
00187    if (ast_eid_cmp(&ast_eid_default, ast_event_get_ie_raw(ast_event, AST_EVENT_IE_EID))) {
00188       /* If the event didn't originate from this server, don't send it back out. */
00189       ast_log(LOG_DEBUG, "Returning here\n");
00190       return;
00191    }
00192 
00193    ais_res = saEvtEventAllocate(event_channel->handle, &event_handle);
00194    if (ais_res != SA_AIS_OK) {
00195       ast_log(LOG_ERROR, "Error allocating event: %s\n", ais_err2str(ais_res));
00196       ast_log(LOG_DEBUG, "Returning here\n");
00197       return;
00198    }
00199 
00200    ais_res = saClmClusterNodeGet(clm_handle, SA_CLM_LOCAL_NODE_ID,
00201       SA_TIME_ONE_SECOND, &local_node);
00202    if (ais_res != SA_AIS_OK) {
00203       ast_log(LOG_ERROR, "Error getting local node name: %s\n", ais_err2str(ais_res));
00204       goto return_event_free;
00205    }
00206 
00207    filter_str = type_to_filter_str(ast_event_get_type(ast_event));
00208    len = strlen(filter_str) + 1;
00209    pattern.pattern = (SaUint8T *) filter_str;
00210    pattern.patternSize = len;
00211    pattern.allocatedSize = len;
00212 
00213    pattern_array.allocatedNumber = 1;
00214    pattern_array.patternsNumber = 1;
00215    pattern_array.patterns = &pattern;
00216 
00217    /*!
00218     * /todo Make retention time configurable
00219     * /todo Make event priorities configurable
00220     */
00221    ais_res = saEvtEventAttributesSet(event_handle, &pattern_array,
00222       SA_EVT_LOWEST_PRIORITY, SA_TIME_ONE_MINUTE, &local_node.nodeName);
00223    if (ais_res != SA_AIS_OK) {
00224       ast_log(LOG_ERROR, "Error setting event attributes: %s\n", ais_err2str(ais_res));
00225       goto return_event_free;
00226    }
00227 
00228    ais_res = saEvtEventPublish(event_handle,
00229       ast_event, ast_event_get_size(ast_event), &event_id);
00230    if (ais_res != SA_AIS_OK) {
00231       ast_log(LOG_ERROR, "Error publishing event: %s\n", ais_err2str(ais_res));
00232       goto return_event_free;
00233    }
00234 
00235 return_event_free:
00236    ais_res = saEvtEventFree(event_handle);
00237    if (ais_res != SA_AIS_OK) {
00238       ast_log(LOG_ERROR, "Error freeing allocated event: %s\n", ais_err2str(ais_res));
00239    }
00240    ast_log(LOG_DEBUG, "Returning here (event_free)\n");
00241 }

ASTERISK_FILE_VERSION ( __FILE__  ,
"$Revision: 294535 $"   
)

static void build_event_channel ( struct ast_config cfg,
const char *  cat 
) [static]

Definition at line 404 of file evt.c.

References add_publish_event(), ais_err2str(), ast_calloc, ast_copy_string(), ast_log(), AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_variable_browse(), subscribe_event::entry, evt_handle, free, LOG_ERROR, LOG_WARNING, event_channel::name, and var.

Referenced by load_config().

00405 {
00406    struct ast_variable *var;
00407    struct event_channel *event_channel;
00408    SaAisErrorT ais_res;
00409    SaNameT sa_name = { 0, };
00410 
00411    AST_RWLIST_WRLOCK(&event_channels);
00412    AST_RWLIST_TRAVERSE(&event_channels, event_channel, entry) {
00413       if (!strcasecmp(event_channel->name, cat))
00414          break;
00415    }
00416    AST_RWLIST_UNLOCK(&event_channels);
00417    if (event_channel) {
00418       ast_log(LOG_WARNING, "Event channel '%s' was specified twice in "
00419          "configuration.  Second instance ignored.\n", cat);
00420       return;
00421    }
00422 
00423    if (!(event_channel = ast_calloc(1, sizeof(*event_channel) + strlen(cat))))
00424       return;
00425 
00426    strcpy(event_channel->name, cat);
00427    ast_copy_string((char *) sa_name.value, cat, sizeof(sa_name.value));
00428    sa_name.length = strlen((char *) sa_name.value);
00429    ais_res = saEvtChannelOpen(evt_handle, &sa_name,
00430       SA_EVT_CHANNEL_PUBLISHER | SA_EVT_CHANNEL_SUBSCRIBER | SA_EVT_CHANNEL_CREATE,
00431       SA_TIME_MAX, &event_channel->handle);
00432    if (ais_res != SA_AIS_OK) {
00433       ast_log(LOG_ERROR, "Error opening event channel: %s\n", ais_err2str(ais_res));
00434       free(event_channel);
00435       return;
00436    }
00437 
00438    for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
00439       if (!strcasecmp(var->name, "type")) {
00440          continue;
00441       } else if (!strcasecmp(var->name, "publish_event")) {
00442          add_publish_event(event_channel, var->value);
00443       } else if (!strcasecmp(var->name, "subscribe_event")) {
00444          add_subscribe_event(event_channel, var->value);
00445       } else {
00446          ast_log(LOG_WARNING, "Event channel '%s' contains invalid option '%s'\n",
00447             event_channel->name, var->name);
00448       }
00449    }
00450 
00451    AST_RWLIST_WRLOCK(&event_channels);
00452    AST_RWLIST_INSERT_TAIL(&event_channels, event_channel, entry);
00453    AST_RWLIST_UNLOCK(&event_channels);
00454 }

static void destroy_event_channels ( void   )  [static]

Definition at line 531 of file evt.c.

References AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, event_channel::entry, and event_channel_destroy().

Referenced by ast_ais_evt_unload_module().

00532 {
00533    struct event_channel *event_channel;
00534 
00535    AST_RWLIST_WRLOCK(&event_channels);
00536    while ((event_channel = AST_RWLIST_REMOVE_HEAD(&event_channels, entry))) {
00537       event_channel_destroy(event_channel);
00538    }
00539    AST_RWLIST_UNLOCK(&event_channels);
00540 }

static void event_channel_destroy ( struct event_channel event_channel  )  [static]

Definition at line 511 of file evt.c.

References ais_err2str(), AST_LIST_REMOVE_HEAD, ast_log(), subscribe_event::entry, free, LOG_ERROR, publish_event_destroy(), event_channel::publish_events, subscribe_event_destroy(), and event_channel::subscribe_events.

Referenced by destroy_event_channels().

00512 {
00513    struct publish_event *publish_event;
00514    struct subscribe_event *subscribe_event;
00515    SaAisErrorT ais_res;
00516 
00517    while ((publish_event = AST_LIST_REMOVE_HEAD(&event_channel->publish_events, entry)))
00518       publish_event_destroy(publish_event);
00519    while ((subscribe_event = AST_LIST_REMOVE_HEAD(&event_channel->subscribe_events, entry)))
00520       subscribe_event_destroy(event_channel, subscribe_event);
00521 
00522    ais_res = saEvtChannelClose(event_channel->handle);
00523    if (ais_res != SA_AIS_OK) {
00524       ast_log(LOG_ERROR, "Error closing event channel '%s': %s\n",
00525          event_channel->name, ais_err2str(ais_res));
00526    }
00527 
00528    free(event_channel);
00529 }

void evt_channel_open_cb ( SaInvocationT  invocation,
SaEvtChannelHandleT  channel_handle,
SaAisErrorT  error 
)

Definition at line 108 of file evt.c.

00110 {
00111 
00112 }

void evt_event_deliver_cb ( SaEvtSubscriptionIdT  subscription_id,
const SaEvtEventHandleT  event_handle,
const SaSizeT  event_datalen 
)

Definition at line 119 of file evt.c.

References ais_err2str(), ast_eid_cmp(), ast_eid_default, ast_event_get_ie_raw(), AST_EVENT_IE_EID, ast_log(), ast_malloc, len(), LOG_ERROR, and queue_event().

00121 {
00122    /* It is important to note that this works because we *know* that this
00123     * function will only be called by a single thread, the dispatch_thread.
00124     * If this module gets changed such that this is no longer the case, this
00125     * should get changed to a thread-local buffer, instead. */
00126    static unsigned char buf[4096];
00127    struct ast_event *event_dup, *event = (void *) buf;
00128    SaAisErrorT ais_res;
00129    SaSizeT len = sizeof(buf);
00130 
00131    if (event_datalen > len) {
00132       ast_log(LOG_ERROR, "Event received with size %u, which is too big\n"
00133          "for the allocated size %u. Change the code to increase the size.\n",
00134          (unsigned int) event_datalen, (unsigned int) len);
00135       return;
00136    }
00137 
00138    ais_res = saEvtEventDataGet(event_handle, event, &len);
00139    if (ais_res != SA_AIS_OK) {
00140       ast_log(LOG_ERROR, "Error retrieving event payload: %s\n",
00141          ais_err2str(ais_res));
00142       return;
00143    }
00144 
00145    if (!ast_eid_cmp(&ast_eid_default, ast_event_get_ie_raw(event, AST_EVENT_IE_EID))) {
00146       /* Don't feed events back in that originated locally. */
00147       return;
00148    }
00149 
00150    if (!(event_dup = ast_malloc(len)))
00151       return;
00152 
00153    memcpy(event_dup, event, len);
00154 
00155    queue_event(event_dup);
00156 }

static void load_config ( void   )  [static]

Definition at line 456 of file evt.c.

References ast_category_browse(), ast_config_destroy(), ast_config_load, ast_log(), ast_variable_retrieve(), build_event_channel(), config_flags, CONFIG_STATUS_FILEINVALID, and LOG_WARNING.

00457 {
00458    static const char filename[] = "ais.conf";
00459    struct ast_config *cfg;
00460    const char *cat = NULL;
00461    struct ast_flags config_flags = { 0 };
00462 
00463    if (!(cfg = ast_config_load(filename, config_flags)) || cfg == CONFIG_STATUS_FILEINVALID)
00464       return;
00465 
00466    while ((cat = ast_category_browse(cfg, cat))) {
00467       const char *type;
00468 
00469       if (!strcasecmp(cat, "general"))
00470          continue;
00471 
00472       if (!(type = ast_variable_retrieve(cfg, cat, "type"))) {
00473          ast_log(LOG_WARNING, "Invalid entry in %s defined with no type!\n",
00474             filename);
00475          continue;
00476       }
00477 
00478       if (!strcasecmp(type, "event_channel")) {
00479          build_event_channel(cfg, cat);
00480       } else {
00481          ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'\n",
00482             filename, type);
00483       }
00484    }
00485 
00486    ast_config_destroy(cfg);
00487 }

static void publish_event_destroy ( struct publish_event publish_event  )  [static]

Definition at line 489 of file evt.c.

References ast_event_unsubscribe(), free, and publish_event::sub.

Referenced by event_channel_destroy().

00490 {
00491    ast_event_unsubscribe(publish_event->sub);
00492 
00493    free(publish_event);
00494 }

static void queue_event ( struct ast_event ast_event  )  [static]

Definition at line 114 of file evt.c.

References ast_event_queue_and_cache().

Referenced by ast_event_queue_and_cache(), and evt_event_deliver_cb().

00115 {
00116    ast_event_queue_and_cache(ast_event);
00117 }

static SaAisErrorT set_egress_subscription ( struct event_channel event_channel,
struct subscribe_event subscribe_event 
) [static]

Definition at line 336 of file evt.c.

References filter(), event_channel::handle, subscribe_event::id, len(), subscribe_event::type, and type_to_filter_str().

Referenced by add_subscribe_event().

00338 {
00339    SaAisErrorT ais_res;
00340    SaEvtEventFilterArrayT filter_array;
00341    SaEvtEventFilterT filter;
00342    const char *filter_str = NULL;
00343    SaSizeT len;
00344 
00345    /* We know it's going to be valid.  It was checked earlier. */
00346    filter_str = type_to_filter_str(subscribe_event->type);
00347 
00348    filter.filterType = SA_EVT_EXACT_FILTER;
00349    len = strlen(filter_str) + 1;
00350    filter.filter.allocatedSize = len;
00351    filter.filter.patternSize = len;
00352    filter.filter.pattern = (SaUint8T *) filter_str;
00353 
00354    filter_array.filtersNumber = 1;
00355    filter_array.filters = &filter;
00356 
00357    ais_res = saEvtEventSubscribe(event_channel->handle, &filter_array,
00358       subscribe_event->id);
00359 
00360    return ais_res;
00361 }

static void subscribe_event_destroy ( const struct event_channel event_channel,
struct subscribe_event subscribe_event 
) [static]

Definition at line 496 of file evt.c.

References ais_err2str(), ast_log(), free, event_channel::handle, subscribe_event::id, and LOG_ERROR.

Referenced by event_channel_destroy().

00498 {
00499    SaAisErrorT ais_res;
00500 
00501    /* saEvtChannelClose() will actually do this automatically, but it just
00502     * feels cleaner to go ahead and do it manually ... */
00503    ais_res = saEvtEventUnsubscribe(event_channel->handle, subscribe_event->id);
00504    if (ais_res != SA_AIS_OK) {
00505       ast_log(LOG_ERROR, "Error unsubscribing: %s\n", ais_err2str(ais_res));
00506    }
00507 
00508    free(subscribe_event);
00509 }

static const char* type_to_filter_str ( enum ast_event_type  type  )  [static]

Definition at line 158 of file evt.c.

References ARRAY_LEN, and supported_event_types.

Referenced by ais_evt_show_event_channels(), ast_event_cb(), and set_egress_subscription().

00159 {
00160    const char *filter_str = NULL;
00161    int i;
00162 
00163    for (i = 0; i < ARRAY_LEN(supported_event_types); i++) {
00164       if (supported_event_types[i].type == type) {
00165          filter_str = supported_event_types[i].str;
00166          break;
00167       }
00168    }
00169 
00170    return filter_str;
00171 }


Variable Documentation

struct ast_cli_entry ais_cli[] [static]

Initial value:

 {
   { .handler =  ais_evt_show_event_channels , .summary =  "Show configured event channels" ,__VA_ARGS__ },
}

Definition at line 297 of file evt.c.

const SaEvtCallbacksT evt_callbacks [static]

Initial value:

 {
   .saEvtChannelOpenCallback  = evt_channel_open_cb,
   .saEvtEventDeliverCallback = evt_event_deliver_cb,
}

Definition at line 65 of file evt.c.

Referenced by ast_ais_evt_load_module().

SaEvtHandleT evt_handle

Definition at line 57 of file evt.c.

Referenced by ast_ais_evt_load_module(), ast_ais_evt_unload_module(), build_event_channel(), and dispatch_thread_handler().

SaAisErrorT evt_init_res [static]

Definition at line 58 of file evt.c.

Referenced by ast_ais_evt_load_module(), and ast_ais_evt_unload_module().

const char* str

Definition at line 71 of file evt.c.

struct { ... } supported_event_types[] [static]

Referenced by add_publish_event(), add_subscribe_event(), and type_to_filter_str().

enum ast_event_type type

Definition at line 72 of file evt.c.

int unique_id [static]

Used to provide unique id's to egress subscriptions

Definition at line 79 of file evt.c.

Referenced by add_subscribe_event().


Generated on Mon Jun 27 16:51:13 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7