37#if defined(HAVE_SYSINFO)
38#include <sys/sysinfo.h>
41#include <sys/loadavg.h>
180#define EXT_DATA_SIZE 256
182#define EXT_DATA_SIZE 8192
185#define SWITCH_DATA_LENGTH 256
188#define VAR_SOFTTRAN 2
189#define VAR_HARDTRAN 3
288static int matchcid(
const char *cidpattern,
const char *callerid);
293 struct match_char *tree,
int length,
int spec,
const char *callerid,
310 const char *application,
void *
data,
void (*
datad)(
void *),
315static unsigned int ext_strncpy(
char *dst,
const char *src,
size_t dst_size,
int nofluff);
330 const unsigned char *ac =
a;
331 const unsigned char *
bc =
b;
344 return strcmp(ac->
name,
bc->name);
351 int x = strcmp(ac->
exten,
bc->exten);
450void check_contexts_trouble(
void);
452void check_contexts_trouble(
void)
458int check_contexts(
char *,
int);
460int check_contexts(
char *file,
int line )
485 ast_log(
LOG_NOTICE,
"Called from: %s:%d: Could not find the %s context in the linked list\n", file, line, c1->
name);
486 check_contexts_trouble();
493 ast_log(
LOG_NOTICE,
"Called from: %s:%d: Could not find the %s context in the hashtab\n", file, line, c2->
name);
494 check_contexts_trouble();
509 char dummy_name[1024];
510 ex.exten = dummy_name;
518 "the exten %s (CID match: %s) but it is not in its root_table\n",
522 "the exten %s but it is not in its root_table\n",
523 file, line, c2->
name, dummy_name);
525 check_contexts_trouble();
545 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);
546 check_contexts_trouble();
558 for(e1 = c2->
root; e1; e1 = e1->
next) {
560 for(e2=e1;e2;e2=e2->
peer) {
563 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 );
564 check_contexts_trouble();
568 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 );
569 check_contexts_trouble();
574 check_contexts_trouble();
579 check_contexts_trouble();
586 check_contexts_trouble();
598 for(e3=e1;e3;e3=e3->
peer) {
606 check_contexts_trouble();
706#ifdef NEED_DEBUG_HERE
720 snprintf(extenstr,
sizeof(extenstr),
"(%p)",
node->exten);
722 if (strlen(
node->x) > 1) {
724 node->deleted?
'D':
'-',
node->specificity,
node->exten?
"EXTEN:":
"",
725 node->exten ?
node->exten->exten :
"", extenstr);
728 node->deleted?
'D':
'-',
node->specificity,
node->exten?
"EXTEN:":
"",
729 node->exten ?
node->exten->exten :
"", extenstr);
750 snprintf(extenstr,
sizeof(extenstr),
"(%p)",
node->exten);
753 if (strlen(
node->x) > 1) {
755 node->deleted ?
'D' :
'-',
node->specificity,
node->exten?
"EXTEN:" :
"",
756 node->exten ?
node->exten->name :
"", extenstr);
759 node->deleted ?
'D' :
'-',
node->specificity,
node->exten?
"EXTEN:" :
"",
760 node->exten ?
node->exten->name :
"", extenstr);
779#ifdef NEED_DEBUG_HERE
785#ifdef NEED_DEBUG_HERE
809 m3 =
node->next_char;
819 for (m4 = m3; m4; m4 = m4->
alt_char) {
853 while (*
str ==
'-') {
859#define MORE(s) (*candidate_exten_advance(s))
860#define ADVANCE(s) candidate_exten_advance(s)
868 ast_log(
LOG_NOTICE,
"new_find_extension called with %s on (sub)tree %s action=%s\n",
str, tree->
x, action2str(action));
870 ast_log(
LOG_NOTICE,
"new_find_extension called with %s on (sub)tree NULL action=%s\n",
str, action2str(action));
872 for (p = tree; p; p = p->
alt_char) {
874 if (p->
x[0] ==
'N') {
875 if (p->
x[1] == 0 && *
str >=
'2' && *
str <=
'9' ) {
876#define NEW_MATCHER_CHK_MATCH \
877 if (p->exten && !MORE(str)) { \
878 if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { \
879 update_scoreboard(score, length + 1, spec + p->specificity, p->exten, 0, callerid, p->deleted, p); \
881 if (action == E_FINDLABEL) { \
882 if (ast_hashtab_lookup(score->exten->peer_label_table, &pattern)) { \
883 ast_debug(4, "Found label in preferred extension\n"); \
887 ast_debug(4, "returning an exact match-- first found-- %s\n", p->exten->name); \
894#define NEW_MATCHER_RECURSE \
895 if (p->next_char && (MORE(str) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0) \
896 || p->next_char->x[0] == '!')) { \
897 if (MORE(str) || p->next_char->x[0] == '!') { \
898 new_find_extension(ADVANCE(str), score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \
899 if (score->exten) { \
900 ast_debug(4 ,"returning an exact match-- %s\n", score->exten->name); \
904 new_find_extension("/", score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \
905 if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) { \
906 ast_debug(4,"returning a (can/more) match--- %s\n", score->exten ? score->exten->name : \
911 } else if ((p->next_char || action == E_CANMATCH) && !MORE(str)) { \
912 score->canmatch = 1; \
913 score->canmatch_exten = get_canmatch_exten(p); \
914 if (action == E_CANMATCH || action == E_MATCHMORE) { \
915 ast_debug(4, "returning a canmatch/matchmore--- str=%s\n", str); \
923 }
else if (p->
x[0] ==
'Z') {
924 if (p->
x[1] == 0 && *
str >=
'1' && *
str <=
'9' ) {
928 }
else if (p->
x[0] ==
'X') {
929 if (p->
x[1] == 0 && *
str >=
'0' && *
str <=
'9' ) {
933 }
else if (p->
x[0] ==
'.' && p->
x[1] == 0) {
936 const char *str2 =
str;
937 while (*str2 && *str2 !=
'/') {
941 if (p->
exten && *str2 !=
'/') {
944 ast_debug(4,
"return because scoreboard has a match with '/'--- %s\n",
952 ast_debug(4,
"return because scoreboard has exact match OR "
953 "CANMATCH/MATCHMORE & canmatch set--- %s\n",
958 }
else if (p->
x[0] ==
'!' && p->
x[1] == 0) {
961 const char *str2 =
str;
962 while (*str2 && *str2 !=
'/') {
966 if (p->
exten && *str2 !=
'/') {
969 ast_debug(4,
"return because scoreboard has a '!' match--- %s\n",
977 ast_debug(4,
"return because scoreboard has exact match OR "
978 "CANMATCH/MATCHMORE & canmatch set with '/' and '!'--- %s\n",
983 }
else if (p->
x[0] ==
'/' && p->
x[1] == 0) {
985 if (p->
next_char && callerid && *callerid) {
988 ast_debug(4,
"return because scoreboard has exact match OR "
989 "CANMATCH/MATCHMORE & canmatch set with '/'--- %s\n",
994 }
else if (strchr(p->
x, *
str)) {
995 ast_debug(4,
"Nothing strange about this match\n");
999 }
else if (strchr(p->
x, *
str)) {
1000 ast_debug(4,
"Nothing strange about this match\n");
1005 ast_debug(4,
"return at end of func\n");
1055 if (!(*parent_ptr)) {
1060 if ((*parent_ptr)->specificity >
node->specificity) {
1062 node->alt_char = (*parent_ptr);
1067 lcurr = *parent_ptr;
1070 node->alt_char = curr;
1094 if (!(m =
ast_calloc(1,
sizeof(*m) + strlen(pattern->
buf)))) {
1101 strcpy(m->
x, pattern->
buf);
1146#define INC_DST_OVERFLOW_CHECK \
1148 if (dst - node->buf < sizeof(node->buf) - 1) { \
1156 node->buf[0] =
'\0';
1158 if (*src ==
'[' && pattern) {
1159 char *dst =
node->buf;
1160 const char *src_next;
1170 if (*src ==
'[' || *src ==
'\\' || *src ==
'-' || *src ==
']') {
1174 }
else if (*src ==
'-') {
1175 unsigned char first;
1179 first = *(src_next - 1);
1203 }
else if (*src ==
'\0') {
1205 "A matching ']' was not found for '[' in exten pattern '%s'\n",
1208 }
else if (*src ==
']') {
1221 "Expanded character set too large to deal with in exten pattern '%s'. Ignoring character set.\n",
1223 node->buf[0] =
'\0';
1228 length = strlen(
node->buf);
1232 node->buf[0] =
'\0';
1239 src_next =
node->buf;
1240 while (*src_next++) {
1241 if (*dst != *src_next) {
1246 length = strlen(
node->buf);
1248 node->specif = length | (
unsigned char)
node->buf[0];
1250 }
else if (*src ==
'-') {
1260 node->buf[0] = *++src;
1261 if (!
node->buf[0]) {
1265 node->buf[0] = *src;
1268 if (
node->buf[0] ==
'n') {
1270 }
else if (
node->buf[0] ==
'x') {
1272 }
else if (
node->buf[0] ==
'z') {
1277 node->buf[1] =
'\0';
1285#undef INC_DST_OVERFLOW_CHECK
1288#define MAX_EXTENBUF_SIZE 512
1300 volatile size_t required_space = strlen(e1->
exten) + 1;
1304 required_space += (strlen(e1->
cidmatch) + 2 );
1307 "The pattern %s/%s is too big to deal with: it will be ignored! Disaster!\n",
1315 "The pattern %s/%s is too big to deal with: it will be ignored! Disaster!\n",
1323 ast_debug(1,
"Adding exten %s to tree\n", extenbuf);
1336 for (; pat_node[idx_cur].
buf[0]; idx_cur = idx_next) {
1337 idx_next = (idx_cur + 1) %
ARRAY_LEN(pat_node);
1344 if (!pat_node[idx_next].
buf[0]) {
1378 if (!pat_node[idx_next].
buf[0]) {
1379 if (m2 && m2->
exten) {
1401 int biggest_bucket, resizes, numobjs, numbucks;
1403 ast_debug(1,
"Creating Extension Trie for context %s(%p)\n", con->
name, con);
1405 ast_debug(1,
"This tree has %d objects in %d bucket lists, longest list=%d objects, and has resized %d times\n",
1406 numobjs, numbucks, biggest_bucket, resizes);
1413 ast_log(
LOG_ERROR,
"Attempt to create extension with no extension name.\n");
1431 pattern_tree->
exten = 0;
1450 while (*
str ==
'-') {
1479 while (*left ==
'-') {
1482 while (*right ==
'-') {
1495 cmp = *left - *right;
1522 while (*left ==
'-') {
1525 while (*right ==
'-') {
1529 cmp = *left - *right;
1629 return 0x0800 |
'2';
1636 return 0x0A00 |
'0';
1643 return 0x0900 |
'1';
1663 end = strchr(*p,
']');
1672 for (; *p <
end; ++*p) {
1677 if (*p + 2 <
end && (*p)[1] ==
'-') {
1686 for (; c1 <= c2; ++c1) {
1695 if (!(bitwise[c1 /
BITS_PER] & mask)) {
1704 return count | cmin;
1725 unsigned char left_bitwise[32] = { 0, };
1726 unsigned char right_bitwise[32] = { 0, };
1730 cmp = left_pos - right_pos;
1739 cmp = memcmp(right_bitwise, left_bitwise,
ARRAY_LEN(left_bitwise));
1766static int ext_cmp(
const char *left,
const char *right)
1769 if (left[0] !=
'_') {
1770 if (right[0] ==
'_') {
1776 if (right[0] !=
'_') {
1792 if (*
exten !=
'_') {
1795 if (*
exten ==
'-') {
1806 if (*
exten ==
'-') {
1808 }
else if (*
exten ==
'[') {
1853#ifdef NEED_DEBUG_HERE
1857 if (pattern[0] !=
'_') {
1862#ifdef NEED_DEBUG_HERE
1869#ifdef NEED_DEBUG_HERE
1875#ifdef NEED_DEBUG_HERE
1876 ast_log(
LOG_NOTICE,
"return (mode(%d) == E_MATCHMORE ? lp(%d) > ld(%d) : 1)\n", mode, lp, ld);
1880#ifdef NEED_DEBUG_HERE
1896#ifdef NEED_DEBUG_HERE
1900#ifdef NEED_DEBUG_HERE
1916 while (*
data ==
'-') {
1919 while (*pattern ==
'-') {
1922 if (!*
data || !*pattern || *pattern ==
'/') {
1929 end = strchr(pattern,
']');
1934 if (pattern ==
end) {
1939 for (; pattern <
end; ++pattern) {
1940 if (pattern+2 <
end && pattern[1] ==
'-') {
1941 if (*
data >= pattern[0] && *
data <= pattern[2])
1947 }
else if (*
data == pattern[0])
1950 if (pattern >=
end) {
1951#ifdef NEED_DEBUG_HERE
1961#ifdef NEED_DEBUG_HERE
1970#ifdef NEED_DEBUG_HERE
1979#ifdef NEED_DEBUG_HERE
1986#ifdef NEED_DEBUG_HERE
1991#ifdef NEED_DEBUG_HERE
1996 if (*
data != *pattern) {
1997#ifdef NEED_DEBUG_HERE
2008#ifdef NEED_DEBUG_HERE
2018 if (*pattern ==
'\0' || *pattern ==
'/') {
2019#ifdef NEED_DEBUG_HERE
2023 }
else if (*pattern ==
'!') {
2024#ifdef NEED_DEBUG_HERE
2029#ifdef NEED_DEBUG_HERE
2032 return (mode ==
E_MATCH) ? 0 : 1;
2043 static int prof_id = -2;
2044 if (prof_id == -2) {
2081 if (!strcasecmp(
name, tmp->
name)) {
2090#define STATUS_NO_CONTEXT 1
2091#define STATUS_NO_EXTENSION 2
2092#define STATUS_NO_PRIORITY 3
2093#define STATUS_NO_LABEL 4
2094#define STATUS_SUCCESS 5
2096static int matchcid(
const char *cidpattern,
const char *callerid)
2121 pattern.
label = label;
2123#ifdef NEED_DEBUG_HERE
2124 ast_log(
LOG_NOTICE,
"Looking for cont/ext/prio/label/action = %s/%s/%d/%s/%d\n", context, exten,
priority, label, (
int) action);
2139 for (x = 0; x < q->
stacklen; x++) {
2140 if (!strcasecmp(q->
incstack[x], context))
2165 ast_debug(1,
"Tree Created in context %s:\n", context);
2190 if (osw && strchr(osw,
'$')) {
2218 res = aswf(chan, context, exten,
priority, callerid, datap);
2235 eroot = score.
exten;
2241#ifdef NEED_DEBUG_HERE
2249#ifdef NEED_DEBUG_HERE
2259#ifdef NEED_DEBUG_HERE
2264#ifdef NEED_DEBUG_HERE
2269#ifdef NEED_DEBUG_HERE
2276#ifdef NEED_DEBUG_HERE
2297#ifdef NEED_DEBUG_HERE
2311 if (!
match || (eroot->matchcid && !
matchcid(eroot->cidmatch, callerid)))
2375 res = aswf(chan, context, exten,
priority, callerid, datap);
2397#ifdef NEED_DEBUG_HERE
2417 .
type =
"EXCEPTION",
2450 ds->
data = exception;
2453 exception = ds->
data;
2473 if (!ds || !ds->
data) {
2477 exception = ds->
data;
2478 if (!strcasecmp(data,
"REASON"))
2480 else if (!strcasecmp(data,
"CONTEXT"))
2482 else if (!strncasecmp(data,
"EXTEN", 5))
2484 else if (!strcasecmp(data,
"PRIORITY"))
2494 .
name =
"EXCEPTION",
2517 const char *context,
const char *exten,
int priority,
2518 const char *label,
const char *callerid,
enum ext_match_t action,
int *found,
int combined_find_spawn)
2522 char *substitute =
NULL;
2530 context = con->
name;
2540 if (matching_action) {
2558 if ((!(tmp = strchr(e->
data,
'$'))) || (!strstr(tmp,
"${") && !strstr(tmp,
"$["))) {
2600 if (matching_action) {
2614 if (!matching_action && !combined_find_spawn)
2618 if (!matching_action && !combined_find_spawn)
2622 if (!matching_action && !combined_find_spawn)
2626 if (context && !combined_find_spawn)
2627 ast_log(
LOG_NOTICE,
"No such label '%s' in extension '%s' in context '%s'\n",
S_OR(label,
""), exten,
S_OR(context,
""));
2633 return (matching_action) ? 0 : -1;
2805 if (found && spawn_error) {
2807 ast_debug(1,
"Spawn extension (%s,%s,%d) exited non-zero on '%s'\n",
2810 ast_verb(2,
"Spawn extension (%s, %s, %d) exited non-zero on '%s'\n",
2856 if (pos < buflen - 1) {
2926 char dst_exten[256];
2933 dst_exten[pos] =
'\0';
2971 ast_debug(1,
"Extension %s, priority %d returned normally even though call was hung up\n",
2978 if (strchr(
"0123456789ABCDEF*#", res)) {
2979 ast_debug(1,
"Oooh, got something to jump out with ('%c')!\n", res);
2981 dst_exten[pos++] =
digit = res;
2982 dst_exten[pos] =
'\0';
2994 pos = strlen(dst_exten);
3058 ast_verb(3,
"Channel '%s' sent to invalid extension: context,exten,priority=%s,%s,%d\n",
3066 ast_log(
LOG_WARNING,
"Channel '%s' sent to invalid extension but no invalid handler: context,exten,priority=%s,%s,%d\n",
3085 if (!strcasecmp(
status,
"CONGESTION"))
3087 else if (!strcasecmp(
status,
"CHANUNAVAIL"))
3089 else if (!strcasecmp(
status,
"BUSY"))
3117 "Invalid extension '%s', but no rule 'i' or 'e' in context '%s'\n",
3133 "Timeout, but no rule 't' or 'e' in context '%s'\n",
3143 if (!found && !
error) {
3147 if (!
args || !
args->no_hangup_chan) {
3165 if (!
args || !
args->no_hangup_chan) {
3181#if defined(HAVE_SYSINFO)
3182 struct sysinfo sys_info;
3199#if defined(HAVE_SYSINFO)
3202 if (!sysinfo(&sys_info)) {
3205 uint64_t curfreemem = sys_info.freeram + sys_info.bufferram;
3206 curfreemem *= sys_info.mem_unit;
3207 curfreemem /= 1024 * 1024;
3209 ast_log(
LOG_WARNING,
"Available system memory (~%" PRIu64
"MB) is below the configured low watermark (%ldMB)\n",
3548 char dummy_name[1024];
3549 char dummy_cid[1024];
3554 if (!already_locked)
3561 check_contexts(__FILE__, __LINE__);
3564 ex.
exten = dummy_name;
3569 ext_strncpy(dummy_cid, callerid,
sizeof(dummy_cid), 1);
3586 ast_log(
LOG_WARNING,
"Trying to delete an exten from a context, but the pattern tree node returned isn't a full extension\n");
3593 if (exten2->
label) {
3597 "from the peer_label_table of context %s, extension %s!\n",
3605 "peer_table of context %s, extension %s!\n",
3618 "context root_table (%s) (priority %d)\n",
3630 ast_debug(3,
"Could not find priority %d of exten %s in context %s!\n",
3657 if (!already_locked)
3666 peer = next_peer, next_peer = next_peer ? (next_peer->
peer ? next_peer->
peer : next_peer->
next) :
NULL) {
3673 if (!previous_peer) {
3688 con->
root = next_node;
3690 prev_exten->
next = next_node;
3703 previous_peer =
peer;
3706 if (!already_locked)
3708 return found ? 0 : -1;
3735 const int blocks_max = 50000;
3736 long long int allocated = 0;
3749 e->
command =
"core eat memory";
3751 "Usage: core eat memory\n"
3752 " Eats all available memory so you can test if the system survives\n";
3758 blocks =
ast_malloc(
sizeof(
void*) * blocks_max);
3764 for (i = 0; sizes[i]; ++i) {
3765 int alloc_size = sizes[i];
3766 ast_log(
LOG_WARNING,
"Allocating %d sized blocks (got %d blocks already)\n", alloc_size, blocks_pos);
3769 if (blocks_pos >= blocks_max) {
3779 blocks[blocks_pos++] = block;
3780 allocated += alloc_size;
3807 wordlen = strlen(
word);
3837 snprintf(
buf, buflen,
"hint: %s",
3840 snprintf(
buf, buflen,
"%d. %s(%s)",
3850 ast_cli(fd,
" %-17s %-45s [%s:%d]\n",
3857 ast_cli(fd,
" %-17s %-45s [%s]\n",
3874 char buf[1024], buf2[1024];
3876 char buf[256], buf2[256];
3878 int context_info_printed = 0;
3895 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
3898 ast_cli(fd,
"Autohints support enabled\n");
3900 context_info_printed = 1;
3914 if (!context_info_printed) {
3917 ast_cli(fd,
"[ Included context '%s' created by '%s' ]\n",
3920 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
3923 ast_cli(fd,
"Autohints support enabled\n");
3926 context_info_printed = 1;
3947 snprintf(
buf,
sizeof(
buf),
" [%s]",
el);
3968 for (x = 0; x < includecount; x++) {
3982 ast_cli(fd,
" Include => %-45s [%s]\n",
3993 snprintf(
buf,
sizeof(
buf),
"'%s'", ipname);
3994 snprintf(ignorepat,
sizeof(ignorepat),
"_%s.", ipname);
3996 ast_cli(fd,
" Ignore pattern => %-45s [%s]\n",
4004 snprintf(
buf,
sizeof(
buf),
"'%s/%s'",
4007 ast_cli(fd,
" Alt. Switch => %-45s [%s]\n",
4015 if (context_info_printed)
4020 return (dpc->
total_exten == old_total_exten) ? -1 : res;
4028 ast_cli(fd,
"\n In-mem exten Trie for Fast Extension Pattern Matching:\n\n");
4030 ast_cli(fd,
"\n Explanation: Node Contents Format = <char(s) to match>:<pattern?>:<specif>:[matched extension]\n");
4031 ast_cli(fd,
" Where <char(s) to match> is a set of chars, any one of which should match the current character\n");
4032 ast_cli(fd,
" <pattern?>: Y if this a pattern match (eg. _XZN[5-7]), N otherwise\n");
4033 ast_cli(fd,
" <specif>: an assigned 'exactness' number for this matching char. The lower the number, the more exact the match\n");
4034 ast_cli(fd,
" [matched exten]: If all chars matched to this point, which extension this matches. In form: EXTEN:<exten string>\n");
4035 ast_cli(fd,
" In general, you match a trie node to a string character, from left to right. All possible matching chars\n");
4036 ast_cli(fd,
" are in a string vertically, separated by an unbroken string of '+' characters.\n\n");
4041 int context_info_printed = 0;
4048 if (!
c->pattern_tree) {
4056 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
4058 context_info_printed = 1;
4060 if (
c->pattern_tree)
4064 ast_cli(fd,
"\n No Pattern Trie present. Perhaps the context is empty...or there is trouble...\n\n");
4070 if (context_info_printed)
4075 return (dpc->
total_exten == old_total_exten) ? -1 : res;
4080 char *exten =
NULL, *context =
NULL;
4089 "Usage: dialplan show [[exten@]context]\n"
4096 memset(&counters, 0,
sizeof(counters));
4098 if (
a->argc != 2 &&
a->argc != 3)
4103 if (strchr(
a->argv[2],
'@')) {
4105 exten =
strsep(&context,
"@");
4120 ast_cli(
a->fd,
"There is no existence of '%s' context\n", context);
4126 ast_cli(
a->fd,
"There is no existence of %s@%s extension\n",
4130 "There is no existence of '%s' extension in all contexts\n",
4135 ast_cli(
a->fd,
"-= %d %s (%d %s) in %d %s. =-\n",
4147 char *exten =
NULL, *context =
NULL;
4154 e->
command =
"dialplan debug";
4156 "Usage: dialplan debug [context]\n"
4157 " Show dialplan context Trie(s). Usually only useful to folks debugging the deep internals of the fast pattern matcher\n";
4163 memset(&counters, 0,
sizeof(counters));
4165 if (
a->argc != 2 &&
a->argc != 3)
4171 if (strchr(
a->argv[2],
'@')) {
4173 exten =
strsep(&context,
"@");
4188 ast_cli(
a->fd,
"There is no existence of '%s' context\n", context);
4211 const char *actionidtext,
const char *context,
4214 int includecount,
const char *includes[])
4224 ast_debug(3,
"manager_show_dialplan: Context: -%s- Extension: -%s-\n", context, exten);
4247 ast_debug(3,
"manager_show_dialplan: Failed to lock context\n");
4275 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
4301 for (x = 0; x < includecount; x++) {
4317 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
4329 snprintf(ignorepat,
sizeof(ignorepat),
"_%s.", ipname);
4333 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
4344 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
4356 ast_debug(3,
"manager_show_dialplan: Found nothing new\n");
4367 const char *exten, *context;
4376 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
4380 memset(&counters, 0,
sizeof(counters));
4388 char errorbuf[BUFSIZ];
4390 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find context %s", context);
4395 char errorbuf[BUFSIZ];
4398 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find extension %s@%s", exten, context);
4400 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find extension %s in any context", exten);
4411 "ListExtensions: %d\r\n"
4412 "ListPriorities: %d\r\n"
4413 "ListContexts: %d\r\n",
4425 int i, j, exten, combined;
4429 e->
command =
"core show device2extenstate";
4431 "Usage: core show device2extenstate\n"
4432 " Lists device state to extension state combinations.\n";
4457 e->
command =
"dialplan set extenpatternmatchnew true";
4459 "Usage: dialplan set extenpatternmatchnew true|false\n"
4460 " Use the NEW extension pattern matching algorithm, true or false.\n";
4472 ast_cli(
a->fd,
"\n -- Still using the NEW pattern match algorithm for extension names in the dialplan.\n");
4474 ast_cli(
a->fd,
"\n -- Switched to using the NEW pattern match algorithm for extension names in the dialplan.\n");
4485 e->
command =
"dialplan set extenpatternmatchnew false";
4487 "Usage: dialplan set extenpatternmatchnew true|false\n"
4488 " Use the NEW extension pattern matching algorithm, true or false.\n";
4500 ast_cli(
a->fd,
"\n -- Still using the OLD pattern match algorithm for extension names in the dialplan.\n");
4502 ast_cli(
a->fd,
"\n -- Switched to using the OLD pattern match algorithm for extension names in the dialplan.\n");
4515 AST_CLI_DEFINE(handle_show_device2extenstate,
"Show expected exten state from multiple device states"),
4532 if (e->cached_app ==
app)
4533 e->cached_app =
NULL;
4548 size_t name_bytes = strlen(
name);
4549 size_t registrar_bytes = strlen(
registrar);
4550 int length =
sizeof(
struct ast_context) + name_bytes + registrar_bytes + 2;
4683 struct ast_exten *exten_item, *prio_item, *new_exten_item, *new_prio_item;
4686 int insert_count = 0;
4694 if (context->root_table) {
4700 new_exten_item =
NULL;
4707 if (new_exten_item) {
4710 new_prio_item =
NULL;
4727 if (pattern_exten && !strcmp(q.
foundcontext, context->name)) {
4746 new->autohints = context->autohints;
4747 if (new->autohints) {
4761 ast_log(
LOG_ERROR,
"Could not allocate a new context for %s in merge_and_delete! Danger!\n", context->name);
4774 if (!res1 && new_exten_item && new_prio_item){
4775 ast_verb(3,
"Dropping old dialplan item %s/%s/%d [%s(%s)] (registrar=%s) due to conflict with new dialplan\n",
4793 if (!insert_count && !
new && (strcmp(context->registrar,
registrar) != 0 ||
4794 (strcmp(context->registrar,
registrar) == 0 && context->refcount > 1))) {
4800 new->autohints = context->autohints;
4801 if (new->autohints) {
4814 struct ast_exten *exten_item, *prio_item;
4824 if (context->autohints) {
4831 if (!context->root_table) {
4866 int ctx_count = 0, promoted_count = 0;
4867 struct timeval begintime;
4868 struct timeval writelocktime;
4869 struct timeval endlocktime;
4870 struct timeval enddeltime;
4929 for (tmp = oldcontextslist; tmp; ) {
4940 ast_verb(5,
"Time to scan old dialplan and merge leftovers back into the new: %8.6f sec\n", ft);
4944 ast_verb(5,
"Time to promote contexts and swap in new dialplan: %8.6f sec\n", ft);
4948 ast_verb(5,
"Time to delete the old dialplan: %8.6f sec\n", ft);
4952 ast_verb(5,
"Total time merge_contexts_delete: %8.6f sec\n", ft);
4953 ast_verb(5,
"%s successfully loaded %d contexts after incorporating %d promoted contexts (enable debug for details).\n",
5014 ast_debug(1,
"Including context '%s' in context '%s'\n",
5081 ast_verb(3,
"Including switch '%s/%s' in context '%s'\n",
5207 int priority,
const char *label,
const char *callerid,
5208 const char *application,
void *data,
void (*datad)(
void *),
const char *
registrar)
5308static unsigned int ext_strncpy(
char *dst,
const char *src,
size_t dst_size,
int nofluff)
5311 unsigned int insquares;
5312 unsigned int is_pattern;
5321 is_pattern = *src ==
'_';
5322 while (*src && count < dst_size) {
5327 }
else if (*src ==
']') {
5329 }
else if (*src ==
' ' && !insquares) {
5332 }
else if (*src ==
'-' && !insquares && nofluff) {
5354 int repeated_label = 0;
5356 for (ep =
NULL; e ; ep = e, e = e->
peer) {
5360 "Extension '%s' priority %d in '%s', label '%s' already in use at aliased extension '%s' priority %d\n",
5364 "Extension '%s' priority %d in '%s', label '%s' already in use at priority %d\n",
5374 if (repeated_label) {
5393 "Unable to register extension '%s' priority %d in '%s', already in use by aliased extension '%s'\n",
5397 "Unable to register extension '%s' priority %d in '%s', already in use\n",
5443 ast_log(
LOG_ERROR,
"Trying to delete an exten from a context, but the pattern tree node returned isn't an extension\n");
5470 ast_log(
LOG_ERROR,
"Trying to delete an exten from a context, but the pattern tree node returned isn't an extension\n");
5541 const char *application,
void *data,
void (*datad)(
void *),
5542 const char *
registrar,
const char *registrar_file,
int registrar_line)
5545 application, data, datad,
registrar, registrar_file, registrar_line, 1);
5550 const char *application,
void *data,
void (*datad)(
void *),
5551 const char *
registrar,
const char *registrar_file,
int registrar_line)
5554 application, data, datad,
registrar, registrar_file, registrar_line, 0);
5567 const char *application,
void *data,
void (*datad)(
void *),
5568 const char *
registrar,
const char *registrar_file,
int registrar_line,
int lock_context)
5582 char dummy_name[1024];
5587 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",
5613 if (0 < inhibited) {
5617 application = expand_buf;
5636 length += strlen(
extension) + 1 - exten_fluff;
5638 length += strlen(application) + 1;
5640 length += strlen(
label) + 1;
5643 length += strlen(callerid) + 1;
5644 if (callerid_fluff) {
5645 length += strlen(callerid) + 1 - callerid_fluff;
5672 p += strlen(
label) + 1;
5688 p +=
ext_strncpy(p, callerid, strlen(callerid) + 1, 0);
5689 if (callerid_fluff) {
5691 p +=
ext_strncpy(p, callerid, strlen(callerid) + 1 - callerid_fluff, 1);
5708 strcpy(p, application);
5722 dummy_exten.
exten = dummy_name;
5733 for (e = con->
root; e;
el = e, e = e->
next) {
5748 if (e && res == 0) {
5824 ast_log(
LOG_DEBUG,
"Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",
5882 if (
outgoing->in_separate_thread) {
5949 ast_verb(4,
"Treating progress as answer on '%s' due to early media option\n",
6004 const char *
app,
const char *appdata,
int *reason,
int synchronous,
6005 const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
6006 const char *account,
struct ast_channel **locked_channel,
int early_media,
6012 char tmp_cid_name[128];
6013 char tmp_cid_num[128];
6046 if (synchronous && reason) {
6064 ast_channel_accountcode_set(
dialed, account);
6065 ast_channel_peeraccount_set(
dialed, account);
6080 cid_num = tmp_cid_num;
6085 cid_name = tmp_cid_name;
6106 connected.id.number.str = (
char *) cid_num;
6111 connected.id.name.str = (
char *) cid_name;
6121 if (locked_channel) {
6154 if (locked_channel) {
6182 if (locked_channel) {
6187 if (locked_channel) {
6192 if (locked_channel) {
6193 *locked_channel = dialed;
6199 int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
6200 int synchronous,
const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
6201 const char *account,
struct ast_channel **locked_channel,
int early_media,
6205 synchronous, cid_num, cid_name, vars, account, locked_channel, early_media, assignedids,
NULL);
6209 int timeout,
const char *context,
const char *exten,
int priority,
int *reason,
6210 int synchronous,
const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
6211 const char *account,
struct ast_channel **locked_channel,
int early_media,
6218 reason = &my_reason;
6221 if (locked_channel) {
6222 *locked_channel =
NULL;
6226 NULL,
NULL, reason, synchronous, cid_num, cid_name, vars, account, locked_channel,
6227 early_media, assignedids, predial_callee);
6235 ast_assert(!locked_channel || !*locked_channel);
6244 char failed_reason[12];
6246 snprintf(failed_reason,
sizeof(failed_reason),
"%d", *reason);
6263 int timeout,
const char *
app,
const char *appdata,
int *reason,
int synchronous,
6264 const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
6265 const char *account,
struct ast_channel **locked_channel,
6269 cid_num, cid_name, vars, account, locked_channel, assignedids,
NULL);
6273 int timeout,
const char *
app,
const char *appdata,
int *reason,
int synchronous,
6274 const char *cid_num,
const char *cid_name,
struct ast_variable *vars,
6275 const char *account,
struct ast_channel **locked_channel,
6281 if (locked_channel) {
6282 *locked_channel =
NULL;
6289 reason, synchronous, cid_num, cid_name, vars, account, locked_channel, 0,
6290 assignedids, predial_callee);
6326 for (e = tmp->
root; e;) {
6327 for (en = e->
peer; en;) {
6345 struct ast_exten *exten_item, *prio_item;
6347 for (tmp = list; tmp; ) {
6355 for (; tmp; tmpl = tmp, tmp = tmp->
next) {
6356 ast_debug(1,
"check ctx %s %s\n", tmp->name, tmp->registrar);
6357 if ( !strcasecmp(tmp->name, con->
name) ) {
6404 int end_traversal = 1;
6422 ast_verb(5,
"Remove %s/%s/%d, registrar=%s; con=%s(%p); con->root=%p\n",
6438 if (end_traversal) {
6524 waittime = waitsec * 1000.0;
6543 char *remainder,
result[30], timezone[80];
6555 sscanf(remainder,
"%79s", timezone);
6558 snprintf(
result,
sizeof(
result),
"%ld", (
long) tv.tv_sec);
6573 }
else if (sscanf(condition,
"%30d", &res) == 1) {
6601 ast_verb(1,
"Asterisk PBX Core Initializing\n");
6603 ast_verb(5,
"Registering builtin functions:\n");
6679 return exten ? exten->
priority : -1;
6687 return c ?
c->registrar :
NULL;
6726 const char *context,
const char *exten,
int priority)
6822 if (inc == include) {
6901 for (idx = 0; idx < includecount; idx++) {
6958 }
else if (!*prip) {
6961 *extenp = *contextp;
6971 }
else if (*pri ==
'-') {
6976 if ((rest && sscanf(pri,
"%30d%1s", ipri, rest) != 1) || sscanf(pri,
"%30d", ipri) != 1) {
6999 ast_log(
LOG_WARNING,
"Goto requires an argument ([[context,]extension,]priority)\n");
7005 pri =
strsep(&stringp,
",");
Prototypes for public functions only of internal interest,.
void ast_context_destroy(void)
void ast_context_verify_includes(void)
void ast_merge_contexts_and_delete(void)
struct ast_context * ast_walk_contexts(void)
void ast_cli_unregister_multiple(void)
struct sla_ringing_trunk * first
struct sla_ringing_trunk * last
int getloadavg(double *list, int nelem)
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
int ast_add_profile(const char *, uint64_t scale)
support for event profiling
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
int64_t ast_mark(int, int start1_stop0)
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
void ast_free_ptr(void *ptr)
free() wrapper
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
#define ao2_alloc(data_size, destructor_fn)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Internal Asterisk hangup causes.
#define AST_CAUSE_SWITCH_CONGESTION
#define AST_CAUSE_UNALLOCATED
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
#define AST_CAUSE_CALL_REJECTED
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
#define AST_CAUSE_ANSWERED_ELSEWHERE
#define AST_CAUSE_NO_ANSWER
#define AST_CAUSE_USER_BUSY
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
General Asterisk PBX channel definitions.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
#define ast_channel_lock(chan)
@ AST_FLAG_BRIDGE_HANGUP_RUN
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
struct ast_channel * ast_channel_yank(struct ast_channel *yankee)
Gain control of a channel in the system.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_channel_priority(const struct ast_channel *chan)
#define ast_channel_ref(c)
Increase channel reference count.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
ast_callid ast_channel_callid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
struct ast_channel * ast_channel_get_by_name(const char *search)
Find a channel by name or uniqueid.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
void ast_channel_context_set(struct ast_channel *chan, const char *value)
@ AST_SOFTHANGUP_ASYNCGOTO
@ AST_SOFTHANGUP_HANGUP_EXEC
@ AST_SOFTHANGUP_APPUNLOAD
#define ast_dummy_channel_alloc()
Create a fake channel structure.
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation.
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups, and do not generate silence.
const char * ast_channel_exten(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
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.
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
const char * ast_devstate_str(enum ast_device_state devstate) attribute_pure
Convert device state to text string that is easier to parse.
void ast_devstate_aggregate_add(struct ast_devstate_aggregate *agg, enum ast_device_state state)
Add a device state to the aggregate device state.
void ast_devstate_aggregate_init(struct ast_devstate_aggregate *agg)
Initialize aggregate device state.
enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg)
Get the aggregate device state result.
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
ast_dial_result
List of return codes for dial run API calls.
@ AST_DIAL_RESULT_ANSWERED
@ AST_DIAL_RESULT_PROGRESS
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
struct ast_dial * ast_dial_create(void)
New dialing structure.
int ast_dial_prerun(struct ast_dial *dial, struct ast_channel *chan, struct ast_format_cap *cap)
Request all appended channels, but do not dial.
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
int ast_dial_reason(struct ast_dial *dial, int num)
Get the reason an outgoing channel has failed.
@ AST_DIAL_OPTION_PREDIAL
struct ast_channel * ast_dial_get_channel(struct ast_dial *dial, int num)
Get the dialing channel, if prerun has been executed.
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
pthread_rwlock_t ast_rwlock_t
#define AST_PBX_MAX_STACK
void pbx_extension_state_hint_set(struct ast_exten *exten, struct ast_context *context)
void pbx_extension_state_hint_remove(struct ast_exten *exten, struct ast_context *context)
static const char registrar[]
The static registrar for the added dialplan hints.
void pbx_extension_state_autohint_set(struct ast_context *context)
void pbx_extension_state_autohint_remove(struct ast_context *context, unsigned int forced)
Generic File Format Support. Should be included by clients of the file handling routines....
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
void astman_append(struct mansession *s, const char *fmt,...)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
int indicate_busy(struct ast_channel *chan, const char *data)
int indicate_congestion(struct ast_channel *chan, const char *data)
static int testtime_write(struct ast_channel *chan, const char *cmd, char *var, const char *value)
double ast_option_maxload
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
#define ast_hashtab_start_traversal(tab)
#define ast_hashtab_insert_safe(tab, obj)
unsigned int ast_hashtab_hash_int(const int num)
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,...
void ast_hashtab_destroy(struct ast_hashtab *tab, void(*objdestroyfunc)(void *obj))
This func will free the hash table and all its memory.
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
void ast_hashtab_end_traversal(struct ast_hashtab_iter *it)
end the traversal, free the iterator, unlock if necc.
#define ast_hashtab_insert_immediate(tab, obj)
Insert without checking.
int ast_hashtab_size(struct ast_hashtab *tab)
Returns the number of elements stored in the hashtab.
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.
void * ast_hashtab_lookup(struct ast_hashtab *tab, const void *obj)
Lookup this object in the hash table.
#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking)
Create the hashtable list.
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.
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...
void * ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj)
Looks up the object, removes the corresponding bucket.
unsigned int ast_hashtab_hash_string(const void *obj)
Hashes a string to a number.
static char prefix[MAX_PREFIX]
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
Configuration File Parser.
ast_control_frame_type
Internal control frame subtype field values.
#define DEBUG_ATLEAST(level)
#define ast_debug(level,...)
Log a DEBUG message.
ast_callid ast_read_threadstorage_callid(void)
extracts the callid from the thread
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
#define VERBOSITY_ATLEAST(level)
#define ast_verb(level,...)
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
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....
Asterisk locking-related definitions:
#define ast_rwlock_wrlock(a)
#define ast_cond_destroy(cond)
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
#define ast_rwlock_rdlock(a)
#define ast_mutex_unlock(a)
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
pthread_cond_t ast_cond_t
#define ast_rwlock_destroy(rwlock)
#define ast_rwlock_unlock(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_cond_signal(cond)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define EVENT_FLAG_REPORTING
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define EVENT_FLAG_CONFIG
Asterisk module definitions.
Asterisk file paths, configured in asterisk.conf.
void * ast_get_extension_app_data(struct ast_exten *e)
static void pbx_outgoing_state_callback(struct ast_dial *dial)
Internal dialing state callback which causes early media to trigger an answer.
static int hashtab_compare_extens(const void *ha_a, const void *ah_b)
const struct ast_sw * ast_context_switches_get(const struct ast_context *con, int idx)
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 unreference_cached_app(struct ast_app *app)
void __ast_context_destroy(struct ast_context *list, struct ast_hashtab *contexttab, struct ast_context *con, const char *registrar)
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.
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
Remove an ignorepat.
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.
static enum ast_control_frame_type pbx_dial_reason(enum ast_dial_result dial_result, int cause)
Attempt to convert disconnect cause to old originate reason.
int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids, const char *predial_callee)
static struct ast_exten * trie_find_next_match(struct match_char *node)
int ast_get_extension_priority(struct ast_exten *exten)
int ast_wrlock_contexts(void)
Write locks the context list.
static void pbx_destroy(struct ast_pbx *p)
void ast_context_set_autohints(struct ast_context *con, int enabled)
Enable or disable autohints support on a context.
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
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.
int ast_pbx_outgoing_app_predial(const char *type, struct ast_format_cap *cap, const char *addr, 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, const struct ast_assigned_ids *assignedids, const char *predial_callee)
int ast_get_extension_registrar_line(struct ast_exten *e)
Get line number of configuration file used by registrar to register this extension.
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 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, const char *registrar_file, int registrar_line, int lock_context)
Same as ast_add_extension2() but controls the context locking.
int ast_get_extension_matchcid(struct ast_exten *e)
const struct ast_include * ast_walk_context_includes(const struct ast_context *con, const struct ast_include *inc)
int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
static int acf_exception_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, const char *addr, 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, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and execute an application on the channel.
enum ast_pbx_result ast_pbx_run_args(struct ast_channel *c, struct ast_pbx_args *args)
Execute the PBX in the current thread.
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)
int ast_wrlock_context(struct ast_context *con)
Write locks a given context.
void wait_for_hangup(struct ast_channel *chan, const void *data)
static int hashtab_compare_exten_numbers(const void *ah_a, const void *ah_b)
static int ext_cmp(const char *left, const char *right)
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.
int ast_context_add_ignorepat(const char *context, const char *value, const char *registrar)
Add an ignorepat.
static void cli_match_char_tree(struct match_char *node, char *prefix, int fd)
const char * ast_get_extension_app(struct ast_exten *e)
static void destroy_pattern_tree(struct match_char *pattern_tree)
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
static int extenpatternmatchnew
static char * complete_show_dialplan_context(const char *line, const char *word, int pos, int state)
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, const char *registrar_file, int registrar_line)
Main interface to add extensions to the list for out context.
static void decrease_call_count(void)
int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
static void * pbx_outgoing_exec(void *data)
Internal function which dials an outgoing leg and sends it to a provided extension or application.
static const struct ast_datastore_info exception_store_info
static int ext_fluff_count(const char *exten)
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
static struct ast_hashtab * contexts_table
static unsigned int hashtab_hash_extens(const void *obj)
static int ext_cmp_exten_strlen(const char *str)
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 unsigned int hashtab_hash_priority(const void *obj)
const char * ast_get_extension_cidmatch(struct ast_exten *e)
static unsigned int ext_strncpy(char *dst, const char *src, size_t dst_size, int nofluff)
int ast_active_calls(void)
Retrieve the number of active calls.
#define STATUS_NO_EXTENSION
static ast_mutex_t maxcalllock
unsigned int ast_hashtab_hash_contexts(const void *obj)
struct ast_context * ast_context_find(const char *name)
Find a context.
static int ext_cmp_exten(const char *left, const char *right)
static void context_merge_incls_swits_igps_other_registrars(struct ast_context *new, struct ast_context *old, const char *registrar)
static int __ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, int async)
static int autofallthrough
static void exception_store_free(void *data)
static struct match_char * already_in_tree(struct match_char *current, char *pat, int is_pattern)
static char * handle_unset_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
static int compare_char(const void *a, const void *b)
int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
static void context_merge(struct ast_context **extcontexts, struct ast_hashtab *exttable, struct ast_context *context, const char *registrar)
static void show_dialplan_helper_extension_output(int fd, char *buf1, char *buf2, struct ast_exten *exten)
Writes CLI output of a single extension for show dialplan.
int pbx_parse_location(struct ast_channel *chan, char **contextp, char **extenp, char **prip, int *ipri, int *mode, char *rest)
Parses a dialplan location into context, extension, priority.
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension.
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
static void manager_dpsendack(struct mansession *s, const struct message *m)
Send ack once.
static void create_match_char_tree(struct ast_context *con)
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
static ast_mutex_t conlock
Lock for the ast_context list.
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)
int raise_exception(struct ast_channel *chan, const char *reason, int priority)
const char * ast_get_context_registrar(struct ast_context *c)
int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar)
Add a switch.
#define NEW_MATCHER_RECURSE
void pbx_set_overrideswitch(const char *newval)
int ast_unlock_context(struct ast_context *con)
static void unload_pbx(void)
static int increase_call_count(const struct ast_channel *c)
Increase call count for channel.
int ast_extension_close(const char *pattern, const char *data, int needmore)
const char * ast_get_extension_label(struct ast_exten *exten)
static struct ast_context * find_context_locked(const char *context)
lookup for a context with a given name,
int pbx_set_extenpatternmatchnew(int newval)
static void pbx_outgoing_destroy(void *obj)
Destructor for outgoing structure.
int ast_context_remove_include2(struct ast_context *con, const char *include, const char *registrar)
Locks context, remove included contexts, unlocks context. When we call this function,...
static char * overrideswitch
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
struct ast_context * ast_get_extension_context(struct ast_exten *exten)
static int ast_remove_hint(struct ast_exten *e)
void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context)
Run the h exten from the given context.
int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Add a context include.
int ast_context_remove_extension_callerid2(struct ast_context *con, const char *extension, int priority, const char *callerid, int matchcallerid, const char *registrar, int already_locked)
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.
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)
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_outgoing_attempt(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, 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, int early_media, const struct ast_assigned_ids *assignedids, const char *predial_callee)
static void print_ext(struct ast_exten *e, char *buf, int buflen)
helper function to print an extension
static char * handle_debug_dialplan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Send ack once.
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...
int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar)
Remove a switch.
#define MAX_EXTENBUF_SIZE
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
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[])
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string, int async)
int ast_rdlock_contexts(void)
Read locks the context list.
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
#define STATUS_NO_CONTEXT
static int matchcid(const char *cidpattern, const char *callerid)
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.
static struct match_char * add_exten_to_pattern_tree(struct ast_context *con, struct ast_exten *e1, int findonly)
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
int ast_context_ignorepats_count(const struct ast_context *con)
int ast_extension_cmp(const char *a, const char *b)
Determine if one extension should match before another.
const struct ast_include * ast_context_includes_get(const struct ast_context *con, int idx)
static struct ast_custom_function testtime_function
static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
static int hashtab_compare_exten_labels(const void *ah_a, const void *ah_b)
static struct ast_context * contexts
const struct ast_sw * ast_walk_context_switches(const struct ast_context *con, const struct ast_sw *sw)
static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, struct ast_pbx_args *args)
static const char * get_pattern_node(struct pattern_node *node, const char *src, int pattern, const char *extenbuf)
#define STATUS_NO_PRIORITY
const char * ast_get_context_name(struct ast_context *con)
int ast_get_extension_data(char *buf, int bufsize, struct ast_channel *c, const char *context, const char *exten, int priority)
Fill a string buffer with the data at a dialplan extension.
static const char * candidate_exten_advance(const char *str)
static struct ast_exten * ast_hint_extension(struct ast_channel *c, const char *context, const char *exten)
@ AST_CONTEXT_SCOPE_GLOBAL
@ AST_CONTEXT_SCOPE_LOCAL
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)
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
Get hint for channel.
static struct ast_cli_entry pbx_cli[]
int pbx_checkcondition(const char *condition)
Evaluate a condition.
static int show_dialplan_helper(int fd, const char *context, const char *exten, struct dialplan_counters *dpc, const struct ast_include *rinclude, int includecount, const char *includes[])
int ast_context_remove_include(const char *context, const char *include, const char *registrar)
Remove included contexts. This function locks contexts list by &conlist, search for the right context...
const struct ast_ignorepat * ast_walk_context_ignorepats(const struct ast_context *con, const struct ast_ignorepat *ip)
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.
static void pbx_shutdown(void)
const struct ast_ignorepat * ast_context_ignorepats_get(const struct ast_context *con, int idx)
static int ext_cmp_pattern(const char *left, const char *right)
static char * handle_set_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
int ast_add_extension2_nolock(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, const char *registrar_file, int registrar_line)
Same as ast_add_extension2, but assumes you have already locked context.
static char * handle_show_dialplan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int ast_change_hint(struct ast_exten *oe, struct ast_exten *ne)
Change hint for an extension.
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.
static void destroy_exten(struct ast_exten *e)
int ast_context_add_switch2(struct ast_context *con, const char *value, const char *data, int eval, const char *registrar)
Adds a switch (first param is a ast_context)
static struct ast_context * find_context(const char *context)
lookup for a context with a given name,
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 ast_add_hint(struct ast_exten *e)
static unsigned int hashtab_hash_labels(const void *obj)
int ast_unlock_contexts(void)
Unlocks contexts.
static struct ast_custom_function exception_function
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
int ast_context_switches_count(const struct ast_context *con)
#define NEW_MATCHER_CHK_MATCH
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
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)
Get hint for channel.
int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcallerid, const char *registrar)
int pbx_set_autofallthrough(int newval)
static int context_promote(struct ast_context *context)
int ast_context_includes_count(const struct ast_context *con)
static int collect_digits(struct ast_channel *c, int waittime, char *buf, int buflen, int pos)
collect digits from the channel into the buffer.
static void * pbx_thread(void *data)
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, const struct ast_include *rinclude, int includecount, const char *includes[])
Show dialplan extensions XXX this function is similar but not exactly the same as the CLI's show dial...
int ast_async_goto_by_name(const char *channame, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
static struct ast_exten * get_canmatch_exten(struct match_char *node)
const char * ast_get_extension_name(struct ast_exten *exten)
static void insert_in_next_chars_alt_char_list(struct match_char **parent_ptr, struct match_char *node)
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
const char * ast_get_extension_registrar_file(struct ast_exten *e)
Get name of configuration file used by registrar to register this extension.
const char * ast_get_extension_registrar(struct ast_exten *e)
static void __ast_internal_context_destroy(struct ast_context *con)
static int ext_cmp_exten_partial(const char *left, const char *right)
#define INC_DST_OVERFLOW_CHECK
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
Core PBX routines and definitions.
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
ast_pbx_result
The result codes when starting the PBX on a channel with ast_pbx_start.
int ast_thread_inhibit_escalations_swap(int inhibit)
Swap the current thread escalation inhibit setting.
@ AST_OUTGOING_WAIT_COMPLETE
enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate)
Map devstate to an extension state.
const char * ast_get_switch_name(const struct ast_sw *sw)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
const char * ast_get_switch_data(const struct ast_sw *sw)
#define AST_PBX_INCOMPLETE
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
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.
const char * ast_get_include_name(const struct ast_include *include)
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
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.
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
#define AST_PBX_GOTO_FAILED
struct ast_app * pbx_findapp(const char *app)
Look up an application.
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
int ast_get_switch_eval(const struct ast_sw *sw)
int ast_thread_inhibit_escalations(void)
Inhibit (in the current thread) the execution of dialplan functions which cause privilege escalations...
const char * ast_get_include_registrar(const struct ast_include *i)
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
const char * ast_get_switch_registrar(const struct ast_sw *sw)
const char * app_name(struct ast_app *app)
static struct ast_context * local_contexts
void ignorepat_free(struct ast_ignorepat *ip)
struct ast_ignorepat * ignorepat_alloc(const char *value, const char *registrar)
void include_free(struct ast_include *inc)
int include_valid(const struct ast_include *inc)
struct ast_include * include_alloc(const char *value, const char *registrar)
const char * include_rname(const struct ast_include *inc)
Private include file for pbx.
struct ast_switch * pbx_findswitch(const char *sw)
struct ast_sw * sw_alloc(const char *value, const char *data, int eval, const char *registrar)
void sw_free(struct ast_sw *sw)
Say numbers and dates (maybe words one day too)
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
#define AST_STRING_FIELD(name)
Declare a string field.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_alloca(init_len)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
size_t attribute_pure ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
ast_app: A registered application
Structure to pass both assignedid values to channel drivers.
Main Channel structure associated with a channel.
char exten[AST_MAX_EXTENSION]
struct ast_party_dialed dialed
Dialed/Called information.
char context[AST_MAX_CONTEXT]
descriptor for a cli entry.
ast_context: An extension context
enum ast_context_scope scope
struct match_char * pattern_tree
struct ast_ignorepats ignorepats
struct ast_includes includes
struct ast_context * next
struct ast_hashtab * root_table
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
You shouldn't care about the contents of this struct.
Main dialing structure. Contains global options, channels being dialed, and more!
ast_exten: An extension The dialplan is saved as a linked list with each context having it's own link...
const char * cidmatch_display
struct ast_hashtab * peer_label_table
struct ast_hashtab * peer_table
const char * registrar_file
struct ast_app * cached_app
struct ast_context * parent
Data structure associated with a single frame of data.
union ast_frame::@237 data
an iterator for traversing the buckets
ast_ignorepat: Ignore patterns in dial plan
struct ast_ignorepat * next
ast_include: include= support in extensions.conf
struct ast_include * next
Connected Line/Party information.
Options for ast_pbx_run()
Support for dynamic strings.
ast_sw: Switch statement in extensions.conf
Structure for variables, used for configurations and for channel variables.
Counters for the show dialplan manager command.
structure to hold extensions
In case you didn't read that giant block of text above the mansession_session struct,...
match_char: forms a syntax tree for quick matching of extension patterns
struct match_char * alt_char
struct match_char * next_char
const ast_string_field app
const ast_string_field context
const ast_string_field exten
const ast_string_field context
const ast_string_field exten
const ast_string_field reason
char * incstack[AST_PBX_MAX_STACK]
const char * foundcontext
Structure which contains information about an outgoing dial.
int dial_res
Result of the dial operation when dialed is set.
ast_cond_t cond
Condition for synchronous dialing.
char app[AST_MAX_APP]
Application to execute.
unsigned int in_separate_thread
Set if we've spawned a thread to do our work.
struct ast_dial * dial
Dialing structure being used.
unsigned int dialed
Set when dialing is completed.
char exten[AST_MAX_EXTENSION]
Dialplan extension.
char context[AST_MAX_CONTEXT]
Dialplan context.
int priority
Dialplan priority.
char * appdata
Application data to pass to application.
struct ast_exten * canmatch_exten
Handy terminal functions for vt* terms.
#define COLORIZE(fg, bg, str)
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
static struct aco_type item
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Time-related functions and macros.
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int error(const char *format,...)
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_set2_flag(p, value, flag)
#define ast_clear_flag(p, flag)
#define ast_pthread_create_detached(a, b, c, d)
#define ast_set_flag(p, flag)
Vector container support.
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)
Remove an element from a vector by index while maintaining order.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Asterisk XML Documentation API.