37 #if defined(HAVE_SYSINFO) 38 #include <sys/sysinfo.h> 41 #include <sys/loadavg.h> 214 #define EXT_DATA_SIZE 256 216 #define EXT_DATA_SIZE 8192 219 #define SWITCH_DATA_LENGTH 256 222 #define VAR_SOFTTRAN 2 223 #define VAR_HARDTRAN 3 290 struct ast_includes includes;
291 struct ast_ignorepats ignorepats;
351 #define HINTDEVICE_DATA_LENGTH 16 356 #define HASH_EXTENHINT_SIZE 17 358 #define HASH_EXTENHINT_SIZE 563 425 const char *right_key = arg;
433 cmp = strcasecmp(left->
hintdevice, right_key);
440 cmp = strncmp(left->
hintdevice, right_key, strlen(right_key));
478 const char *right_key = arg;
486 cmp = strcasecmp(left->
context, right_key);
493 cmp = strncmp(left->
context, right_key, strlen(right_key));
510 if (!strcasecmp(candidate->
hintdevice, device)
511 && candidate->
hint == hint) {
560 if (!hint || !devicelist) {
571 while ((cur =
strsep(&parse,
"&,"))) {
574 devicelength = strlen(cur);
585 "allocating a hintdevice structure");
598 ao2_t_link(hintdevices, device,
"Linking device into hintdevice container.");
599 ao2_t_ref(device, -1,
"hintdevice is linked so we can unref");
630 static int matchcid(
const char *cidpattern,
const char *callerid);
635 struct match_char *tree,
int length,
int spec,
const char *callerid,
654 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
655 const char *application,
void *data,
void (*
datad)(
void *),
661 static unsigned int ext_strncpy(
char *dst,
const char *src,
size_t dst_size,
int nofluff);
676 const unsigned char *ac =
a;
677 const unsigned char *
bc =
b;
819 void check_contexts_trouble(
void);
821 void check_contexts_trouble(
void)
827 int check_contexts(
char *,
int);
829 int check_contexts(
char *
file,
int line )
840 if (!contexts_table) {
847 for(c2=contexts;c2;c2=c2->
next) {
854 ast_log(
LOG_NOTICE,
"Called from: %s:%d: Could not find the %s context in the linked list\n", file, line, c1->
name);
855 check_contexts_trouble();
859 for(c2=contexts;c2;c2=c2->
next) {
862 ast_log(
LOG_NOTICE,
"Called from: %s:%d: Could not find the %s context in the hashtab\n", file, line, c2->
name);
863 check_contexts_trouble();
870 for(c2=contexts;c2;c2=c2->
next) {
878 char dummy_name[1024];
879 ex.exten = dummy_name;
887 "the exten %s (CID match: %s) but it is not in its root_table\n",
891 "the exten %s but it is not in its root_table\n",
892 file, line, c2->
name, dummy_name);
894 check_contexts_trouble();
914 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);
915 check_contexts_trouble();
927 for(e1 = c2->
root; e1; e1 = e1->
next) {
929 for(e2=e1;e2;e2=e2->
peer) {
932 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 );
933 check_contexts_trouble();
937 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 );
938 check_contexts_trouble();
943 check_contexts_trouble();
948 check_contexts_trouble();
955 check_contexts_trouble();
967 for(e3=e1;e3;e3=e3->
peer) {
975 check_contexts_trouble();
1075 #ifdef NEED_DEBUG_HERE 1088 if (node && node->
exten)
1089 snprintf(extenstr,
sizeof(extenstr),
"(%p)", node->
exten);
1091 if (strlen(node->
x) > 1) {
1107 log_match_char_tree(node->
alt_char, prefix);
1119 snprintf(extenstr,
sizeof(extenstr),
"(%p)", node->
exten);
1122 if (strlen(node->
x) > 1) {
1123 ast_cli(fd,
"%s[%s]:%c:%c:%d:%s%s%s\n", prefix, node->
x, node->
is_pattern ?
'Y' :
'N',
1146 for (node2 = node; node2; node2 = node2->
next_char) {
1148 #ifdef NEED_DEBUG_HERE 1151 return node2->
exten;
1154 #ifdef NEED_DEBUG_HERE 1166 if (node && node->
x[0] ==
'.' && !node->
x[1]) {
1170 if (node && node->
x[0] ==
'!' && !node->
x[1]) {
1188 for (m4 = m3; m4; m4 = m4->
alt_char) {
1222 while (*str ==
'-') {
1228 #define MORE(s) (*candidate_exten_advance(s)) 1229 #define ADVANCE(s) candidate_exten_advance(s) 1237 ast_log(
LOG_NOTICE,
"new_find_extension called with %s on (sub)tree %s action=%s\n", str, tree->
x, action2str(action));
1239 ast_log(
LOG_NOTICE,
"new_find_extension called with %s on (sub)tree NULL action=%s\n", str, action2str(action));
1241 for (p = tree; p; p = p->
alt_char) {
1243 if (p->
x[0] ==
'N') {
1244 if (p->
x[1] == 0 && *str >=
'2' && *str <=
'9' ) {
1245 #define NEW_MATCHER_CHK_MATCH \ 1246 if (p->exten && !MORE(str)) { \ 1247 if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { \ 1248 update_scoreboard(score, length + 1, spec + p->specificity, p->exten, 0, callerid, p->deleted, p); \ 1249 if (!p->deleted) { \ 1250 if (action == E_FINDLABEL) { \ 1251 if (ast_hashtab_lookup(score->exten->peer_label_table, &pattern)) { \ 1252 ast_debug(4, "Found label in preferred extension\n"); \ 1256 ast_debug(4, "returning an exact match-- first found-- %s\n", p->exten->name); \ 1263 #define NEW_MATCHER_RECURSE \ 1264 if (p->next_char && (MORE(str) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0) \ 1265 || p->next_char->x[0] == '!')) { \ 1266 if (MORE(str) || p->next_char->x[0] == '!') { \ 1267 new_find_extension(ADVANCE(str), score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \ 1268 if (score->exten) { \ 1269 ast_debug(4 ,"returning an exact match-- %s\n", score->exten->name); \ 1273 new_find_extension("/", score, p->next_char, length + 1, spec + p->specificity, callerid, label, action); \ 1274 if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) { \ 1275 ast_debug(4,"returning a (can/more) match--- %s\n", score->exten ? score->exten->name : \ 1280 } else if ((p->next_char || action == E_CANMATCH) && !MORE(str)) { \ 1281 score->canmatch = 1; \ 1282 score->canmatch_exten = get_canmatch_exten(p); \ 1283 if (action == E_CANMATCH || action == E_MATCHMORE) { \ 1284 ast_debug(4, "returning a canmatch/matchmore--- str=%s\n", str); \ 1292 }
else if (p->
x[0] ==
'Z') {
1293 if (p->
x[1] == 0 && *str >=
'1' && *str <=
'9' ) {
1297 }
else if (p->
x[0] ==
'X') {
1298 if (p->
x[1] == 0 && *str >=
'0' && *str <=
'9' ) {
1302 }
else if (p->
x[0] ==
'.' && p->
x[1] == 0) {
1305 const char *str2 =
str;
1306 while (*str2 && *str2 !=
'/') {
1310 if (p->
exten && *str2 !=
'/') {
1313 ast_debug(4,
"return because scoreboard has a match with '/'--- %s\n",
1321 ast_debug(4,
"return because scoreboard has exact match OR " 1322 "CANMATCH/MATCHMORE & canmatch set--- %s\n",
1327 }
else if (p->
x[0] ==
'!' && p->
x[1] == 0) {
1330 const char *str2 =
str;
1331 while (*str2 && *str2 !=
'/') {
1335 if (p->
exten && *str2 !=
'/') {
1338 ast_debug(4,
"return because scoreboard has a '!' match--- %s\n",
1346 ast_debug(4,
"return because scoreboard has exact match OR " 1347 "CANMATCH/MATCHMORE & canmatch set with '/' and '!'--- %s\n",
1352 }
else if (p->
x[0] ==
'/' && p->
x[1] == 0) {
1354 if (p->
next_char && callerid && *callerid) {
1357 ast_debug(4,
"return because scoreboard has exact match OR " 1358 "CANMATCH/MATCHMORE & canmatch set with '/'--- %s\n",
1363 }
else if (strchr(p->
x, *str)) {
1364 ast_debug(4,
"Nothing strange about this match\n");
1368 }
else if (strchr(p->
x, *str)) {
1369 ast_debug(4,
"Nothing strange about this match\n");
1374 ast_debug(4,
"return at end of func\n");
1405 for (t = current; t; t = t->
alt_char) {
1406 if (is_pattern == t->
is_pattern && !strcmp(pat, t->
x)) {
1424 if (!(*parent_ptr)) {
1429 if ((*parent_ptr)->specificity > node->
specificity) {
1436 lcurr = *parent_ptr;
1463 if (!(m =
ast_calloc(1,
sizeof(*m) + strlen(pattern->
buf)))) {
1470 strcpy(m->
x, pattern->
buf);
1475 if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'N') {
1477 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'Z') {
1479 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'X') {
1481 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'.') {
1483 }
else if (pattern->
specif == 1 && is_pattern && pattern->
buf[0] ==
'!') {
1515 #define INC_DST_OVERFLOW_CHECK \ 1517 if (dst - node->buf < sizeof(node->buf) - 1) { \ 1525 node->
buf[0] =
'\0';
1527 if (*src ==
'[' && pattern) {
1528 char *dst = node->
buf;
1529 const char *src_next;
1539 if (*src ==
'[' || *src ==
'\\' || *src ==
'-' || *src ==
']') {
1543 }
else if (*src ==
'-') {
1544 unsigned char first;
1548 first = *(src_next - 1);
1557 if (node->
buf[0] && last) {
1559 while (++first <= last) {
1572 }
else if (*src ==
'\0') {
1574 "A matching ']' was not found for '[' in exten pattern '%s'\n",
1577 }
else if (*src ==
']') {
1590 "Expanded character set too large to deal with in exten pattern '%s'. Ignoring character set.\n",
1592 node->
buf[0] =
'\0';
1597 length = strlen(node->
buf);
1601 node->
buf[0] =
'\0';
1608 src_next = node->
buf;
1609 while (*src_next++) {
1610 if (*dst != *src_next) {
1615 length = strlen(node->
buf);
1617 node->
specif = length | (
unsigned char) node->
buf[0];
1619 }
else if (*src ==
'-') {
1629 node->
buf[0] = *++src;
1630 if (!node->
buf[0]) {
1634 node->
buf[0] = *src;
1637 if (node->
buf[0] ==
'n') {
1639 }
else if (node->
buf[0] ==
'x') {
1641 }
else if (node->
buf[0] ==
'z') {
1646 node->
buf[1] =
'\0';
1654 #undef INC_DST_OVERFLOW_CHECK 1671 if (
sizeof(extenbuf) < strlen(e1->
exten) + strlen(e1->
cidmatch) + 2) {
1673 "The pattern %s/%s is too big to deal with: it will be ignored! Disaster!\n",
1683 ast_debug(1,
"Adding exten %s to tree\n", extenbuf);
1696 for (; pat_node[idx_cur].
buf[0]; idx_cur = idx_next) {
1697 idx_next = (idx_cur + 1) %
ARRAY_LEN(pat_node);
1704 if (!pat_node[idx_next].buf[0]) {
1738 if (!pat_node[idx_next].buf[0]) {
1739 if (m2 && m2->
exten) {
1761 int biggest_bucket, resizes, numobjs, numbucks;
1763 ast_debug(1,
"Creating Extension Trie for context %s(%p)\n", con->
name, con);
1765 ast_debug(1,
"This tree has %d objects in %d bucket lists, longest list=%d objects, and has resized %d times\n",
1766 numobjs, numbucks, biggest_bucket, resizes);
1773 ast_log(
LOG_ERROR,
"Attempt to create extension with no extension name.\n");
1791 pattern_tree->
exten = 0;
1810 while (*str ==
'-') {
1839 while (*left ==
'-') {
1842 while (*right ==
'-') {
1855 cmp = *left - *right;
1882 while (*left ==
'-') {
1885 while (*right ==
'-') {
1889 cmp = *left - *right;
1989 return 0x0800 |
'2';
1996 return 0x0A00 |
'0';
2003 return 0x0900 |
'1';
2023 end = strchr(*p,
']');
2032 for (; *p <
end; ++*p) {
2037 if (*p + 2 < end && (*p)[1] ==
'-') {
2046 for (; c1 <= c2; ++c1) {
2055 if (!(bitwise[c1 / BITS_PER] & mask)) {
2064 return count | cmin;
2085 unsigned char left_bitwise[32] = { 0, };
2086 unsigned char right_bitwise[32] = { 0, };
2090 cmp = left_pos - right_pos;
2099 cmp = memcmp(right_bitwise, left_bitwise,
ARRAY_LEN(left_bitwise));
2126 static int ext_cmp(
const char *left,
const char *right)
2129 if (left[0] !=
'_') {
2130 if (right[0] ==
'_') {
2136 if (right[0] !=
'_') {
2152 if (*exten !=
'_') {
2155 if (*exten ==
'-') {
2166 if (*exten ==
'-') {
2168 }
else if (*exten ==
'[') {
2170 exten = strchr(exten,
']');
2213 #ifdef NEED_DEBUG_HERE 2214 ast_log(
LOG_NOTICE,
"match core: pat: '%s', dat: '%s', mode=%d\n", pattern, data, (
int)mode);
2217 if (pattern[0] !=
'_') {
2222 #ifdef NEED_DEBUG_HERE 2229 #ifdef NEED_DEBUG_HERE 2230 ast_log(
LOG_NOTICE,
"return (!ext_cmp_exten(%s,%s) when mode== E_MATCH)\n", pattern, data);
2235 #ifdef NEED_DEBUG_HERE 2236 ast_log(
LOG_NOTICE,
"return (mode(%d) == E_MATCHMORE ? lp(%d) > ld(%d) : 1)\n", mode, lp, ld);
2240 #ifdef NEED_DEBUG_HERE 2241 ast_log(
LOG_NOTICE,
"return (0) when ld(%d) > 0 && pattern(%s) != data(%s)\n", ld, pattern, data);
2246 if (mode ==
E_MATCH && data[0] ==
'_') {
2256 #ifdef NEED_DEBUG_HERE 2257 ast_log(
LOG_NOTICE,
"Comparing as patterns first. pattern:%s data:%s\n", pattern, data);
2260 #ifdef NEED_DEBUG_HERE 2276 while (*data ==
'-') {
2279 while (*pattern ==
'-') {
2282 if (!*data || !*pattern || *pattern ==
'/') {
2289 end = strchr(pattern,
']');
2294 if (pattern == end) {
2299 for (; pattern <
end; ++pattern) {
2300 if (pattern+2 < end && pattern[1] ==
'-') {
2301 if (*data >= pattern[0] && *data <= pattern[2])
2307 }
else if (*data == pattern[0])
2310 if (pattern >= end) {
2311 #ifdef NEED_DEBUG_HERE 2320 if (*data < '2' || *data >
'9') {
2321 #ifdef NEED_DEBUG_HERE 2329 if (*data < '0' || *data >
'9') {
2330 #ifdef NEED_DEBUG_HERE 2338 if (*data < '1' || *data >
'9') {
2339 #ifdef NEED_DEBUG_HERE 2346 #ifdef NEED_DEBUG_HERE 2351 #ifdef NEED_DEBUG_HERE 2356 if (*data != *pattern) {
2357 #ifdef NEED_DEBUG_HERE 2358 ast_log(
LOG_NOTICE,
"return (0) when *data(%c) != *pattern(%c)\n", *data, *pattern);
2368 #ifdef NEED_DEBUG_HERE 2378 if (*pattern ==
'\0' || *pattern ==
'/') {
2379 #ifdef NEED_DEBUG_HERE 2383 }
else if (*pattern ==
'!') {
2384 #ifdef NEED_DEBUG_HERE 2389 #ifdef NEED_DEBUG_HERE 2392 return (mode ==
E_MATCH) ? 0 : 1;
2403 static int prof_id = -2;
2404 if (prof_id == -2) {
2433 struct ast_includes includes;
2434 struct ast_ignorepats ignorepats;
2435 struct ast_sws alts;
2452 if (contexts_table) {
2458 if (!strcasecmp(name, tmp->
name)) {
2467 #define STATUS_NO_CONTEXT 1 2468 #define STATUS_NO_EXTENSION 2 2469 #define STATUS_NO_PRIORITY 3 2470 #define STATUS_NO_LABEL 4 2471 #define STATUS_SUCCESS 5 2473 static int matchcid(
const char *cidpattern,
const char *callerid)
2487 const char *context,
const char *
exten,
int priority,
2488 const char *label,
const char *callerid,
enum ext_match_t action)
2500 #ifdef NEED_DEBUG_HERE 2501 ast_log(
LOG_NOTICE,
"Looking for cont/ext/prio/label/action = %s/%s/%d/%s/%d\n", context, exten, priority, label, (
int) action);
2516 for (x = 0; x < q->
stacklen; x++) {
2517 if (!strcasecmp(q->
incstack[x], context))
2542 ast_debug(1,
"Tree Created in context %s:\n", context);
2567 if (osw && strchr(osw,
'$')) {
2595 res = aswf(chan, context, exten, priority, callerid, datap);
2610 if (extenpatternmatchnew) {
2612 eroot = score.
exten;
2618 #ifdef NEED_DEBUG_HERE 2626 #ifdef NEED_DEBUG_HERE 2636 #ifdef NEED_DEBUG_HERE 2641 #ifdef NEED_DEBUG_HERE 2646 #ifdef NEED_DEBUG_HERE 2653 #ifdef NEED_DEBUG_HERE 2674 #ifdef NEED_DEBUG_HERE 2688 if (!match || (eroot->matchcid && !
matchcid(eroot->cidmatch, callerid)))
2752 res = aswf(chan, context, exten, priority, callerid, datap);
2771 #ifdef NEED_DEBUG_HERE 2791 .
type =
"EXCEPTION",
2819 ds->
data = exception;
2822 exception = ds->
data;
2836 if (!ds || !ds->
data)
2838 exception = ds->
data;
2839 if (!strcasecmp(data,
"REASON"))
2841 else if (!strcasecmp(data,
"CONTEXT"))
2843 else if (!strncasecmp(data,
"EXTEN", 5))
2845 else if (!strcasecmp(data,
"PRIORITY"))
2846 snprintf(buf, buflen,
"%d", exception->
priority);
2853 .
name =
"EXCEPTION",
2876 const char *context,
const char *
exten,
int priority,
2877 const char *label,
const char *callerid,
enum ext_match_t action,
int *found,
int combined_find_spawn)
2881 char *substitute =
NULL;
2889 context = con->
name;
2895 e =
pbx_find_extension(c, con, &q, context, exten, priority, label, callerid, action);
2899 if (matching_action) {
2917 if ((!(tmp = strchr(e->
data,
'$'))) || (!strstr(tmp,
"${") && !strstr(tmp,
"$["))) {
2927 ast_log(
LOG_WARNING,
"No application '%s' for extension (%s, %s, %d)\n", e->
app, context, exten, priority);
2941 exten, context, priority,
2953 if (matching_action) {
2967 if (!matching_action && !combined_find_spawn)
2971 if (!matching_action && !combined_find_spawn)
2975 if (!matching_action && !combined_find_spawn)
2976 ast_log(
LOG_NOTICE,
"No such priority %d in extension '%s' in context '%s'\n", priority, exten,
S_OR(context,
""));
2979 if (context && !combined_find_spawn)
2980 ast_log(
LOG_NOTICE,
"No such label '%s' in extension '%s' in context '%s'\n", label, exten,
S_OR(context,
""));
2986 return (matching_action) ? 0 : -1;
3042 if ((tmp = strrchr(copy,
','))) {
3061 if ((tmp = strrchr(copy,
','))) {
3091 while ((cur =
strsep(&rest,
"&"))) {
3095 if (device_state_info) {
3117 if (!e || !hint_app) {
3150 if (e->
exten[0] ==
'_') {
3182 if (device_state_info) {
3187 if (ret < 0 && container) {
3192 if (device_state_info) {
3203 char *presence_provider;
3206 if (!e || !hint_app) {
3234 if (e->
exten[0] ==
'_') {
3251 const char *context,
3284 res = cb(context, exten, &info, data);
3310 struct timeval chantime = {0, };
3337 snprintf(match,
sizeof(match),
"%s-", info->
device_name);
3377 int first_extended_cb_call = 1;
3394 sizeof(context_name));
3396 sizeof(exten_name));
3444 if (state_cb->
extended && first_extended_cb_call) {
3446 first_extended_cb_call = 0;
3449 if (state_cb->
extended || !same_state) {
3485 sizeof(context_name));
3487 sizeof(exten_name));
3558 char *presence_subtype =
NULL;
3559 char *presence_message =
NULL;
3563 hint->
exten, &presence_subtype, &presence_message);
3567 .subtype = presence_subtype,
3568 .message = presence_message
3593 char *virtual_device;
3630 if (dev_state->
eid) {
3655 "find devices in container");
3674 virtual_device = strchr(type,
':');
3675 device_name = strchr(type,
'/');
3676 if (virtual_device && (!device_name || (virtual_device < device_name))) {
3677 device_name = virtual_device;
3685 *device_name++ =
'\0';
3738 if (!context && !exten) {
3762 if (!context || !exten)
3775 if (e->
exten[0] ==
'_') {
3782 if (!e || e->
exten[0] ==
'_') {
3804 }
while (
id == -1 ||
id == 0);
3928 if (!hint_remove_message_type()) {
3987 char *subtype =
NULL;
4011 hint_new->
exten = e;
4012 if (strstr(e->
app,
"${") && e->
exten[0] ==
'_') {
4029 hint_found =
ao2_find(hints, e, 0);
4034 ast_debug(2,
"HINTS: Not re-adding existing hint %s: %s\n",
4040 ast_debug(2,
"HINTS: Adding hint %s: %s\n",
4050 if (!(strstr(e->
app,
"${") && e->
exten[0] ==
'_')) {
4078 if (!hint_change_message_type()) {
4249 if (found && spawn_error) {
4251 ast_debug(1,
"Spawn extension (%s,%s,%d) exited non-zero on '%s'\n",
4254 ast_verb(2,
"Spawn extension (%s, %s, %d) exited non-zero on '%s'\n",
4300 if (pos < buflen - 1) {
4370 char dst_exten[256];
4377 dst_exten[pos] =
'\0';
4415 ast_debug(1,
"Extension %s, priority %d returned normally even though call was hung up\n",
4422 if (strchr(
"0123456789ABCDEF*#", res)) {
4423 ast_debug(1,
"Oooh, got something to jump out with ('%c')!\n", res);
4425 dst_exten[pos++] = digit = res;
4426 dst_exten[pos] =
'\0';
4438 pos = strlen(dst_exten);
4502 ast_verb(3,
"Channel '%s' sent to invalid extension: context,exten,priority=%s,%s,%d\n",
4510 ast_log(
LOG_WARNING,
"Channel '%s' sent to invalid extension but no invalid handler: context,exten,priority=%s,%s,%d\n",
4522 else if (!autofallthrough)
4529 if (!strcasecmp(status,
"CONGESTION"))
4531 else if (!strcasecmp(status,
"CHANUNAVAIL"))
4533 else if (!strcasecmp(status,
"BUSY"))
4539 if (
collect_digits(c, waittime, dst_exten,
sizeof(dst_exten), pos))
4561 "Invalid extension '%s', but no rule 'i' or 'e' in context '%s'\n",
4577 "Timeout, but no rule 't' or 'e' in context '%s'\n",
4587 if (!found && !error) {
4625 #if defined(HAVE_SYSINFO) 4626 struct sysinfo sys_info;
4643 #if defined(HAVE_SYSINFO) 4646 if (!sysinfo(&sys_info)) {
4649 uint64_t curfreemem = sys_info.freeram + sys_info.bufferram;
4650 curfreemem *= sys_info.mem_unit;
4651 curfreemem /= 1024 * 1024;
4653 ast_log(
LOG_WARNING,
"Available system memory (~%" PRIu64
"MB) is below the configured low watermark (%ldMB)\n",
4777 autofallthrough = newval;
4784 extenpatternmatchnew = newval;
4790 if (overrideswitch) {
4796 overrideswitch =
NULL;
4965 matchcallerid, registrar, 0);
4992 char dummy_name[1024];
4993 char dummy_cid[1024];
4998 if (!already_locked)
5002 ast_verb(3,
"Removing %s/%s/%d%s%s from trees, registrar=%s\n", con->
name, extension, priority, matchcallerid ?
"/" :
"", matchcallerid ? callerid :
"", registrar);
5004 #ifdef CONTEXT_DEBUG 5005 check_contexts(__FILE__, __LINE__);
5008 ex.
exten = dummy_name;
5009 ext_strncpy(dummy_name, extension,
sizeof(dummy_name), 1);
5013 ext_strncpy(dummy_cid, callerid,
sizeof(dummy_cid), 1);
5019 if (priority == 0) {
5022 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);
5030 ast_log(
LOG_WARNING,
"Trying to delete an exten from a context, but the pattern tree node returned isn't a full extension\n");
5037 if (exten2->
label) {
5041 "from the peer_label_table of context %s, extension %s!\n",
5049 "peer_table of context %s, extension %s!\n",
5050 priority, con->
name, exten2->
name);
5052 if (exten2 == exten && exten2->
peer) {
5062 "context root_table (%s) (priority %d)\n",
5074 ast_log(
LOG_ERROR,
"Could not find priority %d of exten %s in context %s!\n",
5081 extension, con->
name);
5091 for (exten = con->
root; exten; prev_exten = exten, exten = exten->
next) {
5101 if (!already_locked)
5107 for (peer = exten, next_peer = exten->
peer ? exten->
peer : exten->
next;
5110 peer = next_peer, next_peer = next_peer ? (next_peer->
peer ? next_peer->
peer : next_peer->
next) :
NULL) {
5112 if ((priority == 0 || peer->
priority == priority) &&
5113 (!registrar || !strcmp(peer->
registrar, registrar) )) {
5117 if (!previous_peer) {
5132 con->
root = next_node;
5134 prev_exten->
next = next_node;
5147 previous_peer =
peer;
5150 if (!already_locked)
5152 return found ? 0 : -1;
5215 e->
command =
"core show hints";
5217 "Usage: core show hints\n" 5218 " List registered hints.\n" 5219 " Hint details are shown in five columns. In order from left to right, they are:\n" 5220 " 1. Hint extension URI.\n" 5221 " 2. List of mapped device or presence state identifiers.\n" 5222 " 3. Current extension state. The aggregate of mapped device states.\n" 5223 " 4. Current presence state for the mapped presence state provider.\n" 5224 " 5. Watchers - number of subscriptions and other entities watching this hint.\n";
5231 ast_cli(a->
fd,
"There are no registered dialplan hints\n");
5235 ast_cli(a->
fd,
"\n -= Registered Asterisk Dial Plan Hints =-\n");
5246 snprintf(buf,
sizeof(buf),
"%s@%s",
5250 ast_cli(a->
fd,
"%-20.20s: %-20.20s State:%-15.15s Presence:%-15.15s Watchers %2d\n",
5263 ast_cli(a->
fd,
"- %d hints registered\n", num);
5279 wordlen = strlen(word);
5308 int num = 0, extenlen;
5314 e->
command =
"core show hint";
5316 "Usage: core show hint <exten>\n" 5317 " List registered hint.\n" 5318 " Hint details are shown in five columns. In order from left to right, they are:\n" 5319 " 1. Hint extension URI.\n" 5320 " 2. List of mapped device or presence state identifiers.\n" 5321 " 3. Current extension state. The aggregate of mapped device states.\n" 5322 " 4. Current presence state for the mapped presence state provider.\n" 5323 " 5. Watchers - number of subscriptions and other entities watching this hint.\n";
5333 ast_cli(a->
fd,
"There are no registered dialplan hints\n");
5337 extenlen = strlen(a->
argv[3]);
5348 sprintf(buf,
"%s@%s",
5351 ast_cli(a->
fd,
"%-20.20s: %-20.20s State:%-15.15s Presence:%-15.15s Watchers %2d\n",
5363 ast_cli(a->
fd,
"No hints matching extension %s\n", a->
argv[3]);
5365 ast_cli(a->
fd,
"%d hint%s matching extension %s\n", num, (num!=1 ?
"s":
""), a->
argv[3]);
5389 const int blocks_max = 50000;
5390 long long int allocated = 0;
5403 e->
command =
"core eat memory";
5405 "Usage: core eat memory\n" 5406 " Eats all available memory so you can test if the system survives\n";
5412 blocks =
ast_malloc(
sizeof(
void*) * blocks_max);
5418 for (i = 0; sizes[i]; ++i) {
5419 int alloc_size = sizes[i];
5420 ast_log(
LOG_WARNING,
"Allocating %d sized blocks (got %d blocks already)\n", alloc_size, blocks_pos);
5423 if (blocks_pos >= blocks_max) {
5433 blocks[blocks_pos++] = block;
5434 allocated += alloc_size;
5461 wordlen = strlen(word);
5491 snprintf(buf, buflen,
"hint: %s",
5494 snprintf(buf, buflen,
"%d. %s(%s)",
5504 ast_cli(fd,
" %-17s %-45s [%s:%d]\n",
5511 ast_cli(fd,
" %-17s %-45s [%s]\n",
5530 char buf[256], buf2[256];
5532 int context_info_printed = 0;
5549 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
5552 ast_cli(fd,
"Autohints support enabled\n");
5554 context_info_printed = 1;
5568 if (!context_info_printed) {
5571 ast_cli(fd,
"[ Included context '%s' created by '%s' ]\n",
5574 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
5577 ast_cli(fd,
"Autohints support enabled\n");
5580 context_info_printed = 1;
5601 snprintf(buf,
sizeof(buf),
" [%s]", el);
5622 for (x = 0; x < includecount; x++) {
5636 ast_cli(fd,
" Include => %-45s [%s]\n",
5647 snprintf(buf,
sizeof(buf),
"'%s'", ipname);
5648 snprintf(ignorepat,
sizeof(ignorepat),
"_%s.", ipname);
5650 ast_cli(fd,
" Ignore pattern => %-45s [%s]\n",
5658 snprintf(buf,
sizeof(buf),
"'%s/%s'",
5661 ast_cli(fd,
" Alt. Switch => %-45s [%s]\n",
5669 if (context_info_printed)
5674 return (dpc->
total_exten == old_total_exten) ? -1 : res;
5682 ast_cli(fd,
"\n In-mem exten Trie for Fast Extension Pattern Matching:\n\n");
5684 ast_cli(fd,
"\n Explanation: Node Contents Format = <char(s) to match>:<pattern?>:<specif>:[matched extension]\n");
5685 ast_cli(fd,
" Where <char(s) to match> is a set of chars, any one of which should match the current character\n");
5686 ast_cli(fd,
" <pattern?>: Y if this a pattern match (eg. _XZN[5-7]), N otherwise\n");
5687 ast_cli(fd,
" <specif>: an assigned 'exactness' number for this matching char. The lower the number, the more exact the match\n");
5688 ast_cli(fd,
" [matched exten]: If all chars matched to this point, which extension this matches. In form: EXTEN:<exten string>\n");
5689 ast_cli(fd,
" In general, you match a trie node to a string character, from left to right. All possible matching chars\n");
5690 ast_cli(fd,
" are in a string vertically, separated by an unbroken string of '+' characters.\n\n");
5695 int context_info_printed = 0;
5710 ast_cli(fd,
"[ Context '%s' created by '%s' ]\n",
5712 context_info_printed = 1;
5718 ast_cli(fd,
"\n No Pattern Trie present. Perhaps the context is empty...or there is trouble...\n\n");
5724 if (context_info_printed)
5729 return (dpc->
total_exten == old_total_exten) ? -1 : res;
5743 "Usage: dialplan show [[exten@]context]\n" 5750 memset(&counters, 0,
sizeof(counters));
5757 if (strchr(a->
argv[2],
'@')) {
5759 exten =
strsep(&context,
"@");
5774 ast_cli(a->
fd,
"There is no existence of '%s' context\n", context);
5780 ast_cli(a->
fd,
"There is no existence of %s@%s extension\n",
5784 "There is no existence of '%s' extension in all contexts\n",
5789 ast_cli(a->
fd,
"-= %d %s (%d %s) in %d %s. =-\n",
5808 e->
command =
"dialplan debug";
5810 "Usage: dialplan debug [context]\n" 5811 " Show dialplan context Trie(s). Usually only useful to folks debugging the deep internals of the fast pattern matcher\n";
5817 memset(&counters, 0,
sizeof(counters));
5825 if (strchr(a->
argv[2],
'@')) {
5827 exten =
strsep(&context,
"@");
5842 ast_cli(a->
fd,
"There is no existence of '%s' context\n", context);
5865 const char *actionidtext,
const char *context,
5868 int includecount,
const char *includes[])
5878 ast_debug(3,
"manager_show_dialplan: Context: -%s- Extension: -%s-\n", context, exten);
5901 ast_debug(3,
"manager_show_dialplan: Failed to lock context\n");
5929 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
5955 for (x = 0; x < includecount; x++) {
5971 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
5983 snprintf(ignorepat,
sizeof(ignorepat),
"_%s.", ipname);
5987 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
5998 astman_append(s,
"Event: ListDialplan\r\n%s", actionidtext);
6010 ast_debug(3,
"manager_show_dialplan: Found nothing new\n");
6030 snprintf(idtext,
sizeof(idtext),
"ActionID: %s\r\n",
id);
6034 memset(&counters, 0,
sizeof(counters));
6042 char errorbuf[BUFSIZ];
6044 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find context %s", context);
6049 char errorbuf[BUFSIZ];
6052 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find extension %s@%s", exten, context);
6054 snprintf(errorbuf,
sizeof(errorbuf),
"Did not find extension %s in any context", exten);
6065 "ListExtensions: %d\r\n" 6066 "ListPriorities: %d\r\n" 6067 "ListContexts: %d\r\n",
6079 int i, j,
exten, combined;
6083 e->
command =
"core show device2extenstate";
6085 "Usage: core show device2extenstate\n" 6086 " Lists device state to extension state combinations.\n";
6111 e->
command =
"dialplan set extenpatternmatchnew true";
6113 "Usage: dialplan set extenpatternmatchnew true|false\n" 6114 " Use the NEW extension pattern matching algorithm, true or false.\n";
6126 ast_cli(a->
fd,
"\n -- Still using the NEW pattern match algorithm for extension names in the dialplan.\n");
6128 ast_cli(a->
fd,
"\n -- Switched to using the NEW pattern match algorithm for extension names in the dialplan.\n");
6139 e->
command =
"dialplan set extenpatternmatchnew false";
6141 "Usage: dialplan set extenpatternmatchnew true|false\n" 6142 " Use the NEW extension pattern matching algorithm, true or false.\n";
6154 ast_cli(a->
fd,
"\n -- Still using the OLD pattern match algorithm for extension names in the dialplan.\n");
6156 ast_cli(a->
fd,
"\n -- Switched to using the OLD pattern match algorithm for extension names in the dialplan.\n");
6188 if (e->cached_app == app)
6189 e->cached_app =
NULL;
6202 int length =
sizeof(
struct ast_context) + strlen(name) + 1;
6204 if (!contexts_table) {
6207 if (!contexts_table) {
6229 local_contexts = extcontexts;
6240 strcpy(tmp->
name, name);
6249 ast_log(
LOG_ERROR,
"Danger! We failed to allocate a context for %s!\n", name);
6258 *local_contexts =
tmp;
6266 *local_contexts =
tmp;
6268 ast_debug(1,
"Registered extension context '%s'; registrar: %s\n", tmp->
name, registrar);
6342 size_t name_len = strlen(con->
name) + 1;
6343 size_t registrar_len = strlen(con->
registrar) + 1;
6362 ast_verb(3,
"Enabled autohints support on context '%s'\n", con->
name);
6372 struct ast_exten *exten_item, *prio_item, *new_exten_item, *new_prio_item;
6375 int insert_count = 0;
6389 new_exten_item =
NULL;
6396 if (new_exten_item) {
6399 new_prio_item =
NULL;
6401 if (strcmp(prio_item->
registrar,registrar) == 0) {
6419 ast_log(
LOG_ERROR,
"Could not allocate a new context for %s in merge_and_delete! Danger!\n", context->
name);
6432 if (!res1 && new_exten_item && new_prio_item){
6433 ast_verb(3,
"Dropping old dialplan item %s/%s/%d [%s(%s)] (registrar=%s) due to conflict with new dialplan\n",
6451 if (!insert_count && !
new && (strcmp(context->
registrar, registrar) != 0 ||
6484 struct timeval begintime;
6485 struct timeval writelocktime;
6486 struct timeval endlocktime;
6487 struct timeval enddeltime;
6505 if (!contexts_table) {
6510 contexts_table = exttable;
6511 contexts = *extcontexts;
6542 +
sizeof(*saved_hint);
6557 saved_hint->laststate = hint->
laststate;
6558 saved_hint->context = saved_hint->data;
6560 saved_hint->exten = saved_hint->data + strlen(saved_hint->context) + 1;
6580 contexts_table = exttable;
6581 contexts = *extcontexts;
6597 if (exten && exten->
exten[0] ==
'_') {
6674 for (tmp = oldcontextslist;
tmp; ) {
6685 ast_verb(3,
"Time to scan old dialplan and merge leftovers back into the new: %8.6f sec\n", ft);
6689 ast_verb(3,
"Time to restore hints and swap in new dialplan: %8.6f sec\n", ft);
6693 ast_verb(3,
"Time to delete the old dialplan: %8.6f sec\n", ft);
6697 ast_verb(3,
"Total time merge_contexts_delete: %8.6f sec\n", ft);
6698 ast_verb(3,
"%s successfully loaded %d contexts (enable debug for details).\n", registrar, ctx_count);
6727 const char *registrar)
6758 ast_debug(1,
"Including context '%s' in context '%s'\n",
6792 const char *data,
int eval,
const char *registrar)
6798 if (!(new_sw =
sw_alloc(value, data, eval, registrar))) {
6825 ast_verb(3,
"Including switch '%s/%s' in context '%s'\n",
6951 int priority,
const char *label,
const char *callerid,
6952 const char *application,
void *data,
void (*
datad)(
void *),
const char *registrar)
6960 application, data,
datad, registrar,
NULL, 0, 1);
6971 int priority,
const char *label,
const char *callerid,
6972 const char *application,
void *data,
void (*
datad)(
void *),
const char *registrar)
6980 application, data,
datad, registrar,
NULL, 0);
6998 if (priority > -1) {
7068 static unsigned int ext_strncpy(
char *dst,
const char *src,
size_t dst_size,
int nofluff)
7071 unsigned int insquares;
7072 unsigned int is_pattern;
7081 is_pattern = *src ==
'_';
7082 while (*src && count < dst_size) {
7087 }
else if (*src ==
']') {
7089 }
else if (*src ==
' ' && !insquares) {
7092 }
else if (*src ==
'-' && !insquares && nofluff) {
7114 int repeated_label = 0;
7116 for (ep =
NULL; e ; ep = e, e = e->
peer) {
7117 if (e->label && tmp->
label && e->priority != tmp->
priority && !strcmp(e->label, tmp->
label)) {
7118 if (strcmp(e->name, tmp->
name)) {
7120 "Extension '%s' priority %d in '%s', label '%s' already in use at aliased extension '%s' priority %d\n",
7124 "Extension '%s' priority %d in '%s', label '%s' already in use at priority %d\n",
7129 if (e->priority >= tmp->
priority) {
7134 if (repeated_label) {
7147 if (e->priority == tmp->
priority) {
7151 if (strcmp(e->name, tmp->
name)) {
7153 "Unable to register extension '%s' priority %d in '%s', already in use by aliased extension '%s'\n",
7157 "Unable to register extension '%s' priority %d in '%s', already in use\n",
7203 ast_log(
LOG_ERROR,
"Trying to delete an exten from a context, but the pattern tree node returned isn't an extension\n");
7230 ast_log(
LOG_ERROR,
"Trying to delete an exten from a context, but the pattern tree node returned isn't an extension\n");
7253 e->peer_label_table = 0;
7300 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
7301 const char *application,
void *data,
void (*
datad)(
void *),
7305 application, data,
datad, registrar, registrar_file, registrar_line, 1);
7309 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
7310 const char *application,
void *data,
void (*
datad)(
void *),
7314 application, data,
datad, registrar, registrar_file, registrar_line, 0);
7326 int replace,
const char *extension,
int priority,
const char *label,
const char *callerid,
7327 const char *application,
void *data,
void (*
datad)(
void *),
7342 char dummy_name[1024];
7347 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",
7357 if (priority ==
PRIORITY_HINT && strstr(application,
"${") && extension[0] !=
'_') {
7373 if (0 < inhibited) {
7377 application = expand_buf;
7387 length += strlen(extension) + 1;
7389 length += strlen(extension) + 1 - exten_fluff;
7391 length += strlen(application) + 1;
7393 length += strlen(label) + 1;
7396 length += strlen(callerid) + 1;
7397 if (callerid_fluff) {
7398 length += strlen(callerid) + 1 - callerid_fluff;
7403 if (registrar_file) {
7404 length += strlen(registrar_file) + 1;
7425 p += strlen(label) + 1;
7428 p +=
ext_strncpy(p, extension, strlen(extension) + 1, 0);
7431 p +=
ext_strncpy(p, extension, strlen(extension) + 1 - exten_fluff, 1);
7441 p +=
ext_strncpy(p, callerid, strlen(callerid) + 1, 0);
7442 if (callerid_fluff) {
7444 p +=
ext_strncpy(p, callerid, strlen(callerid) + 1 - callerid_fluff, 1);
7452 if (registrar_file) {
7454 strcpy(p, registrar_file);
7455 p += strlen(registrar_file) + 1;
7461 strcpy(p, application);
7475 dummy_exten.
exten = dummy_name;
7486 for (e = con->
root; e; el = e, e = e->
next) {
7501 if (e && res == 0) {
7577 ast_log(
LOG_DEBUG,
"Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",
7617 if (outgoing->
dial) {
7635 if (
outgoing->in_separate_thread) {
7702 ast_verb(4,
"Treating progress as answer on '%s' due to early media option\n",
7756 const char *addr,
int timeout,
const char *context,
const char *
exten,
int priority,
7757 const char *
app,
const char *appdata,
int *reason,
int synchronous,
7759 const char *account,
struct ast_channel **locked_channel,
int early_media,
7765 char tmp_cid_name[128];
7766 char tmp_cid_num[128];
7799 if (synchronous && reason) {
7817 ast_channel_accountcode_set(dialed, account);
7818 ast_channel_peeraccount_set(dialed, account);
7833 cid_num = tmp_cid_num;
7838 cid_name = tmp_cid_name;
7864 connected.
id.
name.
str = (
char *) cid_name;
7874 if (locked_channel) {
7907 if (locked_channel) {
7935 if (locked_channel) {
7940 if (locked_channel) {
7945 if (locked_channel) {
7946 *locked_channel = dialed;
7952 int timeout,
const char *context,
const char *
exten,
int priority,
int *reason,
7954 const char *account,
struct ast_channel **locked_channel,
int early_media,
7958 synchronous, cid_num, cid_name, vars, account, locked_channel, early_media, assignedids,
NULL);
7962 int timeout,
const char *context,
const char *
exten,
int priority,
int *reason,
7964 const char *account,
struct ast_channel **locked_channel,
int early_media,
7971 reason = &my_reason;
7974 if (locked_channel) {
7975 *locked_channel =
NULL;
7979 NULL,
NULL, reason, synchronous, cid_num, cid_name, vars, account, locked_channel,
7980 early_media, assignedids, predial_callee);
7988 ast_assert(!locked_channel || !*locked_channel);
7995 "failed", context,
NULL,
NULL, 0,
"OutgoingSpoolFailed");
7997 char failed_reason[12];
8000 snprintf(failed_reason,
sizeof(failed_reason),
"%d", *reason);
8016 int timeout,
const char *
app,
const char *appdata,
int *reason,
int synchronous,
8018 const char *account,
struct ast_channel **locked_channel,
8022 cid_num, cid_name, vars, account, locked_channel, assignedids,
NULL);
8026 int timeout,
const char *
app,
const char *appdata,
int *reason,
int synchronous,
8028 const char *account,
struct ast_channel **locked_channel,
8034 if (locked_channel) {
8035 *locked_channel =
NULL;
8042 reason, synchronous, cid_num, cid_name, vars, account, locked_channel, 0,
8043 assignedids, predial_callee);
8078 for (e = tmp->
root; e;) {
8079 for (en = e->
peer; en;) {
8098 struct ast_exten *exten_item, *prio_item;
8100 for (tmp = list;
tmp; ) {
8109 ast_debug(1,
"check ctx %s %s\n", tmp->name, tmp->registrar);
8110 if ( !strcasecmp(tmp->name, con->
name) ) {
8157 int end_traversal = 1;
8175 ast_verb(3,
"Remove %s/%s/%d, registrar=%s; con=%s(%p); con->root=%p\n",
8191 if (end_traversal) {
8274 if (
ast_strlen_zero(data) || (sscanf(data,
"%30lg", &waitsec) != 1) || (waitsec < 0))
8277 waittime = waitsec * 1000.0;
8296 char *remainder,
result[30], timezone[80];
8305 if (!(remainder =
ast_strptime(value,
"%Y/%m/%d %H:%M:%S", &tm))) {
8308 sscanf(remainder,
"%79s", timezone);
8311 snprintf(result,
sizeof(result),
"%ld", (
long) tv.tv_sec);
8326 }
else if (sscanf(condition,
"%30d", &res) == 1) {
8357 cmpdevice =
ast_alloca(
sizeof(*cmpdevice) + strlen(presence_state->provider));
8358 strcpy(cmpdevice->
hintdevice, presence_state->provider);
8365 "find devices in container");
8423 "StatusText: %s\r\n\r\n",
8467 ast_verb(1,
"Asterisk PBX Core Initializing\n");
8469 ast_verb(2,
"Registering builtin functions:\n");
8560 return exten ? exten->
priority : -1;
8665 return priority ? priority->
peer :
exten;
8682 if (inc == include) {
8779 if (context ==
NULL)
8787 return goto_func(chan, context, exten, priority);
8812 ast_log(
LOG_WARNING,
"Goto requires an argument ([[context,]extension,]priority)\n");
8816 context =
strsep(&stringp,
",");
8817 exten =
strsep(&stringp,
",");
8818 pri =
strsep(&stringp,
",");
8831 }
else if (*pri ==
'-') {
8835 if (sscanf(pri,
"%30d%1s", &ipri, rest) != 1) {
8934 if (contexts_table) {
8957 prnt(where,
"%s => %s@%s", hintdevice->
hintdevice,
8969 prnt(where,
"%s", autohint->
context);
8979 prnt(where,
"%d", state_cb->
id);
9014 return (hints && hintdevices && autohints && statecbs) ? 0 : -1;
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
struct ast_hashtab * root_table
static void manager_dpsendack(struct mansession *s, const struct message *m)
Send ack once.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
ast_include: include= support in extensions.conf
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
static int hintdevice_remove_cb(void *obj, void *arg, void *data, int flags)
#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.
struct ast_context * ast_get_extension_context(struct ast_exten *exten)
static void hintdevice_destroy(void *obj)
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)
enum sip_cc_notify_state state
Options for ast_pbx_run()
int presentation
Q.931 encoded presentation-indicator encoded field.
const char * ast_get_switch_name(const struct ast_sw *sw)
const char * ast_get_switch_registrar(const struct ast_sw *sw)
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.
const char * ast_get_extension_name(struct ast_exten *exten)
const char * ast_get_extension_registrar_file(struct ast_exten *e)
Get name of configuration file used by registrar to register this extension.
#define ast_rwlock_rdlock(a)
#define ast_channel_lock(chan)
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)
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
ast_device_state
Device States.
int ast_context_switches_count(const struct ast_context *con)
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.
struct ast_ignorepats ignorepats
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)
char * str
Subscriber phone number (Malloced)
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
static void print_autohint_key(void *v_obj, void *where, ao2_prnt_fn *prnt)
int ast_context_remove_ignorepat2(struct ast_context *con, const char *ignorepat, const char *registrar)
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
Asterisk locking-related definitions:
ast_extension_states
Extension states.
void astman_append(struct mansession *s, const char *fmt,...)
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
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...
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.
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
const char * presence_message
static void __ast_internal_context_destroy(struct ast_context *con)
static unsigned int ext_strncpy(char *dst, const char *src, size_t dst_size, int nofluff)
static int __ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, int async)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
int ast_unlock_context(struct ast_context *con)
int ast_autoservice_start(struct ast_channel *chan)
Automatically service a channel for us...
Private include file for pbx.
static char * parse_hint_presence(struct ast_str *hint_args)
int ast_context_add_include2(struct ast_context *con, const char *value, const char *registrar)
Add a context include.
static int ast_add_hint(struct ast_exten *e)
Add hint to hint list, check initial extension state.
int ast_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message)
Uses hint and presence state callback to get the presence state of an extension.
static struct ao2_container * alloc_device_state_info(void)
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string)
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)
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Main dialing structure. Contains global options, channels being dialed, and more! ...
struct ast_include * include_alloc(const char *value, const char *registrar)
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
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.
#define ao2_t_alloc(data_size, destructor_fn, debug_msg)
static int internal_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container *device_state_info)
int ast_rdlock_context(struct ast_context *con)
Read locks a given context.
#define ast_pthread_create_detached(a, b, c, d)
struct ast_party_id id
Connected party ID.
void include_free(struct ast_include *inc)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
const struct ast_sw * ast_walk_context_switches(const struct ast_context *con, const struct ast_sw *sw)
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE
const char * ast_get_ignorepat_registrar(const struct ast_ignorepat *ip)
#define ast_channel_unref(c)
Decrease channel reference count.
const struct ast_ignorepat * ast_context_ignorepats_get(const struct ast_context *con, int idx)
The arg parameter is a search key, but is not an object.
#define ast_set2_flag(p, value, flag)
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...
#define ast_test_flag(p, flag)
int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
#define AST_CAUSE_SWITCH_CONGESTION
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
struct ast_context * ast_walk_contexts(struct ast_context *con)
int ast_extension_close(const char *pattern, const char *data, int needmore)
#define STATUS_NO_PRIORITY
static void decrease_call_count(void)
void ast_context_set_autohints(struct ast_context *con, int enabled)
Enable or disable autohints support on a context.
#define ast_rwlock_destroy(rwlock)
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, &conlock lock must be locked, because when we giving *con argument, some process can remove/change this context and after that there can be segfault.
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 * include_rname(const struct ast_include *inc)
struct ast_party_name name
Subscriber name.
static int hint_cmp(void *obj, void *arg, int flags)
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...
int pbx_set_extenpatternmatchnew(int newval)
static struct ast_hashtab * contexts_table
static struct match_char * add_exten_to_pattern_tree(struct ast_context *con, struct ast_exten *e1, int findonly)
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Check extension state for an extension by using hint.
#define AST_CAUSE_UNALLOCATED
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)
static int extension_presence_state_helper(struct ast_exten *e, char **subtype, char **message)
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.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
#define ast_set_flag(p, flag)
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
descriptor for a cli entry.
static int publish_hint_remove(struct ast_hint *hint)
Publish a hint removed event.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
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)
static struct stasis_subscription * presence_state_sub
Subscription for presence state change events.
#define VERBOSITY_ATLEAST(level)
static int add_hintdevice(struct ast_hint *hint, const char *devicelist)
add hintdevice structure and link it into the container.
struct ast_app * cached_app
ast_state_cb: An extension state notify register item
static int autofallthrough
static void destroy_hint(void *obj)
char * appdata
Application data to pass to application.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
enum ast_state_cb_update_reason reason
int ast_context_remove_switch(const char *context, const char *sw, const char *data, const char *registrar)
Remove a switch.
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.
void * ast_get_extension_app_data(struct ast_exten *e)
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.
Structure for variables, used for configurations and for channel variables.
const struct ast_sw * ast_context_switches_get(const struct ast_context *con, int idx)
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
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
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)
static struct ao2_container * hintdevices
Container for hint devices.
#define NEW_MATCHER_RECURSE
int dial_res
Result of the dial operation when dialed is set.
static int hashtab_compare_extens(const void *ha_a, const void *ah_b)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static char * handle_show_device2extenstate(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int hint_hash(const void *obj, const int flags)
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct ast_context * ast_context_find(const char *name)
Find a context.
int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container **device_state_info)
Check extended extension state for an extension by using hint.
#define INC_DST_OVERFLOW_CHECK
static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c, struct ast_pbx_args *args)
static void print_statecbs_key(void *v_obj, void *where, ao2_prnt_fn *prnt)
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 stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
Structure to pass both assignedid values to channel drivers.
char context[1]
Name of the context.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
Structure for a data store type.
static void device_state_notify_callbacks(struct ast_hint *hint, struct ast_str **hint_app)
ast_channel_state
ast_channel states
#define ao2_t_link(container, obj, tag)
Add an object to a container.
char * str
Subscriber name (Malloced)
const ast_string_field exten
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
#define AST_VECTOR_REMOVE_UNORDERED(vec, idx)
Remove an element from an unordered vector by index.
#define STATUS_NO_EXTENSION
const ast_string_field app
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct ast_cli_entry pbx_cli[]
static struct ast_threadstorage buf2
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
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)
struct ast_hint * hint
Hint this hintdevice belongs to.
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.
const char * ast_get_include_registrar(const struct ast_include *i)
ast_control_frame_type
Internal control frame subtype field values.
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_channel * ast_channel_yank(struct ast_channel *yankee)
Gain control of a channel in the system.
char * last_presence_message
Stasis message payload representing a presence state update.
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ast_mutex_lock(a)
static ast_mutex_t context_merge_lock
Lock to hold off restructuring of hints by ast_merge_contexts_and_delete.
double ast_option_maxload
static int match(struct ast_sockaddr *addr, unsigned short callno, unsigned short dcallno, const struct chan_iax2_pvt *cur, int check_dcallno)
#define ast_str_alloca(init_len)
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
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)
ast_cond_t cond
Condition for synchronous dialing.
char * incstack[AST_PBX_MAX_STACK]
struct ast_context * local_contexts
static unsigned int hashtab_hash_labels(const void *obj)
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.
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
int include_valid(const struct ast_include *inc)
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
void ast_cli(int fd, const char *fmt,...)
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
#define ast_rwlock_unlock(a)
struct ast_hashtab * peer_table
int ast_rdlock_contexts(void)
Read locks the context list.
static struct ao2_container * hints
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string, int async)
void ast_free_ptr(void *ptr)
free() wrapper
static void presence_state_notify_callbacks(struct ast_hint *hint, struct ast_str **hint_app, struct ast_presence_state_message *presence_state)
static char cid_num[AST_MAX_EXTENSION]
#define ast_cond_signal(cond)
int ast_channel_priority(const struct ast_channel *chan)
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
const ast_string_field context
void ignorepat_free(struct ast_ignorepat *ip)
const char * ast_get_extension_registrar(struct ast_exten *e)
#define ast_verb(level,...)
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 int handle_hint_change_message_type(struct stasis_message *msg, enum ast_state_cb_update_reason reason)
ast_state_cb_type change_cb
unsigned int dialed
Set when dialing is completed.
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.
static void get_device_state_causing_channels(struct ao2_container *c)
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.
#define ast_hashtab_insert_safe(tab, obj)
enum ast_device_state ast_devstate_aggregate_result(struct ast_devstate_aggregate *agg)
Get the aggregate device state result.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
#define COLORIZE(fg, bg, str)
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 const char context_name[]
static void device_state_info_dt(void *obj)
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_extension_cmp(const char *a, const char *b)
Determine if one extension should match before another.
struct ast_context * next
#define ast_hashtab_start_traversal(tab)
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
void wait_for_hangup(struct ast_channel *chan, const void *data)
void() ao2_prnt_fn(void *where, const char *fmt,...)
Print output.
pthread_cond_t ast_cond_t
#define ast_strlen_zero(foo)
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
static char * handle_show_dialplan(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
const ast_string_field exten
static struct devices devices
int ast_get_switch_eval(const struct ast_sw *sw)
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
struct ast_context * next
int indicate_congestion(struct ast_channel *chan, const char *data)
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extension states.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
int ast_wrlock_contexts(void)
Write locks the context list.
Configuration File Parser.
enum ast_extension_states exten_state
void ao2_container_unregister(const char *name)
Unregister a container for CLI stats and integrity check.
struct ast_exten * ast_walk_context_extensions(struct ast_context *con, struct ast_exten *exten)
struct stasis_message_type * ast_device_state_message_type(void)
Get the Stasis message type for device state messages.
static int hintdevice_cmp_multiple(void *obj, void *arg, int flags)
struct ast_channel * causing_channel
static int statecbs_cmp(void *obj, void *arg, int flags)
static void * pbx_outgoing_exec(void *data)
Internal function which dials an outgoing leg and sends it to a provided extension or application...
const char * registrar_file
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj)
Register a container for CLI stats and integrity check.
#define ast_hashtab_insert_immediate(tab, obj)
#define ast_debug(level,...)
Log a DEBUG message.
const char * ast_get_context_registrar(struct ast_context *c)
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
static void presence_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg)
ast_dial_result
List of return codes for dial run API calls.
ast_sw: Switch statement in extensions.conf
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
static int ext_cmp(const char *left, const char *right)
static int ast_extension_state2(struct ast_exten *e, struct ao2_container *device_state_info)
Check state of extension by using hints.
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.
General Asterisk PBX channel definitions.
int raise_exception(struct ast_channel *chan, const char *reason, int priority)
int priority
Dialplan priority.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
static int increase_call_count(const struct ast_channel *c)
Increase call count for channel.
static ast_mutex_t maxcalllock
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.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
struct ast_sw * sw_alloc(const char *value, const char *data, int eval, const char *registrar)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
ast_state_cb_update_reason
enum ast_presence_state presence_state
static int ext_cmp_exten_strlen(const char *str)
static void create_match_char_tree(struct ast_context *con)
const ast_string_field reason
const struct ast_eid * eid
The EID of the server where this message originated.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
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...
void pbx_set_overrideswitch(const char *newval)
#define ast_dummy_channel_alloc()
Create a fake channel structure.
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct sla_ringing_trunk * last
#define AST_CAUSE_ANSWERED_ELSEWHERE
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)
void(* ast_state_cb_destroy_type)(int id, void *data)
Typedef for devicestate and hint callback removal indication callback.
#define HASH_EXTENHINT_SIZE
int ast_context_add_switch(const char *context, const char *sw, const char *data, int eval, const char *registrar)
Add a switch.
#define AST_MAX_EXTENSION
static struct match_char * already_in_tree(struct match_char *current, char *pat, int is_pattern)
static int 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, int extended)
#define AST_STRING_FIELD(name)
Declare a string field.
struct ast_switch * pbx_findswitch(const char *sw)
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a state change watcher by ID.
structure to hold extensions
#define ao2_ref(o, delta)
#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.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
#define COLORIZE_FMT
Shortcut macros for coloring a set of text.
const char * presence_subtype
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)
Remove an element from a vector by index while maintaining order.
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_strdupa(s)
duplicate a string in memory from the stack
static struct ast_threadstorage switch_data
int ast_parseable_goto(struct ast_channel *chan, const char *goto_string)
int indicate_busy(struct ast_channel *chan, const char *data)
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...
enum ast_device_state device_state
static void print_ext(struct ast_exten *e, char *buf, int buflen)
helper function to print an extension
struct ast_dial * dial
Dialing structure being used.
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[])
#define ast_malloc(len)
A wrapper for malloc()
struct ao2_container * container
static void cli_match_char_tree(struct match_char *node, char *prefix, int fd)
#define AST_VECTOR(name, type)
Define a vector structure.
struct ast_includes includes
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
static const struct ast_datastore_info exception_store_info
#define AST_CAUSE_NO_ANSWER
static ast_mutex_t conlock
Lock for the ast_context list.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
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.
struct ast_hashtab * peer_label_table
char * registrar
Name of the registrar.
static void unload_pbx(void)
void ast_hashtab_end_traversal(struct ast_hashtab_iter *it)
end the traversal, free the iterator, unlock if necc.
int ast_context_add_ignorepat(const char *context, const char *value, const char *registrar)
Add an ignorepat.
const char * ast_channel_exten(const struct ast_channel *chan)
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
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_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_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.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
char * last_presence_subtype
int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const char *registrar)
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
#define stasis_subscribe(topic, callback, data)
const char * ast_get_ignorepat_name(const struct ast_ignorepat *ip)
static int extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
struct ao2_container * device_state_info
int ast_get_extension_matchcid(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.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
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
int ast_context_ignorepats_count(const struct ast_context *con)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
static int ext_fluff_count(const char *exten)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_PBX_INCOMPLETE
struct ast_exten * exten
Hint extension.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
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...
static unsigned int hashtab_hash_priority(const void *obj)
Presence state management.
char context_name[AST_MAX_CONTEXT]
int ast_unlock_contexts(void)
Unlocks contexts.
void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
static void context_merge(struct ast_context **extcontexts, struct ast_hashtab *exttable, struct ast_context *context, const char *registrar)
static void * pbx_thread(void *data)
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)
Add watcher for extension states with destructor.
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define EVENT_FLAG_CONFIG
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
struct store_hint::@410 callbacks
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.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
int pbx_set_autofallthrough(int newval)
static int ast_extension_state3(struct ast_str *hint_app, struct ao2_container *device_state_info)
void * ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj)
Looks up the object, removes the corresponding bucket.
static int _extension_match_core(const char *pattern, const char *data, enum ext_match_t mode)
static int manager_show_dialplan(struct mansession *s, const struct message *m)
Manager listing of dial plan.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
int ast_get_extension_registrar_line(struct ast_exten *e)
Get line number of configuration file used by registrar to register this extension.
struct ast_ignorepat * ignorepat_alloc(const char *value, const char *registrar)
static int compare_char(const void *a, const void *b)
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
static int autohint_cmp(void *obj, void *arg, int flags)
ast_ignorepat: Ignore patterns in dial plan
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
#define STATUS_NO_CONTEXT
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Structure for dial plan autohints.
static int acf_exception_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
int ast_thread_inhibit_escalations_swap(int inhibit)
Swap the current thread escalation inhibit setting.
ast_state_cb_destroy_type destroy_cb
Structure for dial plan hints.
int ast_extension_match(const char *pattern, const char *data)
Determine if a given extension matches a given pattern (in NXX format)
#define NEW_MATCHER_CHK_MATCH
#define ao2_t_callback(c, flags, cb_fn, arg, tag)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
Connected Line/Party information.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg)
struct sla_ringing_trunk * first
#define AST_PBX_MAX_STACK
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_wrlock_context(struct ast_context *con)
Write locks a given context.
const char * app_name(struct ast_app *app)
#define ao2_iterator_next(iter)
#define ast_cond_destroy(cond)
#define ao2_alloc(data_size, destructor_fn)
struct timeval ast_channel_creationtime(struct ast_channel *chan)
Structure which contains information about an outgoing dial.
struct stasis_topic * ast_device_state_topic_all(void)
Get the Stasis topic for device state messages.
struct ao2_container * callbacks
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)
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
static int remove_hintdevice(struct ast_hint *hint)
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
static struct ast_threadstorage buf1
int ast_context_destroy_by_name(const char *context, const char *registrar)
Destroy a context by name.
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.
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
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)
static int autohint_hash_cb(const void *obj, const int flags)
#define ast_calloc(num, len)
A wrapper for calloc()
struct ast_dial * ast_dial_create(void)
New dialing structure.
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)
static struct ast_context * find_context(const char *context)
lookup for a context with a given name,
struct ast_channel * ast_dial_get_channel(struct ast_dial *dial, int num)
Get the dialing channel, if prerun has been executed.
static struct ast_context * find_context_locked(const char *context)
lookup for a context with a given name,
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)
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...
const char * foundcontext
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
static int publish_hint_change(struct ast_hint *hint, struct ast_exten *ne)
Publish a hint changed event.
struct ast_exten * ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority)
static int action_extensionstatelist(struct mansession *s, const struct message *m)
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) ...
Asterisk XML Documentation API.
const char * ast_get_switch_data(const struct ast_sw *sw)
void ast_channel_pbx_set(struct ast_channel *chan, struct ast_pbx *value)
enum ast_extension_states ast_devstate_to_extenstate(enum ast_device_state devstate)
Map devstate to an extension state.
Prototypes for public functions only of internal interest,.
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
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...
static struct ast_threadstorage hintdevice_data
Vector container support.
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...
#define ao2_find(container, arg, flags)
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)
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.
static void print_hintdevices_key(void *v_obj, void *where, ao2_prnt_fn *prnt)
static void destroy_state_cb(void *doomed)
void sw_free(struct ast_sw *sw)
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)
static struct ast_custom_function exception_function
#define AST_LIST_HEAD_NOLOCK_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD_NOLOCK.
struct ast_channel_iterator * ast_channel_iterator_by_name_new(const char *name, size_t name_len)
Create a new channel iterator based on name.
#define ast_clear_flag(p, flag)
static int find_hint_by_cb_id(void *obj, void *arg, int flags)
Find Hint by callback id.
static char cid_name[AST_MAX_EXTENSION]
unsigned int in_separate_thread
Set if we've spawned a thread to do our work.
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
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)
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
int pbx_checkcondition(const char *condition)
Evaluate a condition.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
static const struct cfextension_states extension_states[]
struct ast_channel * ast_dial_answered_steal(struct ast_dial *dial)
Steal the channel that answered.
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...
#define ast_rwlock_wrlock(a)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
void unreference_cached_app(struct ast_app *app)
struct match_char * pattern_tree
const struct ast_include * ast_walk_context_includes(const struct ast_context *con, const struct ast_include *inc)
unsigned int ast_hashtab_hash_int(const int num)
#define EVENT_FLAG_REPORTING
static void context_table_create_autohints(struct ast_hashtab *table)
Assume that the ao2_container is already locked.
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
The arg parameter is an object of the same type.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
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)
struct ast_flags ast_options
const char * ast_get_include_name(const struct ast_include *include)
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.
Structure for dial plan hint devices.
char * strsep(char **str, const char *delims)
static const char * get_pattern_node(struct pattern_node *node, const char *src, int pattern, const char *extenbuf)
#define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag)
ao2_callback_data() is a generic function that applies cb_fn() to all objects in a container...
#define ast_channel_ref(c)
Increase channel reference count.
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
const struct ast_ignorepat * ast_walk_context_ignorepats(const struct ast_context *con, const struct ast_ignorepat *ip)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure for rwlock and tracking information.
struct timeval ast_mktime(struct ast_tm *const tmp, const char *zone)
Timezone-independent version of mktime(3).
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.
void ast_pbx_h_exten_run(struct ast_channel *chan, const char *context)
Run the h exten from the given context.
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#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)
ast_app: A registered application
int ast_extension_state_add_extended(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extended extension states.
unsigned int ast_hashtab_hash_contexts(const void *obj)
const char * ast_channel_name(const struct ast_channel *chan)
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[])
#define AST_CAUSE_USER_BUSY
const char * ast_get_extension_app(struct ast_exten *e)
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
#define AST_PBX_GOTO_FAILED
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
static const char * candidate_exten_advance(const char *str)
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static char * overrideswitch
static char * parse_hint_device(struct ast_str *hint_args)
struct stasis_message_type * ast_presence_state_message_type(void)
Get presence state message type.
int ast_context_remove_ignorepat(const char *context, const char *ignorepat, const char *registrar)
int ast_thread_inhibit_escalations(void)
Inhibit (in the current thread) the execution of dialplan functions which cause privilege escalations...
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.
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
static struct ao2_container * statecbs
struct stasis_forward * sub
Data structure associated with a single frame of data.
const char * cidmatch_display
static int hintdevice_hash_cb(const void *obj, const int flags)
int __ast_custom_function_register(struct ast_custom_function *acf, struct ast_module *mod)
Register a custom function.
Internal Asterisk hangup causes.
enum ast_presence_state state
static int ast_remove_hint(struct ast_exten *e)
Remove hint from extension.
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)
int ast_context_lockmacro(const char *context)
locks the macrolock in the given context
int getloadavg(double *list, int nelem)
You shouldn't care about the contents of this struct.
struct ast_hashtab * root_table
Counters for the show dialplan manager command.
static struct ast_context * contexts
The structure that contains device state.
const char * ast_channel_context(const struct ast_channel *chan)
Handy terminal functions for vt* terms.
int error(const char *format,...)
const struct ast_include * ast_context_includes_get(const struct ast_context *con, int idx)
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
const char * ast_get_context_name(struct ast_context *con)
#define ast_datastore_alloc(info, uid)
#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking)
struct ast_context * parent
int ast_context_add_include(const char *context, const char *include, const char *registrar)
Add a context include.
char * last_presence_message
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_active_calls(void)
Retrieve the number of active calls.
#define ast_mutex_init(pmutex)
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.
unsigned char valid
TRUE if the name information is valid/present.
int ast_extension_state_add_destroy_extended(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Add watcher for extended extension states with destructor.
const char * ast_get_extension_label(struct ast_exten *exten)
Search option field mask.
struct match_char * next_char
int(* ast_state_cb_type)(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
Typedef for devicestate and hint callbacks.
static char context[AST_MAX_CONTEXT]
static int execute_state_callback(ast_state_cb_type cb, const char *context, const char *exten, void *data, enum ast_state_cb_update_reason reason, struct ast_hint *hint, struct ao2_container *device_state_info)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
#define ast_mutex_destroy(a)
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 const char exten_name[]
STASIS_MESSAGE_TYPE_DEFN_LOCAL(hint_change_message_type)
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.
static void print_hints_key(void *v_obj, void *where, ao2_prnt_fn *prnt)
int ast_dial_reason(struct ast_dial *dial, int num)
Get the reason an outgoing channel has failed.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
struct stasis_topic * ast_presence_state_topic_all(void)
Get presence state topic.
Say numbers and dates (maybe words one day too)
#define DEBUG_ATLEAST(level)
#define AST_CAUSE_CALL_REJECTED
char * last_presence_subtype
void ast_channel_priority_set(struct ast_channel *chan, int value)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
int ast_context_unlockmacro(const char *context)
Unlocks the macrolock in the given context.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
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
int ast_hashtab_size(struct ast_hashtab *tab)
Returns the number of elements stored in the hashtab.
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]
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
ast_context: An extension context - must remain in sync with fake_context
unsigned char valid
TRUE if the number information is valid/present.
static int hint_id_cmp(void *obj, void *arg, int flags)
ast_callid ast_channel_callid(const struct ast_channel *chan)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
int ast_get_extension_priority(struct ast_exten *exten)
static struct ao2_container * autohints
Container for autohint contexts.
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.
int ast_context_remove_extension_callerid(const char *context, const char *extension, int priority, const char *callerid, int matchcallerid, const char *registrar)
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_MUTEX_DEFINE_STATIC(mutex)
static void pbx_outgoing_destroy(void *obj)
Destructor for outgoing structure.
const char * ast_extension_state2str(int extension_state)
Return extension_state as string.
Structure for mutex and tracking information.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
struct match_char * pattern_tree
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.
int ast_context_includes_count(const struct ast_context *con)
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
const char * ast_get_extension_cidmatch(struct ast_exten *e)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define ast_mutex_unlock(a)
static struct stasis_subscription * device_state_sub
Subscription for device state change events.
static struct ast_exten * get_canmatch_exten(struct match_char *node)
static char prefix[MAX_PREFIX]
static void destroy_exten(struct ast_exten *e)
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
#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 transaction to begin a list.
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.
#define ao2_link(container, obj)
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_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...