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 104 #define DEFAULT_AMA_FLAGS AST_AMA_DOCUMENTATION 108 #define AST_MIN_DTMF_GAP 45 204 #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) 205 static const char *party_number_ton2str(
int ton)
207 #if defined(HAVE_PRI) 208 switch ((ton >> 4) & 0x07) {
209 case PRI_TON_INTERNATIONAL:
210 return "International";
211 case PRI_TON_NATIONAL:
213 case PRI_TON_NET_SPECIFIC:
214 return "Network Specific";
215 case PRI_TON_SUBSCRIBER:
217 case PRI_TON_ABBREVIATED:
218 return "Abbreviated";
219 case PRI_TON_RESERVED:
221 case PRI_TON_UNKNOWN:
230 #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) 231 static const char *party_number_plan2str(
int plan)
233 #if defined(HAVE_PRI) 234 switch (plan & 0x0F) {
236 case PRI_NPI_UNKNOWN:
238 case PRI_NPI_E163_E164:
239 return "Public (E.163/E.164)";
241 return "Data (X.121)";
243 return "Telex (F.69)";
244 case PRI_NPI_NATIONAL:
245 return "National Standard";
246 case PRI_NPI_PRIVATE:
248 case PRI_NPI_RESERVED:
259 #define FORMAT "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n" 265 e->
command =
"core show channeltypes";
267 "Usage: core show channeltypes\n" 268 " Lists available channel types registered in your\n" 269 " Asterisk server.\n";
278 ast_cli(a->
fd,
FORMAT,
"Type",
"Description",
"Devicestate",
"Presencestate",
"Indications",
"Transfer");
279 ast_cli(a->
fd,
FORMAT,
"-------------",
"-------------",
"-------------",
"-------------",
"-------------",
"-------------");
284 (cl->
tech->devicestate) ?
"yes" :
"no",
285 (cl->
tech->presencestate) ?
"yes" :
"no",
286 (cl->
tech->indicate) ?
"yes" :
"no",
287 (cl->
tech->transfer) ?
"yes" :
"no");
292 ast_cli(a->
fd,
"----------\n%d channel drivers registered.\n", count_chan);
308 wordlen = strlen(a->
word);
312 if (!strncasecmp(a->
word, cl->
tech->type, wordlen)) {
329 e->
command =
"core show channeltype";
331 "Usage: core show channeltype <name>\n" 332 " Show details about the specified channel type, <name>.\n";
344 if (!strncasecmp(cl->
tech->type, a->
argv[3], strlen(cl->
tech->type)))
350 ast_cli(a->
fd,
"\n%s is not a registered channel driver.\n", a->
argv[3]);
356 "-- Info about channel driver: %s --\n" 357 " Device State: %s\n" 358 "Presence State: %s\n" 361 " Capabilities: %s\n" 365 " Image Support: %s\n" 366 " Text Support: %s\n",
368 (cl->
tech->devicestate) ?
"yes" :
"no",
369 (cl->
tech->presencestate) ?
"yes" :
"no",
370 (cl->
tech->indicate) ?
"yes" :
"no",
371 (cl->
tech->transfer) ?
"yes" :
"no",
373 (cl->
tech->send_digit_begin) ?
"yes" :
"no",
374 (cl->
tech->send_digit_end) ?
"yes" :
"no",
375 (cl->
tech->send_html) ?
"yes" :
"no",
376 (cl->
tech->send_image) ?
"yes" :
"no",
377 (cl->
tech->send_text) ?
"yes" :
"no" 432 .description =
"Kill channel (should not see this)",
469 ast_debug(1,
"Setting hangupcause of channel %s to %d (is %d now)\n",
521 struct timeval whentohangup;
542 if (!strcasecmp(tech->
type, chan->
tech->type)) {
556 ast_debug(1,
"Registered handler for '%s' (%s)\n", chan->
tech->type, chan->
tech->description);
558 ast_verb(2,
"Registered channel type '%s' (%s)\n", chan->
tech->type, chan->
tech->description);
570 ast_debug(1,
"Unregistering channel type '%s'\n", tech->
type);
575 if (chan->
tech == tech) {
578 ast_verb(2,
"Unregistered channel type '%s'\n", tech->
type);
596 if (!strcasecmp(name, chanls->
tech->type)) {
612 for (x = 0; x <
ARRAY_LEN(causes); x++) {
613 if (causes[x].cause == cause)
614 return causes[x].
desc;
626 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
627 return causes[x].cause;
660 return "Dialing Offhook";
676 switch (transfercapability) {
682 return "RESTRICTED_DIGITAL";
686 return "DIGITAL_W_TONES";
700 .description =
"Surrogate channel used to pull channel from an application",
706 .description =
"Null channel (should not see this)",
724 ast_log(
LOG_ERROR,
"Channel Unique ID '%s' already in use by channel %s(%p)\n",
738 const
char *
file,
int line,
739 const
char *function, const
char *name_fmt, va_list ap)
758 file, line,
function);
775 if (!nativeformats) {
794 ast_log(
LOG_WARNING,
"Channel allocation failed: Unable to create schedule context\n");
862 char *slash, *slash2;
870 ast_channel_name_build_va(tmp, name_fmt, ap);
872 if ((slash = strchr(
tech,
'/'))) {
873 if ((slash2 = strchr(slash + 1,
'/'))) {
894 ast_channel_accountcode_set(tmp, acctcode);
957 const char *
cid_name,
const char *acctcode,
961 const char *
file,
int line,
const char *
function,
962 const char *name_fmt, ...)
967 va_start(ap, name_fmt);
969 assignedids, requestor, amaflag, endpoint, file, line,
function, name_fmt, ap);
983 file, line,
function);
1015 unsigned int new_frames = 0;
1016 unsigned int new_voice_frames = 0;
1017 unsigned int queued_frames = 0;
1018 unsigned int queued_voice_frames = 0;
1080 queued_voice_frames++;
1084 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1117 while (new_frames--) {
1194 f.
data.
ptr = (
void *) musicclass;
1195 f.
datalen = strlen(musicclass) + 1;
1198 "musicclass", musicclass);
1275 void *
data,
int ao2_flags)
1283 const char *
name = arg;
1284 size_t name_len = *(
size_t *) data;
1288 ast_log(
LOG_ERROR,
"BUG! Must supply a channel name or partial name to match!\n");
1329 size_t id_len = *(
size_t *) data;
1333 ast_log(
LOG_ERROR,
"BUG! Must supply a uniqueid or partial uniqueid to match!\n");
1367 char *l_exten = (
char *) exten;
1368 char *l_context = (
char *) context;
1387 char *l_name = (
char *) name;
1433 char *l_name = (
char *) name;
1436 (name_len == 0) ?
OBJ_KEY : 0);
1457 char *l_exten = (
char *) exten;
1458 char *l_context = (
char *) context;
1499 struct timeval start;
1514 if (
cond && ((*
cond)(data) == 0)) {
1614 if (src->
str && src->
str != dest->
str) {
1667 if (src->
str && src->
str != dest->
str) {
1720 if (src->
str && src->
str != dest->
str) {
1738 update_id->
name = 1;
1781 if (!update || update->
name) {
1784 if (!update || update->
number) {
1791 if (src->
tag && src->
tag != dest->
tag) {
1809 int number_priority;
1811 int number_screening;
1821 switch (name_value) {
1842 number_priority = 3;
1846 switch (number_value) {
1848 number_priority = 0;
1851 number_priority = 1;
1854 number_priority = 2;
1859 number_priority = 3;
1865 if (name_priority < number_priority) {
1866 number_value = name_value;
1872 return number_value | number_screening;
1878 id->number.valid = 0;
1879 id->subaddress.valid = 0;
1893 if (overlay->name.valid) {
1894 merged.
name = overlay->name;
1896 if (overlay->number.valid) {
1897 merged.number = overlay->number;
1899 if (overlay->subaddress.valid) {
1900 merged.subaddress = overlay->subaddress;
2051 connected->
id = caller->
id;
2052 connected->
ani = caller->
ani;
2094 if (src->
str && src->
str != dest->
str) {
2245 if ((dashptr = strrchr(device_name,
'-'))) {
2249 device_name[0] =
'\0';
2304 if (device_name[0]) {
2398 if (datastore->
info != info) {
2407 if ((datastore->
uid !=
NULL) && !strcasecmp(uid, datastore->
uid)) {
2496 ast_channel_hangupsource_set(chan, source);
2503 ast_channel_hangupsource_set(bridge, source);
2597 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",
2626 struct timeval answertime;
2701 switch (old_state) {
2711 int timeout_ms =
MAX(delay, 500);
2712 unsigned int done = 0;
2713 struct timeval start;
2727 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));
2877 if (generator && generator->
release) {
2926 if (!tmp || !generate) {
2939 ast_debug(1,
"Auto-deactivating generator\n");
2955 if (generator_old && generator_old->
release) {
2959 if (gen->
alloc && !(generatordata = gen->
alloc(chan, params))) {
2984 int *exception,
int *outfd,
int *ms)
2986 struct timeval start = { 0 , 0 };
2987 struct pollfd *pfds =
NULL;
2992 struct timeval now = { 0, 0 };
2993 struct timeval whentohangup = { 0, 0 }, diff;
3007 for (x = 0; x < n; x++) {
3021 whentohangup = diff;
3037 if (!
ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3038 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000;
3039 if (*ms >= 0 && *ms < rms) {
3042 }
else if (!
ast_tvzero(whentohangup) && rms < 0) {
3052 for (x = 0; x < n; x++) {
3055 fdmap[
max].fdno = y;
3056 fdmap[
max].chan = x;
3063 for (x = 0; x < nfds; x++) {
3064 fdmap[
max].chan = -1;
3072 if (
sizeof(
int) == 4) {
3075 if (kbrms > 600000) {
3082 }
while (!res && (rms > 0));
3086 for (x = 0; x < n; x++) {
3092 if (
errno != EINTR) {
3099 for (x = 0; x < n; x++) {
3103 if (winner ==
NULL) {
3118 for (x = 0; x <
max; x++) {
3119 res = pfds[x].revents;
3123 if (fdmap[x].chan >= 0) {
3124 winner = c[fdmap[x].chan];
3126 if (res & POLLPRI) {
3135 *outfd = pfds[x].fd;
3138 *exception = (res & POLLPRI) ? -1 : 0;
3183 unsigned int real_rate = rate, max_rate;
3198 real_rate = max_rate;
3201 ast_debug(1,
"Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3212 if (data && is_ao2_obj) {
3259 if (!rchan && outfd < 0 && ms) {
3265 }
else if (outfd > -1) {
3267 ast_log(
LOG_WARNING,
"The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3285 if (!breakon || strchr(breakon, res)) {
3353 switch (direction) {
3367 char digit_str[] = {
digit,
'\0' };
3383 char digit_str[] = {
digit,
'\0' };
3419 samples = (int) (((
float) f->
samples) * factor);
3444 ast_debug(1,
"Auto-deactivating generator\n");
3497 int diff = sample_rate - seek_rate;
3500 samples = samples / (float) (sample_rate / seek_rate);
3501 }
else if (diff < 0) {
3502 samples = samples * (float) (seek_rate / sample_rate);
3555 "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3594 if (trigger_dtmf_emulating) {
3604 }
else if (trigger_dtmf_emulating) {
3650 int skipped_dtmf_frame = 0;
3659 skipped_dtmf_frame = 1;
3671 if (!skipped_dtmf_frame) {
3764 if (stream == default_stream) {
3791 if (dropnondefault && stream != default_stream) {
3803 ast_debug(1,
"Dropping duplicate answer!\n");
3816 read_action_payload = f->
data.
ptr;
3817 switch (read_action_payload->
action) {
3934 }
else if (!f->
len) {
4018 if (old_frame != f) {
4036 if (stream != default_stream) {
4142 if (old_frame != f) {
4149 #ifndef MONITOR_CONSTANT_DELAY 4156 ast_log(
LOG_WARNING,
"Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4166 if (jump - MONITOR_DELAY >= 0) {
4168 ast_log(
LOG_WARNING,
"Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
4194 if (old_frame != f) {
4301 switch (condition) {
4369 snprintf(causevar,
sizeof(causevar),
"HASH(SIP_CAUSE,%s)", cause_code->
chan_name);
4376 if (!strcasecmp(flag,
"default"))
4378 if (!strcasecmp(flag,
"omit"))
4380 if (!strcasecmp(flag,
"billing"))
4382 if (!strcasecmp(flag,
"documentation"))
4395 return "DOCUMENTATION";
4420 unsigned char current[1024];
4421 unsigned char proposed[1024];
4437 chan_indicated,
NULL);
4439 chan_connected,
NULL);
4440 if (current_size == -1 || proposed_size == -1) {
4444 if (current_size == proposed_size && !memcmp(current, proposed, current_size)) {
4445 ast_debug(1,
"%s: Dropping redundant connected line update \"%s\" <%s>.\n",
4481 return res ? -1 : 0;
4493 switch (condition) {
4511 t38_parameters = data;
4557 if (_condition < 0) {
4565 switch (condition) {
4649 ast_debug(1,
"Driver for channel '%s' does not support indication %u, emulating it\n",
ast_channel_name(chan), condition);
4680 goto indicate_cleanup;
4687 .subclass.integer = _condition,
4688 .data.ptr = (
void *) data,
4701 goto indicate_cleanup;
4705 data = awesome_frame->
data.
ptr;
4706 datalen = awesome_frame->
datalen;
4713 if (awesome_frame) {
4726 c = *(
unsigned char *)buf;
4784 size_t body_len = strlen(body);
4787 memset(&f, 0,
sizeof(f));
4803 ast_debug(1,
"Sending TEXT_DATA from '%s' to %s:%s %s\n",