Wed Jan 8 2020 09:49:52

Asterisk developer's documentation


ais.h File Reference

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

#include <saAis.h>
#include <saClm.h>
#include <saEvt.h>

Go to the source code of this file.

Enumerations

enum  ast_ais_cmd { AST_AIS_CMD_EXIT, AST_AIS_CMD_MEMBERSHIP_CHANGED }
 

Functions

const char * ais_err2str (SaAisErrorT error)
 
int ast_ais_clm_load_module (void)
 
int ast_ais_clm_unload_module (void)
 
int ast_ais_cmd (enum ast_ais_cmd cmd)
 
int ast_ais_evt_load_module (void)
 
void ast_ais_evt_membership_changed (void)
 
int ast_ais_evt_unload_module (void)
 

Variables

SaVersionT ais_version
 
SaClmHandleT clm_handle
 
SaEvtHandleT evt_handle
 

Detailed Description

Usage of the SAForum AIS (Application Interface Specification)

Author
Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com

Definition in file ais.h.

Enumeration Type Documentation

Enumerator
AST_AIS_CMD_EXIT 
AST_AIS_CMD_MEMBERSHIP_CHANGED 

Definition at line 50 of file ais.h.

Function Documentation

const char* ais_err2str ( SaAisErrorT  error)

Definition at line 105 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().

106 {
107  int x;
108 
109  for (x = 0; x < ARRAY_LEN(ais_errors); x++) {
110  if (ais_errors[x].error == error)
111  return ais_errors[x].desc;
112  }
113 
114  return "Unknown";
115 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
const char * desc
Definition: res_ais.c:74
static struct ais_error ais_errors[]
int ast_ais_clm_load_module ( void  )

Definition at line 157 of file clm.c.

References ais_err2str(), ais_version, ARRAY_LEN, ast_cli_register_multiple(), ast_log(), clm_callbacks, clm_handle, clm_init_res, and LOG_ERROR.

Referenced by load_module().

158 {
159  SaAisErrorT ais_res;
160 
161  clm_init_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version);
162  if (clm_init_res != SA_AIS_OK) {
163  ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n",
165  return -1;
166  }
167 
168  ais_res = saClmClusterTrack(clm_handle, SA_TRACK_CHANGES, NULL);
169  if (ais_res != SA_AIS_OK) {
170  ast_log(LOG_ERROR, "Error starting tracking of cluster membership changes.\n");
171  }
172 
174 
175  return 0;
176 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const SaClmCallbacksT clm_callbacks
Definition: clm.c:60
SaVersionT ais_version
Definition: res_ais.c:70
static SaAisErrorT clm_init_res
Definition: clm.c:53
#define LOG_ERROR
Definition: logger.h:155
SaClmHandleT clm_handle
Definition: clm.c:52
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
const char * ais_err2str(SaAisErrorT error)
Definition: res_ais.c:105
static struct ast_cli_entry ais_cli[]
Definition: clm.c:153
int ast_ais_clm_unload_module ( void  )

Definition at line 178 of file clm.c.

References ais_err2str(), ARRAY_LEN, ast_cli_unregister_multiple(), ast_log(), clm_handle, clm_init_res, and LOG_ERROR.

Referenced by load_module(), and unload_module().

179 {
180  SaAisErrorT ais_res;
181 
182  if (clm_init_res != SA_AIS_OK) {
183  return 0;
184  }
185 
187 
188  ais_res = saClmFinalize(clm_handle);
189  if (ais_res != SA_AIS_OK) {
190  ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n",
191  ais_err2str(ais_res));
192  return -1;
193  }
194 
195  return 0;
196 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: cli.c:2177
static SaAisErrorT clm_init_res
Definition: clm.c:53
#define LOG_ERROR
Definition: logger.h:155
SaClmHandleT clm_handle
Definition: clm.c:52
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const char * ais_err2str(SaAisErrorT error)
Definition: res_ais.c:105
static struct ast_cli_entry ais_cli[]
Definition: clm.c:153
int ast_ais_cmd ( enum ast_ais_cmd  cmd)

Definition at line 182 of file res_ais.c.

References ast_debug, and dispatch_thread.

183 {
184  int res;
185 
186  res = write(dispatch_thread.alert_pipe[1], (char *) &cmd, sizeof(cmd));
187 
188  ast_debug(1, "AIS cmd: %d, res: %d\n", cmd, res);
189 
190  return res;
191 }
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static struct @322 dispatch_thread
int ast_ais_evt_load_module ( void  )

Definition at line 576 of file evt.c.

References 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().

577 {
578  evt_init_res = saEvtInitialize(&evt_handle, &evt_callbacks, &ais_version);
579  if (evt_init_res != SA_AIS_OK) {
580  ast_log(LOG_ERROR, "Could not initialize eventing service: %s\n",
582  return -1;
583  }
584 
585  load_config();
586 
588 
589  return 0;
590 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_cli_entry ais_cli[]
Definition: evt.c:315
SaEvtHandleT evt_handle
Definition: evt.c:61
static void load_config(void)
Definition: evt.c:490
static const SaEvtCallbacksT evt_callbacks
Definition: evt.c:69
SaVersionT ais_version
Definition: res_ais.c:70
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
const char * ais_err2str(SaAisErrorT error)
Definition: res_ais.c:105
static SaAisErrorT evt_init_res
Definition: evt.c:62
void ast_ais_evt_membership_changed ( void  )

Definition at line 319 of file evt.c.

References ast_debug, ast_event_dump_cache(), AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, event_channel::name, event_channel::publish_events, and publish_event::sub.

Referenced by dispatch_thread_handler().

320 {
321  struct event_channel *ec;
322 
324  AST_RWLIST_TRAVERSE(&event_channels, ec, entry) {
325  struct publish_event *pe;
326 
328  ast_debug(1, "Dumping cache for event channel '%s'\n", ec->name);
330  }
331  }
333 }
struct event_channel::@356 publish_events
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
void ast_event_dump_cache(const struct ast_event_sub *event_sub)
Dump the event cache for the subscriber.
Definition: event.c:654
struct publish_event::@355 entry
struct ast_event_sub * sub
Definition: evt.c:98
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
char name[1]
Definition: evt.c:107
int ast_ais_evt_unload_module ( void  )

Definition at line 592 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().

593 {
594  SaAisErrorT ais_res;
595 
596  if (evt_init_res != SA_AIS_OK) {
597  return 0;
598  }
599 
601 
602  ais_res = saEvtFinalize(evt_handle);
603  if (ais_res != SA_AIS_OK) {
604  ast_log(LOG_ERROR, "Problem stopping eventing service: %s\n",
605  ais_err2str(ais_res));
606  return -1;
607  }
608 
609  return 0;
610 }
SaEvtHandleT evt_handle
Definition: evt.c:61
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void destroy_event_channels(void)
Definition: evt.c:565
const char * ais_err2str(SaAisErrorT error)
Definition: res_ais.c:105
static SaAisErrorT evt_init_res
Definition: evt.c:62

Variable Documentation

SaVersionT ais_version

Definition at line 70 of file res_ais.c.

Referenced by ast_ais_clm_load_module(), and ast_ais_evt_load_module().

SaClmHandleT clm_handle
SaEvtHandleT evt_handle