Channel timeout related dialplan functions. More...
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | load_module (void) |
static int | timeout_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | timeout_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Channel timeout dialplan functions" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | timeout_function |
Channel timeout related dialplan functions.
Definition in file func_timeout.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 207 of file func_timeout.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 207 of file func_timeout.c.
static int load_module | ( | void | ) | [static] |
Definition at line 202 of file func_timeout.c.
References ast_custom_function_register.
{ return ast_custom_function_register(&timeout_function); }
static int timeout_read | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
char * | buf, | ||
size_t | len | ||
) | [static] |
Definition at line 73 of file func_timeout.c.
References ast_copy_string(), ast_log(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_pbx::dtimeoutms, LOG_ERROR, ast_channel::pbx, ast_pbx::rtimeoutms, and ast_channel::whentohangup.
{ struct timeval myt; if (!chan) return -1; if (!data) { ast_log(LOG_ERROR, "Must specify type of timeout to get.\n"); return -1; } switch (*data) { case 'a': case 'A': if (ast_tvzero(chan->whentohangup)) { ast_copy_string(buf, "0", len); } else { myt = ast_tvnow(); snprintf(buf, len, "%.3f", ast_tvdiff_ms(chan->whentohangup, myt) / 1000.0); } break; case 'r': case 'R': if (chan->pbx) { snprintf(buf, len, "%.3f", chan->pbx->rtimeoutms / 1000.0); } break; case 'd': case 'D': if (chan->pbx) { snprintf(buf, len, "%.3f", chan->pbx->dtimeoutms / 1000.0); } break; default: ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); return -1; } return 0; }
static int timeout_write | ( | struct ast_channel * | chan, |
const char * | cmd, | ||
char * | data, | ||
const char * | value | ||
) | [static] |
Definition at line 119 of file func_timeout.c.
References ast_channel_setwhentohangup_tv(), ast_localtime(), ast_log(), ast_strftime(), ast_tvadd(), ast_tvnow(), ast_tvzero(), ast_verb, ast_verbose(), ast_pbx::dtimeoutms, LOG_ERROR, ast_channel::pbx, ast_pbx::rtimeoutms, sec, VERBOSITY_ATLEAST, and ast_channel::whentohangup.
{ double x = 0.0; long sec = 0L; char timestr[64]; struct ast_tm myt; struct timeval when = {0,}; int res; if (!chan) return -1; if (!data) { ast_log(LOG_ERROR, "Must specify type of timeout to set.\n"); return -1; } if (!value) return -1; res = sscanf(value, "%30ld%30lf", &sec, &x); if (res == 0 || sec < 0) { when.tv_sec = 0; when.tv_usec = 0; } else if (res == 1) { when.tv_sec = sec; } else if (res == 2) { when.tv_sec = sec; when.tv_usec = x * 1000000; } switch (*data) { case 'a': case 'A': ast_channel_setwhentohangup_tv(chan, when); if (VERBOSITY_ATLEAST(3)) { if (!ast_tvzero(chan->whentohangup)) { when = ast_tvadd(when, ast_tvnow()); ast_strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S.%3q %Z", ast_localtime(&when, &myt, NULL)); ast_verbose("Channel will hangup at %s.\n", timestr); } else { ast_verbose("Channel hangup cancelled.\n"); } } break; case 'r': case 'R': if (chan->pbx) { chan->pbx->rtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000.0; ast_verb(3, "Response timeout set to %.3f\n", chan->pbx->rtimeoutms / 1000.0); } break; case 'd': case 'D': if (chan->pbx) { chan->pbx->dtimeoutms = when.tv_sec * 1000 + when.tv_usec / 1000.0; ast_verb(3, "Digit timeout set to %.3f\n", chan->pbx->dtimeoutms / 1000.0); } break; default: ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); break; } return 0; }
static int unload_module | ( | void | ) | [static] |
Definition at line 197 of file func_timeout.c.
References ast_custom_function_unregister().
{ return ast_custom_function_unregister(&timeout_function); }
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Channel timeout dialplan functions" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 207 of file func_timeout.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 207 of file func_timeout.c.
struct ast_custom_function timeout_function [static] |
{ .name = "TIMEOUT", .read = timeout_read, .write = timeout_write, }
Definition at line 191 of file func_timeout.c.