43 #define AST_API_MODULE 92 static const char context_name[] =
"__func_periodic_hook_context__";
176 .
name =
"HOOK_CHANNEL",
260 if ((res =
do_hook(chan, state))) {
278 if (!(state =
ast_calloc(1,
sizeof(*state)))) {
301 snprintf(uid,
sizeof(uid),
"%u", hook_id);
334 sscanf(
args.interval,
"%30u", &interval) != 1 || interval == 0) {
344 ast_debug(1,
"hook to %s@%s enabled on %s with interval of %u seconds\n",
368 state = datastore->
data;
387 snprintf(buf, len,
"%u", hook_id);
389 return hook_on(chan, data, hook_id);
410 state = datastore->
data;
440 .
name =
"PERIODIC_HOOK",
466 "Set",
"EncodedChannel=${CUT(HOOK_CHANNEL,-,1-2)}",
469 "Set",
"GROUP_NAME=${EncodedChannel}${HOOK_ID}",
472 "Set",
"GROUP(periodic-hook)=${GROUP_NAME}",
475 "$[${GROUP_COUNT(${GROUP_NAME}@periodic-hook)} > 1]?Hangup()",
478 "Set",
"ChannelToSpy=${URIDECODE(${EncodedChannel})}",
502 snprintf(args,
sizeof(args),
"%s,%s,%u",
522 .requires =
"app_chanspy,func_cut,func_groupcount,func_uri",
struct ast_audiohook audiohook
audiohook used as a callback into this module
enum sip_cc_notify_state state
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
static struct hook_state * hook_state_alloc(const char *context, const char *exten, unsigned int interval, unsigned int hook_id)
static int hook_off(struct ast_channel *chan, const char *hook_id)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static int hook_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
Structure for variables, used for configurations and for channel variables.
static void hook_thread_arg_destroy(struct hook_thread_arg *arg)
Structure for a data store type.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
int AST_OPTIONAL_API_NAME() ast_beep_stop(struct ast_channel *chan, const char *beep_id)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static int hook_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
static int do_hook(struct ast_channel *chan, struct hook_state *state)
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension...
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
#define ast_pthread_create_detached_background(a, b, c, d)
static struct hook_thread_arg * hook_thread_arg_alloc(struct ast_channel *chan, struct hook_state *state)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Periodic beeps into the audio of a call.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static const char context_name[]
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_strlen_zero(foo)
ast_audiohook_manipulate_callback manipulate_callback
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags)
Initialize an audiohook structure.
#define ast_custom_function_register_escalating(acf, escalation)
Register a custom function which requires escalated privileges.
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
#define ast_debug(level,...)
Log a DEBUG message.
static int hook_re_enable(struct ast_channel *chan, const char *uid)
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
#define AST_MAX_EXTENSION
static void hook_datastore_destroy_callback(void *data)
#define ast_strdupa(s)
duplicate a string in memory from the stack
static const char beep_exten[]
static unsigned int global_hook_id
Last used hook ID.
Core PBX routines and definitions.
int AST_OPTIONAL_API_NAME() ast_beep_start(struct ast_channel *chan, unsigned int interval, char *beep_id, size_t len)
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static int unload_module(void)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
static int hook_on(struct ast_channel *chan, const char *data, unsigned int hook_id)
#define ast_calloc(num, len)
A wrapper for calloc()
Module has failed to load, may be in an inconsistent state.
static int load_module(void)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int hook_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
static const char full_exten_name[]
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
const char * ast_channel_name(const struct ast_channel *chan)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
Data structure associated with a single frame of data.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
enum ast_audiohook_status status
#define ast_datastore_alloc(info, uid)
#define AST_OPTIONAL_API_NAME(name)
Expands to the name of the implementation function.
static void * hook_launch_thread(void *data)
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
static const char exten_name[]
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define ast_audiohook_lock(ah)
Lock an audiohook.
Asterisk module definitions.
static const struct ast_datastore_info hook_datastore
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static int init_hook(struct ast_channel *chan, const char *context, const char *exten, unsigned int interval, unsigned int hook_id)
static struct ast_custom_function hook_function
#define AST_APP_ARG(name)
Define an application argument.