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;
574 ast_debug(1,
"Unregistering channel type '%s'\n",
tech->type);
582 ast_verb(2,
"Unregistered channel type '%s'\n",
tech->type);
600 if (!strcasecmp(
name, chanls->
tech->type)) {
617 if (
causes[x].cause == cause)
658 return "Dialing Offhook";
674 switch (transfercapability) {
680 return "RESTRICTED_DIGITAL";
684 return "DIGITAL_W_TONES";
698 .description =
"Surrogate channel used to pull channel from an application",
704 .description =
"Null channel (should not see this)",
722 ast_log(
LOG_ERROR,
"Channel Unique ID '%s' already in use by channel %s(%p)\n",
736 const
char *
file,
int line,
737 const
char *function, const
char *name_fmt, va_list ap)
741 char *tech =
"", *tech2 =
NULL;
756 file, line,
function);
773 if (!nativeformats) {
792 ast_log(
LOG_WARNING,
"Channel allocation failed: Unable to create schedule context\n");
860 char *slash, *slash2;
868 ast_channel_name_build_va(
tmp, name_fmt, ap);
870 if ((slash = strchr(tech,
'/'))) {
871 if ((slash2 = strchr(slash + 1,
'/'))) {
892 ast_channel_accountcode_set(
tmp, acctcode);
955 const char *
cid_name,
const char *acctcode,
959 const char *
file,
int line,
const char *
function,
960 const char *name_fmt, ...)
965 va_start(ap, name_fmt);
967 assignedids, requestor, amaflag, endpoint,
file, line,
function, name_fmt, ap);
981 file, line,
function);
1013 unsigned int new_frames = 0;
1014 unsigned int new_voice_frames = 0;
1015 unsigned int queued_frames = 0;
1016 unsigned int queued_voice_frames = 0;
1078 queued_voice_frames++;
1082 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1115 while (new_frames--) {
1273 void *
data,
int ao2_flags)
1281 const char *
name = arg;
1282 size_t name_len = *(
size_t *)
data;
1286 ast_log(
LOG_ERROR,
"BUG! Must supply a channel name or partial name to match!\n");
1327 size_t id_len = *(
size_t *)
data;
1331 ast_log(
LOG_ERROR,
"BUG! Must supply a uniqueid or partial uniqueid to match!\n");
1365 char *l_exten = (
char *)
exten;
1366 char *l_context = (
char *)
context;
1385 char *l_name = (
char *)
name;
1431 char *l_name = (
char *)
name;
1439 (name_len == 0) ?
OBJ_KEY : 0);
1455 char *l_exten = (
char *)
exten;
1456 char *l_context = (
char *)
context;
1497 struct timeval start;
1622 if (src->
str && src->
str != dest->
str) {
1675 if (src->
str && src->
str != dest->
str) {
1728 if (src->
str && src->
str != dest->
str) {
1746 update_id->
name = 1;
1799 if (src->
tag && src->
tag != dest->
tag) {
1817 int number_priority;
1819 int number_screening;
1824 if (!
id->name.valid) {
1829 switch (name_value) {
1847 if (!
id->number.valid) {
1850 number_priority = 3;
1854 switch (number_value) {
1856 number_priority = 0;
1859 number_priority = 1;
1862 number_priority = 2;
1867 number_priority = 3;
1873 if (name_priority < number_priority) {
1874 number_value = name_value;
1880 return number_value | number_screening;
1886 id->number.valid = 0;
1887 id->subaddress.valid = 0;
1901 if (overlay->name.valid) {
1902 merged.
name = overlay->name;
1904 if (overlay->number.valid) {
1905 merged.number = overlay->number;
1907 if (overlay->subaddress.valid) {
1908 merged.subaddress = overlay->subaddress;
2102 if (src->
str && src->
str != dest->
str) {
2253 if ((dashptr = strrchr(device_name,
'-'))) {
2257 device_name[0] =
'\0';
2312 if (device_name[0]) {
2415 if ((datastore->
uid !=
NULL) && !strcasecmp(
uid, datastore->
uid)) {
2504 ast_channel_hangupsource_set(chan, source);
2511 ast_channel_hangupsource_set(bridge, source);
2605 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",
2632 struct timeval answertime;
2707 switch (old_state) {
2717 int timeout_ms =
MAX(delay, 500);
2718 unsigned int done = 0;
2719 struct timeval start;
2733 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));
2883 if (generator && generator->
release) {
2932 if (!
tmp || !generate) {
2945 ast_debug(1,
"Auto-deactivating generator\n");
2961 if (generator_old && generator_old->
release) {
2990 int *exception,
int *outfd,
int *ms)
2992 struct timeval start = { 0 , 0 };
2993 struct pollfd *pfds =
NULL;
2998 struct timeval now = { 0, 0 };
2999 struct timeval whentohangup = { 0, 0 }, diff;
3013 for (x = 0; x < n; x++) {
3027 whentohangup = diff;
3043 if (!
ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3044 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000;
3045 if (*ms >= 0 && *ms < rms) {
3048 }
else if (!
ast_tvzero(whentohangup) && rms < 0) {
3058 for (x = 0; x < n; x++) {
3061 fdmap[
max].fdno = y;
3062 fdmap[
max].chan = x;
3069 for (x = 0; x < nfds; x++) {
3070 fdmap[
max].chan = -1;
3078 if (
sizeof(
int) == 4) {
3081 if (kbrms > 600000) {
3088 }
while (!res && (rms > 0));
3092 for (x = 0; x < n; x++) {
3098 if (
errno != EINTR) {
3105 for (x = 0; x < n; x++) {
3109 if (winner ==
NULL) {
3124 for (x = 0; x <
max; x++) {
3125 res = pfds[x].revents;
3129 if (fdmap[x].chan >= 0) {
3130 winner =
c[fdmap[x].chan];
3132 if (res & POLLPRI) {
3141 *outfd = pfds[x].fd;
3144 *exception = (res & POLLPRI) ? -1 : 0;
3189 unsigned int real_rate = rate, max_rate;
3204 real_rate = max_rate;
3207 ast_debug(3,
"Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3218 if (
data && is_ao2_obj) {
3265 if (!rchan && outfd < 0 && ms) {
3271 }
else if (outfd > -1) {
3273 ast_log(
LOG_WARNING,
"The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3291 if (!breakon || strchr(breakon, res)) {
3374 char digit_str[] = {
digit,
'\0' };
3390 char digit_str[] = {
digit,
'\0' };
3436 samples = (int) (((
float) f->
samples) * factor);
3461 ast_debug(1,
"Auto-deactivating generator\n");
3514 int diff = sample_rate - seek_rate;
3518 }
else if (diff < 0) {
3572 "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3611 if (trigger_dtmf_emulating) {
3621 }
else if (trigger_dtmf_emulating) {
3667 int skipped_dtmf_frame = 0;
3676 skipped_dtmf_frame = 1;
3688 if (!skipped_dtmf_frame) {
3781 if (stream == default_stream) {
3808 if (dropnondefault && stream != default_stream) {
3820 ast_debug(1,
"Dropping duplicate answer!\n");
3833 read_action_payload = f->
data.
ptr;
3834 switch (read_action_payload->
action) {
3955 }
else if (!f->
len) {
4039 if (old_frame != f) {
4057 if (stream != default_stream) {
4163 if (old_frame != f) {
4170 #ifndef MONITOR_CONSTANT_DELAY
4177 ast_log(
LOG_WARNING,
"Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4187 if (jump - MONITOR_DELAY >= 0) {
4189 ast_log(
LOG_WARNING,
"Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4215 if (old_frame != f) {
4322 switch (condition) {
4390 snprintf(causevar,
sizeof(causevar),
"HASH(SIP_CAUSE,%s)", cause_code->
chan_name);
4397 if (!strcasecmp(
flag,
"default"))
4399 if (!strcasecmp(
flag,
"omit"))
4401 if (!strcasecmp(
flag,
"billing"))
4403 if (!strcasecmp(
flag,
"documentation"))
4416 return "DOCUMENTATION";
4442 unsigned char proposed[1024];
4458 chan_indicated,
NULL);
4460 chan_connected,
NULL);
4461 if (current_size == -1 || proposed_size == -1) {
4465 if (current_size == proposed_size && !memcmp(
current, proposed, current_size)) {
4466 ast_debug(1,
"%s: Dropping redundant connected line update \"%s\" <%s>.\n",
4502 return res ? -1 : 0;
4514 switch (condition) {
4532 t38_parameters = data;
4578 if (_condition < 0) {
4586 switch (condition) {