81 #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) 89 #define MONITOR_CONSTANT_DELAY 90 #define MONITOR_DELAY 150 * 8 98 #define STATE2STR_BUFSIZE 32 102 #define AST_DEFAULT_EMULATE_DTMF_DURATION 100 106 #define DEFAULT_EMULATE_MF_DURATION 55 108 #define DEFAULT_AMA_FLAGS AST_AMA_DOCUMENTATION 112 #define AST_MIN_DTMF_GAP 45 208 #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) 209 static const char *party_number_ton2str(
int ton)
211 #if defined(HAVE_PRI) 212 switch ((ton >> 4) & 0x07) {
213 case PRI_TON_INTERNATIONAL:
214 return "International";
215 case PRI_TON_NATIONAL:
217 case PRI_TON_NET_SPECIFIC:
218 return "Network Specific";
219 case PRI_TON_SUBSCRIBER:
221 case PRI_TON_ABBREVIATED:
222 return "Abbreviated";
223 case PRI_TON_RESERVED:
225 case PRI_TON_UNKNOWN:
234 #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) 235 static const char *party_number_plan2str(
int plan)
237 #if defined(HAVE_PRI) 238 switch (plan & 0x0F) {
240 case PRI_NPI_UNKNOWN:
242 case PRI_NPI_E163_E164:
243 return "Public (E.163/E.164)";
245 return "Data (X.121)";
247 return "Telex (F.69)";
248 case PRI_NPI_NATIONAL:
249 return "National Standard";
250 case PRI_NPI_PRIVATE:
252 case PRI_NPI_RESERVED:
263 #define FORMAT "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n" 269 e->
command =
"core show channeltypes";
271 "Usage: core show channeltypes\n" 272 " Lists available channel types registered in your\n" 273 " Asterisk server.\n";
282 ast_cli(a->
fd,
FORMAT,
"Type",
"Description",
"Devicestate",
"Presencestate",
"Indications",
"Transfer");
283 ast_cli(a->
fd,
FORMAT,
"-------------",
"-------------",
"-------------",
"-------------",
"-------------",
"-------------");
288 (cl->
tech->devicestate) ?
"yes" :
"no",
289 (cl->
tech->presencestate) ?
"yes" :
"no",
290 (cl->
tech->indicate) ?
"yes" :
"no",
291 (cl->
tech->transfer) ?
"yes" :
"no");
296 ast_cli(a->
fd,
"----------\n%d channel drivers registered.\n", count_chan);
312 wordlen = strlen(a->
word);
316 if (!strncasecmp(a->
word, cl->
tech->type, wordlen)) {
333 e->
command =
"core show channeltype";
335 "Usage: core show channeltype <name>\n" 336 " Show details about the specified channel type, <name>.\n";
348 if (!strncasecmp(cl->
tech->type, a->
argv[3], strlen(cl->
tech->type)))
354 ast_cli(a->
fd,
"\n%s is not a registered channel driver.\n", a->
argv[3]);
360 "-- Info about channel driver: %s --\n" 361 " Device State: %s\n" 362 "Presence State: %s\n" 365 " Capabilities: %s\n" 369 " Image Support: %s\n" 370 " Text Support: %s\n",
372 (cl->
tech->devicestate) ?
"yes" :
"no",
373 (cl->
tech->presencestate) ?
"yes" :
"no",
374 (cl->
tech->indicate) ?
"yes" :
"no",
375 (cl->
tech->transfer) ?
"yes" :
"no",
377 (cl->
tech->send_digit_begin) ?
"yes" :
"no",
378 (cl->
tech->send_digit_end) ?
"yes" :
"no",
379 (cl->
tech->send_html) ?
"yes" :
"no",
380 (cl->
tech->send_image) ?
"yes" :
"no",
381 (cl->
tech->send_text) ?
"yes" :
"no" 436 .description =
"Kill channel (should not see this)",
473 ast_debug(1,
"Setting hangupcause of channel %s to %d (is %d now)\n",
525 struct timeval whentohangup;
546 if (!strcasecmp(tech->
type, chan->
tech->type)) {
560 ast_debug(1,
"Registered handler for '%s' (%s)\n", chan->
tech->type, chan->
tech->description);
562 ast_verb(2,
"Registered channel type '%s' (%s)\n", chan->
tech->type, chan->
tech->description);
574 ast_debug(1,
"Unregistering channel type '%s'\n", tech->
type);
579 if (chan->
tech == tech) {
582 ast_verb(2,
"Unregistered channel type '%s'\n", tech->
type);
600 if (!strcasecmp(name, chanls->
tech->type)) {
616 for (x = 0; x <
ARRAY_LEN(causes); x++) {
617 if (causes[x].cause == cause)
618 return causes[x].
desc;
630 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
631 return causes[x].cause;
664 return "Dialing Offhook";
680 switch (transfercapability) {
686 return "RESTRICTED_DIGITAL";
690 return "DIGITAL_W_TONES";
704 .description =
"Surrogate channel used to pull channel from an application",
710 .description =
"Null channel (should not see this)",
728 ast_log(
LOG_ERROR,
"Channel Unique ID '%s' already in use by channel %s(%p)\n",
742 const
char *
file,
int line,
743 const
char *function, const
char *name_fmt, va_list ap)
762 file, line,
function);
779 if (!nativeformats) {
798 ast_log(
LOG_WARNING,
"Channel allocation failed: Unable to create schedule context\n");
866 char *slash, *slash2;
874 ast_channel_name_build_va(tmp, name_fmt, ap);
876 if ((slash = strchr(
tech,
'/'))) {
877 if ((slash2 = strchr(slash + 1,
'/'))) {
898 ast_channel_accountcode_set(tmp, acctcode);
961 const char *
cid_name,
const char *acctcode,
965 const char *
file,
int line,
const char *
function,
966 const char *name_fmt, ...)
971 va_start(ap, name_fmt);
973 assignedids, requestor, amaflag, endpoint, file, line,
function, name_fmt, ap);
987 file, line,
function);
1019 unsigned int new_frames = 0;
1020 unsigned int new_voice_frames = 0;
1021 unsigned int queued_frames = 0;
1022 unsigned int queued_voice_frames = 0;
1084 queued_voice_frames++;
1088 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1121 while (new_frames--) {
1198 f.
data.
ptr = (
void *) musicclass;
1199 f.
datalen = strlen(musicclass) + 1;
1202 "musicclass", musicclass);
1279 void *
data,
int ao2_flags)
1287 const char *
name = arg;
1288 size_t name_len = *(
size_t *) data;
1292 ast_log(
LOG_ERROR,
"BUG! Must supply a channel name or partial name to match!\n");
1333 size_t id_len = *(
size_t *) data;
1337 ast_log(
LOG_ERROR,
"BUG! Must supply a uniqueid or partial uniqueid to match!\n");
1371 char *l_exten = (
char *) exten;
1372 char *l_context = (
char *) context;
1391 char *l_name = (
char *) name;
1437 char *l_name = (
char *) name;
1440 (name_len == 0) ?
OBJ_KEY : 0);
1461 char *l_exten = (
char *) exten;
1462 char *l_context = (
char *) context;
1503 struct timeval start;
1518 if (
cond && ((*
cond)(data) == 0)) {
1628 if (src->
str && src->
str != dest->
str) {
1681 if (src->
str && src->
str != dest->
str) {
1734 if (src->
str && src->
str != dest->
str) {
1752 update_id->
name = 1;
1795 if (!update || update->
name) {
1798 if (!update || update->
number) {
1805 if (src->
tag && src->
tag != dest->
tag) {
1823 int number_priority;
1825 int number_screening;
1835 switch (name_value) {
1856 number_priority = 3;
1860 switch (number_value) {
1862 number_priority = 0;
1865 number_priority = 1;
1868 number_priority = 2;
1873 number_priority = 3;
1879 if (name_priority < number_priority) {
1880 number_value = name_value;
1886 return number_value | number_screening;
1892 id->number.valid = 0;
1893 id->subaddress.valid = 0;
1907 if (overlay->name.valid) {
1908 merged.
name = overlay->name;
1910 if (overlay->number.valid) {
1911 merged.number = overlay->number;
1913 if (overlay->subaddress.valid) {
1914 merged.subaddress = overlay->subaddress;
2065 connected->
id = caller->
id;
2066 connected->
ani = caller->
ani;
2108 if (src->
str && src->
str != dest->
str) {
2259 if ((dashptr = strrchr(device_name,
'-'))) {
2263 device_name[0] =
'\0';
2318 if (device_name[0]) {
2412 if (datastore->
info != info) {
2421 if ((datastore->
uid !=
NULL) && !strcasecmp(uid, datastore->
uid)) {
2510 ast_channel_hangupsource_set(chan, source);
2517 ast_channel_hangupsource_set(bridge, source);
2611 ast_log(
LOG_WARNING,
"Hard hangup called by thread LWP %d on %s, while blocked by thread LWP %d in procedure %s! Expect a failure\n",
2640 struct timeval answertime;
2715 switch (old_state) {
2725 int timeout_ms =
MAX(delay, 500);
2726 unsigned int done = 0;
2727 struct timeval start;
2741 ast_debug(2,
"Didn't receive a media frame from %s within %u ms of answering. Continuing anyway\n",
ast_channel_name(chan),
MAX(delay, 500));
2891 if (generator && generator->
release) {
2940 if (!tmp || !generate) {
2953 ast_debug(1,
"Auto-deactivating generator\n");
2969 if (generator_old && generator_old->
release) {
2973 if (gen->
alloc && !(generatordata = gen->
alloc(chan, params))) {
2998 int *exception,
int *outfd,
int *ms)
3000 struct timeval start = { 0 , 0 };
3001 struct pollfd *pfds =
NULL;
3006 struct timeval now = { 0, 0 };
3007 struct timeval whentohangup = { 0, 0 }, diff;
3021 for (x = 0; x < n; x++) {
3035 whentohangup = diff;
3051 if (!
ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3052 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000;
3053 if (*ms >= 0 && *ms < rms) {
3056 }
else if (!
ast_tvzero(whentohangup) && rms < 0) {
3066 for (x = 0; x < n; x++) {
3069 fdmap[
max].fdno = y;
3070 fdmap[
max].chan = x;
3077 for (x = 0; x < nfds; x++) {
3078 fdmap[
max].chan = -1;
3086 if (
sizeof(
int) == 4) {
3089 if (kbrms > 600000) {
3096 }
while (!res && (rms > 0));
3100 for (x = 0; x < n; x++) {
3106 if (
errno != EINTR) {
3113 for (x = 0; x < n; x++) {
3117 if (winner ==
NULL) {
3132 for (x = 0; x <
max; x++) {
3133 res = pfds[x].revents;
3137 if (fdmap[x].chan >= 0) {
3138 winner = c[fdmap[x].chan];
3140 if (res & POLLPRI) {
3149 *outfd = pfds[x].fd;
3152 *exception = (res & POLLPRI) ? -1 : 0;
3197 unsigned int real_rate = rate, max_rate;
3212 real_rate = max_rate;
3215 ast_debug(1,
"Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3226 if (data && is_ao2_obj) {
3273 if (!rchan && outfd < 0 && ms) {
3279 }
else if (outfd > -1) {
3281 ast_log(
LOG_WARNING,
"The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3299 if (!breakon || strchr(breakon, res)) {
3368 switch (direction) {
3382 char digit_str[] = {
digit,
'\0' };
3398 char digit_str[] = {
digit,
'\0' };
3439 samples = (int) (((
float) f->
samples) * factor);
3464 ast_debug(1,
"Auto-deactivating generator\n");
3518 int diff = sample_rate - seek_rate;
3521 samples = samples / (float) (sample_rate / seek_rate);
3522 }
else if (diff < 0) {
3523 samples = samples * (float) (seek_rate / sample_rate);
3577 "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3616 if (trigger_dtmf_emulating) {
3626 }
else if (trigger_dtmf_emulating) {
3672 int skipped_dtmf_frame = 0;
3681 skipped_dtmf_frame = 1;
3693 if (!skipped_dtmf_frame) {
3786 if (stream == default_stream) {
3814 if (dropnondefault && stream != default_stream) {
3826 ast_debug(1,
"Dropping duplicate answer!\n");
3839 read_action_payload = f->
data.
ptr;
3840 switch (read_action_payload->
action) {
3959 }
else if (!f->
len) {
4043 if (old_frame != f) {
4061 if (stream != default_stream) {
4172 if (old_frame != f) {
4179 #ifndef MONITOR_CONSTANT_DELAY 4186 ast_log(
LOG_WARNING,
"Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4196 if (jump - MONITOR_DELAY >= 0) {
4198 ast_log(
LOG_WARNING,
"Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4224 if (old_frame != f) {
4332 switch (condition) {
4400 snprintf(causevar,
sizeof(causevar),
"HASH(SIP_CAUSE,%s)", cause_code->
chan_name);
4407 if (!strcasecmp(flag,
"default"))
4409 if (!strcasecmp(flag,
"omit"))
4411 if (!strcasecmp(flag,
"billing"))
4413 if (!strcasecmp(flag,
"documentation"))
4426 return "DOCUMENTATION";
4451 unsigned char current[1024];
4452 unsigned char proposed[1024];
4468 chan_indicated,
NULL);
4470 chan_connected,
NULL);
4471 if (current_size == -1 || proposed_size == -1) {
4475 if (current_size == proposed_size && !memcmp(current, proposed, current_size)) {
4476 ast_debug(1,
"%s: Dropping redundant connected line update \"%s\" <%s>.\n",
4512 return res ? -1 : 0;
4524 switch (condition) {
4542 t38_parameters = data;
4588 if (_condition < 0) {
4596 switch (condition) {
4680 ast_debug(1,
"Driver for channel '%s' does not support indication %u, emulating it\n",
ast_channel_name(chan), condition);
4711 goto indicate_cleanup;
4718 .subclass.integer = _condition,
4719 .data.ptr = (
void *) data,
4732 goto indicate_cleanup;
4736 data = awesome_frame->
data.
ptr;
4737 datalen = awesome_frame->
datalen;
4744 if (awesome_frame) {
4757 c = *(
unsigned char *)buf;
4815 size_t body_len = strlen(body);
4818 memset(&f, 0,
sizeof(f));
4834 ast_debug(1,
"Sending TEXT_DATA from '%s' to %s:%s %s\n",
4845 ast_debug(1,
"Channel technology does not support sending content type '%s' on channel '%s'\n",
4862 .value = (
char *)text,
4882 static const char *
const mf_tones[] = {