56 #define MODE_MATCHMORE 1 57 #define MODE_CANMATCH 2 59 #define EXT_DATA_SIZE 256 86 static int cache_cmp(
void *obj,
void *arg,
int flags)
89 return e->
priority != f->priority ? 0 :
90 strcmp(e->
exten, f->exten) ? 0 :
91 strcmp(e->
context, f->context) ? 0 :
98 for (; v; v = v->
next) {
120 struct timeval *now = arg;
126 struct timespec forever = { 999999999, 0 }, one_second = { 1, 0 };
130 pthread_testcancel();
132 nanosleep(&forever,
NULL);
134 pthread_testcancel();
137 pthread_testcancel();
138 nanosleep(&one_second,
NULL);
149 return strlen(extenp) - strlen(extenq);
180 snprintf(pri,
sizeof(pri),
"%d", priority);
183 ematch =
"exten LIKE";
184 snprintf(rexten,
sizeof(rexten),
"%s_%%", exten);
187 ematch =
"exten LIKE";
188 snprintf(rexten,
sizeof(rexten),
"%s%%", exten);
231 const char *ctx =
NULL;
239 } cache_search = { { .
priority =
priority, .context = (
char *) context }, };
243 char *opts = strchr(buf,
'/');
246 table = strchr(buf,
'@');
251 ctx =
S_OR(ctx, context);
252 table =
S_OR(table,
"extensions");
256 ast_copy_string(cache_search.exten, exten,
sizeof(cache_search.exten));
276 strcpy(ce->
exten, exten);
282 pthread_kill(cleanup_thread, SIGURG);
315 char *appdata_tmp =
"";
319 for (v = var; v ; v = v->
next) {
320 if (!strcasecmp(v->
name,
"app"))
322 else if (!strcasecmp(v->
name,
"appdata")) {
338 ast_verb(3,
"Executing [%s@%s:%d] %s(\"%s\", \"%s\")\n",
374 ast_log(
LOG_NOTICE,
"No such application '%s' for extension '%s' in context '%s'\n", app, exten, context);
376 ast_log(
LOG_WARNING,
"No application specified for realtime extension '%s' in context '%s'\n", exten, context);
395 .description =
"Realtime Dialplan Switch",
405 pthread_cancel(cleanup_thread);
406 pthread_kill(cleanup_thread, SIGURG);
407 pthread_join(cleanup_thread,
NULL);
static int cache_cmp(void *obj, void *arg, int flags)
struct ast_variable * ast_load_realtime(const char *family,...) attribute_sentinel
struct ast_variable * next
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
void ast_channel_snapshot_invalidate_segment(struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
Invalidate a channel snapshot segment from being reused.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
#define ast_test_flag(p, flag)
void ast_channel_appl_set(struct ast_channel *chan, const char *value)
#define ao2_callback(c, flags, cb_fn, arg)
Structure for variables, used for configurations and for channel variables.
static struct ast_variable * dup_vars(struct ast_variable *v)
static int realtime_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
static struct ast_variable * realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode, struct ast_flags flags)
static int cache_hash(const void *obj, const int flags)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
I/O Management (derived from Cheops-NG)
static int realtime_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
int ast_channel_priority(const struct ast_channel *chan)
#define ast_verb(level,...)
#define ast_strlen_zero(foo)
static int purge_old_fn(void *obj, void *arg, int flags)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
static int load_module(void)
Configuration File Parser.
static int unload_module(void)
General Asterisk PBX channel definitions.
#define AST_MAX_EXTENSION
Scheduler Routines (derived from cheops)
Asterisk internal frame definitions.
#define ao2_ref(o, delta)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ast_strdupa(s)
duplicate a string in memory from the stack
A set of macros to manage forward-linked lists.
#define ast_variable_new(name, value, filename)
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
const char * ast_channel_exten(const struct ast_channel *chan)
Core PBX routines and definitions.
static const struct ast_app_option switch_opts[128]
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
struct ast_config * ast_load_realtime_multientry(const char *family,...) attribute_sentinel
Retrieve realtime configuration.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
static struct ast_variable * realtime_common(const char *context, const char *exten, int priority, const char *data, int mode)
struct ast_variable * var
#define ao2_alloc(data_size, destructor_fn)
const char * ast_channel_appl(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
#define ast_pthread_create(a, b, c, d)
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
Module could not be loaded properly.
int ast_extension_close(const char *pattern, const char *data, int needmore)
const char * ast_variable_find(const struct ast_category *category, const char *variable)
Gets a variable value from a specific category structure by name.
struct ast_variable * ast_category_detach_variables(struct ast_category *cat)
#define ao2_find(container, arg, flags)
struct stasis_message_type * ast_channel_snapshot_type(void)
Message type for ast_channel_snapshot_update.
static void free_entry(void *obj)
static int realtime_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
static void * cleanup(void *unused)
Structure used to handle boolean flags.
Support for logging to various files, console and syslog Configuration in file logger.conf.
struct ao2_container * cache
const char * ast_channel_data(const struct ast_channel *chan)
static int extension_length_comparator(struct ast_category *p, struct ast_category *q)
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
void ast_config_sort_categories(struct ast_config *config, int descending, int(*comparator)(struct ast_category *p, struct ast_category *q))
Sorts categories in a config in the order of a numerical value contained within them.
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
ast_app: A registered application
const char * ast_channel_name(const struct ast_channel *chan)
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
const char * ast_channel_context(const struct ast_channel *chan)
Handy terminal functions for vt* terms.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
struct ast_category * ast_category_get(const struct ast_config *config, const char *category_name, const char *filter)
Retrieve a category if it exists.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Persistant data storage (akin to *doze registry)
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
void ast_channel_data_set(struct ast_channel *chan, const char *value)
static struct ast_switch realtime_switch
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
static int realtime_matchmore(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
#define ao2_link(container, obj)
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Realtime Switch")