73 #include "asterisk/stasis_channels.h"
74 #include "asterisk/max_forwards.h"
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
137 { AST_CAUSE_UNALLOCATED,
"UNALLOCATED",
"Unallocated (unassigned) number" },
138 { AST_CAUSE_NO_ROUTE_TRANSIT_NET,
"NO_ROUTE_TRANSIT_NET",
"No route to specified transmit network" },
139 { AST_CAUSE_NO_ROUTE_DESTINATION,
"NO_ROUTE_DESTINATION",
"No route to destination" },
140 { AST_CAUSE_MISDIALLED_TRUNK_PREFIX,
"MISDIALLED_TRUNK_PREFIX",
"Misdialed trunk prefix" },
141 { AST_CAUSE_CHANNEL_UNACCEPTABLE,
"CHANNEL_UNACCEPTABLE",
"Channel unacceptable" },
142 { AST_CAUSE_CALL_AWARDED_DELIVERED,
"CALL_AWARDED_DELIVERED",
"Call awarded and being delivered in an established channel" },
143 { AST_CAUSE_PRE_EMPTED,
"PRE_EMPTED",
"Pre-empted" },
144 { AST_CAUSE_NUMBER_PORTED_NOT_HERE,
"NUMBER_PORTED_NOT_HERE",
"Number ported elsewhere" },
145 { AST_CAUSE_NORMAL_CLEARING,
"NORMAL_CLEARING",
"Normal Clearing" },
146 { AST_CAUSE_USER_BUSY,
"USER_BUSY",
"User busy" },
147 { AST_CAUSE_NO_USER_RESPONSE,
"NO_USER_RESPONSE",
"No user responding" },
148 { AST_CAUSE_NO_ANSWER,
"NO_ANSWER",
"User alerting, no answer" },
149 { AST_CAUSE_SUBSCRIBER_ABSENT,
"SUBSCRIBER_ABSENT",
"Subscriber absent" },
150 { AST_CAUSE_CALL_REJECTED,
"CALL_REJECTED",
"Call Rejected" },
151 { AST_CAUSE_NUMBER_CHANGED,
"NUMBER_CHANGED",
"Number changed" },
152 { AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION,
"REDIRECTED_TO_NEW_DESTINATION",
"Redirected to new destination" },
153 { AST_CAUSE_ANSWERED_ELSEWHERE,
"ANSWERED_ELSEWHERE",
"Answered elsewhere" },
154 { AST_CAUSE_DESTINATION_OUT_OF_ORDER,
"DESTINATION_OUT_OF_ORDER",
"Destination out of order" },
155 { AST_CAUSE_INVALID_NUMBER_FORMAT,
"INVALID_NUMBER_FORMAT",
"Invalid number format" },
156 { AST_CAUSE_FACILITY_REJECTED,
"FACILITY_REJECTED",
"Facility rejected" },
157 { AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY,
"RESPONSE_TO_STATUS_ENQUIRY",
"Response to STATus ENQuiry" },
158 { AST_CAUSE_NORMAL_UNSPECIFIED,
"NORMAL_UNSPECIFIED",
"Normal, unspecified" },
159 { AST_CAUSE_NORMAL_CIRCUIT_CONGESTION,
"NORMAL_CIRCUIT_CONGESTION",
"Circuit/channel congestion" },
160 { AST_CAUSE_NETWORK_OUT_OF_ORDER,
"NETWORK_OUT_OF_ORDER",
"Network out of order" },
161 { AST_CAUSE_NORMAL_TEMPORARY_FAILURE,
"NORMAL_TEMPORARY_FAILURE",
"Temporary failure" },
162 { AST_CAUSE_SWITCH_CONGESTION,
"SWITCH_CONGESTION",
"Switching equipment congestion" },
163 { AST_CAUSE_ACCESS_INFO_DISCARDED,
"ACCESS_INFO_DISCARDED",
"Access information discarded" },
164 { AST_CAUSE_REQUESTED_CHAN_UNAVAIL,
"REQUESTED_CHAN_UNAVAIL",
"Requested channel not available" },
165 { AST_CAUSE_FACILITY_NOT_SUBSCRIBED,
"FACILITY_NOT_SUBSCRIBED",
"Facility not subscribed" },
166 { AST_CAUSE_OUTGOING_CALL_BARRED,
"OUTGOING_CALL_BARRED",
"Outgoing call barred" },
167 { AST_CAUSE_INCOMING_CALL_BARRED,
"INCOMING_CALL_BARRED",
"Incoming call barred" },
168 { AST_CAUSE_BEARERCAPABILITY_NOTAUTH,
"BEARERCAPABILITY_NOTAUTH",
"Bearer capability not authorized" },
169 { AST_CAUSE_BEARERCAPABILITY_NOTAVAIL,
"BEARERCAPABILITY_NOTAVAIL",
"Bearer capability not available" },
170 { AST_CAUSE_BEARERCAPABILITY_NOTIMPL,
"BEARERCAPABILITY_NOTIMPL",
"Bearer capability not implemented" },
171 { AST_CAUSE_CHAN_NOT_IMPLEMENTED,
"CHAN_NOT_IMPLEMENTED",
"Channel not implemented" },
172 { AST_CAUSE_FACILITY_NOT_IMPLEMENTED,
"FACILITY_NOT_IMPLEMENTED",
"Facility not implemented" },
173 { AST_CAUSE_INVALID_CALL_REFERENCE,
"INVALID_CALL_REFERENCE",
"Invalid call reference value" },
174 { AST_CAUSE_INCOMPATIBLE_DESTINATION,
"INCOMPATIBLE_DESTINATION",
"Incompatible destination" },
175 { AST_CAUSE_INVALID_MSG_UNSPECIFIED,
"INVALID_MSG_UNSPECIFIED",
"Invalid message unspecified" },
176 { AST_CAUSE_MANDATORY_IE_MISSING,
"MANDATORY_IE_MISSING",
"Mandatory information element is missing" },
177 { AST_CAUSE_MESSAGE_TYPE_NONEXIST,
"MESSAGE_TYPE_NONEXIST",
"Message type nonexist." },
178 { AST_CAUSE_WRONG_MESSAGE,
"WRONG_MESSAGE",
"Wrong message" },
179 { AST_CAUSE_IE_NONEXIST,
"IE_NONEXIST",
"Info. element nonexist or not implemented" },
180 { AST_CAUSE_INVALID_IE_CONTENTS,
"INVALID_IE_CONTENTS",
"Invalid information element contents" },
181 { AST_CAUSE_WRONG_CALL_STATE,
"WRONG_CALL_STATE",
"Message not compatible with call state" },
182 { AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE,
"RECOVERY_ON_TIMER_EXPIRE",
"Recover on timer expiry" },
183 { AST_CAUSE_MANDATORY_IE_LENGTH_ERROR,
"MANDATORY_IE_LENGTH_ERROR",
"Mandatory IE length error" },
184 { AST_CAUSE_PROTOCOL_ERROR,
"PROTOCOL_ERROR",
"Protocol error, unspecified" },
185 { AST_CAUSE_INTERWORKING,
"INTERWORKING",
"Interworking, unspecified" },
194 AST_RWLIST_TRAVERSE(&
backends, cl, list) {
196 if ((prev->next = ast_variable_new(cl->
tech->type, cl->
tech->description,
"")))
199 var = ast_variable_new(cl->
tech->type, cl->
tech->description,
"");
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";
280 return CLI_SHOWUSAGE;
282 ast_cli(a->fd, FORMAT,
"Type",
"Description",
"Devicestate",
"Presencestate",
"Indications",
"Transfer");
283 ast_cli(a->fd, FORMAT,
"-------------",
"-------------",
"-------------",
"-------------",
"-------------",
"-------------");
286 AST_RWLIST_TRAVERSE(&
backends, cl, list) {
287 ast_cli(a->fd, FORMAT, cl->
tech->type, cl->
tech->description,
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);
303 static char *complete_channeltypes(
struct ast_cli_args *a)
312 wordlen = strlen(a->word);
315 AST_RWLIST_TRAVERSE(&
backends, cl, list) {
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";
339 return complete_channeltypes(a);
343 return CLI_SHOWUSAGE;
347 AST_RWLIST_TRAVERSE(&
backends, cl, list) {
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"
421 ast_channel_tech_pvt_set(chan, NULL);
436 .description =
"Kill channel (should not see this)",
438 .exception = kill_exception,
441 .hangup = kill_hangup,
447 if (ast_channel_softhangup_internal_flag(chan))
449 if (
ast_tvzero(*ast_channel_whentohangup(chan)))
459 int ast_check_hangup_locked(
struct ast_channel *chan)
462 ast_channel_lock(chan);
464 ast_channel_unlock(chan);
470 ast_channel_lock(chan);
473 ast_debug(1,
"Setting hangupcause of channel %s to %d (is %d now)\n",
474 ast_channel_name(chan), causecode, ast_channel_hangupcause(chan));
476 ast_channel_hangupcause_set(chan, causecode);
481 ast_channel_unlock(chan);
484 static int ast_channel_softhangup_cb(
void *obj,
void *arg,
int flags)
525 struct timeval whentohangup;
527 if (
ast_tvzero(*ast_channel_whentohangup(chan)))
535 return ast_tvdiff_ms(whentohangup, *ast_channel_whentohangup(chan));
545 AST_RWLIST_TRAVERSE(&
backends, chan, list) {
546 if (!strcasecmp(tech->type, chan->
tech->type)) {
547 ast_log(LOG_WARNING,
"Already have a handler for type '%s'\n", tech->type);
558 AST_RWLIST_INSERT_HEAD(&
backends, chan, list);
560 ast_debug(5,
"Registered handler for '%s' (%s)\n", chan->
tech->type, chan->
tech->description);
562 ast_verb(5,
"Registered channel type '%s' (%s)\n", chan->
tech->type, chan->
tech->description);
574 ast_debug(5,
"Unregistering channel type '%s'\n", tech->type);
578 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&
backends, chan, list) {
579 if (chan->
tech == tech) {
582 ast_verb(5,
"Unregistered channel type '%s'\n", tech->type);
599 AST_RWLIST_TRAVERSE(&
backends, chanls, list) {
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;
629 for (x = 0; x < ARRAY_LEN(causes); x++)
630 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name)))
631 return causes[x].cause;
658 return "Dialing Offhook";
666 snprintf(buf, STATE2STR_BUFSIZE,
"Unknown (%u)", state);
674 switch (transfercapability) {
675 case AST_TRANS_CAP_SPEECH:
677 case AST_TRANS_CAP_DIGITAL:
679 case AST_TRANS_CAP_RESTRICTED_DIGITAL:
680 return "RESTRICTED_DIGITAL";
681 case AST_TRANS_CAP_3_1K_AUDIO:
683 case AST_TRANS_CAP_DIGITAL_W_TONES:
684 return "DIGITAL_W_TONES";
685 case AST_TRANS_CAP_VIDEO:
698 .description =
"Surrogate channel used to pull channel from an application",
704 .description =
"Null channel (should not see this)",
709 static int ast_channel_by_uniqueid_cb(
void *obj,
void *arg,
void *data,
int flags);
711 static int does_id_conflict(
const char *uniqueid)
716 if (ast_strlen_zero(uniqueid)) {
722 ast_log(LOG_ERROR,
"Channel Unique ID '%s' already in use by channel %s(%p)\n",
723 uniqueid, ast_channel_name(conflict), conflict);
732 static struct ast_channel *__attribute__((format(printf, 15, 0)))
736 const
char *file,
int line,
737 const
char *function, const
char *name_fmt, va_list ap)
741 char *tech =
"", *tech2 = NULL;
751 ast_log(LOG_WARNING,
"Channel allocation failed: Refusing due to active shutdown\n");
756 file, line,
function);
768 ast_channel_timingfd_set(tmp, -1);
769 ast_channel_internal_alertpipe_clear(tmp);
770 ast_channel_internal_fd_clear_all(tmp);
773 if (!nativeformats) {
783 ast_channel_nativeformats_set(tmp, nativeformats);
792 ast_log(LOG_WARNING,
"Channel allocation failed: Unable to create schedule context\n");
796 ast_channel_sched_set(tmp, schedctx);
807 if (!ast_channel_caller(tmp)->
id.name.str) {
815 if (!ast_channel_caller(tmp)->
id.
number.str) {
822 ast_channel_timer_set(tmp, timer);
826 ast_channel_timingfd_set(tmp,
ast_timer_fd(ast_channel_timer(tmp)));
829 if (needqueue && ast_channel_internal_alertpipe_init(tmp)) {
837 ast_channel_internal_set_stream_topology(tmp, topology);
845 ast_channel_state_set(tmp, state);
848 ast_channel_streamid_set(tmp, -1);
849 ast_channel_vstreamid_set(tmp, -1);
852 ast_channel_fout_set(tmp, global_fout);
855 ast_channel_creationtime_set(tmp, &now);
857 ast_channel_internal_setup_topics(tmp);
859 if (!ast_strlen_zero(name_fmt)) {
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,
'/'))) {
882 ast_channel_name_set(tmp,
"-**Unknown**");
885 if (amaflag != AST_AMA_NONE) {
891 if (!ast_strlen_zero(acctcode)) {
892 ast_channel_accountcode_set(tmp, acctcode);
894 ast_channel_language_set(tmp, ast_defaultlanguage);
896 ast_channel_context_set(tmp,
S_OR(context,
"default"));
897 ast_channel_exten_set(tmp,
S_OR(exten,
"s"));
898 ast_channel_priority_set(tmp, 1);
900 headp = ast_channel_varshead(tmp);
908 if (!channel_tech && !ast_strlen_zero(tech2)) {
912 ast_channel_tech_set(tmp, channel_tech);
914 ast_channel_tech_set(tmp, &null_tech);
920 ast_channel_lock(tmp);
924 if (assignedids && (does_id_conflict(assignedids->uniqueid) || does_id_conflict(assignedids->uniqueid2))) {
925 ast_channel_internal_errno_set(AST_CHANNEL_ERROR_ID_EXISTS);
926 ao2_unlock(channels);
927 ast_channel_unlock(tmp);
933 ast_channel_internal_finalize(tmp);
937 ao2_unlock(channels);
949 ast_debug(1,
"Channel %p '%s' allocated\n", tmp, ast_channel_name(tmp));
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);
975 struct ast_channel *__ast_dummy_channel_alloc(
const char *file,
int line,
const char *
function)
981 file, line,
function);
995 ast_channel_timingfd_set(tmp, -1);
996 ast_channel_internal_alertpipe_clear(tmp);
997 ast_channel_internal_fd_clear_all(tmp);
1001 ast_channel_internal_setup_topics(tmp);
1003 headp = ast_channel_varshead(tmp);
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;
1019 ast_channel_lock(chan);
1027 switch (cur->subclass.integer) {
1049 ast_channel_unlock(chan);
1063 ast_channel_unlock(chan);
1078 queued_voice_frames++;
1082 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1083 int total_queued = queued_frames + new_frames;
1084 int total_voice = queued_voice_frames + new_voice_frames;
1086 ast_log(LOG_WARNING,
"Exceptionally long %squeue length (%d voice / %d total) queuing to %s\n",
1087 queued_frames + new_frames > 128 ?
"" :
"voice ", total_voice, total_queued, ast_channel_name(chan));
1100 ast_channel_internal_alert_read(chan);
1105 ast_debug(4,
"Discarded %d frame%s due to queue overload on %s\n", count,
ESS(count), ast_channel_name(chan));
1119 if (ast_channel_alert_writable(chan)) {
1121 while (new_frames--) {
1122 if (ast_channel_alert_write(chan)) {
1123 ast_log(LOG_WARNING,
"Unable to write to alert pipe on %s (qlen = %u): %s!\n",
1124 ast_channel_name(chan), queued_frames, strerror(errno));
1128 }
else if (ast_channel_timingfd(chan) > -1) {
1131 pthread_kill(ast_channel_blocker(chan), SIGURG);
1134 ast_channel_unlock(chan);
1141 return __ast_queue_frame(chan, fin, 0, NULL);
1146 return __ast_queue_frame(chan, fin, 1, NULL);
1156 ast_channel_lock(chan);
1161 ast_channel_unlock(chan);
1173 f.
data.uint32 = cause;
1177 ast_channel_lock(chan);
1180 f.
data.uint32 = ast_channel_hangupcause(chan);
1187 ast_channel_unlock(chan);
1197 if (!ast_strlen_zero(musicclass)) {
1198 f.
data.ptr = (
void *) musicclass;
1199 f.
datalen = strlen(musicclass) + 1;
1202 "musicclass", musicclass);
1205 ast_channel_lock(chan);
1207 ast_channel_unlock(chan);
1221 ast_channel_lock(chan);
1223 ast_channel_unlock(chan);
1262 ast_channel_lock(chan);
1265 ast_channel_unlock(chan);
1279 void *data,
int ao2_flags)
1281 return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data);
1284 static int ast_channel_by_name_cb(
void *obj,
void *arg,
void *data,
int flags)
1287 const char *
name = arg;
1288 size_t name_len = *(
size_t *) data;
1291 if (ast_strlen_zero(name)) {
1292 ast_log(LOG_ERROR,
"BUG! Must supply a channel name or partial name to match!\n");
1296 ast_channel_lock(chan);
1297 if ((!name_len && strcasecmp(ast_channel_name(chan), name))
1298 || (name_len && strncasecmp(ast_channel_name(chan), name, name_len))) {
1301 ast_channel_unlock(chan);
1306 static int ast_channel_by_exten_cb(
void *obj,
void *arg,
void *data,
int flags)
1313 if (ast_strlen_zero(exten) || ast_strlen_zero(context)) {
1314 ast_log(LOG_ERROR,
"BUG! Must have a context and extension to match!\n");
1318 ast_channel_lock(chan);
1319 if (strcasecmp(ast_channel_context(chan), context)) {
1321 }
else if (strcasecmp(ast_channel_exten(chan), exten)) {
1324 ast_channel_unlock(chan);
1329 static int ast_channel_by_uniqueid_cb(
void *obj,
void *arg,
void *data,
int flags)
1332 char *uniqueid = arg;
1333 size_t id_len = *(
size_t *) data;
1336 if (ast_strlen_zero(uniqueid)) {
1337 ast_log(LOG_ERROR,
"BUG! Must supply a uniqueid or partial uniqueid to match!\n");
1341 ast_channel_lock(chan);
1342 if ((!id_len && strcasecmp(ast_channel_uniqueid(chan), uniqueid))
1343 || (id_len && strncasecmp(ast_channel_uniqueid(chan), uniqueid, id_len))) {
1346 ast_channel_unlock(chan);
1371 char *l_exten = (
char *) exten;
1372 char *l_context = (
char *) context;
1380 if (!i->active_iterator) {
1391 char *l_name = (
char *) name;
1400 if (!i->active_iterator) {
1417 i->active_iterator = &i->simple_iterator;
1424 return ao2_iterator_next(i->active_iterator);
1428 static int ast_channel_cmp_cb(
void *obj,
void *arg,
int flags)
1430 ast_log(LOG_ERROR,
"BUG! Should never be called!\n");
1437 char *l_name = (
char *) name;
1439 if (ast_strlen_zero(l_name)) {
1445 (name_len == 0) ?
OBJ_KEY : 0);
1461 char *l_exten = (
char *) exten;
1462 char *l_context = (
char *) context;
1503 struct timeval start;
1510 if (generate_silence && ast_opt_transmit_silence && !ast_channel_generatordata(chan)) {
1518 if (cond && ((*cond)(data) == 0)) {
1556 ast_channel_lock(chan);
1563 ast_channel_unlock(chan);
1594 init->
char_set = AST_PARTY_CHAR_SET_ISO8859_1;
1595 init->
presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
1606 ast_free(dest->
str);
1628 if (src->
str && src->
str != dest->
str) {
1629 ast_free(dest->
str);
1640 ast_free(doomed->
str);
1648 init->
presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
1659 ast_free(dest->
str);
1681 if (src->
str && src->
str != dest->
str) {
1682 ast_free(dest->
str);
1693 ast_free(doomed->
str);
1712 ast_free(dest->
str);
1734 if (src->
str && src->
str != dest->
str) {
1735 ast_free(dest->
str);
1746 ast_free(doomed->
str);
1752 update_id->
name = 1;
1776 ast_free(dest->
tag);
1795 if (!update || update->
name) {
1798 if (!update || update->
number) {
1805 if (src->
tag && src->
tag != dest->
tag) {
1806 ast_free(dest->
tag);
1817 ast_free(doomed->
tag);
1823 int number_priority;
1825 int number_screening;
1831 name_value = AST_PRES_UNAVAILABLE;
1834 name_value =
id->name.presentation & AST_PRES_RESTRICTION;
1835 switch (name_value) {
1836 case AST_PRES_RESTRICTED:
1839 case AST_PRES_ALLOWED:
1842 case AST_PRES_UNAVAILABLE:
1846 name_value = AST_PRES_UNAVAILABLE;
1854 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1855 number_value = AST_PRES_UNAVAILABLE;
1856 number_priority = 3;
1858 number_screening =
id->number.presentation & AST_PRES_NUMBER_TYPE;
1859 number_value =
id->number.presentation & AST_PRES_RESTRICTION;
1860 switch (number_value) {
1861 case AST_PRES_RESTRICTED:
1862 number_priority = 0;
1864 case AST_PRES_ALLOWED:
1865 number_priority = 1;
1867 case AST_PRES_UNAVAILABLE:
1868 number_priority = 2;
1871 number_screening = AST_PRES_USER_NUMBER_UNSCREENED;
1872 number_value = AST_PRES_UNAVAILABLE;
1873 number_priority = 3;
1879 if (name_priority < number_priority) {
1880 number_value = name_value;
1882 if (number_value == AST_PRES_UNAVAILABLE) {
1883 return AST_PRES_NUMBER_NOT_AVAILABLE;
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;
2082 init->
code = AST_REDIRECTING_REASON_UNKNOWN;
2091 ast_free(dest->
str);
2108 if (src->
str && src->
str != dest->
str) {
2109 ast_free(dest->
str);
2118 ast_free(doomed->
str);
2202 ast_debug(1,
"Channel %p '%s' destroying\n", chan, ast_channel_name(chan));
2205 if (ast_channel_music_state(chan)) {
2206 ast_moh_cleanup(chan);
2214 if (ast_channel_internal_is_finalized(chan)) {
2218 ast_channel_lock(chan);
2220 ast_channel_unlock(chan);
2223 ast_channel_lock(chan);
2231 callid = ast_channel_callid(chan);
2232 ast_channel_callid_cleanup(chan);
2234 ast_channel_unlock(chan);
2238 ast_channel_lock(chan);
2239 ast_channel_unlock(chan);
2241 if (ast_channel_tech_pvt(chan)) {
2242 ast_log_callid(LOG_WARNING, callid,
"Channel '%s' may not have been hung up properly\n", ast_channel_name(chan));
2243 ast_free(ast_channel_tech_pvt(chan));
2246 if (ast_channel_sched(chan)) {
2250 if (ast_channel_internal_is_finalized(chan)) {
2253 ast_copy_string(device_name, ast_channel_name(chan),
sizeof(device_name));
2254 if ((dashptr = strrchr(device_name,
'-'))) {
2258 device_name[0] =
'\0';
2262 if (ast_channel_readtrans(chan))
2264 if (ast_channel_writetrans(chan))
2266 if (ast_channel_pbx(chan))
2267 ast_log_callid(LOG_WARNING, callid,
"PBX may not have been terminated properly on '%s'\n", ast_channel_name(chan));
2270 ast_channel_set_oldwriteformat(chan, NULL);
2271 ast_channel_set_rawreadformat(chan, NULL);
2272 ast_channel_set_rawwriteformat(chan, NULL);
2273 ast_channel_set_readformat(chan, NULL);
2274 ast_channel_set_writeformat(chan, NULL);
2283 ast_channel_internal_alertpipe_close(chan);
2284 if (ast_channel_timer(chan)) {
2286 ast_channel_timer_set(chan, NULL);
2293 headp = ast_channel_varshead(chan);
2295 ast_var_delete(vardata);
2302 if (ast_channel_cdr(chan)) {
2304 ast_channel_cdr_set(chan, NULL);
2307 if (ast_channel_zone(chan)) {
2311 ast_channel_internal_cleanup(chan);
2313 if (device_name[0]) {
2324 ast_channel_nativeformats_set(chan, NULL);
2326 ast_channel_named_callgroups_set(chan, NULL);
2327 ast_channel_named_pickupgroups_set(chan, NULL);
2356 headp = ast_channel_varshead(chan);
2358 ast_var_delete(vardata);
2360 if (ast_channel_cdr(chan)) {
2362 ast_channel_cdr_set(chan, NULL);
2365 ast_channel_internal_cleanup(chan);
2374 datastore2 = ast_datastore_alloc(datastore->
info, datastore->
uid);
2377 datastore2->inheritance = datastore->
inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->
inheritance - 1;
2407 if (datastore->
info != info) {
2416 if ((datastore->
uid != NULL) && !strcasecmp(uid, datastore->
uid)) {
2428 ast_channel_internal_fd_set(chan, which, fd);
2434 ast_channel_lock(chan);
2436 ast_channel_softhangup_internal_flag_clear(chan, flag);
2438 if (!ast_channel_softhangup_internal_flag(chan)) {
2454 ast_channel_unlock(chan);
2460 ast_debug(1,
"Soft-Hanging (%#04x) up channel '%s'\n", (
unsigned)cause, ast_channel_name(chan));
2462 ast_channel_softhangup_internal_flag_add(chan, cause);
2466 pthread_kill(ast_channel_blocker(chan), SIGURG);
2476 ast_channel_lock(chan);
2482 ast_channel_unlock(chan);
2487 static void free_translation(
struct ast_channel *clonechan)
2489 if (ast_channel_writetrans(clonechan)) {
2492 if (ast_channel_readtrans(clonechan)) {
2495 ast_channel_writetrans_set(clonechan, NULL);
2496 ast_channel_readtrans_set(clonechan, NULL);
2503 ast_channel_lock(chan);
2504 if (force || ast_strlen_zero(ast_channel_hangupsource(chan))) {
2505 ast_channel_hangupsource_set(chan, source);
2507 ast_channel_unlock(chan);
2510 ast_channel_lock(bridge);
2511 if (force || ast_strlen_zero(ast_channel_hangupsource(bridge))) {
2512 ast_channel_hangupsource_set(bridge, source);
2514 ast_channel_unlock(bridge);
2530 static void destroy_hooks(
struct ast_channel *chan)
2532 if (ast_channel_audiohooks(chan)) {
2534 ast_channel_audiohooks_set(chan, NULL);
2548 ast_debug(1,
"Channel %p '%s' hanging up. Refs: %d\n", chan, ast_channel_name(chan),
2553 ast_channel_lock(chan);
2555 while (ast_channel_masq(chan) || ast_channel_masqr(chan)) {
2556 CHANNEL_DEADLOCK_AVOIDANCE(chan);
2562 ast_channel_unlock(chan);
2575 ast_channel_lock(chan);
2577 destroy_hooks(chan);
2579 free_translation(chan);
2581 if (ast_channel_stream(chan)) {
2583 ast_channel_stream_set(chan, NULL);
2586 if (ast_channel_vstream(chan)) {
2588 ast_channel_vstream_set(chan, NULL);
2590 if (ast_channel_sched(chan)) {
2592 ast_channel_sched_set(chan, NULL);
2595 if (ast_channel_generatordata(chan)) {
2596 if (ast_channel_generator(chan) && ast_channel_generator(chan)->release) {
2597 ast_channel_generator(chan)->
release(chan, ast_channel_generatordata(chan));
2600 ast_channel_generatordata_set(chan, NULL);
2601 ast_channel_generator_set(chan, NULL);
2604 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",
2605 ast_get_tid(), ast_channel_name(chan), ast_channel_blocker_tid(chan),
2606 ast_channel_blockproc(chan));
2614 ast_channel_unlock(chan);
2628 static void set_channel_answer_time(
struct ast_channel *chan)
2630 if (
ast_tvzero(ast_channel_answertime(chan))) {
2631 struct timeval answertime;
2634 ast_channel_answertime_set(chan, &answertime);
2642 SCOPE_TRACE(1,
"%s\n", ast_channel_name(chan));
2644 ast_channel_lock(chan);
2648 ast_channel_unlock(chan);
2654 ast_channel_unlock(chan);
2662 set_channel_answer_time(chan);
2664 ast_channel_unlock(chan);
2669 ast_channel_lock(chan);
2677 ast_channel_unlock(chan);
2699 SCOPE_TRACE(1,
"%s\n", ast_channel_name(chan));
2706 switch (old_state) {
2716 int timeout_ms = MAX(delay, 500);
2717 unsigned int done = 0;
2718 struct timeval start;
2727 ast_log(LOG_WARNING,
"Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
2732 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));
2742 ast_debug(2,
"Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
2788 ast_channel_lock(chan);
2795 ast_channel_unlock(chan);
2807 SCOPE_TRACE(1,
"%s\n", ast_channel_name(chan));
2822 ast_assert(NULL != chan);
2824 if (
ast_tvzero(ast_channel_creationtime(chan))) {
2837 ast_assert(NULL != chan);
2839 if (
ast_tvzero(ast_channel_answertime(chan))) {
2863 if (!
ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
2877 static void deactivate_generator_nolock(
struct ast_channel *chan)
2879 if (ast_channel_generatordata(chan)) {
2880 struct ast_generator *generator = ast_channel_generator(chan);
2882 if (generator && generator->
release) {
2883 generator->
release(chan, ast_channel_generatordata(chan));
2885 ast_channel_generatordata_set(chan, NULL);
2886 ast_channel_generator_set(chan, NULL);
2895 ast_channel_lock(chan);
2896 deactivate_generator_nolock(chan);
2901 ast_channel_unlock(chan);
2904 static void generator_write_format_change(
struct ast_channel *chan)
2908 ast_channel_lock(chan);
2909 generator = ast_channel_generator(chan);
2913 ast_channel_unlock(chan);
2916 static int generator_force(
const void *data)
2924 ast_channel_lock(chan);
2925 tmp = ast_channel_generatordata(chan);
2926 ast_channel_generatordata_set(chan, NULL);
2927 if (ast_channel_generator(chan))
2928 generate = ast_channel_generator(chan)->
generate;
2929 ast_channel_unlock(chan);
2931 if (!tmp || !generate) {
2937 ast_channel_lock(chan);
2938 if (ast_channel_generator(chan) && generate == ast_channel_generator(chan)->generate) {
2939 ast_channel_generatordata_set(chan, tmp);
2941 ast_channel_unlock(chan);
2944 ast_debug(1,
"Auto-deactivating generator\n");
2956 ast_channel_lock(chan);
2957 if (ast_channel_generatordata(chan)) {
2958 struct ast_generator *generator_old = ast_channel_generator(chan);
2960 if (generator_old && generator_old->
release) {
2961 generator_old->
release(chan, ast_channel_generatordata(chan));
2964 if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
2967 ast_channel_generatordata_set(chan, generatordata);
2970 ast_channel_generator_set(chan, gen);
2972 ast_channel_unlock(chan);
2989 int *exception,
int *outfd,
int *ms)
2991 struct timeval start = { 0 , 0 };
2992 struct pollfd *pfds = NULL;
2997 struct timeval now = { 0, 0 };
2998 struct timeval whentohangup = { 0, 0 }, diff;
3012 for (x = 0; x < n; x++) {
3013 ast_channel_lock(c[x]);
3014 if (!
ast_tvzero(*ast_channel_whentohangup(c[x]))) {
3017 diff =
ast_tvsub(*ast_channel_whentohangup(c[x]), now);
3022 ast_channel_unlock(c[x]);
3026 whentohangup = diff;
3029 ast_channel_unlock(c[x]);
3042 if (!
ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) {
3043 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000;
3044 if (*ms >= 0 && *ms < rms) {
3047 }
else if (!
ast_tvzero(whentohangup) && rms < 0) {
3057 for (x = 0; x < n; x++) {
3058 ast_channel_lock(c[x]);
3060 fdmap[max].fdno = y;
3061 fdmap[max].chan = x;
3062 max +=
ast_add_fd(&pfds[max], ast_channel_fd(c[x], y));
3065 ast_channel_unlock(c[x]);
3068 for (x = 0; x < nfds; x++) {
3069 fdmap[max].chan = -1;
3077 if (
sizeof(
int) == 4) {
3080 if (kbrms > 600000) {
3083 res = ast_poll(pfds, max, kbrms);
3087 }
while (!res && (rms > 0));
3089 res = ast_poll(pfds, max, rms);
3091 for (x = 0; x < n; x++) {
3092 ast_channel_lock(c[x]);
3094 ast_channel_unlock(c[x]);
3097 if (errno != EINTR) {
3104 for (x = 0; x < n; x++) {
3105 if (!
ast_tvzero(*ast_channel_whentohangup(c[x])) &&
ast_tvcmp(*ast_channel_whentohangup(c[x]), now) <= 0) {
3108 if (winner == NULL) {
3123 for (x = 0; x < max; x++) {
3124 res = pfds[x].revents;
3128 if (fdmap[x].chan >= 0) {
3129 winner = c[fdmap[x].chan];
3130 ast_channel_lock(winner);
3131 if (res & POLLPRI) {
3136 ast_channel_fdno_set(winner, fdmap[x].fdno);
3137 ast_channel_unlock(winner);
3140 *outfd = pfds[x].fd;
3143 *exception = (res & POLLPRI) ? -1 : 0;
3182 return ast_settimeout_full(c, rate, func, data, 0);
3185 int ast_settimeout_full(
struct ast_channel *c,
unsigned int rate,
int (*func)(
const void *data),
void *data,
unsigned int is_ao2_obj)
3188 unsigned int real_rate = rate, max_rate;
3190 ast_channel_lock(c);
3192 if (ast_channel_timingfd(c) == -1) {
3193 ast_channel_unlock(c);
3203 real_rate = max_rate;
3206 ast_debug(3,
"Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate);
3211 ao2_ref(ast_channel_timingdata(c), -1);
3214 ast_channel_timingfunc_set(c, func);
3215 ast_channel_timingdata_set(c, data);
3217 if (data && is_ao2_obj) {
3224 if (func == NULL && rate == 0 && ast_channel_fdno(c) ==
AST_TIMING_FD) {
3231 ast_channel_fdno_set(c, -1);
3234 ast_channel_unlock(c);
3264 if (!rchan && outfd < 0 && ms) {
3265 if (errno == 0 || errno == EINTR)
3267 ast_log(LOG_WARNING,
"Wait failed (%s)\n", strerror(errno));
3270 }
else if (outfd > -1) {
3272 ast_log(LOG_WARNING,
"The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n");
3290 if (!breakon || strchr(breakon, res)) {
3329 ast_log(LOG_WARNING,
"Unexpected control subclass '%d'\n", f->
subclass.
integer);
3336 if (write(audiofd, f->
data.ptr, f->
datalen) < 0) {
3337 ast_log(LOG_WARNING,
"write() failed: %s\n", strerror(errno));
3353 enum DtmfDirection {
3358 static const char *dtmf_direction_to_string(
enum DtmfDirection direction)
3360 switch (direction) {
3370 static void send_dtmf_begin_event(
struct ast_channel *chan,
3371 enum DtmfDirection direction,
const char digit)
3374 char digit_str[] = { digit,
'\0' };
3378 "direction", dtmf_direction_to_string(direction));
3386 static void send_dtmf_end_event(
struct ast_channel *chan,
3387 enum DtmfDirection direction,
const char digit,
long duration_ms)
3390 char digit_str[] = { digit,
'\0' };
3394 "direction", dtmf_direction_to_string(direction),
3403 static void send_flash_event(
struct ast_channel *chan)
3408 static void send_wink_event(
struct ast_channel *chan)
3420 generator = ast_channel_generator(chan);
3424 || !ast_channel_generatordata(chan)
3425 || ast_channel_timingfunc(chan)) {
3436 samples = (int) (((
float) f->
samples) * factor);
3441 gendata = ast_channel_generatordata(chan);
3442 ast_channel_generatordata_set(chan, NULL);
3455 ast_channel_unlock(chan);
3457 ast_channel_lock(chan);
3458 if (generator == ast_channel_generator(chan)) {
3459 ast_channel_generatordata_set(chan, gendata);
3461 ast_debug(1,
"Auto-deactivating generator\n");
3469 struct ast_frame *fr = ast_channel_dtmff(chan);
3493 if (!
ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
3514 int diff = sample_rate - seek_rate;
3517 samples = samples / (float) (sample_rate / seek_rate);
3518 }
else if (diff < 0) {
3519 samples = samples * (float) (seek_rate / sample_rate);
3530 struct ast_stream *stream = NULL, *default_stream = NULL;
3535 ast_channel_lock(chan);
3539 if (ast_channel_generator(chan))
3551 if (ast_channel_softhangup_internal_flag(chan)) {
3570 if (ast_channel_fdno(chan) == -1) {
3572 "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3573 ast_channel_name(chan));
3580 if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) ==
AST_TIMING_FD) {
3581 enum ast_timer_event res;
3589 case AST_TIMING_EVENT_EXPIRED:
3591 ast_log(LOG_ERROR,
"Failed to acknowledge timer in ast_read\n");
3595 if (ast_channel_timingfunc(chan)) {
3597 ast_timing_func_t func = ast_channel_timingfunc(chan);
3598 void *data = ast_channel_timingdata(chan);
3604 ast_channel_fdno_set(chan, -1);
3605 ast_channel_unlock(chan);
3611 if (trigger_dtmf_emulating) {
3616 ast_channel_lock(chan);
3621 }
else if (trigger_dtmf_emulating) {
3635 case AST_TIMING_EVENT_CONTINUOUS:
3647 void *tmp = ast_channel_generatordata(chan);
3648 ast_channel_generatordata_set(chan, NULL);
3649 ast_channel_generator(chan)->
generate(chan, tmp, -1, -1);
3650 ast_channel_generatordata_set(chan, tmp);
3652 ast_channel_fdno_set(chan, -1);
3660 if (ast_channel_internal_alert_read(chan) == AST_ALERT_READ_FATAL) {
3667 int skipped_dtmf_frame = 0;
3676 skipped_dtmf_frame = 1;
3688 if (!skipped_dtmf_frame) {
3693 ast_channel_alert_write(chan);
3709 cause = f->
data.uint32;
3745 ast_log(LOG_WARNING,
"Exception flag set on '%s', but no exception handler\n", ast_channel_name(chan));
3778 ast_log(LOG_WARNING,
"No read routine on channel %s\n", ast_channel_name(chan));
3781 if (stream == default_stream) {
3791 ast_channel_fdno_set(chan, -1);
3808 if (dropnondefault && stream != default_stream) {
3820 ast_debug(1,
"Dropping duplicate answer!\n");
3828 set_channel_answer_time(chan);
3833 read_action_payload = f->
data.ptr;
3834 switch (read_action_payload->action) {
3835 case AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO:
3839 read_action_payload->payload_size, &connected)) {
3843 ast_channel_unlock(chan);
3846 read_action_payload->payload,
3847 read_action_payload->payload_size);
3850 ast_channel_lock(chan);
3852 case AST_FRAME_READ_ACTION_SEND_TEXT:
3853 ast_channel_unlock(chan);
3854 ast_sendtext(chan, (
const char *)read_action_payload->payload);
3855 ast_channel_lock(chan);
3857 case AST_FRAME_READ_ACTION_SEND_TEXT_DATA:
3858 ast_channel_unlock(chan);
3860 ast_channel_lock(chan);
3879 send_flash_event(chan);
3881 send_wink_event(chan);
3886 ast_log(LOG_DTMF,
"DTMF end '%c' received on %s, duration %ld ms\n", f->
subclass.
integer, ast_channel_name(chan), f->
len);
3889 queue_dtmf_readq(chan, f);
3893 if (!
ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
3896 queue_dtmf_readq(chan, f);
3905 ast_channel_dtmf_tv_set(chan, &tv);
3908 ast_channel_emulate_dtmf_duration_set(chan, f->
len);
3913 ast_log(LOG_DTMF,
"DTMF begin emulation of '%c' with duration %u queued on %s\n", f->
subclass.
integer, ast_channel_emulate_dtmf_duration(chan), ast_channel_name(chan));
3921 if (!ast_channel_generator(chan)) {
3925 if (ast_channel_audiohooks(chan)) {
3932 ast_frfree(old_frame);
3937 ast_log(LOG_DTMF,
"DTMF end accepted with begin '%c' on %s\n", f->
subclass.
integer, ast_channel_name(chan));
3952 ast_log(LOG_DTMF,
"DTMF end '%c' detected to have actual duration %ld on the wire, emulation will be triggered on %s\n", f->
subclass.
integer, f->
len, ast_channel_name(chan));
3954 }
else if (!f->
len) {
3955 ast_log(LOG_DTMF,
"DTMF end accepted without begin '%c' on %s\n", f->
subclass.
integer, ast_channel_name(chan));
3971 if (!ast_channel_generator(chan)) {
3975 ast_log(LOG_DTMF,
"DTMF end passthrough '%c' on %s\n", f->
subclass.
integer, ast_channel_name(chan));
3979 ast_channel_dtmf_tv_set(chan, &now);
3986 if (!ast_channel_generator(chan)) {
3990 if (ast_channel_audiohooks(chan)) {
3994 ast_frfree(old_frame);
4000 ast_log(LOG_DTMF,
"DTMF begin '%c' received on %s\n", f->
subclass.
integer, ast_channel_name(chan));
4004 ast_log(LOG_DTMF,
"DTMF begin ignored '%c' on %s\n", f->
subclass.
integer, ast_channel_name(chan));
4010 ast_channel_dtmf_tv_set(chan, &now);
4011 ast_log(LOG_DTMF,
"DTMF begin passthrough '%c' on %s\n", f->
subclass.
integer, ast_channel_name(chan));
4021 if (!ast_channel_emulate_dtmf_duration(chan)) {
4023 ast_channel_dtmf_digit_to_emulate_set(chan, 0);
4024 }
else if (
ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) >= ast_channel_emulate_dtmf_duration(chan)) {
4025 ast_channel_emulate_dtmf_duration_set(chan, 0);
4027 f = ast_channel_dtmff(chan);
4031 ast_channel_dtmf_tv_set(chan, &now);
4033 ast_channel_dtmf_digit_to_emulate_set(chan, 0);
4034 ast_log(LOG_DTMF,
"DTMF end emulation of '%c' queued on %s\n", f->
subclass.
integer, ast_channel_name(chan));
4035 if (ast_channel_audiohooks(chan)) {
4038 if (old_frame != f) {
4039 ast_frfree(old_frame);
4048 if (!ast_channel_generator(chan)) {
4056 if (stream != default_stream) {
4064 if (ast_test_flag(ast_channel_flags(chan),
AST_FLAG_EMULATE_DTMF) && !ast_channel_emulate_dtmf_duration(chan)) {
4066 ast_channel_dtmf_digit_to_emulate_set(chan, 0);
4069 if (dropaudio || ast_test_flag(ast_channel_flags(chan),
AST_FLAG_IN_DTMF)) {
4071 ast_read_generator_actions(chan, f);
4078 if (
ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) >= ast_channel_emulate_dtmf_duration(chan)) {
4079 ast_channel_emulate_dtmf_duration_set(chan, 0);
4081 f = ast_channel_dtmff(chan);
4085 ast_channel_dtmf_tv_set(chan, &now);
4086 if (ast_channel_audiohooks(chan)) {
4090 ast_frfree(old_frame);
4092 ast_log(LOG_DTMF,
"DTMF end emulation of '%c' queued on %s\n", f->
subclass.
integer, ast_channel_name(chan));
4140 core_format = ast_channel_readformat(chan);
4162 if (old_frame != f) {
4163 ast_frfree(old_frame);
4167 if (ast_channel_readtrans(chan)
4176 if (ast_channel_audiohooks(chan) && !hooked) {
4180 if (old_frame != f) {
4181 ast_frfree(old_frame);
4204 __ast_queue_frame(chan, multi_frame, 0, readq_tail);
4206 ast_frfree(multi_frame);
4214 ast_read_generator_actions(chan, f);
4219 if (ast_channel_writetrans(chan)) {
4229 if (!ast_channel_softhangup_internal_flag(chan)) {
4233 ast_channel_hangupcause_set(chan, cause);
4234 if (ast_channel_generator(chan))
4242 ast_channel_fin_set(chan, FRAMECOUNT_INC(ast_channel_fin(chan)));
4245 if (ast_channel_music_state(chan) && ast_channel_generator(chan) && ast_channel_generator(chan)->digit && f && f->
frametype ==
AST_FRAME_DTMF_END)
4251 ast_channel_audiohooks_set(chan, NULL);
4253 ast_channel_unlock(chan);
4287 switch (condition) {
4351 ast_log(LOG_WARNING,
"Unable to store hangup cause for %s on %s\n", cause_code->
chan_name, ast_channel_name(chan));
4355 snprintf(causevar,
sizeof(causevar),
"HASH(SIP_CAUSE,%s)", cause_code->
chan_name);
4362 if (!strcasecmp(flag,
"default"))
4363 return DEFAULT_AMA_FLAGS;
4364 if (!strcasecmp(flag,
"omit"))
4365 return AST_AMA_OMIT;
4366 if (!strcasecmp(flag,
"billing"))
4367 return AST_AMA_BILLING;
4368 if (!strcasecmp(flag,
"documentation"))
4369 return AST_AMA_DOCUMENTATION;
4370 return AST_AMA_NONE;
4378 case AST_AMA_BILLING:
4380 case AST_AMA_DOCUMENTATION:
4381 return "DOCUMENTATION";
4401 static int indicate_connected_line(
struct ast_channel *chan,
const void *data,
size_t datalen)
4406 unsigned char current[1024];
4407 unsigned char proposed[1024];
4423 chan_indicated, NULL);
4425 chan_connected, NULL);
4426 if (current_size == -1 || proposed_size == -1) {
4430 if (current_size == proposed_size && !memcmp(current, proposed, current_size)) {
4431 ast_debug(1,
"%s: Dropping redundant connected line update \"%s\" <%s>.\n",
4432 ast_channel_name(chan),
4456 static int indicate_redirecting(
struct ast_channel *chan,
const void *data,
size_t datalen)
4467 return res ? -1 : 0;
4479 switch (condition) {
4481 if (indicate_connected_line(chan, data, datalen)) {
4487 if (indicate_redirecting(chan, data, datalen)) {
4494 ast_channel_hold_state_set(chan, _condition);
4497 t38_parameters = data;
4516 if (is_visible_indication(condition)) {
4518 ast_channel_visible_indication_set(chan, _condition);
4521 ast_channel_visible_indication_set(chan, 0);
4543 if (_condition < 0) {
4551 switch (condition) {
4635 ast_debug(1,
"Driver for channel '%s' does not support indication %u, emulating it\n", ast_channel_name(chan), condition);
4640 ast_channel_name(chan));
4647 ast_log(LOG_WARNING,
"Unable to handle indication %u for '%s'\n", condition, ast_channel_name(chan));
4659 ast_channel_lock(chan);
4666 goto indicate_cleanup;
4673 .subclass.integer = _condition,
4674 .data.ptr = (
void *) data,
4687 goto indicate_cleanup;
4691 data = awesome_frame->
data.ptr;
4692 datalen = awesome_frame->
datalen;
4698 ast_channel_unlock(chan);
4699 if (awesome_frame) {
4700 ast_frfree(awesome_frame);
4712 c = *(
unsigned char *)buf;
4757 ast_channel_lock(chan);
4760 ast_channel_unlock(chan);
4766 && (ast_strlen_zero(content_type) ||
ast_begins_with(content_type,
"text/"))
4770 size_t body_len = strlen(body);
4773 memset(&f, 0,
sizeof(f));
4789 ast_debug(1,
"Sending TEXT_DATA from '%s' to %s:%s %s\n",
4792 ast_channel_name(chan), body);
4795 && (ast_strlen_zero(content_type) ||
ast_begins_with(content_type,
"text/"))) {
4797 ast_debug(1,
"Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
4800 ast_debug(1,
"Channel technology does not support sending content type '%s' on channel '%s'\n",
4801 S_OR(content_type,
"text/plain"), ast_channel_name(chan));
4805 ast_channel_unlock(chan);
4816 .type = AST_MSG_DATA_ATTR_BODY,
4817 .value = (
char *)text,
4821 if (ast_strlen_zero(text)) {
4837 static const char *
const mf_tones[] = {
4855 if (digit >=
'0' && digit <=
'9') {
4857 }
else if (digit ==
'*') {
4859 }
else if (digit ==
'#') {
4861 }
else if (digit ==
'A') {
4863 }
else if (digit ==
'B') {
4865 }
else if (digit ==
'C') {
4869 ast_log(LOG_WARNING,
"Unable to generate MF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4878 static const char *
const dtmf_tones[] = {
4900 ast_channel_lock(chan);
4901 ast_channel_sending_dtmf_digit_set(chan, digit);
4902 ast_channel_sending_dtmf_tv_set(chan,
ast_tvnow());
4903 ast_channel_unlock(chan);
4908 if (digit >=
'0' && digit <=
'9')
4910 else if (digit >=
'A' && digit <=
'D')
4912 else if (digit ==
'*')
4914 else if (digit ==
'#')
4918 ast_debug(1,
"Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
4931 ast_channel_lock(chan);
4932 if (ast_channel_sending_dtmf_digit(chan) == digit) {
4933 ast_channel_sending_dtmf_digit_set(chan, 0);
4935 ast_channel_unlock(chan);
4937 if (res && ast_channel_generator(chan))
4945 if (ast_channel_generator(chan)) {
4953 unsigned int durationkp,
unsigned int durationst,
int is_external)
4960 duration = durationkp;
4961 }
else if (digit ==
'#' || digit ==
'A' || digit ==
'B' || digit ==
'C') {
4962 duration = durationst;
4966 usleep(duration * 1000);
4994 usleep(duration * 1000);
5007 ast_debug(3,
"Prodding channel '%s'\n", ast_channel_name(chan));
5012 ast_log(LOG_WARNING,
"Prodding channel '%s' failed\n", ast_channel_name(chan));
5033 int16_t *samples_buf;
5041 static void plc_ds_destroy(
void *data)
5043 struct plc_ds *plc = data;
5044 ast_free(plc->samples_buf);
5050 .destroy = plc_ds_destroy,
5055 int num_new_samples = frame->
samples;
5077 if (!num_new_samples) {
5085 if (plc->num_samples < num_new_samples) {
5086 ast_free(plc->samples_buf);
5088 if (!plc->samples_buf) {
5093 plc->num_samples = num_new_samples;
5099 frame->
datalen = num_new_samples * 2;
5113 plc = datastore->
data;
5114 adjust_frame_for_plc(chan, frame, datastore);
5118 datastore = ast_datastore_alloc(&plc_ds_info, NULL);
5127 datastore->
data = plc;
5129 adjust_frame_for_plc(chan, frame, datastore);
5151 struct ast_stream *stream = NULL, *default_stream = NULL;
5158 while(ast_channel_trylock(chan)) {
5161 ast_debug(1,
"Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
5172 if (stream_num >= 0) {
5189 type = AST_MEDIA_TYPE_IMAGE;
5211 ast_channel_unlock(chan);
5213 ast_channel_lock(chan);
5237 if (ast_channel_audiohooks(chan)) {
5240 if (old_frame != fr)
5244 ast_channel_unlock(chan);
5246 ast_channel_lock(chan);
5249 if (ast_channel_audiohooks(chan)) {
5253 if (new_frame != fr) {
5254 ast_frfree(new_frame);
5258 ast_channel_unlock(chan);
5260 ast_channel_lock(chan);
5288 }
else if ((stream == default_stream) &&
ast_channel_tech(chan)->write_video) {
5297 res = tech_write(chan, stream, default_stream, fr);
5302 apply_plc(chan, fr);
5311 if ((stream == default_stream) && ast_channel_audiohooks(chan)) {
5335 ast_debug(1,
"Channel %s changing write format from %s to %s, native formats %s\n",
5336 ast_channel_name(chan),
5346 if (ast_channel_writetrans(chan)) {
5348 if (trans_frame != f && f != fr) {
5364 if ((stream == default_stream) && ast_channel_audiohooks(chan) && !hooked) {
5365 struct ast_frame *prev = NULL, *new_frame, *cur, *dup;
5366 int freeoldlist = 0;
5380 if (new_frame != cur) {
5391 if (new_frame != dup) {
5392 ast_frfree(new_frame);
5415 unsigned int skip = 0;
5422 res = tech_write(chan, stream, default_stream, cur);
5430 ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
5440 res = tech_write(chan, stream, default_stream, f);
5476 ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
5482 ast_channel_audiohooks_set(chan, NULL);
5484 ast_channel_unlock(chan);
5499 ast_debug(1,
"Channel %s setting read format path: %s -> %s\n",
5500 ast_channel_name(chan),
5514 trans_old = ast_channel_readtrans(chan);
5518 ast_channel_readtrans_set(chan, trans_new);
5519 ast_channel_set_rawreadformat(chan, raw_format);
5520 ast_channel_set_readformat(chan, core_format);
5535 ast_debug(1,
"Channel %s setting write format path: %s -> %s\n",
5536 ast_channel_name(chan),
5550 trans_old = ast_channel_writetrans(chan);
5554 ast_channel_writetrans_set(chan, trans_new);
5555 ast_channel_set_rawwriteformat(chan, raw_format);
5556 ast_channel_set_writeformat(chan, core_format);
5561 const char *direction;
5572 .direction =
"read",
5573 .get_trans = ast_channel_readtrans,
5574 .set_trans = ast_channel_readtrans_set,
5575 .get_format = ast_channel_readformat,
5576 .set_format = ast_channel_set_readformat,
5577 .get_rawformat = ast_channel_rawreadformat,
5578 .set_rawformat = ast_channel_set_rawreadformat,
5583 .direction =
"write",
5584 .get_trans = ast_channel_writetrans,
5585 .set_trans = ast_channel_writetrans_set,
5586 .get_format = ast_channel_writeformat,
5587 .set_format = ast_channel_set_writeformat,
5588 .get_rawformat = ast_channel_rawwriteformat,
5589 .set_rawformat = ast_channel_set_rawwriteformat,
5593 static int set_format(
struct ast_channel *chan,
struct ast_format_cap *cap_set,
const int direction,
int interleaved_stereo)
5606 access = &set_format_access_read;
5609 access = &set_format_access_write;
5613 if (!best_set_fmt) {
5623 &best_set_fmt,
sizeof(best_set_fmt), 0);
5625 ast_debug(1,
"Channel driver natively set channel %s to %s format %s\n",
5628 ast_channel_lock(chan);
5632 ast_channel_unlock(chan);
5633 ao2_cleanup(cap_native);
5636 ast_channel_nativeformats_set(chan, cap_native);
5637 ao2_cleanup(cap_native);
5638 access->set_format(chan, best_set_fmt);
5639 access->set_rawformat(chan, best_set_fmt);
5641 trans_pvt = access->get_trans(chan);
5644 access->set_trans(chan, NULL);
5646 ast_channel_unlock(chan);
5650 if (direction && ast_channel_generatordata(chan)) {
5651 generator_write_format_change(chan);
5657 ast_channel_lock(chan);
5659 format = access->get_format(chan);
5660 rawformat = access->get_rawformat(chan);
5661 ast_assert(format != NULL);
5662 ast_assert(rawformat != NULL);
5664 cap_native = ast_channel_nativeformats(chan);
5666 ast_channel_unlock(chan);
5667 ast_log(LOG_ERROR,
"Unable to set format because channel %s supports no formats\n",
5668 ast_channel_name(chan));
5685 ast_channel_unlock(chan);
5688 ast_log(LOG_WARNING,
"Unable to find a codec translation path: %s -> %s\n",
5695 trans_pvt = access->get_trans(chan);
5700 if (trans_pvt != NULL) {
5702 ast_channel_unlock(chan);
5711 access->set_trans(chan, NULL);
5736 access->set_trans(chan, trans_pvt);
5737 res = trans_pvt ? 0 : -1;
5741 access->set_format(chan, best_set_fmt);
5742 access->set_rawformat(chan, best_native_fmt);
5744 ast_debug(1,
"Channel %s setting %s format path: %s -> %s\n",
5745 ast_channel_name(chan),
5751 ast_channel_unlock(chan);
5755 if (direction && ast_channel_generatordata(chan)) {
5756 generator_write_format_change(chan);
5767 ast_assert(format != NULL);
5774 res = set_format(chan, cap, 0, 0);
5782 return set_format(chan, cap, 0, 0);
5790 ast_assert(format != NULL);
5797 res = set_format(chan, cap, 1, 1);
5808 ast_assert(format != NULL);
5815 res = set_format(chan, cap, 1, 0);
5823 return set_format(chan, cap, 1, 0);
5831 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)";
5835 return "Local Ring";
5837 return "Remote end Ringing";
5839 return "Remote end has Answered";
5841 return "Remote end is Busy";
5843 return "Congestion (circuits busy)";
5845 return "Unknown Reason!!";
5849 static void handle_cause(
int cause,
int *outstate)
5853 if (cause == AST_CAUSE_BUSY)
5855 else if (cause == AST_CAUSE_CONGESTION)
5880 ast_channel_lock(orig);
5882 ast_channel_unlock(orig);
5893 ast_max_forwards_decrement(new_chan);
5894 ast_channel_unlock(new_chan);
5895 ast_channel_unlock(parent);
5908 ast_copy_string(tmpchan, ast_channel_call_forward(orig),
sizeof(tmpchan));
5909 ast_copy_string(forwarder, ast_channel_name(orig),
sizeof(forwarder));
5910 if ((data = strchr(tmpchan,
'/'))) {
5914 const char *forward_context;
5915 ast_channel_lock(orig);
5917 snprintf(tmpchan,
sizeof(tmpchan),
"%s@%s", ast_channel_call_forward(orig),
S_OR(forward_context, ast_channel_context(orig)));
5918 ast_channel_unlock(orig);
5922 if (!(new_chan =
ast_request(type, cap, NULL, orig, data, &cause))) {
5923 ast_log(LOG_NOTICE,
"Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause);
5924 handle_cause(cause, outstate);
5932 ast_channel_lock(new_chan);
5934 ast_channel_unlock(new_chan);
5936 if (oh->parent_channel) {
5937 call_forward_inherit(new_chan, oh->parent_channel, orig);
5939 if (!ast_strlen_zero(oh->account)) {
5940 ast_channel_lock(new_chan);
5942 ast_channel_accountcode_set(new_chan, oh->account);
5943 ast_channel_peeraccount_set(new_chan, oh->account);
5945 ast_channel_unlock(new_chan);
5947 }
else if (caller) {
5948 call_forward_inherit(new_chan, caller, orig);
5957 ast_channel_unlock(new_chan);
5958 ast_channel_unlock(orig);
5966 ast_log(LOG_NOTICE,
"Unable to call forward to channel %s/%s\n", type, (
char *)data);
5982 int last_subclass = 0;
5988 outstate = &dummy_outstate;
5990 chan =
ast_request(type, cap, assignedids, requestor, addr, &cause);
5992 ast_log(LOG_NOTICE,
"Unable to request channel %s/%s\n", type, addr);
5993 handle_cause(cause, outstate);
5999 ast_channel_lock(chan);
6001 ast_channel_unlock(chan);
6003 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
6008 cid_num = oh->cid_num;
6009 cid_name = oh->cid_name;
6011 if (oh->parent_channel) {
6016 ast_max_forwards_decrement(chan);
6017 ast_channel_unlock(oh->parent_channel);
6018 ast_channel_unlock(chan);
6020 if (!ast_strlen_zero(oh->account)) {
6021 ast_channel_lock(chan);
6023 ast_channel_accountcode_set(chan, oh->account);
6024 ast_channel_peeraccount_set(chan, oh->account);
6026 ast_channel_unlock(chan);
6040 ast_channel_lock(chan);
6042 ast_channel_unlock(chan);
6051 connected.
id.
name.
str = (
char *) cid_name;
6058 ast_channel_unlock(chan);
6059 ast_channel_unlock((
struct ast_channel *) requestor);
6063 ast_log(LOG_NOTICE,
"Unable to call channel %s/%s\n", type, addr);
6078 if (!ast_strlen_zero(ast_channel_call_forward(chan))) {
6122 if (oh && oh->connect_on_early_media) {
6142 ast_log(LOG_NOTICE,
"Don't know what to do with control frame %d\n", f->
subclass.
integer);
6152 if (!ast_strlen_zero(oh->context))
6153 ast_channel_context_set(chan, oh->context);
6154 if (!ast_strlen_zero(oh->exten))
6155 ast_channel_exten_set(chan, oh->exten);
6157 ast_channel_priority_set(chan, oh->priority);
6163 ast_channel_lock(chan);
6165 ast_channel_hangupcause_set(chan, AST_CAUSE_NO_ANSWER);
6167 ast_channel_unlock(chan);
6176 return __ast_request_and_dial(type, cap, assignedids, requestor, addr, timeout, outstate, cidnum, cidname, NULL);
6183 {AST_OPTION_SECURE_MEDIA, 0},
6189 if (!requestor || !out) {
6193 ast_channel_lock(r);
6196 ops[0][1] = encrypt->signaling;
6197 ops[1][1] = encrypt->media;
6199 ast_channel_unlock(r);
6202 ast_channel_unlock(r);
6204 for (i = 0; i < 2; i++) {
6229 *cause = AST_CAUSE_NOTDEFINED;
6232 ast_log(LOG_WARNING,
"Unable to lock technology backend list\n");
6236 AST_RWLIST_TRAVERSE(&
backends, chan, list) {
6237 if (strcasecmp(type, chan->
tech->type)) {
6247 ast_log(LOG_WARNING,
"No channel type registered for '%s'\n", type);
6248 *cause = AST_CAUSE_NOSUCHDRIVER;
6253 if (chan->
tech->requester_with_stream_topology) {
6256 if (!topology && request_cap) {
6261 c = chan->
tech->requester_with_stream_topology(type, topology, assignedids, requestor, addr, cause);
6264 }
else if (chan->
tech->requester) {
6271 if (!request_cap && topology) {
6294 ast_log(LOG_WARNING,
"No translator path exists for channel type %s (native %s) to %s\n", type,
6297 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
6298 ao2_cleanup(tmp_converted_cap);
6310 ao2_cleanup(tmp_converted_cap);
6315 if (best_audio_fmt) {
6318 ao2_cleanup(tmp_converted_cap);
6320 c = chan->
tech->requester(type, joint_cap, assignedids, requestor, addr, cause);
6334 callid = ast_channel_callid(requestor);
6339 ast_channel_unlock(c);
6340 ast_channel_unlock((
struct ast_channel *) requestor);
6343 if (set_security_requirements(requestor, c)) {
6344 ast_log(LOG_WARNING,
"Setting security requirements failed\n");
6346 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
6356 return request_channel(type, request_cap, NULL, assignedids, requestor, addr, cause);
6361 return request_channel(type, NULL, topology, assignedids, requestor, addr, cause);
6388 switch (relationship) {
6391 if (!precious || ast_strlen_zero(ast_channel_accountcode(chan))) {
6396 if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
6402 ast_channel_accountcode_set(chan, ast_channel_peeraccount(requestor));
6403 }
else if (!precious
6404 && !ast_strlen_zero(ast_channel_accountcode(requestor))) {
6409 ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
6412 if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
6413 ast_channel_peeraccount_set(chan, ast_channel_accountcode(requestor));
6418 if (!precious || ast_strlen_zero(ast_channel_accountcode(chan))) {
6423 if (!ast_strlen_zero(ast_channel_accountcode(requestor))) {
6424 ast_channel_accountcode_set(chan, ast_channel_accountcode(requestor));
6427 if (!ast_strlen_zero(ast_channel_peeraccount(requestor))) {
6428 ast_channel_peeraccount_set(chan, ast_channel_peeraccount(requestor));
6436 channel_req_accountcodes(chan, requestor, relationship, 0);
6441 channel_req_accountcodes(chan, requestor, relationship, 1);
6446 int (*pre_call)(
struct ast_channel *chan,
const char *sub_args);
6448 ast_channel_lock(chan);
6453 res = pre_call(chan, sub_args);
6454 ast_channel_unlock(chan);
6457 ast_channel_unlock(chan);
6468 ast_channel_lock(chan);
6474 ast_channel_unlock(chan);
6507 ast_channel_lock(chan);
6516 ast_channel_unlock(chan);
6527 if (res < 0 || !(fr =
ast_read(chan))) {
6544 *protocol = *message;
6560 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
6563 int ast_readstring_full(
struct ast_channel *c,
char *s,
int len,
int timeout,
int ftimeout,
char *enders,
int audiofd,
int ctrlfd)
6577 if (ast_channel_stream(c)) {
6580 if (!silgen && ast_opt_transmit_silence)
6586 if (!silgen && ast_opt_transmit_silence)
6592 return AST_GETDATA_FAILED;
6597 return AST_GETDATA_TIMEOUT;
6602 return AST_GETDATA_INTERRUPTED;
6604 if (strchr(enders, d) && (pos == 0)) {
6609 if (!strchr(enders, d)) {
6612 if (strchr(enders, d) || (pos >= len)) {
6615 return AST_GETDATA_COMPLETE;
6661 src_cap = ast_channel_nativeformats(from);
6662 dst_cap = ast_channel_nativeformats(to);
6667 ast_channel_unlock(to);
6668 ast_channel_unlock(from);
6674 ast_channel_unlock(to);
6675 ast_channel_unlock(from);
6678 ast_log(LOG_WARNING,
"No path to translate from %s to %s\n",
6679 ast_channel_name(from), ast_channel_name(to));
6690 if (ast_opt_generic_plc_on_equal_codecs
6692 && (ast_opt_generic_plc || ast_opt_transcode_via_slin))) {
6696 ? 1 : ast_opt_generic_plc_on_equal_codecs;
6708 ast_log(LOG_WARNING,
"Unable to set read format on channel %s to %s\n",
6713 ast_log(LOG_WARNING,
"Unable to set write format on channel %s to %s\n",
6751 ast_manager_event(chan, EVENT_FLAG_CALL,
"Rename",
6755 ast_channel_name(chan), newname, ast_channel_uniqueid(chan));
6756 ast_channel_name_set(chan, newname);
6763 ast_channel_lock(chan);
6767 ast_channel_unlock(chan);
6768 ao2_unlock(channels);
6775 const char *varname;
6779 varname = ast_var_full_name(current);
6785 if (varname[0] ==
'_') {
6787 if (varname[1] ==
'_') {
6794 newvar = ast_var_assign(&varname[1], ast_var_value(current));
6797 newvar = ast_var_assign(varname, ast_var_value(current));
6803 ast_debug(1,
"Inheriting variable %s from %s to %s.\n",
6804 ast_var_full_name(newvar), ast_channel_name(parent),
6805 ast_channel_name(child));
6808 ast_var_value(newvar));
6827 AST_LIST_APPEND_LIST(ast_channel_varshead(original), ast_channel_varshead(clonechan), entries);
6832 newvar = ast_var_assign(current->name, current->value);
6844 dash = strrchr(channel_name,
'-');
6861 unsigned int orig_disablestatecache;
6862 unsigned int clone_disablestatecache;
6864 int visible_indication;
6865 int clone_hold_state;
6883 char clone_sending_dtmf_digit;
6884 struct timeval clone_sending_dtmf_tv;
6918 moh_is_playing = ast_test_flag(ast_channel_flags(original),
AST_FLAG_MOH);
6919 if (moh_is_playing) {
6928 ast_channel_lock(original);
6929 visible_indication = ast_channel_visible_indication(original);
6930 ast_channel_unlock(original);
6936 ast_debug(1,
"Actually Masquerading %s(%u) into the structure of %s(%u)\n",
6943 ast_set_flag(ast_channel_snapshot_segment_flags(original), AST_FLAGS_ALL);
6944 ast_set_flag(ast_channel_snapshot_segment_flags(clonechan), AST_FLAGS_ALL);
6950 rformat =
ao2_bump(ast_channel_readformat(original));
6951 wformat =
ao2_bump(ast_channel_writeformat(original));
6952 free_translation(clonechan);
6953 free_translation(original);
6955 clone_hold_state = ast_channel_hold_state(clonechan);
6958 clone_sending_dtmf_digit = ast_channel_sending_dtmf_digit(clonechan);
6959 clone_sending_dtmf_tv = ast_channel_sending_dtmf_tv(clonechan);
6980 ast_copy_string(tmp_name, ast_channel_name(clonechan),
sizeof(tmp_name));
6981 ast_channel_name_set(clonechan, ast_channel_name(original));
6982 ast_channel_name_set(original, tmp_name);
6987 ast_channel_tech_set(clonechan, t);
6989 t_pvt = ast_channel_tech_pvt(original);
6990 ast_channel_tech_pvt_set(original, ast_channel_tech_pvt(clonechan));
6991 ast_channel_tech_pvt_set(clonechan, t_pvt);
7016 if (ast_channel_alert_write(original)) {
7017 ast_log(LOG_WARNING,
"write() failed: %s\n", strerror(errno));
7023 tmp_format =
ao2_bump(ast_channel_rawreadformat(original));
7024 ast_channel_set_rawreadformat(original, ast_channel_rawreadformat(clonechan));
7025 ast_channel_set_rawreadformat(clonechan, tmp_format);
7026 ao2_cleanup(tmp_format);
7028 tmp_format =
ao2_bump(ast_channel_rawwriteformat(original));
7029 ast_channel_set_rawwriteformat(original, ast_channel_rawwriteformat(clonechan));
7030 ast_channel_set_rawwriteformat(clonechan, tmp_format);
7031 ao2_cleanup(tmp_format);
7041 ast_channel_state_set(clonechan, origstate);
7047 if (orig_disablestatecache != clone_disablestatecache) {
7048 if (orig_disablestatecache) {
7058 ast_channel_language_set(original, ast_channel_language(clonechan));
7061 ast_channel_parkinglot_set(original, ast_channel_parkinglot(clonechan));
7065 ast_channel_internal_fd_clear_all(original);
7077 exchange.handlers = *ast_channel_hangup_handlers(original);
7078 *ast_channel_hangup_handlers(original) = *ast_channel_hangup_handlers(clonechan);
7079 *ast_channel_hangup_handlers(clonechan) = exchange.handlers;
7124 ast_channel_adsicpe_set(original, ast_channel_adsicpe(clonechan));
7131 ast_channel_fdno_set(original, ast_channel_fdno(clonechan));
7140 exchange.dialed = *ast_channel_dialed(original);
7141 ast_channel_dialed_set(original, ast_channel_dialed(clonechan));
7142 ast_channel_dialed_set(clonechan, &exchange.
dialed);
7148 exchange.caller = *ast_channel_caller(original);
7149 ast_channel_caller_set(original, ast_channel_caller(clonechan));
7150 ast_channel_caller_set(clonechan, &exchange.
caller);
7156 exchange.connected = *ast_channel_connected(original);
7157 ast_channel_connected_set(original, ast_channel_connected(clonechan));
7158 ast_channel_connected_set(clonechan, &exchange.
connected);
7168 exchange.redirecting = *ast_channel_redirecting(original);
7169 ast_channel_redirecting_set(original, ast_channel_redirecting(clonechan));
7170 ast_channel_redirecting_set(clonechan, &exchange.
redirecting);
7181 ast_channel_nativeformats_set(original, tmp_cap);
7195 ast_channel_musicclass_set(original, ast_channel_musicclass(clonechan));
7198 ast_channel_accountcode_set(original,
S_OR(ast_channel_accountcode(clonechan),
""));
7200 ast_debug(1,
"Putting channel %s in %s/%s formats\n", ast_channel_name(original),
7205 ast_log(LOG_WARNING,
"Channel type '%s' could not fixup channel %s, strange things may happen. (clonechan)\n",
7211 ast_log(LOG_WARNING,
"Channel type '%s' could not fixup channel %s, strange things may happen. (original)\n",
7215 ast_channel_internal_swap_stream_topology(original, clonechan);
7227 ast_channel_unlock(original);
7228 ast_channel_unlock(clonechan);
7246 ast_debug(1,
"Channel %s simulating UNHOLD for masquerade.\n",
7247 ast_channel_name(original));
7250 if (clone_sending_dtmf_digit) {
7268 if (visible_indication) {
7270 const char *latest_musicclass;
7273 ast_channel_lock(original);
7274 latest_musicclass =
ast_strdupa(ast_channel_latest_musicclass(original));
7275 ast_channel_unlock(original);
7276 if (ast_strlen_zero(latest_musicclass)) {
7277 latest_musicclass = NULL;
7280 len = strlen(latest_musicclass) + 1;
7292 if (moh_is_playing) {
7297 ast_channel_lock(original);
7301 pthread_kill(ast_channel_blocker(original), SIGURG);
7305 ast_channel_unlock(original);
7317 ast_channel_masq_set(original, NULL);
7318 ast_channel_masqr_set(clonechan, NULL);
7319 ast_channel_unlock(original);
7320 ast_channel_unlock(clonechan);
7324 ao2_unlock(channels);
7330 ao2_cleanup(rformat);
7331 ao2_cleanup(wformat);
7336 ast_channel_lock(chan);
7340 ast_free(ast_channel_caller(chan)->
id.
number.str);
7345 ast_free(ast_channel_caller(chan)->
id.name.str);
7350 ast_free(ast_channel_caller(chan)->ani.number.str);
7356 ast_channel_unlock(chan);
7361 if (ast_channel_caller(chan) == caller) {
7366 ast_channel_lock(chan);
7369 ast_channel_unlock(chan);
7374 if (ast_channel_caller(chan) == caller) {
7379 ast_channel_lock(chan);
7383 ast_channel_unlock(chan);
7391 if (oldstate == state)
7395 if ((dashptr = strrchr(name,
'-'))) {
7399 ast_channel_state_set(chan, state);
7426 ast_channel_lock(chan);
7429 ast_channel_unlock(chan);
7434 ast_log(LOG_ERROR,
"XXX Blocking not implemented yet XXX\n");
7437 ast_channel_unlock(chan);
7446 ast_channel_lock(chan);
7449 ast_channel_unlock(chan);
7454 ast_log(LOG_ERROR,
"XXX Blocking not implemented yet XXX\n");
7457 ast_channel_unlock(chan);
7487 static void tonepair_release(
struct ast_channel *chan,
void *params)
7494 ao2_cleanup(ts->origwfmt);
7498 static void *tonepair_alloc(
struct ast_channel *chan,
void *params)
7507 ts->origwfmt =
ao2_bump(ast_channel_writeformat(chan));
7509 ast_log(LOG_WARNING,
"Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
7510 tonepair_release(NULL, ts);
7513 ts->fac1 = 2.0 * cos(2.0 * M_PI * (td->freq1 / 8000.0)) * 32768.0;
7515 ts->v2_1 = sin(-4.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
7516 ts->v3_1 = sin(-2.0 * M_PI * (td->freq1 / 8000.0)) * td->vol;
7518 ts->fac2 = 2.0 * cos(2.0 * M_PI * (td->freq2 / 8000.0)) * 32768.0;
7519 ts->v2_2 = sin(-4.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
7520 ts->v3_2 = sin(-2.0 * M_PI * (td->freq2 / 8000.0)) * td->vol;
7521 ts->duration = td->duration;
7529 static int tonepair_generator(
struct ast_channel *chan,
void *data,
int len,
int samples)
7539 if (len >
sizeof(ts->data) / 2 - 1) {
7540 ast_log(LOG_WARNING,
"Can't generate that much data!\n");
7543 memset(&ts->f, 0,
sizeof(ts->f));
7544 for (x=0;x<len/2;x++) {
7545 ts->v1_1 = ts->v2_1;
7546 ts->v2_1 = ts->v3_1;
7547 ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1;
7549 ts->v1_2 = ts->v2_2;
7550 ts->v2_2 = ts->v3_2;
7551 ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2;
7554 p = ts->v3_2 - 32768;
7556 p = ((p * 9) / 10) + 1;
7557 ts->data[x] = (ts->v3_1 * p) >> 15;
7559 ts->data[x] = ts->v3_1 + ts->v3_2;
7566 ts->f.
data.ptr = ts->data;
7569 if (ts->duration > 0) {
7570 if (ts->pos >= ts->duration * 8)
7577 .alloc = tonepair_alloc,
7578 .release = tonepair_release,
7579 .generate = tonepair_generator,
7588 d.duration = duration;
7589 d.vol = (vol < 1) ? 8192 : vol;
7608 while (ast_channel_generatordata(chan) &&
ast_waitfor(chan, 100) >= 0) {
7618 ast_group_t ast_get_group(
const char *s)
7622 int start=0, finish=0, x;
7623 ast_group_t
group = 0;
7625 if (ast_strlen_zero(s))
7630 while ((piece = strsep(&c,
","))) {
7631 if (sscanf(piece,
"%30d-%30d", &start, &finish) == 2) {
7633 }
else if (sscanf(piece,
"%30d", &start)) {
7637 ast_log(LOG_ERROR,
"Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece);
7640 for (x = start; x <= finish; x++) {
7641 if ((x > 63) || (x < 0)) {
7642 ast_log(LOG_WARNING,
"Ignoring invalid group %d (maximum group is 63)\n", x);
7644 group |= ((ast_group_t) 1 << x);
7672 return member->
hash;
7687 if (ast_strlen_zero(c)) {
7697 while ((piece = strsep(&c,
","))) {
7704 len = strlen(piece);
7714 strcpy(member->
name, piece);
7729 return (
struct ast_namedgroups *) namedgroups;
7732 struct ast_namedgroups *ast_unref_namedgroups(
struct ast_namedgroups *
groups)
7734 ao2_cleanup(groups);
7738 struct ast_namedgroups *ast_ref_namedgroups(
struct ast_namedgroups *
groups)
7746 static int (*ast_moh_start_ptr)(
struct ast_channel *,
const char *,
const char *) = NULL;
7747 static void (*ast_moh_stop_ptr)(
struct ast_channel *) = NULL;
7748 static void (*ast_moh_cleanup_ptr)(
struct ast_channel *) = NULL;
7750 void ast_install_music_functions(
int (*start_ptr)(
struct ast_channel *,
const char *,
const char *),
7754 ast_moh_start_ptr = start_ptr;
7755 ast_moh_stop_ptr = stop_ptr;
7756 ast_moh_cleanup_ptr = cleanup_ptr;
7759 void ast_uninstall_music_functions(
void)
7761 ast_moh_start_ptr = NULL;
7762 ast_moh_stop_ptr = NULL;
7763 ast_moh_cleanup_ptr = NULL;
7768 if (ast_moh_start_ptr)
7769 return ast_moh_start_ptr(chan, mclass, interpclass);
7771 ast_verb(3,
"Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : (interpclass ? interpclass :
"default"));
7778 if (ast_moh_stop_ptr)
7779 ast_moh_stop_ptr(chan);
7784 if (ast_moh_cleanup_ptr)
7785 ast_moh_cleanup_ptr(chan);
7788 static int ast_channel_hash_cb(
const void *obj,
const int flags)
7790 const char *name = (flags &
OBJ_KEY) ? obj : ast_channel_name((
struct ast_channel *) obj);
7794 if (ast_strlen_zero(name)) {
7810 static void prnt_channel_key(
void *v_obj,
void *where,
ao2_prnt_fn *prnt)
7817 prnt(where,
"%s", ast_channel_name(chan));
7825 unsigned int isfunc:1;
7834 static void free_external_channelvars(
struct external_vars *channelvars)
7838 while ((var = AST_RWLIST_REMOVE_HEAD(channelvars,
entry))) {
7844 static int channel_has_external_vars(
struct external_vars *channelvars)
7852 return vars_present;
7857 return channel_has_external_vars(&ami_vars);
7862 return channel_has_external_vars(&ari_vars);
7865 static void channel_set_external_vars(
struct external_vars *channelvars,
size_t varc,
char **vars)
7869 free_external_channelvars(channelvars);
7871 for (i = 0; i < varc; ++i) {
7872 const char *var = vars[i];
7874 if (!(mcv =
ast_calloc(1,
sizeof(*mcv) + strlen(var) + 1))) {
7877 strcpy(mcv->name, var);
7878 if (strchr(var,
'(')) {
7881 AST_RWLIST_INSERT_TAIL(channelvars, mcv,
entry);
7889 channel_set_external_vars(&ami_vars, varc, vars);
7894 channel_set_external_vars(&ari_vars, varc, vars);
7906 while ((var = AST_RWLIST_REMOVE_HEAD(head, entries))) {
7907 ast_var_delete(var);
7923 struct ast_var_t *var = ast_var_assign(ast_var_name(cv), ast_var_value(cv));
7956 const char *
val = NULL;
7964 "Error invoking function %s\n", mcv->name);
7970 var = ast_var_assign(mcv->name, val ? val :
"");
7975 AST_RWLIST_INSERT_TAIL(ret, var, entries);
7985 return channel_get_external_vars(&ami_vars, chan);
7990 return channel_get_external_vars(&ari_vars, chan);
7993 static void channels_shutdown(
void)
7995 free_external_channelvars(&ami_vars);
7996 free_external_channelvars(&ari_vars);
8010 ast_channel_hash_cb, NULL, ast_channel_cmp_cb);
8042 for (i = 0; i <= 63; i++) {
8043 if (group & ((ast_group_t) 1 << i)) {
8045 strncat(buf,
", ", buflen - strlen(buf) - 1);
8049 snprintf(num,
sizeof(num),
"%u", i);
8050 strncat(buf, num, buflen - strlen(buf) - 1);
8080 static int namedgroup_match(
void *obj,
void *arg,
int flags)
8107 SWAP(group_a, group_b);
8109 match =
ao2_callback(group_a, 0, namedgroup_match, group_b);
8112 return match != NULL;
8119 for (cur = vars; cur; cur = cur->
next) {
8124 static void *silence_generator_alloc(
struct ast_channel *chan,
void *data)
8130 static void silence_generator_release(
struct ast_channel *chan,
void *data)
8135 static int silence_generator_generate(
struct ast_channel *chan,
void *data,
int len,
int samples)
8142 .datalen =
sizeof(buf),
8146 memset(buf, 0,
sizeof(buf));
8155 .alloc = silence_generator_alloc,
8156 .release = silence_generator_release,
8157 .generate = silence_generator_generate,
8168 if (!(state =
ast_calloc(1,
sizeof(*state)))) {
8172 state->old_write_format =
ao2_bump(ast_channel_writeformat(chan));
8175 ast_log(LOG_ERROR,
"Could not set write format to SLINEAR\n");
8182 ast_debug(1,
"Started silence generator on '%s'\n", ast_channel_name(chan));
8187 static int deactivate_silence_generator(
struct ast_channel *chan)
8189 ast_channel_lock(chan);
8191 if (!ast_channel_generatordata(chan)) {
8192 ast_debug(1,
"Trying to stop silence generator when there is no generator on '%s'\n",
8193 ast_channel_name(chan));
8194 ast_channel_unlock(chan);
8197 if (ast_channel_generator(chan) != &silence_generator) {
8198 ast_debug(1,
"Trying to stop silence generator when it is not the current generator on '%s'\n",
8199 ast_channel_name(chan));
8200 ast_channel_unlock(chan);
8203 deactivate_generator_nolock(chan);
8205 ast_channel_unlock(chan);
8216 if (deactivate_silence_generator(chan)) {
8217 ast_debug(1,
"Stopped silence generator on '%s'\n", ast_channel_name(chan));
8219 ast_log(LOG_ERROR,
"Could not return write format to its original state\n");
8222 ao2_cleanup(state->old_write_format);
8236 const char *ints,
const char *language,
const char *options)
8242 const char *ints,
const char *language,
const char *options)
8248 const char *ints,
const char *language,
const char *options)
8254 const char *ints,
const char *lang)
8260 const char *ints,
const char *lang)
8266 const char *ints,
const char *lang)
8268 return ast_say_money_str_full(chan, str, ints, lang, -1, -1);
8274 return ast_say_character_str_full(chan, str, ints, lang, sensitivity, -1, -1);
8277 int ast_say_phonetic_str(
struct ast_channel *chan,
const char *str,
8278 const char *ints,
const char *lang)
8280 return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1);
8284 const char *ints,
const char *lang,
int audiofd,
int ctrlfd)
8288 snprintf(buf,
sizeof(buf),
"%d", num);
8310 if (ast_channel_connected(chan) == connected) {
8315 ast_channel_lock(chan);
8319 ast_channel_unlock(chan);
8348 static int party_name_build_data(
unsigned char *data,
size_t datalen,
const struct ast_party_name *name,
const char *label,
const struct ast_party_name_ies *ies)
8358 length = strlen(name->
str);
8359 if (datalen < pos + (
sizeof(data[0]) * 2) + length) {
8360 ast_log(LOG_WARNING,
"No space left for %s name\n", label);
8363 data[pos++] = ies->
str;
8364 data[pos++] = length;
8365 memcpy(data + pos, name->
str, length);
8369 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8370 ast_log(LOG_WARNING,
"No space left for %s name char set\n", label);
8377 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8378 ast_log(LOG_WARNING,
"No space left for %s name presentation\n", label);
8385 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8386 ast_log(LOG_WARNING,
"No space left for %s name valid\n", label);
8389 data[pos++] = ies->
valid;
8391 data[pos++] = name->
valid;
8432 length = strlen(number->
str);
8433 if (datalen < pos + (
sizeof(data[0]) * 2) + length) {
8434 ast_log(LOG_WARNING,
"No space left for %s number\n", label);
8437 data[pos++] = ies->
str;
8438 data[pos++] = length;
8439 memcpy(data + pos, number->
str, length);
8443 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8444 ast_log(LOG_WARNING,
"No space left for %s numbering plan\n", label);
8447 data[pos++] = ies->
plan;
8449 data[pos++] = number->
plan;
8451 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8452 ast_log(LOG_WARNING,
"No space left for %s number presentation\n", label);
8459 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8460 ast_log(LOG_WARNING,
"No space left for %s number valid\n", label);
8463 data[pos++] = ies->
valid;
8465 data[pos++] = number->
valid;
8505 if (subaddress->
str) {
8506 length = strlen(subaddress->
str);
8507 if (datalen < pos + (
sizeof(data[0]) * 2) + length) {
8508 ast_log(LOG_WARNING,
"No space left for %s subaddress\n", label);
8511 data[pos++] = ies->
str;
8512 data[pos++] = length;
8513 memcpy(data + pos, subaddress->
str, length);
8517 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8518 ast_log(LOG_WARNING,
"No space left for %s type of subaddress\n", label);
8521 data[pos++] = ies->
type;
8523 data[pos++] = subaddress->
type;
8525 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8526 ast_log(LOG_WARNING,
8527 "No space left for %s subaddress odd-even indicator\n", label);
8534 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8535 ast_log(LOG_WARNING,
"No space left for %s subaddress valid\n", label);
8538 data[pos++] = ies->
valid;
8540 data[pos++] = subaddress->
valid;
8577 static int party_id_build_data(
unsigned char *data,
size_t datalen,
8590 if (!update || update->
name) {
8591 res = party_name_build_data(data + pos, datalen - pos, &id->
name, label,
8599 if (!update || update->
number) {
8600 res = party_number_build_data(data + pos, datalen - pos, &id->
number, label,
8609 res = party_subaddress_build_data(data + pos, datalen - pos, &id->
subaddress,
8619 length = strlen(id->
tag);
8620 if (datalen < pos + (
sizeof(data[0]) * 2) + length) {
8621 ast_log(LOG_WARNING,
"No space left for %s tag\n", label);
8624 data[pos++] = ies->
tag;
8625 data[pos++] = length;
8626 memcpy(data + pos, id->
tag, length);
8634 if (!update || update->
name) {
8642 presentation =
id->number.presentation;
8645 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8646 ast_log(LOG_WARNING,
"No space left for %s combined presentation\n", label);
8651 data[pos++] = presentation;
8662 AST_CONNECTED_LINE_NUMBER,
8663 AST_CONNECTED_LINE_NAME,
8664 AST_CONNECTED_LINE_NUMBER_PLAN,
8665 AST_CONNECTED_LINE_ID_PRESENTATION,
8666 AST_CONNECTED_LINE_SOURCE,
8667 AST_CONNECTED_LINE_SUBADDRESS,
8668 AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8669 AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8670 AST_CONNECTED_LINE_SUBADDRESS_VALID,
8671 AST_CONNECTED_LINE_TAG,
8672 AST_CONNECTED_LINE_VERSION,
8677 AST_CONNECTED_LINE_NAME_VALID,
8678 AST_CONNECTED_LINE_NAME_CHAR_SET,
8679 AST_CONNECTED_LINE_NAME_PRESENTATION,
8680 AST_CONNECTED_LINE_NUMBER_VALID,
8681 AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8682 AST_CONNECTED_LINE_PRIV_NUMBER,
8683 AST_CONNECTED_LINE_PRIV_NUMBER_PLAN,
8684 AST_CONNECTED_LINE_PRIV_NUMBER_VALID,
8685 AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8686 AST_CONNECTED_LINE_PRIV_NAME,
8687 AST_CONNECTED_LINE_PRIV_NAME_VALID,
8688 AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET,
8689 AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8690 AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8691 AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8692 AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8693 AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8694 AST_CONNECTED_LINE_PRIV_TAG,
8704 .
name.
str = AST_CONNECTED_LINE_NAME,
8705 .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET,
8706 .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION,
8707 .name.valid = AST_CONNECTED_LINE_NAME_VALID,
8709 .number.str = AST_CONNECTED_LINE_NUMBER,
8710 .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN,
8711 .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION,
8712 .number.valid = AST_CONNECTED_LINE_NUMBER_VALID,
8714 .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS,
8715 .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE,
8716 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN,
8717 .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID,
8719 .tag = AST_CONNECTED_LINE_TAG,
8720 .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION,
8724 .
name.
str = AST_CONNECTED_LINE_PRIV_NAME,
8725 .name.char_set = AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET,
8726 .name.presentation = AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION,
8727 .name.valid = AST_CONNECTED_LINE_PRIV_NAME_VALID,
8729 .number.str = AST_CONNECTED_LINE_PRIV_NUMBER,
8730 .number.plan = AST_CONNECTED_LINE_PRIV_NUMBER_PLAN,
8731 .number.presentation = AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION,
8732 .number.valid = AST_CONNECTED_LINE_PRIV_NUMBER_VALID,
8734 .subaddress.str = AST_CONNECTED_LINE_PRIV_SUBADDRESS,
8735 .subaddress.type = AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE,
8736 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN,
8737 .subaddress.valid = AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID,
8739 .tag = AST_CONNECTED_LINE_PRIV_TAG,
8740 .combined_presentation = 0,
8749 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
8750 ast_log(LOG_WARNING,
"No space left for connected line frame version\n");
8753 data[pos++] = AST_CONNECTED_LINE_VERSION;
8757 res = party_id_build_data(data + pos, datalen - pos, &connected->
id,
8758 "connected line", &ies, update ? &update->
id : NULL);
8764 res = party_id_build_data(data + pos, datalen - pos, &connected->
priv,
8765 "connected line priv", &priv_ies, update ? &update->
priv : NULL);
8772 if (datalen < pos + (
sizeof(data[0]) * 2) +
sizeof(value)) {
8773 ast_log(LOG_WARNING,
"No space left for connected line source\n");
8776 data[pos++] = AST_CONNECTED_LINE_SOURCE;
8777 data[pos++] =
sizeof(value);
8778 value = htonl(connected->
source);
8779 memcpy(data + pos, &value,
sizeof(value));
8780 pos +=
sizeof(value);
8788 unsigned char ie_len;
8789 unsigned char ie_id;
8791 int frame_version = 1;
8793 int got_combined_presentation = 0;
8795 for (pos = 0; pos < datalen; pos += ie_len) {
8796 if (datalen < pos +
sizeof(ie_id) +
sizeof(ie_len)) {
8797 ast_log(LOG_WARNING,
"Invalid connected line update\n");
8800 ie_id = data[pos++];
8801 ie_len = data[pos++];
8802 if (datalen < pos + ie_len) {
8803 ast_log(LOG_WARNING,
"Invalid connected line update\n");
8809 case AST_CONNECTED_LINE_VERSION:
8811 ast_log(LOG_WARNING,
"Invalid connected line frame version (%u)\n",
8815 frame_version = data[pos];
8818 case AST_CONNECTED_LINE_NAME:
8822 memcpy(connected->
id.
name.
str, data + pos, ie_len);
8826 case AST_CONNECTED_LINE_NAME_CHAR_SET:
8828 ast_log(LOG_WARNING,
"Invalid connected line name char set (%u)\n",
8834 case AST_CONNECTED_LINE_NAME_PRESENTATION:
8836 ast_log(LOG_WARNING,
"Invalid connected line name presentation (%u)\n",
8842 case AST_CONNECTED_LINE_NAME_VALID:
8844 ast_log(LOG_WARNING,
"Invalid connected line name valid (%u)\n",
8851 case AST_CONNECTED_LINE_NUMBER:
8855 memcpy(connected->
id.
number.
str, data + pos, ie_len);
8859 case AST_CONNECTED_LINE_NUMBER_PLAN:
8861 ast_log(LOG_WARNING,
"Invalid connected line numbering plan (%u)\n",
8867 case AST_CONNECTED_LINE_NUMBER_PRESENTATION:
8869 ast_log(LOG_WARNING,
"Invalid connected line number presentation (%u)\n",
8875 case AST_CONNECTED_LINE_NUMBER_VALID:
8877 ast_log(LOG_WARNING,
"Invalid connected line number valid (%u)\n",
8884 case AST_CONNECTED_LINE_SUBADDRESS:
8892 case AST_CONNECTED_LINE_SUBADDRESS_TYPE:
8894 ast_log(LOG_WARNING,
"Invalid connected line type of subaddress (%u)\n",
8900 case AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN:
8902 ast_log(LOG_WARNING,
8903 "Invalid connected line subaddress odd-even indicator (%u)\n",
8909 case AST_CONNECTED_LINE_SUBADDRESS_VALID:
8911 ast_log(LOG_WARNING,
"Invalid connected line subaddress valid (%u)\n",
8918 case AST_CONNECTED_LINE_TAG:
8919 ast_free(connected->
id.
tag);
8921 if (connected->
id.
tag) {
8922 memcpy(connected->
id.
tag, data + pos, ie_len);
8923 connected->
id.
tag[ie_len] = 0;
8927 case AST_CONNECTED_LINE_ID_PRESENTATION:
8929 ast_log(LOG_WARNING,
"Invalid connected line combined presentation (%u)\n",
8933 combined_presentation = data[pos];
8934 got_combined_presentation = 1;
8937 case AST_CONNECTED_LINE_PRIV_NAME:
8941 memcpy(connected->
priv.
name.
str, data + pos, ie_len);
8945 case AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET:
8947 ast_log(LOG_WARNING,
"Invalid connected line private name char set (%u)\n",
8953 case AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION:
8955 ast_log(LOG_WARNING,
"Invalid connected line private name presentation (%u)\n",
8961 case AST_CONNECTED_LINE_PRIV_NAME_VALID:
8963 ast_log(LOG_WARNING,
"Invalid connected line private name valid (%u)\n",
8970 case AST_CONNECTED_LINE_PRIV_NUMBER:
8978 case AST_CONNECTED_LINE_PRIV_NUMBER_PLAN:
8980 ast_log(LOG_WARNING,
"Invalid connected line private numbering plan (%u)\n",
8986 case AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION:
8988 ast_log(LOG_WARNING,
"Invalid connected line private number presentation (%u)\n",
8994 case AST_CONNECTED_LINE_PRIV_NUMBER_VALID:
8996 ast_log(LOG_WARNING,
"Invalid connected line private number valid (%u)\n",
9003 case AST_CONNECTED_LINE_PRIV_SUBADDRESS:
9011 case AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE:
9013 ast_log(LOG_WARNING,
"Invalid connected line private type of subaddress (%u)\n",
9019 case AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN:
9021 ast_log(LOG_WARNING,
9022 "Invalid connected line private subaddress odd-even indicator (%u)\n",
9028 case AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID:
9030 ast_log(LOG_WARNING,
"Invalid connected line private subaddress valid (%u)\n",
9037 case AST_CONNECTED_LINE_PRIV_TAG:
9038 ast_free(connected->
priv.
tag);
9041 memcpy(connected->
priv.
tag, data + pos, ie_len);
9042 connected->
priv.
tag[ie_len] = 0;
9046 case AST_CONNECTED_LINE_SOURCE:
9047 if (ie_len !=
sizeof(value)) {
9048 ast_log(LOG_WARNING,
"Invalid connected line source (%u)\n",
9052 memcpy(&value, data + pos,
sizeof(value));
9053 connected->
source = ntohl(value);
9057 ast_debug(1,
"Unknown connected line element: %u (%u)\n",
9058 (
unsigned) ie_id, (
unsigned) ie_len);
9063 switch (frame_version) {
9072 if (got_combined_presentation) {
9085 ast_debug(1,
"Connected line frame has newer version: %u\n",
9086 (
unsigned) frame_version);
9095 unsigned char data[1024];
9099 if (datalen == (
size_t) -1) {
9108 unsigned char data[1024];
9112 if (datalen == (
size_t) -1) {
9121 if (ast_channel_redirecting(chan) == redirecting) {
9126 ast_channel_lock(chan);
9130 ast_channel_unlock(chan);
9138 AST_REDIRECTING_FROM_NUMBER,
9139 AST_REDIRECTING_FROM_NAME,
9140 AST_REDIRECTING_FROM_NUMBER_PLAN,
9141 AST_REDIRECTING_FROM_ID_PRESENTATION,
9142 AST_REDIRECTING_TO_NUMBER,
9143 AST_REDIRECTING_TO_NAME,
9144 AST_REDIRECTING_TO_NUMBER_PLAN,
9145 AST_REDIRECTING_TO_ID_PRESENTATION,
9146 AST_REDIRECTING_REASON_CODE,
9147 AST_REDIRECTING_COUNT,
9148 AST_REDIRECTING_FROM_SUBADDRESS,
9149 AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9150 AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9151 AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9152 AST_REDIRECTING_TO_SUBADDRESS,
9153 AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9154 AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9155 AST_REDIRECTING_TO_SUBADDRESS_VALID,
9156 AST_REDIRECTING_FROM_TAG,
9157 AST_REDIRECTING_TO_TAG,
9158 AST_REDIRECTING_VERSION,
9163 AST_REDIRECTING_FROM_NAME_VALID,
9164 AST_REDIRECTING_FROM_NAME_CHAR_SET,
9165 AST_REDIRECTING_FROM_NAME_PRESENTATION,
9166 AST_REDIRECTING_FROM_NUMBER_VALID,
9167 AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9168 AST_REDIRECTING_TO_NAME_VALID,
9169 AST_REDIRECTING_TO_NAME_CHAR_SET,
9170 AST_REDIRECTING_TO_NAME_PRESENTATION,
9171 AST_REDIRECTING_TO_NUMBER_VALID,
9172 AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9173 AST_REDIRECTING_ORIG_NUMBER,
9174 AST_REDIRECTING_ORIG_NUMBER_VALID,
9175 AST_REDIRECTING_ORIG_NUMBER_PLAN,
9176 AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9177 AST_REDIRECTING_ORIG_NAME,
9178 AST_REDIRECTING_ORIG_NAME_VALID,
9179 AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9180 AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9181 AST_REDIRECTING_ORIG_SUBADDRESS,
9182 AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9183 AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9184 AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9185 AST_REDIRECTING_ORIG_TAG,
9186 AST_REDIRECTING_ORIG_REASON_CODE,
9187 AST_REDIRECTING_PRIV_TO_NUMBER,
9188 AST_REDIRECTING_PRIV_TO_NUMBER_PLAN,
9189 AST_REDIRECTING_PRIV_TO_NUMBER_VALID,
9190 AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9191 AST_REDIRECTING_PRIV_TO_NAME,
9192 AST_REDIRECTING_PRIV_TO_NAME_VALID,
9193 AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET,
9194 AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9195 AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9196 AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9197 AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9198 AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9199 AST_REDIRECTING_PRIV_TO_TAG,
9200 AST_REDIRECTING_PRIV_FROM_NUMBER,
9201 AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN,
9202 AST_REDIRECTING_PRIV_FROM_NUMBER_VALID,
9203 AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9204 AST_REDIRECTING_PRIV_FROM_NAME,
9205 AST_REDIRECTING_PRIV_FROM_NAME_VALID,
9206 AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET,
9207 AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION,
9208 AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9209 AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE,
9210 AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9211 AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID,
9212 AST_REDIRECTING_PRIV_FROM_TAG,
9213 AST_REDIRECTING_PRIV_ORIG_NUMBER,
9214 AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID,
9215 AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN,
9216 AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9217 AST_REDIRECTING_PRIV_ORIG_NAME,
9218 AST_REDIRECTING_PRIV_ORIG_NAME_VALID,
9219 AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET,
9220 AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION,
9221 AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9222 AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE,
9223 AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9224 AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID,
9225 AST_REDIRECTING_PRIV_ORIG_TAG,
9226 AST_REDIRECTING_REASON_STR,
9227 AST_REDIRECTING_ORIG_REASON_STR,
9235 static int redirecting_reason_build_data(
unsigned char *data,
size_t datalen,
9243 if (datalen < pos + (
sizeof(data[0]) * 2) +
sizeof(value)) {
9244 ast_log(LOG_WARNING,
"No space left for %s code\n", label);
9247 data[pos++] = ies->code;
9248 data[pos++] =
sizeof(value);
9249 value = htonl(reason->
code);
9250 memcpy(data + pos, &value,
sizeof(value));
9251 pos +=
sizeof(value);
9254 length = strlen(reason->
str);
9255 if (datalen < pos + (
sizeof(data[0]) * 2) + length) {
9256 ast_log(LOG_WARNING,
"No space left for %s string\n", label);
9259 data[pos++] = ies->str;
9260 data[pos++] = length;
9261 memcpy(data + pos, reason->
str, length);
9275 .
name.
str = AST_REDIRECTING_ORIG_NAME,
9276 .name.char_set = AST_REDIRECTING_ORIG_NAME_CHAR_SET,
9277 .name.presentation = AST_REDIRECTING_ORIG_NAME_PRESENTATION,
9278 .name.valid = AST_REDIRECTING_ORIG_NAME_VALID,
9280 .number.str = AST_REDIRECTING_ORIG_NUMBER,
9281 .number.plan = AST_REDIRECTING_ORIG_NUMBER_PLAN,
9282 .number.presentation = AST_REDIRECTING_ORIG_NUMBER_PRESENTATION,
9283 .number.valid = AST_REDIRECTING_ORIG_NUMBER_VALID,
9285 .subaddress.str = AST_REDIRECTING_ORIG_SUBADDRESS,
9286 .subaddress.type = AST_REDIRECTING_ORIG_SUBADDRESS_TYPE,
9287 .subaddress.odd_even_indicator = AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN,
9288 .subaddress.valid = AST_REDIRECTING_ORIG_SUBADDRESS_VALID,
9290 .tag = AST_REDIRECTING_ORIG_TAG,
9291 .combined_presentation = 0,
9294 .
name.
str = AST_REDIRECTING_FROM_NAME,
9295 .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET,
9296 .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION,
9297 .name.valid = AST_REDIRECTING_FROM_NAME_VALID,
9299 .number.str = AST_REDIRECTING_FROM_NUMBER,
9300 .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN,
9301 .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION,
9302 .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID,
9304 .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS,
9305 .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE,
9306 .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN,
9307 .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID,
9309 .tag = AST_REDIRECTING_FROM_TAG,
9310 .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION,
9313 .
name.
str = AST_REDIRECTING_TO_NAME,
9314 .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET,
9315 .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION,
9316 .name.valid = AST_REDIRECTING_TO_NAME_VALID,
9318 .number.str = AST_REDIRECTING_TO_NUMBER,
9319 .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN,
9320 .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION,
9321 .number.valid = AST_REDIRECTING_TO_NUMBER_VALID,
9323 .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS,
9324 .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE,
9325 .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN,
9326 .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID,
9328 .tag = AST_REDIRECTING_TO_TAG,
9329 .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION,
9332 .
name.
str = AST_REDIRECTING_PRIV_ORIG_NAME,
9333 .name.char_set = AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET,
9334 .name.presentation = AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION,
9335 .name.valid = AST_REDIRECTING_PRIV_ORIG_NAME_VALID,
9337 .number.str = AST_REDIRECTING_PRIV_ORIG_NUMBER,
9338 .number.plan = AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN,
9339 .number.presentation = AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION,
9340 .number.valid = AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID,
9342 .subaddress.str = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS,
9343 .subaddress.type = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE,
9344 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN,
9345 .subaddress.valid = AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID,
9347 .tag = AST_REDIRECTING_PRIV_ORIG_TAG,
9348 .combined_presentation = 0,
9351 .
name.
str = AST_REDIRECTING_PRIV_FROM_NAME,
9352 .name.char_set = AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET,
9353 .name.presentation = AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION,
9354 .name.valid = AST_REDIRECTING_PRIV_FROM_NAME_VALID,
9356 .number.str = AST_REDIRECTING_PRIV_FROM_NUMBER,
9357 .number.plan = AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN,
9358 .number.presentation = AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION,
9359 .number.valid = AST_REDIRECTING_PRIV_FROM_NUMBER_VALID,
9361 .subaddress.str = AST_REDIRECTING_PRIV_FROM_SUBADDRESS,
9362 .subaddress.type = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE,
9363 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN,
9364 .subaddress.valid = AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID,
9366 .tag = AST_REDIRECTING_PRIV_FROM_TAG,
9367 .combined_presentation = 0,
9370 .
name.
str = AST_REDIRECTING_PRIV_TO_NAME,
9371 .name.char_set = AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET,
9372 .name.presentation = AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION,
9373 .name.valid = AST_REDIRECTING_PRIV_TO_NAME_VALID,
9375 .number.str = AST_REDIRECTING_PRIV_TO_NUMBER,
9376 .number.plan = AST_REDIRECTING_PRIV_TO_NUMBER_PLAN,
9377 .number.presentation = AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION,
9378 .number.valid = AST_REDIRECTING_PRIV_TO_NUMBER_VALID,
9380 .subaddress.str = AST_REDIRECTING_PRIV_TO_SUBADDRESS,
9381 .subaddress.type = AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE,
9382 .subaddress.odd_even_indicator = AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN,
9383 .subaddress.valid = AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID,
9385 .tag = AST_REDIRECTING_PRIV_TO_TAG,
9386 .combined_presentation = 0,
9389 .code = AST_REDIRECTING_REASON_CODE,
9390 .str = AST_REDIRECTING_REASON_STR,
9394 .code = AST_REDIRECTING_ORIG_REASON_CODE,
9395 .str = AST_REDIRECTING_ORIG_REASON_STR,
9399 if (datalen < pos + (
sizeof(data[0]) * 2) + 1) {
9400 ast_log(LOG_WARNING,
"No space left for redirecting frame version\n");
9403 data[pos++] = AST_REDIRECTING_VERSION;
9407 res = party_id_build_data(data + pos, datalen - pos, &redirecting->
orig,
9408 "redirecting-orig", &orig_ies, update ? &update->
orig : NULL);
9414 res = party_id_build_data(data + pos, datalen - pos, &redirecting->
from,
9415 "redirecting-from", &from_ies, update ? &update->
from : NULL);
9421 res = party_id_build_data(data + pos, datalen - pos, &redirecting->
to,
9422 "redirecting-to", &to_ies, update ? &update->
to : NULL);
9428 res = party_id_build_data(data + pos, datalen - pos, &redirecting->
priv_orig,
9429 "redirecting-priv-orig", &priv_orig_ies, update ? &update->
priv_orig : NULL);
9435 res = party_id_build_data(data + pos, datalen - pos, &redirecting->
priv_from,
9436 "redirecting-priv-from", &priv_from_ies, update ? &update->
priv_from : NULL);
9442 res = party_id_build_data(data + pos, datalen - pos, &redirecting->
priv_to,
9443 "redirecting-priv-to", &priv_to_ies, update ? &update->
priv_to : NULL);
9450 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->
reason,
9451 "redirecting-reason", &reason_ies);
9458 res = redirecting_reason_build_data(data + pos, datalen - pos, &redirecting->
orig_reason,
9459 "redirecting-orig-reason", &orig_reason_ies);
9466 if (datalen < pos + (
sizeof(data[0]) * 2) +
sizeof(value)) {
9467 ast_log(LOG_WARNING,
"No space left for redirecting count\n");
9470 data[pos++] = AST_REDIRECTING_COUNT;
9471 data[pos++] =
sizeof(value);
9472 value = htonl(redirecting->
count);
9473 memcpy(data + pos, &value,
sizeof(value));
9474 pos +=
sizeof(value);
9482 unsigned char ie_len;
9483 unsigned char ie_id;
9485 int frame_version = 1;
9486 int from_combined_presentation = 0;
9487 int got_from_combined_presentation = 0;
9488 int to_combined_presentation = 0;
9489 int got_to_combined_presentation = 0;
9491 for (pos = 0; pos < datalen; pos += ie_len) {
9492 if (datalen < pos +
sizeof(ie_id) +
sizeof(ie_len)) {
9493 ast_log(LOG_WARNING,
"Invalid redirecting update\n");
9496 ie_id = data[pos++];
9497 ie_len = data[pos++];
9498 if (datalen < pos + ie_len) {
9499 ast_log(LOG_WARNING,
"Invalid redirecting update\n");
9505 case AST_REDIRECTING_VERSION:
9507 ast_log(LOG_WARNING,
"Invalid redirecting frame version (%u)\n",
9511 frame_version = data[pos];
9514 case AST_REDIRECTING_ORIG_NAME:
9518 memcpy(redirecting->
orig.
name.
str, data + pos, ie_len);
9522 case AST_REDIRECTING_ORIG_NAME_CHAR_SET:
9524 ast_log(LOG_WARNING,
"Invalid redirecting-orig name char set (%u)\n",
9530 case AST_REDIRECTING_ORIG_NAME_PRESENTATION:
9532 ast_log(LOG_WARNING,
"Invalid redirecting-orig name presentation (%u)\n",
9538 case AST_REDIRECTING_ORIG_NAME_VALID:
9540 ast_log(LOG_WARNING,
"Invalid redirecting-orig name valid (%u)\n",
9547 case AST_REDIRECTING_ORIG_NUMBER:
9555 case AST_REDIRECTING_ORIG_NUMBER_PLAN:
9557 ast_log(LOG_WARNING,
"Invalid redirecting-orig numbering plan (%u)\n",
9563 case AST_REDIRECTING_ORIG_NUMBER_PRESENTATION:
9565 ast_log(LOG_WARNING,
"Invalid redirecting-orig number presentation (%u)\n",
9571 case AST_REDIRECTING_ORIG_NUMBER_VALID:
9573 ast_log(LOG_WARNING,
"Invalid redirecting-orig number valid (%u)\n",
9580 case AST_REDIRECTING_ORIG_SUBADDRESS:
9588 case AST_REDIRECTING_ORIG_SUBADDRESS_TYPE:
9590 ast_log(LOG_WARNING,
"Invalid redirecting-orig type of subaddress (%u)\n",
9596 case AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN:
9598 ast_log(LOG_WARNING,
9599 "Invalid redirecting-orig subaddress odd-even indicator (%u)\n",
9605 case AST_REDIRECTING_ORIG_SUBADDRESS_VALID:
9607 ast_log(LOG_WARNING,
"Invalid redirecting-orig subaddress valid (%u)\n",
9614 case AST_REDIRECTING_ORIG_TAG:
9615 ast_free(redirecting->
orig.
tag);
9618 memcpy(redirecting->
orig.
tag, data + pos, ie_len);
9619 redirecting->
orig.
tag[ie_len] = 0;
9623 case AST_REDIRECTING_FROM_NAME:
9627 memcpy(redirecting->
from.
name.
str, data + pos, ie_len);
9631 case AST_REDIRECTING_FROM_NAME_CHAR_SET:
9633 ast_log(LOG_WARNING,
"Invalid redirecting-from name char set (%u)\n",
9639 case AST_REDIRECTING_FROM_NAME_PRESENTATION:
9641 ast_log(LOG_WARNING,
"Invalid redirecting-from name presentation (%u)\n",
9647 case AST_REDIRECTING_FROM_NAME_VALID:
9649 ast_log(LOG_WARNING,
"Invalid redirecting-from name valid (%u)\n",
9656 case AST_REDIRECTING_FROM_NUMBER:
9664 case AST_REDIRECTING_FROM_NUMBER_PLAN:
9666 ast_log(LOG_WARNING,
"Invalid redirecting-from numbering plan (%u)\n",
9672 case AST_REDIRECTING_FROM_NUMBER_PRESENTATION:
9674 ast_log(LOG_WARNING,
"Invalid redirecting-from number presentation (%u)\n",
9680 case AST_REDIRECTING_FROM_NUMBER_VALID:
9682 ast_log(LOG_WARNING,
"Invalid redirecting-from number valid (%u)\n",
9689 case AST_REDIRECTING_FROM_ID_PRESENTATION:
9691 ast_log(LOG_WARNING,
"Invalid redirecting-from combined presentation (%u)\n",
9695 from_combined_presentation = data[pos];
9696 got_from_combined_presentation = 1;
9699 case AST_REDIRECTING_FROM_SUBADDRESS:
9707 case AST_REDIRECTING_FROM_SUBADDRESS_TYPE:
9709 ast_log(LOG_WARNING,
"Invalid redirecting-from type of subaddress (%u)\n",
9715 case AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN:
9717 ast_log(LOG_WARNING,
9718 "Invalid redirecting-from subaddress odd-even indicator (%u)\n",
9724 case AST_REDIRECTING_FROM_SUBADDRESS_VALID:
9726 ast_log(LOG_WARNING,
"Invalid redirecting-from subaddress valid (%u)\n",
9733 case AST_REDIRECTING_FROM_TAG:
9734 ast_free(redirecting->
from.
tag);
9737 memcpy(redirecting->
from.
tag, data + pos, ie_len);
9738 redirecting->
from.
tag[ie_len] = 0;
9742 case AST_REDIRECTING_TO_NAME:
9746 memcpy(redirecting->
to.
name.
str, data + pos, ie_len);
9750 case AST_REDIRECTING_TO_NAME_CHAR_SET:
9752 ast_log(LOG_WARNING,
"Invalid redirecting-to name char set (%u)\n",
9758 case AST_REDIRECTING_TO_NAME_PRESENTATION:
9760 ast_log(LOG_WARNING,
"Invalid redirecting-to name presentation (%u)\n",
9766 case AST_REDIRECTING_TO_NAME_VALID:
9768 ast_log(LOG_WARNING,
"Invalid redirecting-to name valid (%u)\n",
9775 case AST_REDIRECTING_TO_NUMBER:
9779 memcpy(redirecting->
to.
number.
str, data + pos, ie_len);
9783 case AST_REDIRECTING_TO_NUMBER_PLAN:
9785 ast_log(LOG_WARNING,
"Invalid redirecting-to numbering plan (%u)\n",
9791 case AST_REDIRECTING_TO_NUMBER_PRESENTATION:
9793 ast_log(LOG_WARNING,
"Invalid redirecting-to number presentation (%u)\n",
9799 case AST_REDIRECTING_TO_NUMBER_VALID:
9801 ast_log(LOG_WARNING,
"Invalid redirecting-to number valid (%u)\n",
9808 case AST_REDIRECTING_TO_ID_PRESENTATION:
9810 ast_log(LOG_WARNING,
"Invalid redirecting-to combined presentation (%u)\n",
9814 to_combined_presentation = data[pos];
9815 got_to_combined_presentation = 1;
9818 case AST_REDIRECTING_TO_SUBADDRESS:
9826 case AST_REDIRECTING_TO_SUBADDRESS_TYPE:
9828 ast_log(LOG_WARNING,
"Invalid redirecting-to type of subaddress (%u)\n",
9834 case AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN:
9836 ast_log(LOG_WARNING,
9837 "Invalid redirecting-to subaddress odd-even indicator (%u)\n",
9843 case AST_REDIRECTING_TO_SUBADDRESS_VALID:
9845 ast_log(LOG_WARNING,
"Invalid redirecting-to subaddress valid (%u)\n",
9852 case AST_REDIRECTING_TO_TAG:
9853 ast_free(redirecting->
to.
tag);
9855 if (redirecting->
to.
tag) {
9856 memcpy(redirecting->
to.
tag, data + pos, ie_len);
9857 redirecting->
to.
tag[ie_len] = 0;
9861 case AST_REDIRECTING_PRIV_ORIG_NAME:
9869 case AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET:
9871 ast_log(LOG_WARNING,
"Invalid private redirecting-orig name char set (%u)\n",
9877 case AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION:
9879 ast_log(LOG_WARNING,
"Invalid private redirecting-orig name presentation (%u)\n",
9885 case AST_REDIRECTING_PRIV_ORIG_NAME_VALID:
9887 ast_log(LOG_WARNING,
"Invalid private redirecting-orig name valid (%u)\n",
9894 case AST_REDIRECTING_PRIV_ORIG_NUMBER:
9902 case AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN:
9904 ast_log(LOG_WARNING,
"Invalid private redirecting-orig numbering plan (%u)\n",
9910 case AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION:
9912 ast_log(LOG_WARNING,
"Invalid private redirecting-orig number presentation (%u)\n",
9918 case AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID:
9920 ast_log(LOG_WARNING,
"Invalid private redirecting-orig number valid (%u)\n",
9927 case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS:
9935 case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE:
9937 ast_log(LOG_WARNING,
"Invalid private redirecting-orig type of subaddress (%u)\n",
9943 case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN:
9945 ast_log(LOG_WARNING,
9946 "Invalid private redirecting-orig subaddress odd-even indicator (%u)\n",
9952 case AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID:
9954 ast_log(LOG_WARNING,
"Invalid private redirecting-orig subaddress valid (%u)\n",
9961 case AST_REDIRECTING_PRIV_ORIG_TAG:
9965 memcpy(redirecting->
priv_orig.
tag, data + pos, ie_len);
9970 case AST_REDIRECTING_PRIV_FROM_NAME:
9978 case AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET:
9980 ast_log(LOG_WARNING,
"Invalid private redirecting-from name char set (%u)\n",
9986 case AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION:
9988 ast_log(LOG_WARNING,
"Invalid private redirecting-from name presentation (%u)\n",
9994 case AST_REDIRECTING_PRIV_FROM_NAME_VALID:
9996 ast_log(LOG_WARNING,
"Invalid private redirecting-from name valid (%u)\n",
10003 case AST_REDIRECTING_PRIV_FROM_NUMBER:
10011 case AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN:
10013 ast_log(LOG_WARNING,
"Invalid private redirecting-from numbering plan (%u)\n",
10014 (
unsigned) ie_len);
10019 case AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION:
10021 ast_log(LOG_WARNING,
"Invalid private redirecting-from number presentation (%u)\n",
10022 (
unsigned) ie_len);
10027 case AST_REDIRECTING_PRIV_FROM_NUMBER_VALID:
10029 ast_log(LOG_WARNING,
"Invalid private redirecting-from number valid (%u)\n",
10030 (
unsigned) ie_len);
10036 case AST_REDIRECTING_PRIV_FROM_SUBADDRESS:
10044 case AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE:
10046 ast_log(LOG_WARNING,
"Invalid private redirecting-from type of subaddress (%u)\n",
10047 (
unsigned) ie_len);
10052 case AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN:
10054 ast_log(LOG_WARNING,
10055 "Invalid private redirecting-from subaddress odd-even indicator (%u)\n",
10056 (
unsigned) ie_len);
10061 case AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID:
10063 ast_log(LOG_WARNING,
"Invalid private redirecting-from subaddress valid (%u)\n",
10064 (
unsigned) ie_len);
10070 case AST_REDIRECTING_PRIV_FROM_TAG:
10074 memcpy(redirecting->
priv_from.
tag, data + pos, ie_len);
10079 case AST_REDIRECTING_PRIV_TO_NAME:
10087 case AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET:
10089 ast_log(LOG_WARNING,
"Invalid private redirecting-to name char set (%u)\n",
10090 (
unsigned) ie_len);
10095 case AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION:
10097 ast_log(LOG_WARNING,
"Invalid private redirecting-to name presentation (%u)\n",
10098 (
unsigned) ie_len);
10103 case AST_REDIRECTING_PRIV_TO_NAME_VALID:
10105 ast_log(LOG_WARNING,
"Invalid private redirecting-to name valid (%u)\n",
10106 (
unsigned) ie_len);
10112 case AST_REDIRECTING_PRIV_TO_NUMBER:
10120 case AST_REDIRECTING_PRIV_TO_NUMBER_PLAN:
10122 ast_log(LOG_WARNING,
"Invalid private redirecting-to numbering plan (%u)\n",
10123 (
unsigned) ie_len);
10128 case AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION:
10130 ast_log(LOG_WARNING,
"Invalid private redirecting-to number presentation (%u)\n",
10131 (
unsigned) ie_len);
10136 case AST_REDIRECTING_PRIV_TO_NUMBER_VALID:
10138 ast_log(LOG_WARNING,
"Invalid private redirecting-to number valid (%u)\n",
10139 (
unsigned) ie_len);
10145 case AST_REDIRECTING_PRIV_TO_SUBADDRESS:
10153 case AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE:
10155 ast_log(LOG_WARNING,
"Invalid private redirecting-to type of subaddress (%u)\n",
10156 (
unsigned) ie_len);
10161 case AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN:
10163 ast_log(LOG_WARNING,
10164 "Invalid private redirecting-to subaddress odd-even indicator (%u)\n",
10165 (
unsigned) ie_len);
10170 case AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID:
10172 ast_log(LOG_WARNING,
"Invalid private redirecting-to subaddress valid (%u)\n",
10173 (
unsigned) ie_len);
10179 case AST_REDIRECTING_PRIV_TO_TAG:
10183 memcpy(redirecting->
priv_to.
tag, data + pos, ie_len);
10188 case AST_REDIRECTING_REASON_CODE:
10189 if (ie_len !=
sizeof(value)) {
10190 ast_log(LOG_WARNING,
"Invalid redirecting reason (%u)\n",
10191 (
unsigned) ie_len);
10194 memcpy(&value, data + pos,
sizeof(value));
10198 case AST_REDIRECTING_REASON_STR:
10202 memcpy(redirecting->
reason.
str, data + pos, ie_len);
10207 case AST_REDIRECTING_ORIG_REASON_CODE:
10208 if (ie_len !=
sizeof(value)) {
10209 ast_log(LOG_WARNING,
"Invalid redirecting original reason (%u)\n",
10210 (
unsigned) ie_len);
10213 memcpy(&value, data + pos,
sizeof(value));
10217 case AST_REDIRECTING_ORIG_REASON_STR:
10226 case AST_REDIRECTING_COUNT:
10227 if (ie_len !=
sizeof(value)) {
10228 ast_log(LOG_WARNING,
"Invalid redirecting count (%u)\n",
10229 (
unsigned) ie_len);
10232 memcpy(&value, data + pos,
sizeof(value));
10233 redirecting->
count = ntohl(value);
10237 ast_debug(1,
"Unknown redirecting element: %u (%u)\n",
10238 (
unsigned) ie_id, (
unsigned) ie_len);
10243 switch (frame_version) {
10255 if (got_from_combined_presentation) {
10263 if (got_to_combined_presentation) {
10276 ast_debug(1,
"Redirecting frame has newer version: %u\n",
10277 (
unsigned) frame_version);
10286 unsigned char data[1024];
10290 if (datalen == (
size_t) -1) {
10299 unsigned char data[1024];
10303 if (datalen == (
size_t) -1) {
10322 static void channel_set_intercept_mode(
int in_intercept_mode)
10327 in_intercept_mode ? &(
int) { 1 } : NULL);
10329 ast_log(LOG_ERROR,
"Failed to set dialplan intercept mode\n");
10341 const char *sub_args;
10344 ast_channel_lock(sub_chan);
10350 if (ast_strlen_zero(sub)) {
10351 ast_channel_unlock(sub_chan);
10356 const struct ast_frame *frame = connected_info;
10364 ast_channel_unlock(sub_chan);
10366 channel_set_intercept_mode(1);
10367 retval =
ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10368 channel_set_intercept_mode(0);
10373 ast_channel_lock(sub_chan);
10375 ast_channel_unlock(sub_chan);
10386 const char *sub_args;
10389 ast_channel_lock(sub_chan);
10395 if (ast_strlen_zero(sub)) {
10396 ast_channel_unlock(sub_chan);
10401 const struct ast_frame *frame = redirecting_info;
10409 ast_channel_unlock(sub_chan);
10411 channel_set_intercept_mode(1);
10412 retval =
ast_app_run_sub(autoservice_chan, sub_chan, sub, sub_args, 0);
10413 channel_set_intercept_mode(0);
10418 ast_channel_lock(sub_chan);
10420 ast_channel_unlock(sub_chan);
10428 static void *channel_cc_params_copy(
void *data)
10439 static void channel_cc_params_destroy(
void *data)
10446 .
type =
"Call Completion",
10447 .duplicate = channel_cc_params_copy,
10448 .destroy = channel_cc_params_destroy,
10461 if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) {
10469 cc_datastore->
data = cc_params;
10492 ast_assert(cc_datastore->
data != NULL);
10493 return cc_datastore->
data;
10498 int len = name_buffer_length;
10505 ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
10506 if ((dash = strrchr(device_name,
'-'))) {
10523 if ((slash = strchr(agent_type,
'/'))) {
10538 bridge = ast_channel_internal_bridge(chan);
10547 return ast_channel_internal_bridge(chan) != NULL;
10552 int hangup_flags = ast_channel_softhangup_internal_flag(chan);
10561 return ((hangup_test || unbridge) && (hangup_test == hangup_flags));
10570 ast_channel_lock(chan);
10572 ast_channel_unlock(chan);
10586 bridge_channel = ast_channel_internal_bridge_channel(chan);
10587 if (bridge_channel) {
10590 return bridge_channel;
10605 } my_vars = { 0, };
10607 ast_channel_lock(yankee);
10608 my_vars.accountcode =
ast_strdupa(ast_channel_accountcode(yankee));
10609 my_vars.exten =
ast_strdupa(ast_channel_exten(yankee));
10610 my_vars.context =
ast_strdupa(ast_channel_context(yankee));
10611 my_vars.name =
ast_strdupa(ast_channel_name(yankee));
10612 my_vars.amaflags = ast_channel_amaflags(yankee);
10613 my_vars.priority = ast_channel_priority(yankee);
10621 my_vars.priority++;
10623 my_vars.writeformat =
ao2_bump(ast_channel_writeformat(yankee));
10624 my_vars.readformat =
ao2_bump(ast_channel_readformat(yankee));
10625 ast_channel_unlock(yankee);
10630 my_vars.exten, my_vars.context, NULL, yankee, my_vars.
amaflags,
10631 "Surrogate/%s", my_vars.name))) {
10632 ao2_cleanup(my_vars.writeformat);
10633 ao2_cleanup(my_vars.readformat);
10638 ast_channel_set_readformat(yanked_chan, my_vars.
readformat);
10639 ast_channel_set_writeformat(yanked_chan, my_vars.
writeformat);
10640 ao2_cleanup(my_vars.readformat);
10641 ao2_cleanup(my_vars.writeformat);
10642 ast_channel_priority_set(yanked_chan, my_vars.
priority);
10644 ast_channel_unlock(yanked_chan);
10651 return yanked_chan;
10671 if (dest == source) {
10672 ast_log(LOG_WARNING,
"Can't move channel '%s' into itself!\n",
10673 ast_channel_name(dest));
10682 ast_log(LOG_WARNING,
10683 "Can't move channel. One or both is dead (%s <-- %s)\n",
10684 ast_channel_name(dest), ast_channel_name(source));
10685 ast_channel_unlock(source);
10686 ast_channel_unlock(dest);
10690 ast_channel_masq_set(dest, source);
10691 ast_channel_masqr_set(source, dest);
10694 "newchanneluniqueid", ast_channel_uniqueid(dest));
10697 ast_channel_unlock(dest);
10698 ast_channel_unlock(source);
10704 static void suppress_datastore_destroy_cb(
void *data)
10710 .
type =
"suppressvoice",
10711 .destroy = suppress_datastore_destroy_cb
10714 static void suppress_framehook_destroy_cb(
void *data)
10721 unsigned int direction;
10725 static void suppress_framehook_fixup_cb(
void *data,
int framehook_id,
struct ast_channel *old_chan,
struct ast_channel *new_chan)
10729 suppress->framehook_id = framehook_id;
10735 int suppress_frame = 0;
10741 if (frame->
frametype != suppress->frametype) {
10746 suppress_frame = 1;
10748 suppress_frame = 1;
10751 if (suppress_frame) {
10769 switch (frametype) {
10771 return &suppress_datastore_voice;
10783 .
version = AST_FRAMEHOOK_INTERFACE_VERSION,
10784 .event_cb = suppress_framehook_event_cb,
10785 .destroy_cb = suppress_framehook_destroy_cb,
10786 .chan_fixup_cb = suppress_framehook_fixup_cb,
10790 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10791 ast_log(LOG_WARNING,
"Attempted to suppress an unsupported frame type (%u).\n", frametype);
10796 suppress = datastore->
data;
10797 suppress->direction |= direction;
10801 if (!(suppress = ao2_alloc(
sizeof(*suppress), NULL))) {
10802 ast_log(LOG_WARNING,
"Failed to allocate data while attempting to suppress a stream.\n");
10806 suppress->frametype = frametype;
10807 suppress->direction |= direction;
10809 interface.
data = suppress;
10812 if (framehook_id < 0) {
10814 ast_log(LOG_WARNING,
"Failed to attach framehook while attempting to suppress a stream.\n");
10822 suppress->framehook_id = framehook_id;
10824 if (!(datastore = ast_datastore_alloc(datastore_info, NULL))) {
10825 ast_log(LOG_WARNING,
"Failed to allocate datastore while attempting to suppress a stream.\n");
10832 datastore->
data = suppress;
10845 if (!(datastore_info = suppress_get_datastore_information(frametype))) {
10846 ast_log(LOG_WARNING,
"Attempted to unsuppress an unsupported frame type (%u).\n", frametype);
10855 suppress = datastore->
data;
10857 suppress->direction &= ~(direction);
10859 if (suppress->direction == 0) {
10874 ast_channel_lock(chan);
10876 || (ast_channel_softhangup_internal_flag(chan)
10878 ast_channel_unlock(chan);
10889 ast_log(LOG_DTMF,
"DTMF end '%c' simulated on %s due to %s, duration %ld ms\n",
10890 digit, ast_channel_name(chan), why, duration);
10893 static void features_destroy(
void *obj)
10899 .
type =
"bridge-features",
10900 .destroy = features_destroy,
10911 return datastore->
data;
10921 ds_features = datastore->
data;
10932 datastore = ast_datastore_alloc(&bridge_features_info, NULL);
10938 if (!ds_features) {
10946 datastore->
data = ds_features;
10953 return channel_feature_hooks_set_full(chan, features, 0);
10958 return channel_feature_hooks_set_full(chan, features, 1);
10963 return ast_channel_internal_errno();
10971 ast_assert(chan != NULL);
10972 ast_assert(topology != NULL);
10974 ast_channel_lock(chan);
10976 ast_channel_unlock(chan);
10981 ast_debug(2,
"%s: Topologies already match. Current: %s Requested: %s\n",
10982 ast_channel_name(chan),
10985 ast_channel_unlock(chan);
10989 ast_channel_internal_set_stream_topology_change_source(chan, change_source);
10992 ast_channel_unlock(chan);
10998 ast_assert(chan != NULL);
10999 ast_assert(topology != NULL);
11013 ast_assert(chan != NULL);
11019 ast_channel_lock(chan);
11022 ast_channel_unlock(chan);
11029 ast_channel_lock(chan);
11030 ast_set_flag(ast_channel_flags(chan), flag);
11031 ast_channel_unlock(chan);
11036 ast_channel_lock(chan);
11037 ast_clear_flag(ast_channel_flags(chan), flag);
11038 ast_channel_unlock(chan);
int ast_say_digit_str(struct ast_channel *chan, const char *str, const char *ints, const char *lang)
says digits of a string
int valid
valid/present ie
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
struct ast_party_id ast_party_id_merge(struct ast_party_id *base, struct ast_party_id *overlay)
Merge a given party id into another given party id.
int(*const answer_with_stream_topology)(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer the channel with topology.
struct ast_variable * next
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
says a number
void ast_party_name_set(struct ast_party_name *dest, const struct ast_party_name *src)
Set the source party name information into the destination party name.
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
Wait for x amount of time on a file descriptor to have input.
Information needed to identify an endpoint in a call.
#define AST_LIST_INSERT_LIST_AFTER(head, list, elm, field)
Inserts a whole list after a specific entry in a list.
void ast_channel_unlink(struct ast_channel *chan)
Remove a channel from the global channels container.
int char_set
Character set ie.
int presentation
Q.931 encoded presentation-indicator encoded field.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame.
void ast_party_dialed_set_init(struct ast_party_dialed *init, const struct ast_party_dialed *guide)
Initialize the given dialed structure using the given guide for a set update operation.
void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
Clear a set of softhangup flags from a channel.
Main Channel structure associated with a channel.
SAY_EXTERN int(* ast_say_number_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_number_full)
Same as ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable...
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
void ast_set_party_id_all(struct ast_set_party_id *update_id)
Set the update marker to update all information of a corresponding party id.
void *(* duplicate)(void *data)
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
#define ast_frdup(fr)
Copies a frame.
char * str
Subscriber phone number (Malloced)
int ast_channel_get_up_time(struct ast_channel *chan)
Obtain how long it has been since the channel was answered.
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
General Asterisk channel transcoding definitions.
struct ast_party_connected_line connected
Channel Connected Line ID information.
int(*const setoption)(struct ast_channel *chan, int option, void *data, int datalen)
Set a given option. Called with chan locked.
void( ao2_prnt_fn)(void *where, const char *fmt,...)
Print output.
void ast_party_caller_set(struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
Set the caller information based on another caller source.
Asterisk locking-related definitions:
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
Channels have this property if they implement send_text_data.
struct stasis_message_type * ast_channel_dtmf_end_type(void)
Message type for when DTMF ends on a channel.
Channels with this particular technology are an implementation detail of Asterisk and should generall...
Asterisk main include file. File version handling, generic pbx functions.
int ast_shutting_down(void)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
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.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
SAY_EXTERN int(* ast_say_enumeration_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_enumeration_full)
Same as ast_say_enumeration() with audiofd for received audio and returns 1 on ctrlfd being readable...
struct ast_party_id priv_to
Call is redirecting to a new party (Sent to the caller) - private representation. ...
char * str
Subscriber phone number (Malloced)
char chan_name[AST_CHANNEL_NAME]
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
struct ast_party_caller caller
Channel Caller ID information.
static ast_mutex_t channel_move_lock
struct ast_set_party_id ani
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
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...
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
struct varshead * ast_channel_get_ari_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_ari_vars().
int(*const write_video)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format.
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.
unsigned int option_dtmfminduration
int ast_channel_get_duration(struct ast_channel *chan)
Obtain how long the channel since the channel was created.
void ast_channel_snapshot_invalidate_segment(struct ast_channel *chan, enum ast_channel_snapshot_segment_invalidation segment)
Invalidate a channel snapshot segment from being reused.
int str
Subscriber phone number ie.
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
struct ast_channel::@335 fds
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
struct ast_party_subaddress_ies subaddress
Subscriber subaddress ies.
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
ast_channel_requestor_relationship
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Queue a redirecting update frame on a channel.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup a channel, lock.
void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Copy the source dialed party information to the destination dialed party.
struct ast_party_id id
Connected party ID.
const char * ast_channel_reason2str(int reason)
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument ...
static int calc_monitor_jump(int samples, int sample_rate, int seek_rate)
calculates the number of samples to jump forward with in a monitor stream.
void(* chan_breakdown)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Fix up channel references on the channel being masqueraded into.
Structure that contains features information.
struct ast_format_cap * ast_stream_topology_get_formats(struct ast_stream_topology *topology)
Create a format capabilities structure representing the topology.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders)
Reads multiple digits.
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
void ast_party_subaddress_set(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Set the source party subaddress information into the destination party subaddress.
int(*const write)(struct ast_channel *chan, struct ast_frame *frame)
Write a frame, in standard format (see frame.h)
#define ast_channel_unref(c)
Decrease channel reference count.
void ast_audiohook_move_all(struct ast_channel *old_chan, struct ast_channel *new_chan)
Move all audiohooks from one channel to another.
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup a channel, don't lock.
struct ast_party_id priv_orig
Who originally redirected the call (Sent to the party the call is redirected toward) - private repres...
#define AST_OPTION_DEVICE_NAME
void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Support for translation of data formats. translate.c.
int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups *b)
Return TRUE if group a and b contain at least one common groupname.
void ast_party_dialed_set(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Set the dialed information based on another dialed source.
void ast_party_number_set_init(struct ast_party_number *init, const struct ast_party_number *guide)
Initialize the given party number structure using the given guide for a set update operation...
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_party_name name
Subscriber name.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
struct ast_channel * __ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
int presentation
presentation-indicator ie
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
int ast_func_read2(struct ast_channel *chan, const char *function, struct ast_str **str, ssize_t maxlen)
executes a read operation on a function
#define AST_DEFAULT_EMULATE_DTMF_DURATION
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait, look for hangups.
int(*const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration)
Stop sending a literal DTMF digit.
int ast_channels_init(void)
char context[AST_MAX_CONTEXT]
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
struct ast_party_number_ies number
Subscriber phone number ies.
int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
Determine if an framehook list is empty or not.
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)
Provide notice to a channel that the stream topology has changed.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
ast_framehook_event
These are the types of events that the framehook's event callback can receive.
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container, as described below.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
int ast_say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang)
says digits
int plan
Type-Of-Number and Numbering-Plan ie.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
struct ast_party_id priv_from
Who is redirecting the call (Sent to the party the call is redirected toward) - private representatio...
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
static int ast_add_fd(struct pollfd *pfd, int fd)
if fd is a valid descriptor, set *pfd with the descriptor
char * ast_recvtext(struct ast_channel *chan, int timeout)
Receives a text string from a channel Read a string of text from a channel.
void ast_tonepair_stop(struct ast_channel *chan)
int ast_channel_has_hook_requiring_audio(struct ast_channel *chan)
Check if the channel has any active hooks that require audio.
Structure for variables, used for configurations and for channel variables.
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame.h), with stream num.
Named group member structure.
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
globally accessible channel datastores
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
struct ast_set_party_id priv_orig
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
int(*const answer)(struct ast_channel *chan)
Answer the channel.
AST_THREADSTORAGE_RAW(in_intercept_routine)
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
enum ast_control_t38 request_response
int char_set
Character set the name is using.
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
Assume that the ao2_container is already locked.
Structure to pass both assignedid values to channel drivers.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
struct stasis_message_type * ast_channel_wink_type(void)
Message type for when a wink occurs on a channel.
int ast_answer(struct ast_channel *chan)
Answer a channel.
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
Structure for a data store type.
Structure used to transport a message through the frame core.
ast_channel_state
ast_channel states
struct ast_timer * ast_timer_open(void)
Open a timer.
static void clone_variables(struct ast_channel *original, struct ast_channel *clonechan)
Clone channel variables from 'clone' channel into 'original' channel.
char * str
Subscriber name (Malloced)
int ast_transfer(struct ast_channel *chan, char *dest)
Transfer a call to dest, if the channel supports transfer.
struct stasis_message_type * ast_channel_flash_type(void)
Message type for when a hook flash occurs on a channel.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame for channel.
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
int ast_say_character_str(struct ast_channel *chan, const char *str, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
function to pronounce character and phonetic strings
#define AST_NUM_CHANNEL_BUCKETS
int ast_senddigit_begin(struct ast_channel *chan, char digit)
Send a DTMF digit to a channel.
int ast_recvchar(struct ast_channel *chan, int timeout)
Receives a text character from a channel.
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int(*const hangup)(struct ast_channel *chan)
Hangup (and possibly destroy) the channel.
unsigned char valid
TRUE if the subaddress information is valid/present.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
void ast_party_redirecting_set(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
Set the redirecting information based on another redirecting source.
#define AST_OPTION_CC_AGENT_TYPE
ast_control_frame_type
Internal control frame subtype field values.
int plc_fillin(plc_state_t *s, int16_t amp[], int len)
Fill-in a block of missing audio samples.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
static int should_skip_dtmf(struct ast_channel *chan)
Determine whether or not we should ignore DTMF in the readq.
int ani2
Automatic Number Identification 2 (Info Digits)
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
int presentation
presentation-indicator ie
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister channel driver.
int64_t ast_channel_get_duration_ms(struct ast_channel *chan)
Obtain how long it's been, in milliseconds, since the channel was created.
int ast_channel_sendhtml(struct ast_channel *chan, int subclass, const char *data, int datalen)
Sends HTML on given channel Send HTML or URL on link.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
struct ast_msg_data * ast_msg_data_alloc(enum ast_msg_data_source_type source, struct ast_msg_data_attribute attributes[], size_t count)
Allocates an ast_msg_data structure.
struct ast_frame * ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
translates one or more frames Apply an input frame into the translator and receive zero or one output...
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
struct ast_variable * ast_channeltype_list(void)
return an ast_variable list of channeltypes
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
char * str
Malloced subaddress string.
#define AST_RWLIST_HEAD_INIT(head)
Initializes an rwlist head structure.
static int should_trigger_dtmf_emulating(struct ast_channel *chan)
Determine whether or not we have to trigger dtmf emulating using 50 fps timer events especially when ...
void ast_party_redirecting_reason_set(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Set the redirecting reason information based on another redirecting reason source.
void ast_party_id_merge_copy(struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay)
Copy a merge of a given party id into another given party id to a given destination party id...
Definitions to aid in the use of thread local storage.
struct ast_channel * ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *outstate, const char *cidnum, const char *cidname)
Request a channel of a given type, with data as optional information used by the low level module and...
Out-of-call text message support.
int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format)
Sets write format for a channel. All internal data will than be handled in an interleaved format...
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
int ast_framehook_list_destroy(struct ast_channel *chan)
This is used by the channel API to detach and destroy all framehooks on a channel during channel dest...
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
int code
enum AST_REDIRECTING_REASON value for redirection
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Wait for x amount of time on a file descriptor to have input.
unsigned char odd_even_indicator
TRUE if odd number of address signals.
void ast_bridge_features_destroy(struct ast_bridge_features *features)
Destroy an allocated bridge features struct.
struct ast_party_name_ies name
Subscriber name ies.
struct ast_channel * ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Indicate what information in ast_party_caller should be set.
int ast_raw_answer_with_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Answer a channel passing in a stream topology.
static const char ast_stream_topology_changed_external[]
Set as the change source reason when a channel stream topology has been changed externally as a resul...
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
int ast_translator_best_choice(struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format **dst_fmt_out, struct ast_format **src_fmt_out)
Chooses the best translation path.
the list of registered channel types
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_frame_subclass subclass
void ast_change_name(struct ast_channel *chan, const char *newname)
Change channel name.
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel.
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
struct ast_format * writeformat
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
#define AST_OPTION_FORMAT_WRITE
void ast_party_redirecting_reason_free(struct ast_party_redirecting_reason *doomed)
Destroy the redirecting reason contents.
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel's call_forward str...
void ast_party_caller_set_init(struct ast_party_caller *init, const struct ast_party_caller *guide)
Initialize the given caller structure using the given guide for a set update operation.
struct ast_set_party_id from
int ast_channel_suppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
Suppress passing of a frame type on a channel.
struct ast_party_id orig
Who originally redirected the call (Sent to the party the call is redirected toward) ...
int(*const call)(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
int ast_framehook_list_contains_no_active_of_type(struct ast_framehook_list *framehooks, enum ast_frame_type type)
Determine if a framehook list is free of active framehooks consuming a specific type of frame...
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
Swap the interal alertpipe between two channels.
static const struct ast_channel_tech surrogate_tech
Channel technology used to extract a channel from a running application. The channel created with thi...
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
static int indicate_data_internal(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
void ast_party_caller_free(struct ast_party_caller *doomed)
Destroy the caller party contents.
struct ast_party_id id
Caller party ID.
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
void(* write_format_change)(struct ast_channel *chan, void *data)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
List of channel variables to append to all channel-related events.
void ao2_container_unregister(const char *name)
Unregister a container for CLI stats and integrity check.
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call group and pickup group —.
void ast_channel_internal_swap_endpoint_forward(struct ast_channel *a, struct ast_channel *b)
Swap endpoint_forward between two channels.
void(* chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
Fix up channel references on the masquerading channel.
int ast_indicate_data(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
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.
void ast_party_redirecting_reason_init(struct ast_party_redirecting_reason *init)
Initialize the given redirecting reason structure.
int ast_channel_supports_html(struct ast_channel *chan)
Checks for HTML support on a channel.
int ast_say_enumeration(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
says an enumeration
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap *cap)
Sets read format on channel chan from capabilities Set read format for channel to whichever component...
void ast_channel_internal_swap_topics(struct ast_channel *a, struct ast_channel *b)
Swap topics beteween two channels.
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
struct ast_trans_pvt * ast_translator_build_path(struct ast_format *dest, struct ast_format *source)
Builds a translator path Build a path (possibly NULL) from source to dest.
void ast_party_id_set(struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
Set the source party id information into the destination party id.
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
struct ast_party_id ani
Automatic Number Identification (ANI)
int ast_channel_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels together (early)
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
General Asterisk PBX channel definitions.
static void varshead_dtor(void *obj)
Destructor for lists of variables.
#define SCOPED_MUTEX(varname, lock)
scoped lock specialization for mutexes
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Asterisk file paths, configured in asterisk.conf.
int(*const send_html)(struct ast_channel *chan, int subclass, const char *data, int len)
Send HTML data.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.
static char * handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show details about a channel driver - CLI command.
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
SAY_EXTERN int(* ast_say_digit_str_full)(struct ast_channel *chan, const char *num, const char *ints, const char *lang, int audiofd, int ctrlfd) SAY_INIT(ast_say_digit_str_full)
Same as ast_say_digit_str() with audiofd for received audio and returns 1 on ctrlfd being readable...
int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *fr)
Write a frame to a stream This function writes the given frame to the indicated stream on the channel...
struct ast_stream * ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type)
Retrieve the default stream of a specific media type on a channel.
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
int ast_get_tid(void)
Get current thread ID.
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src)
Copy the connected line information to the caller information.
struct ast_party_redirecting_reason orig_reason
Reason for the redirection by the original party.
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
int ast_stasis_channels_init(void)
Initialize the stasis channel topic and message types.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_timer_disable_continuous(const struct ast_timer *handle)
Disable continuous mode.
int(*const write_text)(struct ast_channel *chan, struct ast_frame *frame)
Write a text frame, in standard format.
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ast_channel_set_flag(struct ast_channel *chan, unsigned int flag)
Set a flag on a channel.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Scheduler Routines (derived from cheops)
Caller Party information.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Asterisk internal frame definitions.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
void ast_party_number_copy(struct ast_party_number *dest, const struct ast_party_number *src)
Copy the source party number information to the destination party number.
void ast_jb_destroy(struct ast_channel *chan)
Destroys jitterbuffer on a channel.
void(* release)(struct ast_channel *chan, void *data)
int ast_redirecting_parse_data(const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
Parse redirecting indication frame data.
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
const struct ast_datastore_info * info
struct ast_party_id priv
Private caller party ID.
SAY_EXTERN int(* ast_say_ordinal_full)(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options, int audiofd, int ctrlfd) SAY_INIT(ast_say_ordinal_full)
Same as ast_say_number() with audiofd for received audio and returns 1 on ctrlfd being readable...
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
void ast_channel_undefer_dtmf(struct ast_channel *chan)
Unset defer DTMF flag on channel.
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
struct ast_set_party_id id
map AST_CAUSE's to readable string representations
void ast_party_subaddress_free(struct ast_party_subaddress *doomed)
Destroy the party subaddress contents.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
A set of macros to manage forward-linked lists.
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
int ast_senddigit_end(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
#define ast_malloc(len)
A wrapper for malloc()
void ast_channel_internal_swap_uniqueid_and_linkedid(struct ast_channel *a, struct ast_channel *b)
Swap uniqueid and linkedid beteween two channels.
#define ast_debug(level,...)
Log a DEBUG message.
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback...
struct varshead * ast_channel_get_vars(struct ast_channel *chan)
Gets the variables for a given channel, as set using pbx_builtin_setvar_helper(). ...
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
struct ast_format * readformat
int ast_settimeout(struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data)
Enable or disable timer ticks for a channel.
int ast_channel_unsuppress(struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
Stop suppressing of a frame type on a channel.
struct ast_party_id ani
Automatic Number Identification (ANI)
int ast_auto_answer(struct ast_channel *chan)
Answer a channel, if it's not already answered.
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
int odd_even_indicator
odd/even indicator ie
const char * ast_state2str(enum ast_channel_state state)
Gives the string form of a given channel state.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
int ast_endpoint_add_channel(struct ast_endpoint *endpoint, struct ast_channel *chan)
Adds a channel to the given endpoint.
void ast_party_subaddress_copy(struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
Copy the source party subaddress information to the destination party subaddress. ...
int(* pre_call)(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel in a technology specific way before a call is placed...
int ast_autoservice_stop(struct ast_channel *chan)
Stop servicing a channel for us...
int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size)
Find the appropriate CC agent type to use given a channel.
struct ast_set_party_id priv
ast_say_case_sensitivity
Controls how ast_say_character_str denotes the case of characters in a string.
const char * ast_channel_amaflags2string(enum ama_flags flag)
Convert the enum representation of an AMA flag to a string representation.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
#define ast_test_suite_event_notify(s, f,...)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
ast_frame_type
Frame types.
int ast_senddigit_mf_begin(struct ast_channel *chan, char digit)
Send an MF digit to a channel.
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
static void channel_do_masquerade(struct ast_channel *original, struct ast_channel *clonechan)
Masquerade a channel.
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
void ast_bridge_features_merge(struct ast_bridge_features *into, const struct ast_bridge_features *from)
Merge one ast_bridge_features into another.
struct ast_party_dialed dialed
Dialed/Called information.
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
Make the frame formats of two channels compatible.
Redirecting reason information.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
void ast_framehook_list_fixup(struct ast_channel *old_chan, struct ast_channel *new_chan)
This is used by the channel API during a masquerade operation to move all mobile framehooks from the ...
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
int tag
User party id tag ie.
int ast_waitfordigit_full(struct ast_channel *c, int timeout_ms, const char *breakon, int audiofd, int cmdfd)
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to mon...
struct ast_party_subaddress subaddress
Subscriber subaddress.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
"smart" channels that update automatically if a channel is masqueraded
Dialed/Called Party information.
static int namedgroup_hash_cb(const void *obj, const int flags)
Hashing function used for named group container.
Structure that contains information about a bridge.
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
void ast_party_connected_line_set(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
Set the connected line information based on another connected line source.
Indicate what information in ast_party_id should be set.
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
int ast_tvcmp(struct timeval _a, struct timeval _b)
Compress two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
void ast_party_caller_copy(struct ast_party_caller *dest, const struct ast_party_caller *src)
Copy the source caller information to the destination caller.
struct ast_frame * ast_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame)
Pass a frame off to be handled by the audiohook core.
void ast_party_redirecting_reason_set_init(struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
Initialize the given redirecting reason structure using the given guide for a set update operation...
int(*const write_stream)(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame on a specific stream, in standard format (see frame.h)
int ast_channel_has_ari_vars(void)
Return whether or not any ARI variables have been set.
struct ast_channel * ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
Call a function with every active channel.
Support for dynamic strings.
int ast_cc_offer(struct ast_channel *caller_chan)
Offer CC to a caller.
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
struct ast_channel * ast_waitfor_n(struct ast_channel **c, int n, int *ms)
Waits for input on a group of channels Wait for input on an array of channels for a given # of millis...
Internal channel functions for channel.c to use.
int ast_stream_topology_equal(const struct ast_stream_topology *left, const struct ast_stream_topology *right)
Compare two stream topologies to see if they are equal.
struct ast_set_party_id priv_from
static struct ast_channel * __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
Create a new channel structure.
#define ao2_unlink(container, obj)
Remove an object from a container.
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
static struct ao2_container * channels
All active channels on the system.
void ast_party_name_copy(struct ast_party_name *dest, const struct ast_party_name *src)
Copy the source party name information to the destination party name.
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
void ast_channel_publish_varset(struct ast_channel *chan, const char *variable, const char *value)
Publish a ast_channel_publish_varset for a channel.
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
int ast_set_write_format_path(struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
Set specific write path on channel.
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
struct ast_bridge_features * ast_channel_feature_hooks_get(struct ast_channel *chan)
Gets the channel-attached features a channel has access to upon being bridged.
void ast_channel_publish_final_snapshot(struct ast_channel *chan)
Send the final channel snapshot for a channel, thus removing it from cache.
int ast_queue_answer(struct ast_channel *chan, const struct ast_stream_topology *topology)
Queue an ANSWER control frame with topology.
int ani2
Automatic Number Identification 2 (Info Digits)
const char * ast_msg_data_get_attribute(struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type)
Get attribute from ast_msg_data.
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
struct ast_channel * ast_channel_get_by_exten(const char *exten, const char *context)
Find a channel by extension and context.
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Connected Line/Party information.
int ast_channel_get_intercept_mode(void)
Am I currently running an intercept dialplan routine.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
const ast_string_field name
int ast_write_video(struct ast_channel *chan, struct ast_frame *fr)
Write video frame to a channel This function writes the given frame to the indicated channel...
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
#define ast_strndup(str, len)
A wrapper for strndup()
void ast_channel_name_to_dial_string(char *channel_name)
Removes the trailing identifiers from a channel name string.
void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
Used for sending a log message with a known call_id This is a modified logger function which is funct...
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
static void __ast_change_name_nolink(struct ast_channel *chan, const char *newname)
this function simply changes the name of the channel and issues a manager_event with out unlinking an...
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
struct ast_frame * ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame write event to a channel's framehook list...
void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
enum ast_channel_error ast_channel_errno(void)
Get error code for latest channel operation.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
void(* digit)(struct ast_channel *chan, char digit)
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
char * str
a string value for the redirecting reason
int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features)
Appends to the channel-attached features a channel has access to upon being bridged.
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
int ast_senddigit_external(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel from an external thread.
int ast_write(struct ast_channel *chan, struct ast_frame *fr)
Write a frame to a channel This function writes the given frame to the indicated channel.
A machine to gather up arbitrary frames and convert them to raw slinear on demand.
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
struct ast_channel_iterator * ast_channel_iterator_by_exten_new(const char *exten, const char *context)
Create a new channel iterator based on extension.
union ast_frame::@224 data
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
int source
Information about the source of an update.
void ast_party_subaddress_set_init(struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
Initialize the given party subaddress structure using the given guide for a set update operation...
int valid
valid/present ie
void ast_party_id_set_init(struct ast_party_id *init, const struct ast_party_id *guide)
Initialize the given party id structure using the given guide for a set update operation.
#define ast_calloc(num, len)
A wrapper for calloc()
void ast_autochan_new_channel(struct ast_channel *old_chan, struct ast_channel *new_chan)
Switch what channel autochans point to.
void ast_party_name_set_init(struct ast_party_name *init, const struct ast_party_name *guide)
Initialize the given party name structure using the given guide for a set update operation.
#define AST_OPTION_SECURE_SIGNALING
int ast_channel_setoption(struct ast_channel *chan, int option, void *data, int datalen, int block)
Sets an option on a channel.
int valid
valid/present ie
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
static int safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data, unsigned int generate_silence)
Wait, look for hangups and condition arg.
void ast_bridge_notify_masquerade(struct ast_channel *chan)
Notify bridging that this channel was just masqueraded.
int ast_closestream(struct ast_filestream *f)
Closes a stream.
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
int ast_channel_stream_topology_changed_externally(struct ast_channel *chan)
Provide notice from a channel that the topology has changed on it as a result of the remote party ren...
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
int ast_channel_sendurl(struct ast_channel *chan, const char *url)
Sends a URL on a given link Send URL on link.
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get handle to channel driver based on name.
Prototypes for public functions only of internal interest,.
int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan)
Check if the channel has active audiohooks, active framehooks, or a monitor.
void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int causecode)
Lock the given channel, then request softhangup on the channel with the given causecode.
int ast_senddigit(struct ast_channel *chan, char digit, unsigned int duration)
Send a DTMF digit to a channel.
struct ast_frame * ast_read_stream_noaudio(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if aud...
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel. ...
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
static int namedgroup_cmp_cb(void *obj, void *arg, int flags)
Comparison function used for named group container.
void ast_deactivate_generator(struct ast_channel *chan)
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
struct ast_party_redirecting_reason reason
Reason for the redirection.
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
int ast_timer_enable_continuous(const struct ast_timer *handle)
Enable continuous mode.
int ast_framehook_list_contains_no_active(struct ast_framehook_list *framehooks)
Determine if a framehook list is free of active framehooks or not.
struct stasis_message_type * ast_channel_dtmf_begin_type(void)
Message type for when DTMF begins on a channel.
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
void ast_channel_update_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Indicate that the redirecting id has changed.
int64_t ast_channel_get_up_time_ms(struct ast_channel *chan)
Obtain how long it has been since the channel was answered in ms.
int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Compare a offset with when to hangup channel.
#define AST_RWLIST_HEAD(name, type)
Defines a structure to be used to hold a read/write list of specified type.
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *group)
Print named call groups and named pickup groups.
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame.h)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
Indicate what information in ast_party_connected_line should be set.
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
int ast_pbx_hangup_handler_run(struct ast_channel *chan)
Run all hangup handlers on the channel.
int ast_senddigit_mf_end(struct ast_channel *chan)
End sending an MF digit to a channel.
struct varshead * ast_channel_get_manager_vars(struct ast_channel *chan)
Gets the variables for a given channel, as specified by ast_channel_set_manager_vars().
void ast_party_id_invalidate(struct ast_party_id *id)
Invalidate all components of the given party id.
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...
int ast_pre_call(struct ast_channel *chan, const char *sub_args)
Execute a Gosub call on the channel before a call is placed.
struct ast_set_party_id orig
struct ast_bridge_features * ast_bridge_features_new(void)
Allocate a new bridge features struct.
struct ast_frame ast_null_frame
int combined_presentation
Combined name and number presentation ie.
int ast_channel_is_leaving_bridge(struct ast_channel *chan)
Determine if a channel is leaving a bridge, but not hung up.
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
char * tag
User-set "tag".
struct ast_set_party_id id
int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
Set specific read path on channel.
int type
Q.931 subaddress type.
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
struct ast_set_party_id priv
int transit_network_select
Transit Network Select.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
int ast_waitstream_full(struct ast_channel *c, const char *breakon, int audiofd, int monfd)
char * ast_transfercapability2str(int transfercapability)
Gives the string form of a given transfer capability.
int ast_channel_defer_dtmf(struct ast_channel *chan)
Set defer DTMF flag on channel.
Structure that contains information regarding a channel in a bridge.
struct ast_set_party_id to
int ast_channel_dialed_causes_add(const struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Add cause code information to the channel.
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_channel_ref(c)
Increase channel reference count.
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
int ast_say_ordinal(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
says an ordinal number
Indicate what information in ast_party_redirecting should be set.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_party_redirecting_reason_copy(struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
Copy the source redirecting reason information to the destination redirecting reason.
int count
Number of times the call was redirected.
Standard Command Line Interface.
struct ast_channel * __ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, const char *file, int line, const char *function, const char *name_fmt,...)
Create a channel structure.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_queryoption(struct ast_channel *chan, int option, void *data, int *datalen, int block)
Checks the value of an option.
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to)
Set up translation from one channel to another.
unsigned int emulate_sip_cause
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int type
subaddress type ie
void ast_channel_set_manager_vars(size_t varc, char **vars)
Sets the variables to be stored in the manager_vars field of all snapshots.
struct ast_set_party_id ani
int ast_channel_fd_count(const struct ast_channel *chan)
Retrieve the number of file decriptor positions present on the channel.
void ast_party_dialed_free(struct ast_party_dialed *doomed)
Destroy the dialed party contents.
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Information needed to specify a number in a call.
void ast_pbx_hangup_handler_destroy(struct ast_channel *chan)
Destroy the hangup handler container on a channel.
struct ast_party_dialed::@206 number
Dialed/Called number.
int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Build the redirecting id data frame.
#define AST_OPTION_FORMAT_READ
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
struct ast_set_party_id priv_to
void ast_cdr_free(struct ast_cdr *cdr)
Free a CDR record.
const ast_string_field accountcode
Data structure associated with a single frame of data.
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Internal Asterisk hangup causes.
void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name...
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
void ast_party_number_set(struct ast_party_number *dest, const struct ast_party_number *src)
Set the source party number information into the destination party number.
static void ast_channel_destructor(void *obj)
Free a channel structure.
Abstract JSON element (object, array, string, int, ...).
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
int(*const send_text_data)(struct ast_channel *chan, struct ast_msg_data *data)
Display or transmit text with data.
const struct ast_channel_tech ast_kill_tech
Kill the channel channel driver technology descriptor.
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
#define AST_JITTERBUFFER_FD
int(*const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen)
Query a given option. Called with chan locked.
static struct ast_frame * __ast_read(struct ast_channel *chan, int dropaudio, int dropnondefault)
struct ast_channel * ast_channel_yank(struct ast_channel *yankee)
Gain control of a channel in the system.
int plc_rx(plc_state_t *s, int16_t amp[], int len)
Process a block of received audio samples.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
const char * ast_cause2str(int cause)
Gives the string form of a given hangup cause.
const char * data
Description of a tone.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
ast_media_type
Types of media.
static char * handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Show channel types - CLI command.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
int ast_channel_register(const struct ast_channel_tech *tech)
Register a new telephony channel in Asterisk.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
int ast_transfer_protocol(struct ast_channel *chan, char *dest, int *protocol)
Transfer a call to dest, if the channel supports transfer.
void ast_softhangup_all(void)
Soft hangup all active channels.
ama_flags
Channel AMA Flags.
int ast_channel_request_stream_topology_change(struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
Request that the stream topology of a channel change.
unsigned char valid
TRUE if the name information is valid/present.
int ast_say_digits_full(struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
Same as ast_say_digits() with audiofd for received audio and returns 1 on ctrlfd being readable...
int ast_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
int ast_safe_sleep_without_silence(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups, and do not generate silence.
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
Information needed to specify a subaddress in a call.
int ast_senddigit_mf(struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send an MF digit to a channel.
void ast_channel_internal_swap_snapshots(struct ast_channel *a, struct ast_channel *b)
Swap snapshots beteween two channels.
struct ast_format * format
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device)
Tells Asterisk the State for Device is changed.
#define DEFAULT_EMULATE_MF_DURATION
enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle)
Retrieve timing event.
int ast_str2cause(const char *name)
Convert a symbolic hangup cause to number.
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Build the connected line information data frame.
const char * ast_timer_get_name(const struct ast_timer *handle)
Get name of timer in use.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
struct ast_channel * ast_request_with_stream_topology(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel (specifying stream topology)
struct stasis_message_type * ast_channel_hangup_request_type(void)
Message type for when a hangup is requested on a channel.
Say numbers and dates (maybe words one day too)
unsigned int ast_translate_path_steps(struct ast_format *dest, struct ast_format *src)
Returns the number of steps required to convert from 'src' to 'dest'.
void ast_channel_set_ari_vars(size_t varc, char **vars)
Sets the variables to be stored in the ari_vars field of all snapshots.
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
int ast_undestroyed_channels(void)
struct stasis_message_type * ast_channel_masquerade_type(void)
Message type for when a channel is being masqueraded.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
void ast_channel_set_is_t38_active_nolock(struct ast_channel *chan, int is_t38_active)
Variant of ast_channel_set_is_t38_active. Use this if the channel is already locked prior to calling...
Information needed to specify a name in a call.
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
enum ast_bridge_result(*const early_bridge)(struct ast_channel *c0, struct ast_channel *c1)
Bridge two channels of the same type together (early)
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
struct ast_party_id priv
Private connected party ID.
int ast_say_money_str(struct ast_channel *chan, const char *str, const char *ints, const char *lang)
function to pronounce monetary amounts
unsigned char valid
TRUE if the number information is valid/present.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame for channel.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
int str
Subscriber name ie.
void ast_channel_update_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Indicate that the connected line information has changed.
int( ao2_callback_data_fn)(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
struct ast_frame * ast_framehook_list_read_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame read event to a channel's framehook list.
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
Change the state of a channel.
char exten[AST_MAX_EXTENSION]
Timing source management.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
void ast_party_connected_line_collect_caller(struct ast_party_connected_line *connected, struct ast_party_caller *caller)
Collect the caller party information into a connected line structure.
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int is_frame)
Run a connected line interception subroutine and update a channel's connected line information...
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
void ast_party_redirecting_set_init(struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
Initialize the given redirecting id structure using the given guide for a set update operation...
int ast_active_channels(void)
returns number of active/allocated channels
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features)
Sets the channel-attached features a channel has access to upon being bridged.
void ast_channel_req_accountcodes_precious(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
struct ast_frame * ast_read_noaudio(struct ast_channel *chan)
Reads a frame, returning AST_FRAME_NULL frame if audio.
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
int ast_safe_sleep_conditional(struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data)
Wait for a specified amount of time, looking for hangups and a condition argument.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
int ast_channel_has_manager_vars(void)
Return whether or not any manager variables have been set.
void ast_channel_setwhentohangup_tv(struct ast_channel *chan, struct timeval offset)
Set when to hangup channel.
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
struct ast_party_number number
Subscriber phone number.
int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
#define ao2_link(container, obj)
Add an object to a container.
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to the head of a channel's frame queue.