34 #include "asterisk/_private.h"
39 #if defined(HAVE_SYSINFO)
40 #include <sys/sysinfo.h>
43 #include <sys/loadavg.h>
826 #define EXT_DATA_SIZE 256
828 #define EXT_DATA_SIZE 8192
831 #define SWITCH_DATA_LENGTH 256
833 #define VAR_BUF_SIZE 4096
836 #define VAR_SOFTTRAN 2
837 #define VAR_HARDTRAN 3
839 #define BACKGROUND_SKIP (1 << 0)
840 #define BACKGROUND_NOANSWER (1 << 1)
841 #define BACKGROUND_MATCHEXTEN (1 << 2)
842 #define BACKGROUND_PLAYBACK (1 << 3)
851 #define WAITEXTEN_MOH (1 << 0)
852 #define WAITEXTEN_DIALTONE (1 << 1)
1026 #define HASH_EXTENHINT_SIZE 17
1028 #define HASH_EXTENHINT_SIZE 563
1084 static int matchcid(
const char *cidpattern,
const char *callerid);
1091 struct match_char *tree,
int length,
int spec,
const char *callerid,
1108 const char *application,
void *data,
void (*
datad)(
void *),
const char *
registrar);
1110 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
1111 const char *application,
void *data,
void (*
datad)(
void *),
1112 const char *
registrar,
int lock_context);
1129 const unsigned char *ac = a;
1130 const unsigned char *bc = b;
1318 #ifdef CONTEXT_DEBUG
1332 void check_contexts_trouble(
void);
1334 void check_contexts_trouble(
void)
1340 int check_contexts(
char *,
int);
1342 int check_contexts(
char *file,
int line )
1367 ast_log(
LOG_NOTICE,
"Called from: %s:%d: Could not find the %s context in the linked list\n", file, line, c1->
name);
1368 check_contexts_trouble();
1375 ast_log(
LOG_NOTICE,
"Called from: %s:%d: Could not find the %s context in the hashtab\n", file, line, c2->
name);
1376 check_contexts_trouble();
1389 for(e1 = c1->
root; e1; e1=e1->
next)
1391 char dummy_name[1024];
1392 ex.exten = dummy_name;
1399 ast_log(
LOG_NOTICE,
"Called from: %s:%d: The %s context records the exten %s (CID match: %s) but it is not in its root_table\n", file, line, c2->
name, dummy_name, e1->
cidmatch );
1401 ast_log(
LOG_NOTICE,
"Called from: %s:%d: The %s context records the exten %s but it is not in its root_table\n", file, line, c2->
name, dummy_name );
1403 check_contexts_trouble();
1410 ast_log(
LOG_NOTICE,
"Called from: %s:%d: No c2->root_table for context %s!\n", file, line, c2->
name);
1423 ast_log(
LOG_NOTICE,
"Called from: %s:%d: The %s context records the exten %s but it is not in its root_table\n", file, line, c2->
name, e2->
exten);
1424 check_contexts_trouble();
1436 for(e1 = c2->
root; e1; e1 = e1->
next) {
1438 for(e2=e1;e2;e2=e2->
peer) {
1441 ast_log(
LOG_NOTICE,
"Called from: %s:%d: The %s context, %s exten, %d priority has a peer_table entry, and shouldn't!\n", file, line, c2->
name, e1->
exten, e2->
priority );
1442 check_contexts_trouble();
1446 ast_log(
LOG_NOTICE,
"Called from: %s:%d: The %s context, %s exten, %d priority has a peer_label_table entry, and shouldn't!\n", file, line, c2->
name, e1->
exten, e2->
priority );
1447 check_contexts_trouble();
1452 check_contexts_trouble();
1457 check_contexts_trouble();
1463 ast_log(
LOG_NOTICE,
"Called from: %s:%d: The %s context, %s exten, %d priority is not reflected in the peer_table\n", file, line, c2->
name, e1->
exten, e2->
priority );
1464 check_contexts_trouble();
1476 for(e3=e1;e3;e3=e3->
peer) {
1484 check_contexts_trouble();
1498 struct ast_app *
app,
1503 const char *saved_c_appl;
1504 const char *saved_c_data;
1510 saved_c_appl= c->
appl;
1511 saved_c_data= c->
data;
1513 c->
appl = app->name;
1522 "the pipe. Did you forget to convert your dialplan? (%s(%s))\n",
1523 app->name, (
char *) data);
1526 if (app->module && u)
1530 c->
appl = saved_c_appl;
1531 c->
data = saved_c_data;
1539 struct ast_app *tmp;
1543 if (!strcasecmp(tmp->name, app))
1557 if (!strcasecmp(asw->
name, sw))
1663 #ifdef NEED_DEBUG_HERE
1676 if (node && node->
exten)
1677 snprintf(extenstr,
sizeof(extenstr),
"(%p)", node->
exten);
1679 if (strlen(node->
x) > 1) {
1695 log_match_char_tree(node->
alt_char, prefix);
1707 snprintf(extenstr,
sizeof(extenstr),
"(%p)", node->
exten);
1710 if (strlen(node->
x) > 1) {
1711 ast_cli(fd,
"%s[%s]:%c:%c:%d:%s%s%s\n", prefix, node->
x, node->
is_pattern ?
'Y' :
'N',
1734 for (node2 = node; node2; node2 = node2->
next_char) {
1736 #ifdef NEED_DEBUG_HERE
1739 return node2->
exten;
1742 #ifdef NEED_DEBUG_HERE
1754 if (node && node->
x[0] ==
'.' && !node->
x[1]) {
1758 if (node && node->
x[0] ==
'!' && !node->
x[1]) {
1776 for (m4 = m3; m4; m4 = m4->
alt_char) {
1813 ast_log(
LOG_NOTICE,
"new_find_extension called with %s on (sub)tree %s action=%s\n", str, tree->
x, action2str(action));
1815 ast_log(
LOG_NOTICE,
"new_find_extension called with %s on (sub)tree NULL action=%s\n", str, action2str(action));
1817 for (p = tree; p; p = p->
alt_char) {
1819 if (p->
x[0] ==
'N') {
1820 if (p->
x[1] == 0 && *str >=
'2' && *str <=
'9' ) {
1821 #define NEW_MATCHER_CHK_MATCH \
1822 if (p->exten && !(*(str + 1))) { \
1823 if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { \
1824 update_scoreboard(score, length + 1, spec + p->specificity, p->exten, 0, callerid, p->deleted, p); \
1825 if (!p->deleted) { \
1826 if (action == E_FINDLABEL) { \
1827 if (ast_hashtab_lookup(score->exten->peer_label_table, &pattern)) { \
1828 ast_debug(4, "Found label in preferred extension\n"); \
1832 ast_debug(4, "returning an exact match-- first found-- %s\n", p->exten->exten); \
1839 #define NEW_MATCHER_RECURSE \
1840 if (p->next_char && (*(str + 1) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0) \
1841 || p->next_char->x[0] == '!')) { \
1842 if (*(str + 1) || p->next_char->x[0] == '!') { \
1843 new_find_extension(str + 1, score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \
1844 if (score->exten) { \
1845 ast_debug(4 ,"returning an exact match-- %s\n", score->exten->exten); \
1849 new_find_extension("/", score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \
1850 if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) { \
1851 ast_debug(4,"returning a (can/more) match--- %s\n", score->exten ? score->exten->exten : \
1856 } else if ((p->next_char || action == E_CANMATCH) && !*(str + 1)) { \
1857 score->canmatch = 1; \
1858 score->canmatch_exten = get_canmatch_exten(p); \
1859 if (action == E_CANMATCH || action == E_MATCHMORE) { \
1860 ast_debug(4, "returning a canmatch/matchmore--- str=%s\n", str); \
1868 }
else if (p->
x[0] ==
'Z') {
1869 if (p->
x[1] == 0 && *str >=
'1' && *str <=
'9' ) {
1873 }
else if (p->
x[0] ==
'X') {
1874 if (p->
x[1] == 0 && *str >=
'0' && *str <=
'9' ) {
1878 }
else if (p->
x[0] ==
'.' && p->
x[1] == 0) {
1881 const char *str2 =
str;
1882 while (*str2 && *str2 !=
'/') {
1886 if (p->
exten && *str2 !=
'/') {
1889 ast_debug(4,
"return because scoreboard has a match with '/'--- %s\n", score->
exten->
exten);
1896 ast_debug(4,
"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set--- %s\n", score->
exten ? score->
exten->
exten :
"NULL");
1900 }
else if (p->
x[0] ==
'!' && p->
x[1] == 0) {
1903 const char *str2 =
str;
1904 while (*str2 && *str2 !=
'/') {
1908 if (p->
exten && *str2 !=
'/') {
1918 ast_debug(4,
"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/' and '!'--- %s\n", score->
exten ? score->
exten->
exten :
"NULL");
1922 }
else if (p->
x[0] ==
'/' && p->
x[1] == 0) {
1924 if (p->
next_char && callerid && *callerid) {
1927 ast_debug(4,
"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/'--- %s\n", score->
exten ? score->
exten->
exten :
"NULL");
1931 }
else if (strchr(p->
x, *str)) {
1932 ast_debug(4,
"Nothing strange about this match\n");
1936 }
else if (strchr(p->
x, *str)) {
1937 ast_debug(4,
"Nothing strange about this match\n");
1942 ast_debug(4,
"return at end of func\n");
1970 for (t = current; t; t = t->
alt_char) {
1971 if (is_pattern == t->
is_pattern && !strcmp(pat, t->
x)) {
1989 if (!(*parent_ptr)) {
1994 if ((*parent_ptr)->specificity > node->
specificity) {
2001 lcurr = *parent_ptr;
2028 if (!(m =
ast_calloc(1,
sizeof(*m) + strlen(pattern->
buf)))) {
2035 strcpy(m->
x, pattern->
buf);
2040 if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'N') {
2042 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'Z') {
2044 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'X') {
2046 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'.') {
2048 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'!') {
2080 #define INC_DST_OVERFLOW_CHECK \
2082 if (dst - node->buf < sizeof(node->buf) - 1) { \
2090 node->
buf[0] =
'\0';
2092 if (*src ==
'[' && pattern) {
2093 char *dst = node->
buf;
2094 const char *src_next;
2104 if (*src ==
'[' || *src ==
'\\' || *src ==
'-' || *src ==
']') {
2108 }
else if (*src ==
'-') {
2109 unsigned char first;
2113 first = *(src_next - 1);
2122 if (node->
buf[0] && last) {
2124 while (++first <= last) {
2137 }
else if (*src ==
'\0') {
2139 "A matching ']' was not found for '[' in exten pattern '%s'\n",
2142 }
else if (*src ==
']') {
2155 "Expanded character set too large to deal with in exten pattern '%s'. Ignoring character set.\n",
2157 node->
buf[0] =
'\0';
2162 length = strlen(node->
buf);
2166 node->
buf[0] =
'\0';
2173 src_next = node->
buf;
2174 while (*src_next++) {
2175 if (*dst != *src_next) {
2180 length = strlen(node->
buf);
2182 node->
specif = length | (
unsigned char) node->
buf[0];
2184 }
else if (*src ==
'-') {
2194 node->
buf[0] = *++src;
2195 if (!node->
buf[0]) {
2199 node->
buf[0] = *src;
2202 if (node->
buf[0] ==
'n') {
2204 }
else if (node->
buf[0] ==
'x') {
2206 }
else if (node->
buf[0] ==
'z') {
2211 node->
buf[1] =
'\0';
2219 #undef INC_DST_OVERFLOW_CHECK
2236 if (
sizeof(extenbuf) < strlen(e1->
exten) + strlen(e1->
cidmatch) + 2) {
2238 "The pattern %s/%s is too big to deal with: it will be ignored! Disaster!\n",
2261 for (; pat_node[idx_cur].
buf[0]; idx_cur = idx_next) {
2262 idx_next = (idx_cur + 1) %
ARRAY_LEN(pat_node);
2269 if (!pat_node[idx_next].buf[0]) {
2303 if (!pat_node[idx_next].buf[0]) {
2304 if (m2 && m2->
exten) {
2326 int biggest_bucket, resizes, numobjs, numbucks;
2330 ast_log(
LOG_DEBUG,
"This tree has %d objects in %d bucket lists, longest list=%d objects, and has resized %d times\n",
2331 numobjs, numbucks, biggest_bucket, resizes);
2338 ast_log(
LOG_ERROR,
"Attempt to create extension with no extension name.\n");
2356 pattern_tree->
exten = 0;
2375 while (*str ==
'-') {
2404 while (*left ==
'-') {
2407 while (*right ==
'-') {
2420 cmp = *left - *right;
2447 while (*left ==
'-') {
2450 while (*right ==
'-') {
2454 cmp = *left - *right;
2554 return 0x0800 |
'2';
2561 return 0x0A00 |
'0';
2568 return 0x0900 |
'1';
2588 end = strchr(*p,
']');
2597 for (; *p < end; ++*p) {
2602 if (*p + 2 < end && (*p)[1] ==
'-') {
2611 for (; c1 <= c2; ++c1) {
2620 if (!(bitwise[c1 / BITS_PER] & mask)) {
2629 return count | cmin;
2650 unsigned char left_bitwise[32] = { 0, };
2651 unsigned char right_bitwise[32] = { 0, };
2655 cmp = left_pos - right_pos;
2664 cmp = memcmp(right_bitwise, left_bitwise,
ARRAY_LEN(left_bitwise));
2691 static int ext_cmp(
const char *left,
const char *right)
2694 if (left[0] !=
'_') {
2695 if (right[0] ==
'_') {
2701 if (right[0] !=
'_') {
2743 #ifdef NEED_DEBUG_HERE
2744 ast_log(
LOG_NOTICE,
"match core: pat: '%s', dat: '%s', mode=%d\n", pattern, data, (
int)mode);
2747 if (pattern[0] !=
'_') {
2752 #ifdef NEED_DEBUG_HERE
2759 #ifdef NEED_DEBUG_HERE
2760 ast_log(
LOG_NOTICE,
"return (!ext_cmp_exten(%s,%s) when mode== E_MATCH)\n", pattern, data);
2765 #ifdef NEED_DEBUG_HERE
2766 ast_log(
LOG_NOTICE,
"return (mode(%d) == E_MATCHMORE ? lp(%d) > ld(%d) : 1)\n", mode, lp, ld);
2770 #ifdef NEED_DEBUG_HERE
2771 ast_log(
LOG_NOTICE,
"return (0) when ld(%d) > 0 && pattern(%s) != data(%s)\n", ld, pattern, data);
2776 if (mode ==
E_MATCH && data[0] ==
'_') {
2786 #ifdef NEED_DEBUG_HERE
2787 ast_log(
LOG_NOTICE,
"Comparing as patterns first. pattern:%s data:%s\n", pattern, data);
2790 #ifdef NEED_DEBUG_HERE
2806 while (*data ==
'-') {
2809 while (*pattern ==
'-') {
2812 if (!*data || !*pattern || *pattern ==
'/') {
2819 end = strchr(pattern,
']');
2824 if (pattern == end) {
2829 for (; pattern < end; ++pattern) {
2830 if (pattern+2 < end && pattern[1] ==
'-') {
2831 if (*data >= pattern[0] && *data <= pattern[2])
2837 }
else if (*data == pattern[0])
2840 if (pattern >= end) {
2841 #ifdef NEED_DEBUG_HERE
2850 if (*data < '2' || *data >
'9') {
2851 #ifdef NEED_DEBUG_HERE
2859 if (*data < '0' || *data >
'9') {
2860 #ifdef NEED_DEBUG_HERE
2868 if (*data < '1' || *data >
'9') {
2869 #ifdef NEED_DEBUG_HERE
2876 #ifdef NEED_DEBUG_HERE
2881 #ifdef NEED_DEBUG_HERE
2886 if (*data != *pattern) {
2887 #ifdef NEED_DEBUG_HERE
2888 ast_log(
LOG_NOTICE,
"return (0) when *data(%c) != *pattern(%c)\n", *data, *pattern);
2898 #ifdef NEED_DEBUG_HERE
2908 if (*pattern ==
'\0' || *pattern ==
'/') {
2909 #ifdef NEED_DEBUG_HERE
2913 }
else if (*pattern ==
'!') {
2914 #ifdef NEED_DEBUG_HERE
2919 #ifdef NEED_DEBUG_HERE
2922 return (mode ==
E_MATCH) ? 0 : 1;
2933 static int prof_id = -2;
2934 if (prof_id == -2) {
2986 if (!strcasecmp(name, tmp->
name)) {
2995 #define STATUS_NO_CONTEXT 1
2996 #define STATUS_NO_EXTENSION 2
2997 #define STATUS_NO_PRIORITY 3
2998 #define STATUS_NO_LABEL 4
2999 #define STATUS_SUCCESS 5
3001 static int matchcid(
const char *cidpattern,
const char *callerid)
3015 const char *context,
const char *
exten,
int priority,
3016 const char *label,
const char *callerid,
enum ext_match_t action)
3020 struct ast_exten *e = NULL, *eroot = NULL;
3022 struct ast_sw *sw = NULL;
3025 struct ast_str *tmpdata = NULL;
3027 pattern.
label = label;
3029 #ifdef NEED_DEBUG_HERE
3030 ast_log(
LOG_NOTICE,
"Looking for cont/ext/prio/label/action = %s/%s/%d/%s/%d\n", context, exten, priority, label, (
int) action);
3045 for (x = 0; x < q->
stacklen; x++) {
3046 if (!strcasecmp(q->
incstack[x], context))
3088 name =
strsep(&osw,
"/");
3096 if (osw && strchr(osw,
'$')) {
3124 res = aswf(chan, context, exten, priority, callerid, datap);
3141 eroot = score.
exten;
3147 #ifdef NEED_DEBUG_HERE
3155 #ifdef NEED_DEBUG_HERE
3165 #ifdef NEED_DEBUG_HERE
3170 #ifdef NEED_DEBUG_HERE
3175 #ifdef NEED_DEBUG_HERE
3182 #ifdef NEED_DEBUG_HERE
3203 #ifdef NEED_DEBUG_HERE
3217 if (!match || (eroot->matchcid && !
matchcid(eroot->cidmatch, callerid)))
3277 res = aswf(chan, context, exten, priority, callerid, datap);
3294 #ifdef NEED_DEBUG_HERE
3318 for (; *
var; var++) {
3322 }
else if (*var ==
')') {
3324 }
else if (*var ==
':' && parens == 0) {
3326 sscanf(var,
"%30d:%30d", offset, length);
3344 static char *
substring(
const char *
value,
int offset,
int length,
char *workspace,
size_t workspace_len)
3346 char *ret = workspace;
3354 if (offset == 0 && length >= lr)
3358 offset = lr + offset;
3368 if (length >= 0 && length < lr - offset)
3370 else if (length < 0) {
3371 if (lr > offset - length)
3372 ret[lr + length - offset] =
'\0';
3387 if (offset == 0 && length >= lr)
3391 offset = lr + offset;
3408 if (length >= 0 && length < lr) {
3412 }
else if (length < 0) {
3415 tmp[lr + length] =
'\0';
3441 *ret = cret ? workspace : NULL;
3447 const char not_found =
'\0';
3452 int i, need_substring;
3486 if (!strncmp(var,
"CALL", 4)) {
3487 if (!strncmp(var + 4,
"ING", 3)) {
3488 if (!strcmp(var + 7,
"PRES")) {
3492 }
else if (!strcmp(var + 7,
"ANI2")) {
3495 }
else if (!strcmp(var + 7,
"TON")) {
3498 }
else if (!strcmp(var + 7,
"TNS")) {
3503 }
else if (!strcmp(var,
"HINT")) {
3505 }
else if (!strcmp(var,
"HINTNAME")) {
3507 }
else if (!strcmp(var,
"EXTEN")) {
3509 }
else if (!strcmp(var,
"CONTEXT")) {
3511 }
else if (!strcmp(var,
"PRIORITY")) {
3514 }
else if (!strcmp(var,
"CHANNEL")) {
3516 }
else if (!strcmp(var,
"UNIQUEID")) {
3518 }
else if (!strcmp(var,
"HANGUPCAUSE")) {
3523 if (s == ¬_found) {
3524 if (!strcmp(var,
"EPOCH")) {
3527 }
else if (!strcmp(var,
"SYSTEMNAME")) {
3529 }
else if (!strcmp(var,
"ENTITYID")) {
3535 for (i = 0; s == ¬_found && i <
ARRAY_LEN(places); i++) {
3550 if (s == ¬_found || s == NULL) {
3551 ast_debug(5,
"Result of '%s' is NULL\n", var);
3554 ast_debug(5,
"Result of '%s' is '%s'\n", var, s);
3559 if (need_substring) {
3561 ast_debug(2,
"Final result of '%s' is '%s'\n", var, ret);
3579 .
type =
"EXCEPTION",
3607 ds->
data = exception;
3610 exception = ds->
data;
3630 if (!ds || !ds->
data)
3632 exception = ds->
data;
3633 if (!strcasecmp(data,
"REASON"))
3635 else if (!strcasecmp(data,
"CONTEXT"))
3637 else if (!strncasecmp(data,
"EXTEN", 5))
3639 else if (!strcasecmp(data,
"PRIORITY"))
3640 snprintf(buf, buflen,
"%d", exception->
priority);
3647 .
name =
"EXCEPTION",
3659 e->
command =
"core show functions [like]";
3661 "Usage: core show functions [like <text>]\n"
3662 " List builtin functions, optionally only those matching a given string\n";
3668 if (a->
argc == 5 && (!strcmp(a->
argv[3],
"like")) ) {
3670 }
else if (a->
argc != 3) {
3674 ast_cli(a->
fd,
"%s Custom Functions:\n--------------------------------------------------------------------------------\n", like ?
"Matching" :
"Installed");
3678 if (!like || strstr(acf->
name, a->
argv[4])) {
3680 ast_cli(a->
fd,
"%-20.20s %-35.35s %s\n",
3688 ast_cli(a->
fd,
"%d %scustom functions installed.\n", count_acf, like ?
"matching " :
"");
3697 char infotitle[64 +
AST_MAX_APP + 22], syntitle[40], destitle[40], argtitle[40], seealsotitle[40];
3700 int syntax_size, description_size, synopsis_size, arguments_size, seealso_size;
3707 e->
command =
"core show function";
3709 "Usage: core show function <function>\n"
3710 " Describe a particular dialplan function.\n";
3713 wordlen = strlen(a->
word);
3717 if (!strncasecmp(a->
word, acf->
name, wordlen) && ++which > a->
n) {
3732 ast_cli(a->
fd,
"No function by that name registered.\n");
3738 ast_cli(a->
fd,
"Memory allocation failure!\n");
3742 snprintf(info,
sizeof(info),
"\n -= Info about function '%s' =- \n\n", acf->
name);
3772 if (!synopsis || !description || !arguments || !seealso) {
3787 ast_cli(a->
fd,
"%s%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n",
3788 infotitle, syntitle, synopsis, destitle, description,
3789 stxtitle, syntax, argtitle, arguments, seealsotitle, seealso);
3806 if (!strcmp(name, acf->
name))
3830 ast_verb(2,
"Unregistered custom function %s\n", cur->
name);
3837 if (cur_escalation->acf == acf) {
3846 return cur ? 0 : -1;
3862 if (cur_escalation->acf == acf) {
3863 res = cur_escalation->read_escalates;
3884 if (cur_escalation->acf == acf) {
3885 res = cur_escalation->write_escalates;
3967 if (!strcmp(acf->
name, cur->
name)) {
3976 if (strcasecmp(acf->
name, cur->
name) < 0) {
4009 acf_escalation =
ast_calloc(1,
sizeof(*acf_escalation));
4010 if (!acf_escalation) {
4015 acf_escalation->acf = acf;
4016 switch (escalation) {
4020 acf_escalation->read_escalates = 1;
4023 acf_escalation->write_escalates = 1;
4026 acf_escalation->read_escalates = 1;
4027 acf_escalation->write_escalates = 1;
4043 char *
args = strchr(
function,
'(');
4046 ast_log(
LOG_WARNING,
"Function '%s' doesn't contain parentheses. Assuming null argument.\n",
function);
4050 if ((p = strrchr(args,
')'))) {
4053 ast_log(
LOG_WARNING,
"Can't find trailing parenthesis for function '%s(%s'?\n",
function, args);
4061 if (new_live_dangerously && !live_dangerously) {
4063 "See https://wiki.asterisk.org/wiki/x/1gKfAQ for more details.\n");
4066 if (!new_live_dangerously && live_dangerously) {
4069 live_dangerously = new_live_dangerously;
4074 int *thread_inhibit_escalations;
4079 if (thread_inhibit_escalations == NULL) {
4080 ast_log(
LOG_ERROR,
"Error inhibiting privilege escalations for current thread\n");
4084 *thread_inhibit_escalations = 1;
4097 int *thread_inhibit_escalations;
4102 if (thread_inhibit_escalations == NULL) {
4103 ast_log(
LOG_ERROR,
"Error checking thread's ability to run dangerous functions\n");
4108 return *thread_inhibit_escalations;
4133 if (live_dangerously) {
4135 ast_debug(2,
"Reading %s from a dangerous context\n",
4166 if (live_dangerously) {
4168 ast_debug(2,
"Writing %s from a dangerous context\n",
4185 if (acfptr == NULL) {
4187 }
else if (!acfptr->
read && !acfptr->
read2) {
4191 }
else if (acfptr->
read) {
4195 res = acfptr->
read(chan, copy, args, workspace, len);
4196 if (acfptr->
mod && u) {
4205 res = acfptr->
read2(chan, copy, args, &str, 0);
4206 if (acfptr->
mod && u) {
4224 if (acfptr == NULL) {
4226 }
else if (!acfptr->
read && !acfptr->
read2) {
4235 if (acfptr->
read2) {
4237 res = acfptr->
read2(chan, copy, args, str, maxlen);
4255 if (acfptr->
mod && u) {
4269 if (acfptr == NULL) {
4271 }
else if (!acfptr->
write) {
4280 res = acfptr->
write(chan, copy, args, value);
4281 if (acfptr->
mod && u)
4293 const char *tmp, *whereweare;
4295 int offset, offset2, isfunction;
4296 const char *nextvar, *nextexp, *nextthing;
4297 const char *vars, *vare;
4299 int pos, brackets, needsub,
len;
4303 whereweare = tmp = templ;
4309 pos = strlen(whereweare);
4312 nextthing = strchr(whereweare,
'$');
4314 switch (nextthing[1]) {
4316 nextvar = nextthing;
4317 pos = nextvar - whereweare;
4320 nextexp = nextthing;
4321 pos = nextexp - whereweare;
4340 vars = vare = nextvar + 2;
4345 while (brackets && *vare) {
4346 if ((vare[0] ==
'$') && (vare[1] ==
'{')) {
4348 }
else if (vare[0] ==
'{') {
4350 }
else if (vare[0] ==
'}') {
4352 }
else if ((vare[0] ==
'$') && (vare[1] ==
'['))
4358 len = vare - vars - 1;
4361 whereweare += (len + 3);
4389 memcpy(&old, &bogus->
varshead,
sizeof(old));
4396 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
4399 ast_debug(2,
"Function %s result is '%s'\n", finalvars, cp4 ? cp4 :
"(null)");
4409 }
else if (nextexp) {
4413 vars = vare = nextexp + 2;
4418 while (brackets && *vare) {
4419 if ((vare[0] ==
'$') && (vare[1] ==
'[')) {
4423 }
else if (vare[0] ==
'[') {
4425 }
else if (vare[0] ==
']') {
4427 }
else if ((vare[0] ==
'$') && (vare[1] ==
'{')) {
4435 len = vare - vars - 1;
4438 whereweare += (len + 3);
4484 const char *tmp, *whereweare, *orig_cp2 = cp2;
4485 int length, offset, offset2, isfunction;
4486 char *workspace = NULL;
4487 char *ltmp = NULL, *
var = NULL;
4488 char *nextvar, *nextexp, *nextthing;
4490 int pos, brackets, needsub,
len;
4496 pos = strlen(whereweare);
4499 nextthing = strchr(whereweare,
'$');
4501 switch (nextthing[1]) {
4503 nextvar = nextthing;
4504 pos = nextvar - whereweare;
4507 nextexp = nextthing;
4508 pos = nextexp - whereweare;
4521 memcpy(cp2, whereweare, pos);
4533 vars = vare = nextvar + 2;
4538 while (brackets && *vare) {
4539 if ((vare[0] ==
'$') && (vare[1] ==
'{')) {
4541 }
else if (vare[0] ==
'{') {
4543 }
else if (vare[0] ==
'}') {
4545 }
else if ((vare[0] ==
'$') && (vare[1] ==
'['))
4551 len = vare - vars - 1;
4554 whereweare += (len + 3);
4577 workspace[0] =
'\0';
4588 memcpy(&old, &c->
varshead,
sizeof(old));
4595 ast_log(
LOG_ERROR,
"Unable to allocate bogus channel for variable substitution. Function results may be blank.\n");
4598 ast_debug(2,
"Function %s result is '%s'\n", vars, cp4 ? cp4 :
"(null)");
4606 length = strlen(cp4);
4609 memcpy(cp2, cp4, length);
4614 }
else if (nextexp) {
4618 vars = vare = nextexp + 2;
4623 while (brackets && *vare) {
4624 if ((vare[0] ==
'$') && (vare[1] ==
'[')) {
4628 }
else if (vare[0] ==
'[') {
4630 }
else if (vare[0] ==
']') {
4632 }
else if ((vare[0] ==
'$') && (vare[1] ==
'{')) {
4640 len = vare - vars - 1;
4643 whereweare += (len + 3);
4663 length =
ast_expr(vars, cp2, count, c);
4666 ast_debug(1,
"Expression result is '%s'\n", cp2);
4673 *used = cp2 - orig_cp2;
4707 const char *context,
const char *
exten,
int priority,
4708 const char *label,
const char *callerid,
enum ext_match_t action,
int *found,
int combined_find_spawn)
4711 struct ast_app *
app;
4712 char *substitute = NULL;
4723 e =
pbx_find_extension(c, con, &q, context, exten, priority, label, callerid, action);
4727 if (matching_action) {
4742 if ((!(tmp = strchr(e->
data,
'$'))) || (!strstr(tmp,
"${") && !strstr(tmp,
"$["))) {
4752 ast_log(
LOG_WARNING,
"No application '%s' for extension (%s, %s, %d)\n", e->
app, context, exten, priority);
4757 if (c->
exten != exten)
4763 #ifdef CHANNEL_TRACE
4764 ast_channel_trace_update(c);
4766 ast_debug(1,
"Launching '%s'\n", app->name);
4769 ast_verb(3,
"Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n",
4770 exten, context, priority,
4781 "Application: %s\r\n"
4791 if (matching_action) {
4805 if (!matching_action && !combined_find_spawn)
4809 if (!matching_action && !combined_find_spawn)
4813 if (!matching_action && !combined_find_spawn)
4814 ast_log(
LOG_NOTICE,
"No such priority %d in extension '%s' in context '%s'\n", priority, exten,
S_OR(context,
""));
4817 if (context && !combined_find_spawn)
4818 ast_log(
LOG_NOTICE,
"No such label '%s' in extension '%s' in context '%s'\n", label, exten,
S_OR(context,
""));
4824 return (matching_action) ? 0 : -1;
4881 while ((cur =
strsep(&rest,
"&"))) {
4893 if (!e || !hint_app) {
4922 if (e->
exten[0] ==
'_') {
4955 struct ast_state_cb *state_cb;
4969 while ((cur =
strsep(&parse,
"&"))) {
4970 if (!strcasecmp(cur, sc->
dev)) {
4987 sizeof(context_name));
4989 sizeof(exten_name));
5011 state_cb->
change_cb(context_name, exten_name, state, state_cb->
data);
5018 state_cb->
change_cb(context_name, exten_name, state, state_cb->
data);
5040 struct ast_state_cb *state_cb = doomed;
5052 struct ast_state_cb *state_cb;
5057 if (!context && !exten) {
5080 if (!context || !exten)
5093 if (e->
exten[0] ==
'_') {
5098 if (!e || e->
exten[0] ==
'_') {
5120 }
while (
id == -1 ||
id == 0);
5144 struct ast_state_cb *state_cb;
5159 struct ast_state_cb *p_cur;
5193 const struct ast_state_cb *cb = obj;
5212 struct ast_state_cb *state_cb;
5213 const char *context_name;
5214 const char *exten_name;
5228 state_cb->
change_cb((
char *) context_name, (
char *) exten_name,
5295 hint_new->
exten = e;
5296 if (strstr(e->
app,
"${") && e->
exten[0] ==
'_') {
5311 ast_debug(2,
"HINTS: Not re-adding existing hint %s: %s\n",
5317 ast_debug(2,
"HINTS: Adding hint %s: %s\n",
5463 if (pos < buflen - 1) {
5520 char dst_exten[256];
5527 dst_exten[pos] =
'\0';
5564 ast_debug(1,
"Extension %s, priority %d returned normally even though call was hung up\n",
5571 if (strchr(
"0123456789ABCDEF*#", res)) {
5572 ast_debug(1,
"Oooh, got something to jump out with ('%c')!\n", res);
5574 dst_exten[pos++] = digit = res;
5575 dst_exten[pos] =
'\0';
5587 pos = strlen(dst_exten);
5597 if (!strcmp(c->
exten,
"e")) {
5663 ast_log(
LOG_WARNING,
"Channel '%s' sent into invalid extension '%s' in context '%s', but no invalid handler\n",
5681 ast_verb(3,
"Auto fallthrough, channel '%s' status is '%s'\n", c->
name, status);
5682 if (!strcasecmp(status,
"CONGESTION"))
5684 else if (!strcasecmp(status,
"CHANUNAVAIL"))
5686 else if (!strcasecmp(status,
"BUSY"))
5692 if (
collect_digits(c, waittime, dst_exten,
sizeof(dst_exten), pos))
5706 ast_verb(3,
"Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->
context, c->
name);
5714 "Invalid extension '%s', but no rule 'i' or 'e' in context '%s'\n",
5730 "Timeout, but no rule 't' or 'e' in context '%s'\n",
5746 if (!found && !error) {
5794 #if defined(HAVE_SYSINFO)
5796 struct sysinfo sys_info;
5813 #if defined(HAVE_SYSINFO)
5815 if (!sysinfo(&sys_info)) {
5818 curfreemem = sys_info.freeram * sys_info.mem_unit;
5819 curfreemem /= 1024 * 1024;
6039 if (!strcmp(i->
name, include) &&
6040 (!registrar || !strcmp(i->
registrar, registrar))) {
6096 if (!strcmp(i->
name, sw) && !strcmp(i->
data, data) &&
6097 (!registrar || !strcmp(i->
registrar, registrar))) {
6127 matchcallerid, registrar, 0);
6154 char dummy_name[1024];
6159 if (!already_locked)
6163 ast_verb(3,
"Removing %s/%s/%d%s%s from trees, registrar=%s\n", con->
name, extension, priority, matchcallerid ?
"/" :
"", matchcallerid ? callerid :
"", registrar);
6165 #ifdef CONTEXT_DEBUG
6166 check_contexts(__FILE__, __LINE__);
6169 ex.
exten = dummy_name;
6175 if (priority == 0) {
6178 ast_log(
LOG_ERROR,
"Trying to delete the exten %s from context %s, but could not remove from the root_table\n", extension, con->
name);
6186 ast_log(
LOG_WARNING,
"Trying to delete an exten from a context, but the pattern tree node returned isn't a full extension\n");
6193 if (exten2->
label) {
6196 ast_log(
LOG_ERROR,
"Did not remove this priority label (%d/%s) from the peer_label_table of context %s, extension %s!\n", priority, exten2->
label, con->
name, exten2->
exten);
6201 ast_log(
LOG_ERROR,
"Did not remove this priority (%d) from the peer_table of context %s, extension %s!\n", priority, con->
name, exten2->
exten);
6202 if (exten2 == exten && exten2->
peer) {
6211 ast_log(
LOG_ERROR,
"Did not remove this exten (%s) from the context root_table (%s) (priority %d)\n", exten->
exten, con->
name, priority);
6221 ast_log(
LOG_ERROR,
"Could not find priority %d of exten %s in context %s!\n",
6228 extension, con->
name);
6238 for (exten = con->
root; exten; prev_exten = exten, exten = exten->
next) {
6239 if (!strcmp(exten->
exten, extension) &&
6240 (!registrar || !strcmp(exten->
registrar, registrar)) &&
6246 if (!already_locked)
6252 for (peer = exten, next_peer = exten->
peer ? exten->
peer : exten->
next;
6253 peer && !strcmp(peer->
exten, extension) &&
6254 (!callerid || (!matchcallerid && !peer->
matchcid) || (matchcallerid && peer->
matchcid && !strcmp(peer->
cidmatch, callerid))) ;
6255 peer = next_peer, next_peer = next_peer ? (next_peer->
peer ? next_peer->
peer : next_peer->
next) : NULL) {
6257 if ((priority == 0 || peer->
priority == priority) &&
6258 (!registrar || !strcmp(peer->
registrar, registrar) )) {
6262 if (!previous_peer) {
6277 con->
root = next_node;
6279 prev_exten->
next = next_node;
6292 previous_peer =
peer;
6295 if (!already_locked)
6297 return found ? 0 : -1;
6346 struct ast_app *tmp, *cur = NULL;
6355 if (!(res = strcasecmp(app, tmp->name))) {
6363 length =
sizeof(*tmp) + strlen(app) + 1;
6376 strcpy(tmp->name, app);
6419 if (strcasecmp(tmp->name, cur->name) < 0) {
6445 if (!strcasecmp(tmp->
name, sw->
name)) {
6471 char infotitle[64 +
AST_MAX_APP + 22], syntitle[40], destitle[40], stxtitle[40], argtitle[40];
6472 char seealsotitle[40];
6474 char *seealso = NULL;
6475 int syntax_size, synopsis_size, description_size, arguments_size, seealso_size;
6477 snprintf(info,
sizeof(info),
"\n -= Info about application '%s' =- \n\n", aa->name);
6493 if (!synopsis || !description || !arguments || !seealso) {
6494 goto return_cleanup;
6511 if (!synopsis || !description || !arguments || !seealso) {
6512 goto return_cleanup;
6524 goto return_cleanup;
6528 ast_cli(fd,
"%s%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n",
6529 infotitle, syntitle, synopsis, destitle, description,
6530 stxtitle, syntax, argtitle, arguments, seealsotitle, seealso);
6546 int app, no_registered_app = 1;
6550 e->
command =
"core show application";
6552 "Usage: core show application <application> [<application> [<application> [...]]]\n"
6553 " Describes a particular application.\n";
6571 for (app = 3; app < a->
argc; app++) {
6572 if (strcasecmp(aa->name, a->
argv[app])) {
6577 no_registered_app = 0;
6585 if (no_registered_app) {
6586 ast_cli(a->
fd,
"Your application(s) is (are) not registered\n");
6603 e->
command =
"core show hints";
6605 "Usage: core show hints\n"
6606 " List registered hints.\n"
6607 " Hint details are shown in four columns. In order from left to right, they are:\n"
6608 " 1. Hint extension URI.\n"
6609 " 2. Mapped device state identifiers.\n"
6610 " 3. Current extension state. The aggregate of mapped device states.\n"
6611 " 4. Watchers - number of subscriptions and other entities watching this hint.\n";
6618 ast_cli(a->
fd,
"There are no registered dialplan hints\n");
6622 ast_cli(a->
fd,
"\n -= Registered Asterisk Dial Plan Hints =-\n");
6633 ast_cli(a->
fd,
" %20s@%-20.20s: %-20.20s State:%-15.15s Watchers %2d\n",
6644 ast_cli(a->
fd,
"- %d hints registered\n", num);
6660 wordlen = strlen(word);
6689 int num = 0, extenlen;
6694 e->
command =
"core show hint";
6696 "Usage: core show hint <exten>\n"
6697 " List registered hint.\n"
6698 " Hint details are shown in four columns. In order from left to right, they are:\n"
6699 " 1. Hint extension URI.\n"
6700 " 2. Mapped device state identifiers.\n"
6701 " 3. Current extension state. The aggregate of mapped device states.\n"
6702 " 4. Watchers - number of subscriptions and other entities watching this hint.\n";
6713 ast_cli(a->
fd,
"There are no registered dialplan hints\n");
6717 extenlen = strlen(a->
argv[3]);
6728 ast_cli(a->
fd,
" %20s@%-20.20s: %-20.20s State:%-15.15s Watchers %2d\n",
6739 ast_cli(a->
fd,
"No hints matching extension %s\n", a->
argv[3]);
6741 ast_cli(a->
fd,
"%d hint%s matching extension %s\n", num, (num!=1 ?
"s":
""), a->
argv[3]);
6753 e->
command =
"core show switches";
6755 "Usage: core show switches\n"
6756 " List registered switches\n";
6766 ast_cli(a->
fd,
"There are no registered alternative switches\n");
6770 ast_cli(a->
fd,
"\n -= Registered Asterisk Alternative Switches =-\n");
6782 int like = 0, describing = 0;
6783 int total_match = 0;
6785 static const char *
const choices[] = {
"like",
"describing", NULL };
6789 e->
command =
"core show applications [like|describing]";
6791 "Usage: core show applications [{like|describing} <text>]\n"
6792 " List applications which are currently available.\n"
6793 " If 'like', <text> will be a substring of the app name\n"
6794 " If 'describing', <text> will be a substring of the description\n";
6803 ast_cli(a->
fd,
"There are no registered applications\n");
6809 if ((a->
argc == 5) && (!strcmp(a->
argv[3],
"like"))) {
6811 }
else if ((a->
argc > 4) && (!strcmp(a->
argv[3],
"describing"))) {
6816 if ((!like) && (!describing)) {
6817 ast_cli(a->
fd,
" -= Registered Asterisk Applications =-\n");
6819 ast_cli(a->
fd,
" -= Matching Asterisk Applications =-\n");
6830 }
else if (describing) {
6835 for (i = 4; i < a->
argc; i++) {
6851 if ((!like) && (!describing)) {
6852 ast_cli(a->
fd,
" -= %d Applications Registered =-\n",total_apps);
6854 ast_cli(a->
fd,
" -= %d Applications Matching =-\n",total_match);
6879 wordlen = strlen(word);
6909 snprintf(buf, buflen,
"hint: %s",
6912 snprintf(buf, buflen,
"%d. %s(%s)",
6932 char buf[1024],
buf2[1024];
6934 char buf[256], buf2[256];
6936 int context_info_printed = 0;
6953 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
6955 context_info_printed = 1;
6969 if (!context_info_printed) {
6972 ast_cli(fd,
"[ Included context '%s' created by '%s' ]\n",
6975 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
6978 context_info_printed = 1;
6990 ast_cli(fd,
" %-17s %-45s [%s]\n", buf, buf2,
7000 snprintf(buf,
sizeof(buf),
" [%s]", el);
7005 ast_cli(fd,
" %-17s %-45s [%s]\n", buf, buf2,
7021 for (x = 0; x < includecount; x++) {
7035 ast_cli(fd,
" Include => %-45s [%s]\n",
7045 snprintf(buf,
sizeof(buf),
"'%s'", ipname);
7046 snprintf(ignorepat,
sizeof(ignorepat),
"_%s.", ipname);
7048 ast_cli(fd,
" Ignore pattern => %-45s [%s]\n",
7053 struct ast_sw *sw = NULL;
7055 snprintf(buf,
sizeof(buf),
"'%s/%s'",
7058 ast_cli(fd,
" Alt. Switch => %-45s [%s]\n",
7066 if (context_info_printed)
7071 return (dpc->
total_exten == old_total_exten) ? -1 : res;
7079 ast_cli(fd,
"\n In-mem exten Trie for Fast Extension Pattern Matching:\n\n");
7081 ast_cli(fd,
"\n Explanation: Node Contents Format = <char(s) to match>:<pattern?>:<specif>:[matched extension]\n");
7082 ast_cli(fd,
" Where <char(s) to match> is a set of chars, any one of which should match the current character\n");
7083 ast_cli(fd,
" <pattern?>: Y if this a pattern match (eg. _XZN[5-7]), N otherwise\n");
7084 ast_cli(fd,
" <specif>: an assigned 'exactness' number for this matching char. The lower the number, the more exact the match\n");
7085 ast_cli(fd,
" [matched exten]: If all chars matched to this point, which extension this matches. In form: EXTEN:<exten string>\n");
7086 ast_cli(fd,
" In general, you match a trie node to a string character, from left to right. All possible matching chars\n");
7087 ast_cli(fd,
" are in a string vertically, separated by an unbroken string of '+' characters.\n\n");
7092 int context_info_printed = 0;
7107 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
7109 context_info_printed = 1;
7115 ast_cli(fd,
"\n No Pattern Trie present. Perhaps the context is empty...or there is trouble...\n\n");
7121 if (context_info_printed)
7126 return (dpc->
total_exten == old_total_exten) ? -1 : res;
7131 char *
exten = NULL, *context = NULL;
7140 "Usage: dialplan show [[exten@]context]\n"
7147 memset(&counters, 0,
sizeof(counters));
7154 if (strchr(a->
argv[2],
'@')) {
7156 exten =
strsep(&context,
"@");
7171 ast_cli(a->
fd,
"There is no existence of '%s' context\n", context);
7177 ast_cli(a->
fd,
"There is no existence of %s@%s extension\n",
7181 "There is no existence of '%s' extension in all contexts\n",
7186 ast_cli(a->
fd,
"-= %d %s (%d %s) in %d %s. =-\n",
7198 char *
exten = NULL, *context = NULL;
7205 e->
command =
"dialplan debug";
7207 "Usage: dialplan debug [context]\n"
7208 " Show dialplan context Trie(s). Usually only useful to folks debugging the deep internals of the fast pattern matcher\n";
7214 memset(&counters, 0,
sizeof(counters));
7222 if (strchr(a->
argv[2],
'@')) {
7224 exten =
strsep(&context,
"@");
7239 ast_cli(a->
fd,
"There is no existence of '%s' context\n", context);
7262 const char *actionidtext,
const char *context,
7274 ast_debug(3,
"manager_show_dialplan: Context: -%s- Extension: -%s-\n", context, exten);
7298 ast_debug(3,
"manager_show_dialplan: Failed to lock context\n");
7326 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
7350 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
7362 snprintf(ignorepat,
sizeof(ignorepat),
"_%s.", ipname);
7366 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
7372 struct ast_sw *sw = NULL;
7376 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
7388 ast_debug(3,
"manager_show_dialplan: Found nothing new\n");
7407 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
7411 memset(&counters, 0,
sizeof(counters));
7419 char errorbuf[BUFSIZ];
7421 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find context %s", context);
7426 char errorbuf[BUFSIZ];
7429 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find extension %s@%s", exten, context);
7431 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find extension %s in any context", exten);
7441 "EventList: Complete\r\n"
7443 "ListExtensions: %d\r\n"
7444 "ListPriorities: %d\r\n"
7445 "ListContexts: %d\r\n"
7461 e->
command =
"dialplan show globals";
7463 "Usage: dialplan show globals\n"
7464 " List current global dialplan variables and their values\n";
7476 ast_cli(a->
fd,
"\n -- %d variable(s)\n", i);
7485 int i, j,
exten, combined;
7489 e->
command =
"core show device2extenstate";
7491 "Usage: core show device2extenstate\n"
7492 " Lists device state to extension state combinations.\n";
7519 e->
command =
"dialplan show chanvar";
7521 "Usage: dialplan show chanvar <channel>\n"
7522 " List current channel variables and their values\n";
7551 e->
command =
"dialplan set global";
7553 "Usage: dialplan set global <name> <value>\n"
7554 " Set global dialplan variable <name> to <value>\n";
7564 ast_cli(a->
fd,
"\n -- Global variable '%s' set to '%s'\n", a->
argv[3], a->
argv[4]);
7572 const char *chan_name, *var_name, *var_value;
7576 e->
command =
"dialplan set chanvar";
7578 "Usage: dialplan set chanvar <channel> <varname> <value>\n"
7579 " Set channel variable <varname> to <value>\n";
7593 ast_cli(a->
fd,
"Channel '%s' not found\n", chan_name);
7601 ast_cli(a->
fd,
"\n -- Channel variable '%s' set to '%s' for '%s'\n", var_name, var_value, chan_name);
7612 e->
command =
"dialplan set extenpatternmatchnew true";
7614 "Usage: dialplan set extenpatternmatchnew true|false\n"
7615 " Use the NEW extension pattern matching algorithm, true or false.\n";
7627 ast_cli(a->
fd,
"\n -- Still using the NEW pattern match algorithm for extension names in the dialplan.\n");
7629 ast_cli(a->
fd,
"\n -- Switched to using the NEW pattern match algorithm for extension names in the dialplan.\n");
7640 e->
command =
"dialplan set extenpatternmatchnew false";
7642 "Usage: dialplan set extenpatternmatchnew true|false\n"
7643 " Use the NEW extension pattern matching algorithm, true or false.\n";
7655 ast_cli(a->
fd,
"\n -- Still using the OLD pattern match algorithm for extension names in the dialplan.\n");
7657 ast_cli(a->
fd,
"\n -- Switched to using the OLD pattern match algorithm for extension names in the dialplan.\n");
7673 AST_CLI_DEFINE(handle_show_device2extenstate,
"Show expected exten state from multiple device states"),
7689 struct ast_exten *eroot = NULL, *e = NULL;
7695 if (e->cached_app == app)
7696 e->cached_app = NULL;
7707 struct ast_app *tmp;
7711 if (!strcasecmp(app, tmp->name)) {
7714 ast_verb(2,
"Unregistered application '%s'\n", tmp->name);
7723 return tmp ? 0 : -1;
7730 int length =
sizeof(
struct ast_context) + strlen(name) + 1;
7757 local_contexts = extcontexts;
7768 strcpy(tmp->
name, name);
7776 ast_log(
LOG_ERROR,
"Danger! We failed to allocate a context for %s!\n", name);
7783 *local_contexts = tmp;
7787 ast_verb(3,
"Registered extension context '%s'; registrar: %s\n", tmp->
name, registrar);
7793 *local_contexts = tmp;
7794 ast_debug(1,
"Registered context '%s'(%p) in local table %p; registrar: %s\n", tmp->
name, tmp, exttable, registrar);
7795 ast_verb(3,
"Registered extension context '%s'; registrar: %s\n", tmp->
name, registrar);
7849 struct ast_exten *exten_item, *prio_item, *new_exten_item, *new_prio_item;
7852 int insert_count = 0;
7866 new_exten_item = NULL;
7873 if (new_exten_item) {
7876 new_prio_item = NULL;
7878 if (strcmp(prio_item->
registrar,registrar) == 0) {
7893 ast_log(
LOG_ERROR,
"Could not allocate a new context for %s in merge_and_delete! Danger!\n", context->
name);
7905 if (!res1 && new_exten_item && new_prio_item){
7906 ast_verb(3,
"Dropping old dialplan item %s/%s/%d [%s(%s)] (registrar=%s) due to conflict with new dialplan\n",
7924 if (!insert_count && !
new && (strcmp(context->
registrar, registrar) != 0 ||
7949 struct ast_state_cb *thiscb;
7952 struct timeval begintime;
7953 struct timeval writelocktime;
7954 struct timeval endlocktime;
7955 struct timeval enddeltime;
8003 +
sizeof(*saved_hint);
8051 if (exten && exten->
exten[0] ==
'_') {
8111 for (tmp = oldcontextslist; tmp; ) {
8122 ast_verb(3,
"Time to scan old dialplan and merge leftovers back into the new: %8.6f sec\n", ft);
8126 ast_verb(3,
"Time to restore hints and swap in new dialplan: %8.6f sec\n", ft);
8130 ast_verb(3,
"Time to delete the old dialplan: %8.6f sec\n", ft);
8134 ast_verb(3,
"Total time merge_contexts_delete: %8.6f sec\n", ft);
8159 static int lookup_name(
const char *s,
const char *
const names[],
int max)
8163 if (names && *s >
'9') {
8164 for (i = 0; names[i]; i++) {
8165 if (!strcasecmp(s, names[i])) {
8172 if (sscanf(s,
"%2d", &i) == 1 && i >= 1 && i <= max) {
8182 static unsigned get_range(
char *src,
int max,
const char *
const names[],
const char *msg)
8185 unsigned int mask = 0;
8190 return (1 << max) - 1;
8193 while ((part =
strsep(&src,
"&"))) {
8195 char *endpart = strchr(part,
'-');
8200 if ((start =
lookup_name(part, names, max)) < 0) {
8205 if ((end =
lookup_name(endpart, names, max)) < 0) {
8214 while (start != end) {
8215 mask |= (1 << start);
8216 if (++start >= max) {
8227 char *endpart, *part;
8231 int minute_start, minute_end;
8240 for (x = 0; x < 48; x++) {
8246 while ((part =
strsep(×,
"&"))) {
8247 if (!(endpart = strchr(part,
'-'))) {
8248 if (sscanf(part,
"%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
8252 i->
minmask[st_h * 2 + (st_m >= 30 ? 1 : 0)] |= (1 << (st_m % 30));
8257 while (*endpart && !isdigit(*endpart)) {
8264 if (sscanf(part,
"%2d:%2d", &st_h, &st_m) != 2 || st_h < 0 || st_h > 23 || st_m < 0 || st_m > 59) {
8268 if (sscanf(endpart,
"%2d:%2d", &endh, &endm) != 2 || endh < 0 || endh > 23 || endm < 0 || endm > 59) {
8272 minute_start = st_h * 60 + st_m;
8273 minute_end = endh * 60 + endm;
8275 for (x = minute_start; x != minute_end; x = (x + 1) % (24 * 60)) {
8276 i->
minmask[x / 30] |= (1 << (x % 30));
8279 i->
minmask[x / 30] |= (1 << (x % 30));
8317 int j, num_fields, last_sep = -1;
8330 for (j = 0, num_fields = 1; info[j] !=
'\0'; j++) {
8331 if (info[j] ==
',') {
8338 if (num_fields == 5) {
8421 length += 2 * (strlen(value) + 1);
8429 p = new_include->
stuff;
8430 new_include->
name = p;
8432 p += strlen(value) + 1;
8433 new_include->
rname = p;
8436 if ( (c = strchr(p,
',')) ) {
8440 new_include->
next = NULL;
8447 if (!strcasecmp(i->
name, new_include->
name)) {
8459 il->
next = new_include;
8502 length =
sizeof(
struct ast_sw);
8503 length += strlen(value) + 1;
8505 length += strlen(data);
8514 strcpy(new_sw->
name, value);
8515 p += strlen(value) + 1;
8518 strcpy(new_sw->
data, data);
8519 p += strlen(data) + 1;
8521 strcpy(new_sw->
data,
"");
8532 if (!strcasecmp(i->
name, new_sw->
name) && !strcasecmp(i->
data, new_sw->
data)) {
8574 if (!strcmp(ip->
pattern, ignorepat) &&
8575 (!registrar || (registrar == ip->
registrar))) {
8613 struct ast_ignorepat *ignorepat, *ignorepatc, *ignorepatl = NULL;
8617 length += strlen(value) + 1;
8626 pattern = (
char *) ignorepat->
pattern;
8627 strcpy(pattern, value);
8628 ignorepat->
next = NULL;
8631 for (ignorepatc = con->
ignorepats; ignorepatc; ignorepatc = ignorepatc->
next) {
8632 ignorepatl = ignorepatc;
8633 if (!strcasecmp(ignorepatc->
pattern, value)) {
8642 ignorepatl->
next = ignorepat;
8672 int priority,
const char *label,
const char *callerid,
8673 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar)
8681 application, data, datad, registrar, 1);
8692 int priority,
const char *label,
const char *callerid,
8693 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar)
8701 application, data, datad, registrar);
8719 if (priority > -1) {
8765 tmpvars.state = chan->
_state;
8774 if (!(tmpchan =
ast_channel_alloc(0, tmpvars.state, 0, 0, tmpvars.accountcode, tmpvars.exten, tmpvars.context, tmpvars.linkedid, tmpvars.amaflags,
"AsyncGoto/%s", tmpvars.name))) {
8782 tmpchan->
cdr = tmpvars.cdr;
8832 while (*src && (count < len - 1)) {
8835 }
else if (*src ==
']') {
8837 }
else if (*src ==
' ' && !insquares) {
8861 int repeated_label = 0;
8863 for (ep = NULL; e ; ep = e, e = e->
peer) {
8864 if (e->label && tmp->
label && e->priority != tmp->
priority && !strcmp(e->label, tmp->
label)) {
8865 if (strcmp(e->exten, tmp->
exten)) {
8867 "Extension '%s' priority %d in '%s', label '%s' already in use at aliased extension '%s' priority %d\n",
8871 "Extension '%s' priority %d in '%s', label '%s' already in use at priority %d\n",
8876 if (e->priority >= tmp->
priority) {
8881 if (repeated_label) {
8894 if (e->priority == tmp->
priority) {
8898 if (strcmp(e->exten, tmp->
exten)) {
8900 "Unable to register extension '%s' priority %d in '%s', already in use by aliased extension '%s'\n",
8904 "Unable to register extension '%s' priority %d in '%s', already in use\n",
8956 ast_log(
LOG_ERROR,
"Trying to delete an exten from a context, but the pattern tree node returned isn't an extension\n");
8983 ast_log(
LOG_ERROR,
"Trying to delete an exten from a context, but the pattern tree node returned isn't an extension\n");
9006 e->peer_label_table = 0;
9053 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
9054 const char *application,
void *data,
void (*datad)(
void *),
9058 application, data, datad, registrar, 1);
9069 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
9070 const char *application,
void *data,
void (*datad)(
void *),
9071 const char *
registrar,
int lock_context)
9085 char dummy_name[1024];
9088 ast_log(
LOG_ERROR,
"You have to be kidding-- add exten '' to context %s? Figure out a name and call me back. Action ignored.\n",
9094 if (priority ==
PRIORITY_HINT && strstr(application,
"${") && extension[0] !=
'_') {
9102 application = expand_buf;
9109 length += strlen(extension) + 1;
9110 length += strlen(application) + 1;
9112 length += strlen(label) + 1;
9114 length += strlen(callerid) + 1;
9130 p += strlen(label) + 1;
9133 p +=
ext_strncpy(p, extension, strlen(extension) + 1) + 1;
9139 p +=
ext_strncpy(p, callerid, strlen(callerid) + 1) + 1;
9146 strcpy(p, application);
9159 dummy_exten.
exten = dummy_name;
9170 for (e = con->
root; e; el = e, e = e->
next) {
9185 if (e && res == 0) {
9255 ast_debug(1,
"Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",
9258 ast_debug(1,
"Added extension '%s' priority %d to %s (%p)\n",
9264 ast_verb(3,
"Added extension '%s' priority %d (CID match '%s') to %s\n",
9267 ast_verb(3,
"Added extension '%s' priority %d to %s\n",
9292 struct ast_app *
app;
9375 int ast_pbx_outgoing_exten(
const char *
type,
format_t format,
void *data,
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 **channel)
9379 int res = -1, cdr_res = -1;
9403 if (synchronous > 1) {
9427 ast_verb(4,
"Channel %s was never answered.\n", chan->
name);
9451 goto outgoing_exten_cleanup;
9460 char failed_reason[4] =
"";
9465 snprintf(failed_reason,
sizeof(failed_reason),
"%d", *reason);
9480 goto outgoing_exten_cleanup;
9491 goto outgoing_exten_cleanup;
9509 goto outgoing_exten_cleanup;
9513 outgoing_exten_cleanup:
9531 struct ast_app *
app;
9544 int ast_pbx_outgoing_app(
const char *
type,
format_t format,
void *data,
int timeout,
const char *app,
const char *appdata,
int *reason,
int synchronous,
const char *
cid_num,
const char *
cid_name,
struct ast_variable *vars,
const char *account,
struct ast_channel **locked_channel)
9548 int res = -1, cdr_res = -1;
9551 memset(&oh, 0,
sizeof(oh));
9556 *locked_channel = NULL;
9559 goto outgoing_app_cleanup;
9580 if (synchronous > 1) {
9597 *locked_channel = chan;
9602 ast_verb(4,
"Channel %s was never answered.\n", chan->
name);
9619 goto outgoing_app_cleanup;
9628 goto outgoing_app_cleanup;
9634 goto outgoing_app_cleanup;
9654 goto outgoing_app_cleanup;
9657 *locked_channel =
chan;
9661 outgoing_app_cleanup:
9678 for (tmpi = tmp->
includes; tmpi; ) {
9701 for (e = tmp->
root; e;) {
9702 for (en = e->
peer; en;) {
9721 struct ast_exten *exten_item, *prio_item;
9723 for (tmp = list; tmp; ) {
9731 for (; tmp; tmpl = tmp, tmp = tmp->
next) {
9732 ast_debug(1,
"check ctx %s %s\n", tmp->name, tmp->registrar);
9733 if ( !strcasecmp(tmp->name, con->
name) ) {
9749 struct ast_sw *sw = NULL;
9754 if (!strcmp(ip->
registrar, registrar)) {
9768 for (i = tmp->
includes; i; i = ni) {
9770 if (strcmp(i->
registrar, registrar) == 0) {
9788 if (strcmp(sw->
registrar,registrar) == 0) {
9798 int end_traversal = 1;
9806 ast_verb(3,
"Remove %s/%s/%d, registrar=%s; con=%s(%p); con->root=%p\n",
9822 if (end_traversal) {
9871 tmp = con ? NULL :
next;
9889 if (
ast_strlen_zero(data) || (sscanf(data,
"%30lg", &waitsec) != 1) || (waitsec < 0))
9892 waittime = waitsec * 1000.0;
9998 const char *options =
data;
10071 cause = strtol((
const char *) data, &endptr, 10);
10072 if (cause != 0 || (data != endptr)) {
10094 char *remainder, result[30], timezone[80];
10103 if (!(remainder =
ast_strptime(value,
"%Y/%m/%d %H:%M:%S", &tm))) {
10106 sscanf(remainder,
"%79s", timezone);
10109 snprintf(result,
sizeof(result),
"%ld", (
long) tv.tv_sec);
10115 .
name =
"TESTTIME",
10124 char *s, *ts, *branch1, *branch2, *branch;
10136 ast_log(
LOG_WARNING,
"GotoIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?'labeliftrue':'labeliffalse'\n");
10144 tv.tv_sec = timesecs;
10145 }
else if (ctime) {
10154 branch1 =
strsep(&ts,
":");
10155 branch2 =
strsep(&ts,
"");
10166 ast_debug(1,
"Not taking any branch\n");
10180 struct ast_app *
app;
10181 static const char *
const usage =
"ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
10190 s =
strsep(&appname,
"?");
10209 if ((s = strchr(appname,
'('))) {
10212 if ((e = strrchr(s,
')')))
10248 char *opts[1] = { NULL };
10265 ast_log(
LOG_WARNING,
"The 'm' option has been specified for WaitExten without a class.\n");
10281 }
else if (chan->
pbx) {
10294 ast_verb(3,
"Timeout on %s, continuing...\n", chan->
name);
10297 ast_verb(3,
"Timeout on %s, going to 't'\n", chan->
name);
10325 char *
parse, exten[2] =
"";
10356 if (
args.options) {
10357 if (!strcasecmp(
args.options,
"skip"))
10359 else if (!strcasecmp(
args.options,
"noanswer"))
10380 while (!res && (front =
strsep(&back,
"&")) ) {
10417 && (exten[0] = res)
10422 snprintf(chan->
exten,
sizeof(chan->
exten),
"%c", res);
10478 const char *ret = NULL;
10490 for (i = 0; i < 2; i++) {
10518 if (name[strlen(name)-1] ==
')') {
10536 ast_verb(2,
"Setting global variable '%s' to '%s'\n", name, value);
10550 const char *nametail =
name;
10552 if (name[strlen(name) - 1] ==
')') {
10567 if (*nametail ==
'_') {
10569 if (*nametail ==
'_')
10574 if (strcmp(
ast_var_name(newvariable), nametail) == 0) {
10585 ast_verb(2,
"Setting global variable '%s' to '%s'\n", name, value);
10591 "Uniqueid: %s\r\n",
10592 chan ? chan->
name :
"none", name, value,
10617 name =
strsep(&mydata,
"=");
10624 if (strchr(name,
' ')) {
10625 ast_log(
LOG_WARNING,
"Please avoid unnecessary spaces on variables as it may lead to unexpected results ('%s' set to '%s').\n", name, mydata);
10653 for (x = 0; x <
args.argc; x++) {
10655 if (pair.argc == 2) {
10657 if (strchr(pair.name,
' '))
10658 ast_log(
LOG_WARNING,
"Please avoid unnecessary spaces on variables as it may lead to unexpected results ('%s' set to '%s').\n", pair.name, pair.value);
10659 }
else if (!chan) {
10675 static int deprecation_warning = 0;
10682 if (!deprecation_warning) {
10683 ast_log(
LOG_WARNING,
"ImportVar is deprecated. Please use Set(varname=${IMPORT(channel,variable)}) instead.\n");
10684 deprecation_warning = 1;
10688 name =
strsep(&value,
"=");
10689 channel =
strsep(&value,
",");
10690 if (channel && value && name) {
10694 sprintf(s,
"${%s}", value);
10724 }
else if (sscanf(condition,
"%30d", &res) == 1) {
10733 char *condition, *branch1, *branch2, *branch;
10742 condition =
strsep(&stringp,
"?");
10743 branch1 =
strsep(&stringp,
":");
10744 branch2 =
strsep(&stringp,
"");
10748 ast_debug(1,
"Not taking any branch\n");
10767 options =
strsep(&number,
",");
10769 if ( strcasecmp(options,
"f") && strcasecmp(options,
"m") &&
10770 strcasecmp(options,
"c") && strcasecmp(options,
"n") ) {
10777 ast_log(
LOG_WARNING,
"We were unable to say the number %s, is it too large?\n", tmp);
10836 ast_log(
LOG_WARNING,
"SayDate escape digits must be a subset from '0123456789*#'\n");
10840 if (sscanf(
args.datestr,
"%d", &unixdate) != 1) {
10847 if (isdigit(res) || (res ==
'*') || (res ==
'#')) {
10848 snprintf(charascii, 2,
"%c", res);
10883 ast_log(
LOG_WARNING,
"SayTime escape digits must be a subset from '0123456789*#'\n");
10887 if (sscanf(
args.timestr,
"%d", &secs) != 1) {
10888 ast_log(
LOG_WARNING,
"Firt argument to SayTime must be numeric (time in seconds)\n");
10894 if (isdigit(res) || (res ==
'*') || (res ==
'#')) {
10895 snprintf(charascii, 2,
"%c", res);
10907 const char *device;
10916 if (!(sc =
ast_calloc(1,
sizeof(*sc) + strlen(device) + 1)))
10918 strcpy(sc->
dev, device);
10980 if (device_state_tps) {
10982 device_state_tps = NULL;
11003 ast_verb(1,
"Asterisk PBX Core Initializing\n");
11008 ast_verb(1,
"Registering builtin applications:\n");
11075 return con ? con->
name : NULL;
11080 return exten ? exten->
parent : NULL;
11085 return exten ? exten->
exten : NULL;
11090 return exten ? exten->
label : NULL;
11095 return inc ? inc->
name : NULL;
11100 return ip ? ip->
pattern : NULL;
11105 return exten ? exten->
priority : -1;
11143 return e ? e->
app : NULL;
11148 return e ? e->
data : NULL;
11153 return sw ? sw->
name : NULL;
11158 return sw ? sw->
data : NULL;
11183 return con ? con->
root : NULL;
11185 return exten->
next;
11200 return priority ? priority->
peer :
exten;
11207 return con ? con->
includes : NULL;
11247 if (context == NULL)
11250 exten = chan->
exten;
11255 return goto_func(chan, context, exten, priority);
11279 ast_log(
LOG_WARNING,
"Goto requires an argument ([[context,]extension,]priority)\n");
11283 context =
strsep(&stringp,
",");
11284 exten =
strsep(&stringp,
",");
11285 pri =
strsep(&stringp,
",");
11298 }
else if (*pri ==
'-') {
11302 if (sscanf(pri,
"%30d", &ipri) != 1) {
11304 exten ? exten : chan->
exten, pri,
11315 ipri = chan->
priority + (ipri * mode);
11338 struct ast_app *app = NULL;
11341 size_t wordlen = strlen(word);
11345 if (!strncasecmp(word, app->name, wordlen) && ++which > state) {
11357 const struct ast_hint *hint = obj;
11377 const struct ast_hint *hint = obj;
11385 const struct ast_state_cb *state_cb = obj;
int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags)
Set AMA flags for channel.
struct ast_hashtab * root_table
struct ast_include * ast_walk_context_includes(struct ast_context *con, struct ast_include *inc)
static void manager_dpsendack(struct mansession *s, const struct message *m)
Send ack once.
ast_include: include= support in extensions.conf
int ast_cdr_disposition(struct ast_cdr *cdr, int cause)
Save the result of the call based on the AST_CAUSE_*.
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
static struct ast_threadstorage extensionstate_buf
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
union ast_frame_subclass subclass
struct ast_app * cached_app
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
int ast_unlock_context(struct ast_context *con)
enum sip_cc_notify_state state
Options for ast_pbx_run()
int( ast_switch_f)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
All switch functions have the same interface, so define a type for them.
static char accountcode[AST_MAX_ACCOUNT_CODE]
const ast_string_field description
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
#define ast_rwlock_rdlock(a)
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
#define ast_channel_lock(chan)
int ast_func_read(struct ast_channel *chan, const char *function, char *workspace, size_t len)
executes a read operation on a function
void __ast_context_destroy(struct ast_context *list, struct ast_hashtab *contexttab, struct ast_context *con, const char *registrar)
int64_t ast_mark(int, int start1_stop0)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
int ast_check_timing2(const struct ast_timing *i, const struct timeval tv)
Evaluate a pre-constructed bitmap as to whether a particular time falls within the range specified...
struct ast_include * includes
#define AST_CLI_DEFINE(fn, txt,...)
int ast_context_add_include2(struct ast_context *con, const char *include, const char *registrar)
Add a context include.
ast_device_state
Device States.
void ast_cdr_failed(struct ast_cdr *cdr)
Fail a call.
char * str
Subscriber phone number (Malloced)
int ast_get_extension_priority(struct ast_exten *exten)
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Asterisk locking-related definitions:
ast_extension_states
Extension states.
void astman_append(struct mansession *s, const char *fmt,...)
Asterisk main include file. File version handling, generic pbx functions.
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
#define ao2_link(arg1, arg2)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
void * ast_hashtab_lookup(struct ast_hashtab *tab, const void *obj)
Lookup this object in the hash table.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
struct ast_include * next
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove a context include.
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
The data tree to be returned by the callbacks and managed by functions local to this file...
static void __ast_internal_context_destroy(struct ast_context *con)
static int __ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, int async)
int ast_active_calls(void)
Retrieve the number of active calls.
struct ast_party_caller caller
Channel Caller ID information.
struct ast_tone_zone * zone
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
void pbx_builtin_clear_globals(void)
char * strsep(char **str, const char *delims)
const char * ast_get_extension_registrar(struct ast_exten *e)
struct ast_app * pbx_findapp(const char *app)
Look up an application.
static void unreference_cached_app(struct ast_app *app)
static int ast_add_hint(struct ast_exten *e)
Add hint to hint list, check initial extension state.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
const ast_string_field uniqueid
static char * handle_debug_dialplan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Send ack once.
static int ast_change_hint(struct ast_exten *oe, struct ast_exten *ne)
Change hint for an extension.
static void exception_store_free(void *data)
struct ast_include * includes
struct ast_channel * chan
char context[AST_MAX_CONTEXT]
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
Weird function made for call transfers.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
static char * handle_show_applications(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const ast_string_field synopsis
struct ast_channel * parent_channel
#define ast_pthread_create_detached(a, b, c, d)
void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *flags)
Reset the detail record, optionally posting it first.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
static int ast_extension_state2(struct ast_exten *e)
Check state of extension by using hints.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
static int pbx_builtin_gotoif(struct ast_channel *, const char *)
#define ast_channel_unref(c)
Decrease channel reference count.
static int ast_pbx_outgoing_cdr_failed(void)
Function to post an empty cdr after a spool call fails.
static int pbx_builtin_saydigits(struct ast_channel *, const char *)
int __ast_custom_function_register_escalating(struct ast_custom_function *acf, enum ast_custom_function_escalation escalation, struct ast_module *mod)
Register a custom function which requires escalated privileges.
#define ast_set2_flag(p, value, flag)
#define ast_test_flag(p, flag)
static char * handle_show_function(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
Answer a channel, with a selectable delay before returning.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
#define STATUS_NO_PRIORITY
void ast_cdr_end(struct ast_cdr *cdr)
End a call.
static int pbx_builtin_hangup(struct ast_channel *, const char *)
static void decrease_call_count(void)
#define ast_rwlock_destroy(rwlock)
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
Time-related functions and macros.
const char * ast_var_value(const struct ast_var_t *var)
int ast_context_lockmacro(const char *macrocontext)
locks the macrolock in the given given context
static int hint_cmp(void *obj, void *arg, int flags)
#define BACKGROUND_NOANSWER
static struct ast_hashtab * contexts_table
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a registered state change callback by ID.
static struct match_char * add_exten_to_pattern_tree(struct ast_context *con, struct ast_exten *e1, int findonly)
const ast_string_field syntax
static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *callerid, const char *label, enum ext_match_t action)
struct ast_var_t * ast_var_assign(const char *name, const char *value)
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
int ast_taskprocessor_push(struct ast_taskprocessor *tps, int(*task_exe)(void *datap), void *datap)
Push a task into the specified taskprocessor queue and signal the taskprocessor thread.
static char * handle_show_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI support for listing chanvar's variables in a parseable way.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
char context[AST_MAX_CONTEXT]
int(* ast_state_cb_type)(char *context, char *id, enum ast_extension_states state, void *data)
Typedef for devicestate and hint callbacks.
const char * ast_var_name(const struct ast_var_t *var)
#define ao2_iterator_next(arg1)
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit)
Common routine to parse time lengths, with optional time unit specifier.
#define ast_set_flag(p, flag)
static char * substring(const char *value, int offset, int length, char *workspace, size_t workspace_len)
takes a substring. It is ok to call with value == workspace.
static int pbx_builtin_progress(struct ast_channel *, const char *)
static int pbx_builtin_gotoiftime(struct ast_channel *, const char *)
struct ast_channel * __ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
descriptor for a cli entry.
int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event_type, const char *userdefevname, const char *extra, struct ast_channel *peer2)
Report a channel event.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
#define BACKGROUND_PLAYBACK
static int live_dangerously
Set to true (non-zero) to globally allow all dangerous dialplan functions to run. ...
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int ast_extension_cmp(const char *a, const char *b)
Determine if one extension should match before another.
void __ast_module_user_remove(struct ast_module *, struct ast_module_user *)
const char * ast_get_extension_app(struct ast_exten *e)
struct ast_ignorepat * ignorepats
int ast_add_extension2(struct ast_context *con, 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 an extension to an extension context, this time with an ast_context *.
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
static void context_merge_incls_swits_igps_other_registrars(struct ast_context *new, struct ast_context *old, const char *registrar)
#define ao2_callback(c, flags, cb_fn, arg)
struct ast_taskprocessor * ast_taskprocessor_get(const char *name, enum ast_tps_options create)
Get a reference to a taskprocessor with the specified name and create the taskprocessor if necessary...
struct ast_exten * exten
Hint extension.
ast_custom_function_escalation
Description of the ways in which a function may escalate privileges.
#define VERBOSITY_ATLEAST(level)
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.
ast_state_cb: An extension state notify register item
#define ast_opt_end_cdr_before_h_exten
char * ast_complete_applications(const char *line, const char *word, int state)
Command completion for the list of installed applications.
static int autofallthrough
static void destroy_hint(void *obj)
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
char * ast_xmldoc_build_description(const char *type, const char *name, const char *module)
Generate description documentation from XML.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
Set account code, will generate AMI event.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
char exten[AST_MAX_EXTENSION]
This entries are for multiple registers.
static ast_rwlock_t globalslock
void * ast_hashtab_next(struct ast_hashtab_iter *it)
Gets the next object in the list, advances iter one step returns null on end of traversal.
static int pbx_builtin_goto(struct ast_channel *, const char *)
Structure for variables, used for configurations and for channel variables.
static char * handle_show_hints(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handle_show_hints: CLI support for listing registered dial plan hints
static char * handle_show_switches(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handle_show_switches: CLI support for listing registered dial plan switches
static int thread_inhibits_escalations(void)
Indicates whether the current thread inhibits the execution of dangerous functions.
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
static int testtime_write(struct ast_channel *chan, const char *cmd, char *var, const char *value)
struct ast_cdr * ast_cdr_dup(struct ast_cdr *cdr)
Duplicate a record.
#define NEW_MATCHER_RECURSE
static int hashtab_compare_extens(const void *ha_a, const void *ah_b)
static int pbx_builtin_sayphonetic(struct ast_channel *, const char *)
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
int pbx_checkcondition(const char *condition)
Evaluate a condition.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
static struct ast_threadstorage thread_inhibit_escalations_tl
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int hint_hash(const void *obj, const int flags)
int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
says digits of a string
const ast_string_field desc
#define INC_DST_OVERFLOW_CHECK
static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, struct ast_pbx_args *args)
#define ast_compat_app_set
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
Structure for a data store type.
Configuration File Parser.
const ast_string_field exten
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
void ast_unregister_switch(struct ast_switch *sw)
Unregister an alternative switch.
const ast_string_field arguments
#define STATUS_NO_EXTENSION
void * ast_get_extension_app_data(struct ast_exten *e)
static int is_write_allowed(struct ast_custom_function *acfptr)
Determines whether execution of a custom function's write function is allowed.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
int ast_rdlock_contexts(void)
Read locks the context list.
static struct ast_cli_entry pbx_cli[]
static int pbx_builtin_proceeding(struct ast_channel *, const char *)
struct ast_hashtab_iter * ast_hashtab_start_traversal(struct ast_hashtab *tab)
Gives an iterator to hastable.
static struct ast_threadstorage buf2
static struct match_char * add_pattern_node(struct ast_context *con, struct match_char *current, const struct pattern_node *pattern, int is_pattern, int already, struct match_char **nextcharptr)
const char * ast_get_extension_label(struct ast_exten *e)
static int copy(char *infile, char *outfile)
Utility function to copy a file.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
struct match_char * alt_char
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
struct ast_str * ast_str_create(size_t init_len)
Create a malloc'ed dynamic length string.
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define ast_mutex_lock(a)
int ast_wrlock_contexts(void)
Write locks the context list.
static ast_mutex_t context_merge_lock
Lock to hold off restructuring of hints by ast_merge_contexts_and_delete.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
#define ast_str_alloca(init_len)
int ast_context_remove_extension_callerid2(struct ast_context *con, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar, int already_locked)
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.
int ast_context_remove_include2(struct ast_context *con, const char *include, const char *registrar)
Removes an include by an ast_context structure.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static int hashtab_compare_exten_labels(const void *ah_a, const void *ah_b)
static int pbx_builtin_setamaflags(struct ast_channel *, const char *)
static int pbx_builtin_importvar(struct ast_channel *, const char *)
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, without removing any previously set value...
char * incstack[AST_PBX_MAX_STACK]
static unsigned int hashtab_hash_labels(const void *obj)
const char * ast_get_context_registrar(struct ast_context *c)
char * ast_xmldoc_build_synopsis(const char *type, const char *name, const char *module)
Generate synopsis documentation from XML.
void ast_cli(int fd, const char *fmt,...)
int ast_str_get_hint(struct ast_str **hint, ssize_t hintsize, struct ast_str **name, ssize_t namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
const ast_string_field linkedid
#define AST_DATA_ENTRY(__path, __handler)
#define ast_rwlock_unlock(a)
struct ast_hashtab * peer_table
#define EVENT_FLAG_DIALPLAN
int ast_unregister_application(const char *app)
Unregister an application.
int ast_context_add_switch2(struct ast_context *con, const char *sw, const char *data, int eval, const char *registrar)
Adds a switch (first param is a ast_context)
static struct ao2_container * hints
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string, int async)
void ast_free_ptr(void *ptr)
static char cid_num[AST_MAX_EXTENSION]
char * ast_xmldoc_build_arguments(const char *type, const char *name, const char *module)
Generate the [arguments] tag based on type of node ('application', 'function' or 'agi') and name...
struct ast_channel * chan
static int acf_retrieve_docs(struct ast_custom_function *acf)
void ast_var_delete(struct ast_var_t *var)
ast_doc_src
From where the documentation come from, this structure is useful for use it inside application/functi...
#define ast_verb(level,...)
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
static int pbx_builtin_execiftime(struct ast_channel *, const char *)
ast_state_cb_type change_cb
static int ast_add_extension2_lockopt(struct ast_context *con, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar, int lock_context)
Same as ast_add_extension2() but controls the context locking.
static char * handle_set_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_hashtab_resize_java(struct ast_hashtab *tab)
Determines if a table resize should occur using the Java algorithm (if the table load factor is 75% o...
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.
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
struct ast_variable * vars
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
static void pbx_destroy(struct ast_pbx *p)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg)
Get the aggregate device state result.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
static char * handle_show_hint(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
handle_show_hint: CLI support for listing registered dial plan hint
static struct ast_exten * trie_find_next_match(struct match_char *node)
static struct ast_datastore_info exception_store_info
int args
This gets set in ast_cli_register()
static struct cfextension_states extension_states[]
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
static struct ast_app_option waitexten_opts[128]
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
static struct ast_data_handler hints_data_provider
static int show_dialplan_helper(int fd, const char *context, const char *exten, struct dialplan_counters *dpc, struct ast_include *rinclude, int includecount, const char *includes[])
const char * ast_config_AST_SYSTEM_NAME
static char * handle_show_dialplan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar)
Remove a switch.
const char * ast_get_switch_name(struct ast_sw *sw)
#define AST_TERM_MAX_ESCAPE_CHARS
Maximum number of characters needed for a color escape sequence, plus a null char.
struct ast_context * next
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
struct ast_party_id id
Caller party ID.
const char * ast_get_include_name(struct ast_include *include)
static int lookup_name(const char *s, const char *const names[], int max)
Helper for get_range. return the index of the matching entry, starting from 1. If names is not suppli...
const char * ast_get_include_registrar(struct ast_include *i)
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
static int raise_exception(struct ast_channel *chan, const char *reason, int priority)
#define ast_opt_dont_warn
SAY_EXTERN int(* ast_say_date)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_date)
static int statecbs_cmp(void *obj, void *arg, int flags)
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_DATA_HANDLER_VERSION
The Data API structures version.
static int pbx_builtin_wait(struct ast_channel *, const char *)
ast_sw: Switch statement in extensions.conf
static int ext_cmp(const char *left, const char *right)
General Asterisk PBX channel definitions.
#define ast_data_register_multiple_core(data_entries, entries)
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *priority)
static int increase_call_count(const struct ast_channel *c)
Increase call count for channel.
int pbx_builtin_raise_exception(struct ast_channel *chan, const char *data)
static ast_mutex_t maxcalllock
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Asterisk file paths, configured in asterisk.conf.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
int ast_str_make_space(struct ast_str **buf, size_t new_len)
static int ext_cmp_exten_strlen(const char *str)
static void create_match_char_tree(struct ast_context *con)
const ast_string_field reason
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
int ast_context_add_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Add an ignorepat.
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
static int ext_cmp_pattern_pos(const char **p, unsigned char *bitwise)
helper functions to sort extension patterns in the desired way, so that more specific patterns appear...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char * ast_str_append_substr(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
Append a non-NULL terminated substring to the end of a dynamic string.
struct sla_ringing_trunk * last
Data structure associated with a custom dialplan function.
static struct ast_exten * ast_hint_extension(struct ast_channel *c, const char *context, const char *exten)
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
struct ast_data * ast_data_add_node(struct ast_data *root, const char *childname)
Add a container child.
#define HASH_EXTENHINT_SIZE
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
#define AST_MAX_EXTENSION
int pbx_set_extenpatternmatchnew(int newval)
#define AST_RWLIST_TRAVERSE
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define AST_CAUSE_NORMAL_CLEARING
static struct match_char * already_in_tree(struct match_char *current, char *pat, int is_pattern)
const char * ast_get_ignorepat_registrar(struct ast_ignorepat *ip)
static int pbx_builtin_background(struct ast_channel *, const char *)
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_data_unregister(path)
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
static int is_read_allowed(struct ast_custom_function *acfptr)
Determines whether execution of a custom function's read function is allowed.
#define ao2_ref(o, delta)
static struct ast_event_sub * device_state_sub
Subscription for device state change events.
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
static const char *const months[]
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
Insert without checking.
const char * ast_get_switch_data(struct ast_sw *sw)
struct ast_exten * canmatch_exten
static int ext_cmp_pattern(const char *left, const char *right)
static struct ast_custom_function testtime_function
#define AST_RWLIST_REMOVE_CURRENT
static struct ast_threadstorage switch_data
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
static int manager_show_dialplan_helper(struct mansession *s, const struct message *m, const char *actionidtext, const char *context, const char *exten, struct dialplan_counters *dpc, struct ast_include *rinclude)
Show dialplan extensions XXX this function is similar but not exactly the same as the CLI's show dial...
static void print_ext(struct ast_exten *e, char *buf, int buflen)
helper function to print an extension
int ast_extension_state_add_destroy(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Registers a state change callback with destructor.
A set of macros to manage forward-linked lists.
static int show_debug_helper(int fd, const char *context, const char *exten, struct dialplan_counters *dpc, struct ast_include *rinclude, int includecount, const char *includes[])
struct ast_ignorepat * ignorepats
void ast_str_substitute_variables_full(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used)
static void cli_match_char_tree(struct match_char *node, char *prefix, int fd)
#define AST_RWLIST_INSERT_BEFORE_CURRENT
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
static int pbx_builtin_saynumber(struct ast_channel *, const char *)
static void wait_for_hangup(struct ast_channel *chan, const void *data)
struct ast_ignorepat * ast_walk_context_ignorepats(struct ast_context *con, struct ast_ignorepat *ip)
int pbx_set_autofallthrough(int newval)
static ast_mutex_t conlock
Lock for the ast_context list.
struct ast_hashtab * ast_hashtab_create(int initial_buckets, int(*compare)(const void *a, const void *b), int(*resize)(struct ast_hashtab *), int(*newsize)(struct ast_hashtab *tab), unsigned int(*hash)(const void *obj), int do_locking)
Create the hashtable list.
const char * ast_get_extension_cidmatch(struct ast_exten *e)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_context_add_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
struct ast_context * ast_walk_contexts(struct ast_context *con)
struct ast_hashtab * peer_label_table
const char * ast_get_context_name(struct ast_context *con)
static void unload_pbx(void)
void ast_hashtab_end_traversal(struct ast_hashtab_iter *it)
end the traversal, free the iterator, unlock if necc.
Core PBX routines and definitions.
char * ast_strptime(const char *s, const char *format, struct ast_tm *tm)
Special version of strptime(3) which places the answer in the common structure ast_tm. Also, unlike strptime(3), ast_strptime() initializes its memory prior to use.
int ast_cdr_update(struct ast_channel *chan)
Update CDR on a channel.
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
The list of nodes with their search requirement.
static int pbx_builtin_saycharacters(struct ast_channel *, const char *)
struct ast_module_user * __ast_module_user_add(struct ast_module *, struct ast_channel *)
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
void ast_devstate_aggregate_add(struct ast_devstate_aggregate *agg, enum ast_device_state state)
Add a device state to the aggregate device state.
const char * ast_devstate_str(enum ast_device_state devstate) attribute_pure
Convert device state to text string that is easier to parse.
struct ast_party_dialed dialed
Dialed/Called information.
static void pbx_shutdown(void)
int ast_add_profile(const char *, uint64_t scale)
support for event profiling
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_PBX_INCOMPLETE
static int pbx_builtin_busy(struct ast_channel *, const char *)
#define ast_strdupa(s)
duplicate a string in memory from the stack
struct ast_custom_function * ast_custom_function_find(const char *name)
static unsigned int hashtab_hash_priority(const void *obj)
Responsible for call detail data.
char context_name[AST_MAX_CONTEXT]
static void context_merge(struct ast_context **extcontexts, struct ast_hashtab *exttable, struct ast_context *context, const char *registrar)
void ast_cdr_start(struct ast_cdr *cdr)
Start a call.
int ast_get_switch_eval(struct ast_sw *sw)
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
static void * pbx_thread(void *data)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
#define EVENT_FLAG_CONFIG
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
void ast_str_substitute_variables_varshead(struct ast_str **buf, ssize_t maxlen, struct varshead *headp, const char *templ)
static int pbx_builtin_incomplete(struct ast_channel *, const char *)
const ast_string_field syntax
void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp)
Retrieve the value of a builtin variable or variable from the channel variable stack.
void * ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj)
Looks up the object, removes the corresponding bucket.
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
Merge the temporary contexts into a global contexts list and delete from the global list the ones tha...
void ast_data_remove_node(struct ast_data *root, struct ast_data *child)
Remove a node that was added using ast_data_add_.
const char * ast_get_switch_registrar(struct ast_sw *sw)
static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
int ast_check_timing(const struct ast_timing *i)
Evaluate a pre-constructed bitmap as to whether the current time falls within the range specified...
void(* ast_state_cb_destroy_type)(int id, void *data)
Typedef for devicestate and hint callback removal indication callback.
static int compare_char(const void *a, const void *b)
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
ast_ignorepat: Ignore patterns in dial plan
int ast_unlock_contexts(void)
Unlocks contexts.
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
#define STATUS_NO_CONTEXT
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ani2
Automatic Number Identification 2 (Info Digits)
static int acf_exception_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
void ast_cdr_detach(struct ast_cdr *cdr)
Detaches the detail record for posting (and freeing) either now or at a later time in bulk with other...
enum ast_channel_state _state
ast_state_cb_destroy_type destroy_cb
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Structure for dial plan hints.
#define NEW_MATCHER_CHK_MATCH
const ast_string_field name
int pbx_builtin_setvar_multiple(struct ast_channel *chan, const char *data)
Parse and set multiple channel variables, where the pairs are separated by the ',' character...
struct sla_ringing_trunk * first
#define AST_PBX_MAX_STACK
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...
int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcid, const char *registrar)
#define ao2_alloc(data_size, destructor_fn)
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
const char * ast_get_extension_name(struct ast_exten *exten)
int ast_wrlock_context(struct ast_context *con)
Write locks a given context.
struct ast_context * next
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
static const char *const days[]
static struct ast_data_entry pbx_data_providers[]
static int extenpatternmatchnew
an iterator for traversing the buckets
static int collect_digits(struct ast_channel *c, int waittime, char *buf, int buflen, int pos)
collect digits from the channel into the buffer.
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static int hashtab_compare_exten_numbers(const void *ah_a, const void *ah_b)
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate)
Map devstate to an extension state.
static int read_escalates(const struct ast_custom_function *acf)
Returns true if given custom function escalates privileges on read.
#define ao2_find(arg1, arg2, arg3)
int ast_destroy_timing(struct ast_timing *i)
Deallocates memory structures associated with a timing bitmap.
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
static int matchcid(const char *cidpattern, const char *callerid)
struct ast_var_t::@158 entries
static char * complete_show_dialplan_context(const char *line, const char *word, int pos, int state)
static void destroy_pattern_tree(struct match_char *pattern_tree)
const char * ast_get_ignorepat_name(struct ast_ignorepat *ip)
static int ext_cmp_exten_partial(const char *left, const char *right)
void ast_devstate_aggregate_init(struct ast_devstate_aggregate *agg)
Initialize aggregate device state.
static char * handle_unset_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
unsigned int ast_hashtab_hash_contexts(const void *obj)
static struct ast_context * find_context_locked(const char *context)
lookup for a context with a given name,
void pbx_live_dangerously(int new_live_dangerously)
Enable/disable the execution of 'dangerous' functions from external protocols (AMI, etc.).
int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
static char * handle_show_functions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const char * foundcontext
int ast_register_switch(struct ast_switch *sw)
Register an alternative dialplan switch.
int ast_extension_close(const char *pattern, const char *data, int needmore)
static char * handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Asterisk XML Documentation API.
char app[AST_MAX_EXTENSION]
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
static int pbx_builtin_answer(struct ast_channel *, const char *)
void ast_cdr_setapp(struct ast_cdr *cdr, const char *app, const char *data)
Set the last executed application.
static int pbx_builtin_congestion(struct ast_channel *, const char *)
static int handle_statechange(void *datap)
int pbx_builtin_setvar(struct ast_channel *chan, const char *data)
Parse and set a single channel variable, where the name and value are separated with an '=' character...
unsigned int ast_hashtab_hash_string(const void *obj)
Hashes a string to a number.
An API for managing task processing threads that can be shared across modules.
char * ast_xmldoc_printable(const char *bwinput, int withcolors)
Colorize and put delimiters (instead of tags) to the xmldoc output.
static char * handle_show_application(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
static void destroy_state_cb(void *doomed)
struct pval * find_context(char *name)
if(yyss+yystacksize-1<=yyssp)
static int ast_add_extension_nolock(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)
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
const ast_string_field synopsis
static struct ast_custom_function exception_function
Structure used to handle boolean flags.
#define BACKGROUND_MATCHEXTEN
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
char * ast_xmldoc_build_syntax(const char *type, const char *name, const char *module)
Get the syntax for a specified application or function.
int ast_build_timing(struct ast_timing *i, const char *info)
Construct a timing bitmap, for use in time-based conditionals.
char * ast_xmldoc_build_seealso(const char *type, const char *name, const char *module)
Parse the <see-also> node content.
#define ast_clear_flag(p, flag)
int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid, int *found, int combined_find_spawn)
Launch a new extension (i.e. new stack)
static int find_hint_by_cb_id(void *obj, void *arg, int flags)
Remove a watcher from the callback list.
static char cid_name[AST_MAX_EXTENSION]
static int pbx_builtin_waitexten(struct ast_channel *, const char *)
int ast_say_phonetic_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
Evaluate the given expression.
#define ast_rwlock_wrlock(a)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
struct match_char * pattern_tree
struct ast_eid ast_eid_default
Global EID.
struct ast_sw * ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw)
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
unsigned int ast_hashtab_hash_int(const int num)
#define EVENT_FLAG_REPORTING
static int pbx_builtin_ringing(struct ast_channel *, const char *)
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define AST_RWLIST_INSERT_TAIL
int transit_network_select
Transit Network Select.
void ast_cdr_discard(struct ast_cdr *cdr)
Discard and free a CDR record.
static void * async_wait(void *data)
struct ast_flags ast_options
static struct ast_exten * ast_hint_extension_nolock(struct ast_channel *c, const char *context, const char *exten)
Find hint for given extension in context.
struct ast_context * parent
static const char * get_pattern_node(struct pattern_node *node, const char *src, int pattern, const char *extenbuf)
A ast_taskprocessor structure is a singleton by name.
const char * ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var)
static int pbx_builtin_saydate(struct ast_channel *, const char *)
static int pbx_builtin_saytime(struct ast_channel *, const char *)
const char * ast_module_name(const struct ast_module *mod)
Get the name of a module.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
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.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
struct ast_channel * ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name)
Request a channel of a given type, with data as optional information used by the low level module and...
Structure for rwlock and tracking information.
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options)
says a number
static char * complete_core_show_hint(const char *line, const char *word, int pos, int state)
autocomplete for CLI command 'core show hint'
Standard Command Line Interface.
struct ast_event_sub * ast_event_subscribe(enum ast_event_type event_type, ast_event_cb_t cb, const char *description, void *userdata,...)
Subscribe to events.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
Check and insert new object only if it is not there.
#define ao2_container_alloc(arg1, arg2, arg3)
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
static struct ast_switch * pbx_findswitch(const char *sw)
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
static void update_scoreboard(struct scoreboard *board, int length, int spec, struct ast_exten *exten, char last, const char *callerid, int deleted, struct match_char *node)
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
ast_app: A registered application
Extra information for an ast_custom_function holding privilege escalation information. Kept in a separate structure for ABI compatibility.
static void * ast_pbx_run_app(void *data)
run the application and free the descriptor once done
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
struct ast_context::@290 alts
static struct ast_context * local_contexts
#define AST_PBX_GOTO_FAILED
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
int ast_answer(struct ast_channel *chan)
Answer a channel.
static char * overrideswitch
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
void pbx_set_overrideswitch(const char *newval)
int ast_thread_inhibit_escalations(void)
Inhibit (in the current thread) the execution of dialplan functions which cause privilege escalations...
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
static unsigned int hashtab_hash_extens(const void *obj)
static int add_priority(struct ast_context *con, struct ast_exten *tmp, struct ast_exten *el, struct ast_exten *e, int replace)
add the extension in the priority chain.
static int parse_variable_name(char *var, int *offset, int *length, int *isfunc)
extract offset:length from variable name.
static struct ao2_container * statecbs
const ast_string_field accountcode
int ast_context_remove_extension2(struct ast_context *con, const char *extension, int priority, const char *registrar, int already_locked)
This functionc locks given context, search for the right extension and fires out all peer in this ext...
static void print_app_docs(struct ast_app *aa, int fd)
char * ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
Command completion for the list of active channels.
Data structure associated with a single frame of data.
const ast_string_field seealso
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
Internal Asterisk hangup causes.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context (or ANY context if NULL)
static int ast_remove_hint(struct ast_exten *e)
Remove hint from extension.
static struct ast_taskprocessor * device_state_tps
static int include_valid(struct ast_include *i)
int ast_register_application2(const char *app, int(*execute)(struct ast_channel *, const char *), const char *synopsis, const char *description, void *mod)
Register an application.
You shouldn't care about the contents of this struct.
struct ast_hashtab * root_table
Counters for the show dialplan manager command.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
static struct ast_app_option background_opts[128]
static struct ast_context * contexts
#define WAITEXTEN_DIALTONE
static char * handle_set_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_RWLIST_REMOVE
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
char * ast_str_set_substr(struct ast_str **buf, ssize_t maxlen, const char *src, size_t maxsrc)
Set a dynamic string to a non-NULL terminated substring.
Handy terminal functions for vt* terms.
struct timeval whentohangup
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
const char * data
Description of a tone.
void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead *headp, const char *cp1, char *cp2, int cp2_size, size_t *used)
#define AST_APP_ARG(name)
Define an application argument.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
enum ast_frame_type frametype
int ast_str2cause(const char *name) attribute_pure
Convert the string form of a cause code to a number.
struct store_hint::@294 callbacks
static char * handle_show_globals(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI support for listing global variables in a parseable way.
#define ast_mutex_init(pmutex)
struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
static int ext_cmp_exten(const char *left, const char *right)
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static struct ast_app_option resetcdr_opts[128]
struct match_char * next_char
static char context[AST_MAX_CONTEXT]
#define ast_mutex_destroy(a)
int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
int(* execute)(struct ast_channel *chan, const char *data)
SAY_EXTERN int(* ast_say_time)(struct ast_channel *chan, time_t t, const char *ints, const char *lang) SAY_INIT(ast_say_time)
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.
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Registers a state change callback.
int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar)
Add a switch.
static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action, int *found, int combined_find_spawn)
The return value depends on the action:
static int pbx_builtin_noop(struct ast_channel *, const char *)
const char * ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has a string payload.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
static int write_escalates(const struct ast_custom_function *acf)
Returns true if given custom function escalates privileges on write.
struct ast_channel * ast_dummy_channel_alloc(void)
Create a fake channel structure.
const ast_string_field seealso
static void device_state_cb(const struct ast_event *event, void *unused)
static struct varshead globals
static int hints_data_provider_get(const struct ast_data_search *search, struct ast_data *data_root)
Say numbers and dates (maybe words one day too)
static int pbx_builtin_resetcdr(struct ast_channel *, const char *)
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
static void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
static int ext_strncpy(char *dst, const char *src, int len)
copy a string skipping whitespace
int ast_get_extension_matchcid(struct ast_exten *e)
struct ast_data * ast_data_add_str(struct ast_data *root, const char *childname, const char *string)
Add a string node type.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
const ast_string_field context
unsigned int no_hangup_chan
char * strcasestr(const char *, const char *)
int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
int ast_hashtab_size(struct ast_hashtab *tab)
Returns the number of elements stored in the hashtab.
int ast_context_remove_switch2(struct ast_context *con, const char *sw, const char *data, const char *registrar)
This function locks given context, removes switch, unlock context and return.
static char * func_args(char *function)
return a pointer to the arguments of the function, and terminates the function name with '\0' ...
void ast_hashtab_get_stats(struct ast_hashtab *tab, int *biggest_bucket_size, int *resize_count, int *num_objects, int *num_buckets)
Returns key stats for the table.
char exten_name[AST_MAX_EXTENSION]
Device Name Used by AST_EVENT_DEVICE_STATE_CHANGE Payload type: STR.
static snd_pcm_format_t format
static int ast_extension_state3(struct ast_str *hint_app)
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
static int match(struct sockaddr_in *sin, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
static unsigned get_range(char *src, int max, const char *const names[], const char *msg)
helper function to return a range up to max (7, 12, 31 respectively). names, if supplied, is an array of names that should be mapped to numbers.
struct ast_data * ast_data_add_int(struct ast_data *root, const char *childname, int value)
Add an integer node type.
static struct pbx_builtin builtins[]
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
struct ast_event_sub * ast_event_unsubscribe(struct ast_event_sub *event_sub)
Un-subscribe from events.
ast_context: An extension context
int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
Evaluate the given expression.
unsigned char valid
TRUE if the number information is valid/present.
static int hint_id_cmp(void *obj, void *arg, int flags)
struct ao2_container * callbacks
int getloadavg(double *list, int nelem)
const ast_string_field data
int ast_context_unlockmacro(const char *macrocontext)
Unlocks the macrolock in the given context.
int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan)
Initialize based on a channel.
int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data)
Check the current generated node to know if it matches the search condition.
#define AST_RWLIST_TRAVERSE_SAFE_END
const ast_string_field language
uint32_t version
Structure version.
struct ast_ignorepat * next
struct ast_context * ast_context_find(const char *name)
Find a context.
struct ast_cdr * ast_cdr_alloc(void)
Allocate a CDR record.
const ast_string_field app
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
char exten[AST_MAX_EXTENSION]
#define AST_MUTEX_DEFINE_STATIC(mutex)
int ast_stopstream(struct ast_channel *c)
Stops a stream.
int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Structure for mutex and tracking information.
void pbx_substitute_variables_varshead(struct varshead *headp, const char *cp1, char *cp2, int count)
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
Declaration of builtin applications.
struct match_char * pattern_tree
The structure of the node handler.
int ast_manager_unregister(char *action)
Unregister a registered manager command.
static const char * ast_str_substring(struct ast_str *value, int offset, int length)
struct ast_context * ast_get_extension_context(struct ast_exten *exten)
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define ast_mutex_unlock(a)
static struct ast_exten * get_canmatch_exten(struct match_char *node)
int ast_waitstream_exten(struct ast_channel *c, const char *context)
Waits for a stream to stop or digit matching a valid one digit exten to be pressed.
int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf)
Create a human-readable string, specifying all variables and their corresponding values.
static char prefix[MAX_PREFIX]
static void destroy_exten(struct ast_exten *e)
const ast_string_field arguments
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
match_char: forms a syntax tree for quick matching of extension patterns
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager list transaction.
void ast_cdr_busy(struct ast_cdr *cdr)
Busy a call.
void ast_hashtab_destroy(struct ast_hashtab *tab, void(*objdestroyfunc)(void *obj))
This func will free the hash table and all its memory.
static void insert_in_next_chars_alt_char_list(struct match_char **parent_ptr, struct match_char *node)
struct ast_party_number number
Subscriber phone number.
static void get_timerange(struct ast_timing *i, char *times)
store a bitmask of valid times, one bit each 1 minute
void * ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj)
Hash the object and then compare ptrs in bucket list instead of calling the compare routine...