44 #define CATEGORY "/main/amihooks/" 53 struct timespec timeout = {
54 .tv_sec = start.tv_sec + 2,
55 .tv_nsec = start.tv_usec * 1000
76 info->name = __func__;
78 info->summary =
"Execute an action using an AMI hook";
97 ast_log(
LOG_NOTICE,
"AMI Event: \nCategory: %d Event: %s\n%s\n", category, event, content);
115 res =
ast_hook_send_action(&test_hook,
"Action: Command\nCommand: core show version\nActionID: 987654321\n");
143 "Usage: amihook send" 160 e->
command =
"amihook register";
162 "Usage: amihook register" 179 e->
command =
"amihook unregister";
181 "Usage: amihook unregister" static char * handle_cli_amihook_unregister_hook(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
AST_TEST_DEFINE(amihook_cli_send)
static int wait_for_hook(struct ast_test *test)
#define AST_CLI_DEFINE(fn, txt,...)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
void ast_manager_unregister_hook(struct manager_custom_hook *hook)
Delete a custom hook to be called when an event is fired.
static ast_mutex_t hook_lock
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
int ast_hook_send_action(struct manager_custom_hook *hook, const char *msg)
Registered hooks can call this function to invoke actions and they will receive responses through reg...
void ast_manager_register_hook(struct manager_custom_hook *hook)
Add a custom hook to be called when an event is fired.
static int load_module(void)
static char * handle_cli_amihook_register_hook(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
descriptor for a cli entry.
static int hook_send(void)
#define AST_TEST_REGISTER(cb)
static void unregister_hook(void)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_mutex_lock(a)
#define ast_cond_signal(cond)
pthread_cond_t ast_cond_t
#define ast_test_status_update(a, b, c...)
static int unload_module(void)
ast_cli_command
calling arguments for new-style handlers.
static int amihook_helper(int category, const char *event, char *content)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_TEST_UNREGISTER(cb)
static struct manager_custom_hook test_hook
Module has failed to load, may be in an inconsistent state.
Standard Command Line Interface.
static struct ast_cli_entry cli_amihook_evt[]
static char * handle_cli_amihook_send(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
static void register_hook(void)
#define ast_cond_timedwait(cond, mutex, time)
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_mutex_unlock(a)