summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2012-01-09 22:15:50 +0000
committerTerry Wilson <twilson@digium.com>2012-01-09 22:15:50 +0000
commit04da92c3799e546fa4d84bdaeebd499fb64aea7a (patch)
tree9617b8b2d6d06f96ba27c0baefc5b93eb9e3bc5b /main
parent64d1b247c407de2af029392a6c32a99bf11c7ded (diff)
Replace direct access to channel name with accessor functions
There are many benefits to making the ast_channel an opaque handle, from increasing maintainability to presenting ways to kill masquerades. This patch kicks things off by taking things a field at a time, renaming the field to '__do_not_use_${fieldname}' and then writing setters/getters and converting the existing code to using them. When all fields are done, we can move ast_channel to a C file from channel.h and lop off the '__do_not_use_'. This patch sets up main/channel_interal_api.c to be the only file that actually accesses the ast_channel's fields directly. The intent would be for any API functions in channel.c to use the accessor functions. No more monkeying around with channel internals. We should use our own APIs. The interesting changes in this patch are the addition of channel_internal_api.c, the moving of the AST_DATA stuff from channel.c to channel_internal_api.c (note: the AST_DATA stuff will have to be reworked to use accessor functions when ast_channel is really opaque), and some re-working of the way channel iterators/callbacks are handled so as to avoid creating fake ast_channels on the stack to pass in matching data by directly accessing fields (since "name" is a stringfield and the fake channel doesn't init the stringfields, you can't use the ast_channel_name_set() function). I went with ast_channel_name(chan) for a getter, and ast_channel_name_set(chan, name) for a setter. The majority of the grunt-work for this change was done by writing a semantic patch using Coccinelle ( http://coccinelle.lip6.fr/ ). Review: https://reviewboard.asterisk.org/r/1655/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@350223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/abstract_jb.c16
-rw-r--r--main/aoc.c10
-rw-r--r--main/app.c14
-rw-r--r--main/autochan.c4
-rw-r--r--main/bridging.c20
-rw-r--r--main/ccss.c4
-rw-r--r--main/cdr.c6
-rw-r--r--main/cel.c8
-rw-r--r--main/channel.c575
-rw-r--r--main/channel_internal_api.c261
-rw-r--r--main/cli.c24
-rw-r--r--main/dial.c38
-rw-r--r--main/dsp.c2
-rw-r--r--main/features.c214
-rw-r--r--main/file.c12
-rw-r--r--main/indications.c2
-rw-r--r--main/manager.c16
-rw-r--r--main/pbx.c76
-rw-r--r--main/rtp_engine.c66
-rw-r--r--main/say.c2
-rw-r--r--main/udptl.c16
21 files changed, 729 insertions, 657 deletions
diff --git a/main/abstract_jb.c b/main/abstract_jb.c
index 5ecce8c40..3ae3e0331 100644
--- a/main/abstract_jb.c
+++ b/main/abstract_jb.c
@@ -279,14 +279,14 @@ int ast_jb_put(struct ast_channel *chan, struct ast_frame *f)
if (!ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO) || f->len < 2 || f->ts < 0) {
ast_log(LOG_WARNING, "%s received frame with invalid timing info: "
"has_timing_info=%d, len=%ld, ts=%ld, src=%s\n",
- chan->name, ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO), f->len, f->ts, f->src);
+ ast_channel_name(chan), ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO), f->len, f->ts, f->src);
return -1;
}
frr = ast_frdup(f);
if (!frr) {
- ast_log(LOG_ERROR, "Failed to isolate frame for the jitterbuffer on channel '%s'\n", chan->name);
+ ast_log(LOG_ERROR, "Failed to isolate frame for the jitterbuffer on channel '%s'\n", ast_channel_name(chan));
return -1;
}
@@ -411,7 +411,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
jbobj = jb->jbobj = jbimpl->create(jbconf, jbconf->resync_threshold);
if (!jbobj) {
- ast_log(LOG_WARNING, "Failed to create jitterbuffer on channel '%s'\n", chan->name);
+ ast_log(LOG_WARNING, "Failed to create jitterbuffer on channel '%s'\n", ast_channel_name(chan));
return -1;
}
@@ -421,7 +421,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
/* The result of putting the first frame should not differ from OK. However, its possible
some implementations (i.e. adaptive's when resynch_threshold is specified) to drop it. */
if (res != AST_JB_IMPL_OK) {
- ast_log(LOG_WARNING, "Failed to put first frame in the jitterbuffer on channel '%s'\n", chan->name);
+ ast_log(LOG_WARNING, "Failed to put first frame in the jitterbuffer on channel '%s'\n", ast_channel_name(chan));
/*
jbimpl->destroy(jbobj);
return -1;
@@ -438,7 +438,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
if (ast_test_flag(jbconf, AST_JB_LOG)) {
char safe_logfile[30] = "/tmp/logfile-XXXXXX";
int safe_fd;
- snprintf(name2, sizeof(name2), "%s", chan->name);
+ snprintf(name2, sizeof(name2), "%s", ast_channel_name(chan));
if ((tmp = strchr(name2, '/'))) {
*tmp = '#';
}
@@ -447,7 +447,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
/* We should always have bridged chan if a jitterbuffer is in use */
ast_assert(bridged != NULL);
- snprintf(name1, sizeof(name1), "%s", bridged->name);
+ snprintf(name1, sizeof(name1), "%s", ast_channel_name(bridged));
if ((tmp = strchr(name1, '/'))) {
*tmp = '#';
}
@@ -473,7 +473,7 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
}
}
- ast_verb(3, "%s jitterbuffer created on channel %s\n", jbimpl->name, chan->name);
+ ast_verb(3, "%s jitterbuffer created on channel %s\n", jbimpl->name, ast_channel_name(chan));
/* Free the frame if it has not been queued in the jb */
if (res != AST_JB_IMPL_OK) {
@@ -507,7 +507,7 @@ void ast_jb_destroy(struct ast_channel *chan)
ast_clear_flag(jb, JB_CREATED);
- ast_verb(3, "%s jitterbuffer destroyed on channel %s\n", jbimpl->name, chan->name);
+ ast_verb(3, "%s jitterbuffer destroyed on channel %s\n", jbimpl->name, ast_channel_name(chan));
}
}
diff --git a/main/aoc.c b/main/aoc.c
index 733d322db..aaf4647b9 100644
--- a/main/aoc.c
+++ b/main/aoc.c
@@ -1288,7 +1288,7 @@ static void aoc_amount_str(struct ast_str **msg, const char *prefix, unsigned in
static void aoc_request_event(const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg)
{
if (chan) {
- ast_str_append(msg, 0, "Channel: %s\r\n", chan->name);
+ ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(chan));
ast_str_append(msg, 0, "UniqueID: %s\r\n", chan->uniqueid);
}
@@ -1317,7 +1317,7 @@ static void aoc_s_event(const struct ast_aoc_decoded *decoded, struct ast_channe
int idx;
if (owner) {
- ast_str_append(msg, 0, "Channel: %s\r\n", owner->name);
+ ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(owner));
ast_str_append(msg, 0, "UniqueID: %s\r\n", owner->uniqueid);
}
@@ -1390,7 +1390,7 @@ static void aoc_d_event(const struct ast_aoc_decoded *decoded, struct ast_channe
char prefix[32];
if (chan) {
- ast_str_append(msg, 0, "Channel: %s\r\n", chan->name);
+ ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(chan));
ast_str_append(msg, 0, "UniqueID: %s\r\n", chan->uniqueid);
}
@@ -1444,7 +1444,7 @@ static void aoc_e_event(const struct ast_aoc_decoded *decoded, struct ast_channe
char prefix[32];
if (chan) {
- ast_str_append(msg, 0, "Channel: %s\r\n", chan->name);
+ ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(chan));
ast_str_append(msg, 0, "UniqueID: %s\r\n", chan->uniqueid);
}
@@ -1585,7 +1585,7 @@ static void aoc_display_decoded_debug(const struct ast_aoc_decoded *decoded, int
ast_str_append(&msg, 0, "---- ENCODED AOC MSG ----\r\n");
}
if (chan) {
- ast_str_append(&msg, 0, "CHANNEL: %s\r\n", chan->name);
+ ast_str_append(&msg, 0, "CHANNEL: %s\r\n", ast_channel_name(chan));
}
if (ast_aoc_decoded2str(decoded, &msg)) {
diff --git a/main/app.c b/main/app.c
index 3e3cf5614..ca25964a5 100644
--- a/main/app.c
+++ b/main/app.c
@@ -183,7 +183,7 @@ enum ast_getdata_result ast_app_getdata(struct ast_channel *c, const char *promp
filename = ast_strdupa(prompt);
while ((front = strsep(&filename, "&"))) {
- ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", front, c->name);
+ ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", front, ast_channel_name(c));
if (!ast_strlen_zero(front)) {
res = ast_streamfile(c, front, c->language);
if (res)
@@ -455,7 +455,7 @@ static void linear_release(struct ast_channel *chan, void *params)
struct linear_state *ls = params;
if (ls->origwfmt.id && ast_set_write_format(chan, &ls->origwfmt)) {
- ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, ls->origwfmt.id);
+ ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", ast_channel_name(chan), ls->origwfmt.id);
}
if (ls->autoclose) {
@@ -513,7 +513,7 @@ static void *linear_alloc(struct ast_channel *chan, void *params)
ast_format_copy(&ls->origwfmt, &chan->writeformat);
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
- ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", chan->name);
+ ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", ast_channel_name(chan));
ast_free(ls);
ls = params = NULL;
}
@@ -700,7 +700,7 @@ int ast_play_and_wait(struct ast_channel *chan, const char *fn)
{
int d = 0;
- ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", fn, chan->name);
+ ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", fn, ast_channel_name(chan));
if ((d = ast_streamfile(chan, fn, chan->language))) {
return d;
}
@@ -771,7 +771,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
}
ast_debug(1, "play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
- snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
+ snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, ast_channel_name(chan));
if (playfile || beep) {
if (!beep) {
@@ -853,7 +853,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
ast_debug(1, "One waitfor failed, trying another\n");
/* Try one more time in case of masq */
if (!(res = ast_waitfor(chan, 2000))) {
- ast_log(LOG_WARNING, "No audio available on %s??\n", chan->name);
+ ast_log(LOG_WARNING, "No audio available on %s??\n", ast_channel_name(chan));
res = -1;
}
}
@@ -1031,7 +1031,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
}
}
if (rfmt.id && ast_set_read_format(chan, &rfmt)) {
- ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(&rfmt), chan->name);
+ ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(&rfmt), ast_channel_name(chan));
}
if ((outmsg == 2) && (!skip_confirmation_sound)) {
ast_stream_and_wait(chan, "auth-thankyou", "");
diff --git a/main/autochan.c b/main/autochan.c
index 4ad65a371..31f11573f 100644
--- a/main/autochan.c
+++ b/main/autochan.c
@@ -51,7 +51,7 @@ struct ast_autochan *ast_autochan_setup(struct ast_channel *chan)
AST_LIST_INSERT_TAIL(&autochan->chan->autochans, autochan, list);
ast_channel_unlock(autochan->chan);
- ast_debug(1, "Created autochan %p to hold channel %s (%p)\n", autochan, chan->name, chan);
+ ast_debug(1, "Created autochan %p to hold channel %s (%p)\n", autochan, ast_channel_name(chan), chan);
return autochan;
}
@@ -88,7 +88,7 @@ void ast_autochan_new_channel(struct ast_channel *old_chan, struct ast_channel *
autochan->chan = ast_channel_ref(new_chan);
ast_debug(1, "Autochan %p used to hold channel %s (%p) but now holds channel %s (%p)\n",
- autochan, old_chan->name, old_chan, new_chan->name, new_chan);
+ autochan, ast_channel_name(old_chan), old_chan, ast_channel_name(new_chan), new_chan);
}
}
}
diff --git a/main/bridging.c b/main/bridging.c
index 9bc0edc82..abf5a0386 100644
--- a/main/bridging.c
+++ b/main/bridging.c
@@ -155,7 +155,7 @@ static void bridge_array_add(struct ast_bridge *bridge, struct ast_channel *chan
bridge->array[bridge->array_num++] = chan;
- ast_debug(1, "Added channel %s(%p) to bridge array on %p, new count is %d\n", chan->name, chan, bridge, (int)bridge->array_num);
+ ast_debug(1, "Added channel %s(%p) to bridge array on %p, new count is %d\n", ast_channel_name(chan), chan, bridge, (int)bridge->array_num);
/* If the next addition of a channel will exceed our array size grow it out */
if (bridge->array_num == bridge->array_size) {
@@ -570,12 +570,12 @@ static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_c
}
/* Switch read format to the best one chosen */
if (ast_set_read_format(bridge_channel->chan, &best_format)) {
- ast_log(LOG_WARNING, "Failed to set channel %s to read format %s\n", bridge_channel->chan->name, ast_getformatname(&best_format));
+ ast_log(LOG_WARNING, "Failed to set channel %s to read format %s\n", ast_channel_name(bridge_channel->chan), ast_getformatname(&best_format));
return -1;
}
- ast_debug(1, "Bridge %p put channel %s into read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(&best_format));
+ ast_debug(1, "Bridge %p put channel %s into read format %s\n", bridge, ast_channel_name(bridge_channel->chan), ast_getformatname(&best_format));
} else {
- ast_debug(1, "Bridge %p is happy that channel %s already has read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(&formats[0]));
+ ast_debug(1, "Bridge %p is happy that channel %s already has read format %s\n", bridge, ast_channel_name(bridge_channel->chan), ast_getformatname(&formats[0]));
}
if (!ast_format_cap_iscompatible(bridge->technology->format_capabilities, &formats[1])) {
@@ -591,12 +591,12 @@ static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_c
}
/* Switch write format to the best one chosen */
if (ast_set_write_format(bridge_channel->chan, &best_format)) {
- ast_log(LOG_WARNING, "Failed to set channel %s to write format %s\n", bridge_channel->chan->name, ast_getformatname(&best_format));
+ ast_log(LOG_WARNING, "Failed to set channel %s to write format %s\n", ast_channel_name(bridge_channel->chan), ast_getformatname(&best_format));
return -1;
}
- ast_debug(1, "Bridge %p put channel %s into write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(&best_format));
+ ast_debug(1, "Bridge %p put channel %s into write format %s\n", bridge, ast_channel_name(bridge_channel->chan), ast_getformatname(&best_format));
} else {
- ast_debug(1, "Bridge %p is happy that channel %s already has write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(&formats[1]));
+ ast_debug(1, "Bridge %p is happy that channel %s already has write format %s\n", bridge, ast_channel_name(bridge_channel->chan), ast_getformatname(&formats[1]));
}
return 0;
@@ -1511,7 +1511,7 @@ void ast_bridge_set_single_src_video_mode(struct ast_bridge *bridge, struct ast_
cleanup_video_mode(bridge);
bridge->video_mode.mode = AST_BRIDGE_VIDEO_MODE_SINGLE_SRC;
bridge->video_mode.mode_data.single_src_data.chan_vsrc = ast_channel_ref(video_src_chan);
- ast_test_suite_event_notify("BRIDGE_VIDEO_MODE", "Message: video mode set to single source\r\nVideo Mode: %d\r\nVideo Channel: %s", bridge->video_mode.mode, video_src_chan->name);
+ ast_test_suite_event_notify("BRIDGE_VIDEO_MODE", "Message: video mode set to single source\r\nVideo Mode: %d\r\nVideo Channel: %s", bridge->video_mode.mode, ast_channel_name(video_src_chan));
ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE);
ao2_unlock(bridge);
}
@@ -1548,14 +1548,14 @@ void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct a
}
data->chan_vsrc = ast_channel_ref(chan);
data->average_talking_energy = talker_energy;
- ast_test_suite_event_notify("BRIDGE_VIDEO_SRC", "Message: video source updated\r\nVideo Channel: %s", data->chan_vsrc->name);
+ ast_test_suite_event_notify("BRIDGE_VIDEO_SRC", "Message: video source updated\r\nVideo Channel: %s", ast_channel_name(data->chan_vsrc));
ast_indicate(data->chan_vsrc, AST_CONTROL_VIDUPDATE);
} else if ((data->average_talking_energy < talker_energy) && !is_keyframe) {
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
} else if (!data->chan_vsrc && is_keyframe) {
data->chan_vsrc = ast_channel_ref(chan);
data->average_talking_energy = talker_energy;
- ast_test_suite_event_notify("BRIDGE_VIDEO_SRC", "Message: video source updated\r\nVideo Channel: %s", data->chan_vsrc->name);
+ ast_test_suite_event_notify("BRIDGE_VIDEO_SRC", "Message: video source updated\r\nVideo Channel: %s", ast_channel_name(data->chan_vsrc));
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
} else if (!data->chan_old_vsrc && is_keyframe) {
data->chan_old_vsrc = ast_channel_ref(chan);
diff --git a/main/ccss.c b/main/ccss.c
index 2db5f338b..39fca0e15 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -2278,7 +2278,7 @@ int ast_cc_call_init(struct ast_channel *chan, int *ignore_cc)
*/
*ignore_cc = 1;
ast_channel_unlock(chan);
- ast_log_dynamic_level(cc_logger_level, "Agent policy for %s is 'never'. CC not possible\n", chan->name);
+ ast_log_dynamic_level(cc_logger_level, "Agent policy for %s is 'never'. CC not possible\n", ast_channel_name(chan));
return 0;
}
@@ -3608,7 +3608,7 @@ int ast_cc_offer(struct ast_channel *caller_chan)
ast_channel_unlock(caller_chan);
if (cc_is_offerable) {
- res = cc_offer(core_id, "CC offered to caller %s", caller_chan->name);
+ res = cc_offer(core_id, "CC offered to caller %s", ast_channel_name(caller_chan));
}
return res;
}
diff --git a/main/cdr.c b/main/cdr.c
index fdfaad185..d70e2337f 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -926,7 +926,7 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *c)
{
for ( ; cdr ; cdr = cdr->next) {
if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
- ast_copy_string(cdr->channel, c->name, sizeof(cdr->channel));
+ ast_copy_string(cdr->channel, ast_channel_name(c), sizeof(cdr->channel));
set_one_cid(cdr, c);
cdr_seq_inc(cdr);
@@ -1038,7 +1038,7 @@ int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
"Uniqueid: %s\r\n"
"AccountCode: %s\r\n"
"OldAccountCode: %s\r\n",
- chan->name, chan->uniqueid, chan->accountcode, old_acct);
+ ast_channel_name(chan), chan->uniqueid, chan->accountcode, old_acct);
return 0;
}
@@ -1064,7 +1064,7 @@ int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account)
"Uniqueid: %s\r\n"
"PeerAccount: %s\r\n"
"OldPeerAccount: %s\r\n",
- chan->name, chan->uniqueid, chan->peeraccount, old_acct);
+ ast_channel_name(chan), chan->uniqueid, chan->peeraccount, old_acct);
return 0;
}
diff --git a/main/cel.c b/main/cel.c
index ef37a1196..f03b51d60 100644
--- a/main/cel.c
+++ b/main/cel.c
@@ -455,7 +455,7 @@ struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event
ast_copy_string(tchan->exten, record.extension, sizeof(tchan->exten));
ast_copy_string(tchan->context, record.context, sizeof(tchan->context));
- ast_string_field_set(tchan, name, record.channel_name);
+ ast_channel_name_set(tchan, record.channel_name);
ast_string_field_set(tchan, uniqueid, record.unique_id);
ast_string_field_set(tchan, linkedid, record.linked_id);
ast_string_field_set(tchan, accountcode, record.account_code);
@@ -515,11 +515,11 @@ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event
if (peer) {
ast_channel_lock(peer);
- peername = ast_strdupa(peer->name);
+ peername = ast_strdupa(ast_channel_name(peer));
ast_channel_unlock(peer);
} else if (peer2) {
ast_channel_lock(peer2);
- peername = ast_strdupa(peer2->name);
+ peername = ast_strdupa(ast_channel_name(peer2));
ast_channel_unlock(peer2);
}
@@ -552,7 +552,7 @@ int ast_cel_report_event(struct ast_channel *chan, enum ast_cel_event_type event
S_OR(chan->dialed.number.str, ""),
AST_EVENT_IE_CEL_EXTEN, AST_EVENT_IE_PLTYPE_STR, chan->exten,
AST_EVENT_IE_CEL_CONTEXT, AST_EVENT_IE_PLTYPE_STR, chan->context,
- AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, chan->name,
+ AST_EVENT_IE_CEL_CHANNAME, AST_EVENT_IE_PLTYPE_STR, ast_channel_name(chan),
AST_EVENT_IE_CEL_APPNAME, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->appl, ""),
AST_EVENT_IE_CEL_APPDATA, AST_EVENT_IE_PLTYPE_STR, S_OR(chan->data, ""),
AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, chan->amaflags,
diff --git a/main/channel.c b/main/channel.c
index 017fba98d..3e9fb834e 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -141,51 +141,6 @@ static AST_RWLIST_HEAD_STATIC(backends, chanlist);
#define NUM_CHANNEL_BUCKETS 1567
#endif
-#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
-#define DATA_EXPORT_CALLERID(MEMBER) \
- MEMBER(ast_callerid, cid_dnid, AST_DATA_STRING) \
- MEMBER(ast_callerid, cid_num, AST_DATA_STRING) \
- MEMBER(ast_callerid, cid_name, AST_DATA_STRING) \
- MEMBER(ast_callerid, cid_ani, AST_DATA_STRING) \
- MEMBER(ast_callerid, cid_pres, AST_DATA_INTEGER) \
- MEMBER(ast_callerid, cid_ani2, AST_DATA_INTEGER) \
- MEMBER(ast_callerid, cid_tag, AST_DATA_STRING)
-
-AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
-#endif
-
-#define DATA_EXPORT_CHANNEL(MEMBER) \
- MEMBER(ast_channel, blockproc, AST_DATA_STRING) \
- MEMBER(ast_channel, appl, AST_DATA_STRING) \
- MEMBER(ast_channel, data, AST_DATA_STRING) \
- MEMBER(ast_channel, name, AST_DATA_STRING) \
- MEMBER(ast_channel, language, AST_DATA_STRING) \
- MEMBER(ast_channel, musicclass, AST_DATA_STRING) \
- MEMBER(ast_channel, accountcode, AST_DATA_STRING) \
- MEMBER(ast_channel, peeraccount, AST_DATA_STRING) \
- MEMBER(ast_channel, userfield, AST_DATA_STRING) \
- MEMBER(ast_channel, call_forward, AST_DATA_STRING) \
- MEMBER(ast_channel, uniqueid, AST_DATA_STRING) \
- MEMBER(ast_channel, linkedid, AST_DATA_STRING) \
- MEMBER(ast_channel, parkinglot, AST_DATA_STRING) \
- MEMBER(ast_channel, hangupsource, AST_DATA_STRING) \
- MEMBER(ast_channel, dialcontext, AST_DATA_STRING) \
- MEMBER(ast_channel, rings, AST_DATA_INTEGER) \
- MEMBER(ast_channel, priority, AST_DATA_INTEGER) \
- MEMBER(ast_channel, macropriority, AST_DATA_INTEGER) \
- MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER) \
- MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER) \
- MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER) \
- MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \
- MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER) \
- MEMBER(ast_channel, context, AST_DATA_STRING) \
- MEMBER(ast_channel, exten, AST_DATA_STRING) \
- MEMBER(ast_channel, macrocontext, AST_DATA_STRING) \
- MEMBER(ast_channel, macroexten, AST_DATA_STRING)
-
-AST_DATA_STRUCTURE(ast_channel, DATA_EXPORT_CHANNEL);
-
-
/*! \brief All active channels on the system */
static struct ao2_container *channels;
@@ -264,29 +219,6 @@ struct ast_variable *ast_channeltype_list(void)
return var;
}
-static void channel_data_add_flags(struct ast_data *tree,
- struct ast_channel *chan)
-{
- ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF));
- ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT));
- ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING));
- ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE));
- ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION));
- ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH));
- ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING));
- ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE));
- ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP));
- ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING));
- ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF));
- ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF));
- ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY));
- ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE));
- ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM));
- ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN));
- ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT));
- ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS));
-}
-
#if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED)
static const char *party_number_ton2str(int ton)
{
@@ -339,144 +271,6 @@ static const char *party_number_plan2str(int plan)
}
#endif /* defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED) */
-int ast_channel_data_add_structure(struct ast_data *tree,
- struct ast_channel *chan, int add_bridged)
-{
- struct ast_channel *bc;
- struct ast_data *data_bridged;
- struct ast_data *data_cdr;
- struct ast_data *data_flags;
- struct ast_data *data_zones;
- struct ast_data *enum_node;
- struct ast_data *data_softhangup;
-#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
- struct ast_data *data_callerid;
- char value_str[100];
-#endif
-
- if (!tree) {
- return -1;
- }
-
- ast_data_add_structure(ast_channel, tree, chan);
-
- if (add_bridged) {
- bc = ast_bridged_channel(chan);
- if (bc) {
- data_bridged = ast_data_add_node(tree, "bridged");
- if (!data_bridged) {
- return -1;
- }
- ast_channel_data_add_structure(data_bridged, bc, 0);
- }
- }
-
- ast_data_add_codec(tree, "oldwriteformat", &chan->oldwriteformat);
- ast_data_add_codec(tree, "readformat", &chan->readformat);
- ast_data_add_codec(tree, "writeformat", &chan->writeformat);
- ast_data_add_codec(tree, "rawreadformat", &chan->rawreadformat);
- ast_data_add_codec(tree, "rawwriteformat", &chan->rawwriteformat);
- ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
-
- /* state */
- enum_node = ast_data_add_node(tree, "state");
- if (!enum_node) {
- return -1;
- }
- ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
- ast_data_add_int(enum_node, "value", chan->_state);
-
- /* hangupcause */
- enum_node = ast_data_add_node(tree, "hangupcause");
- if (!enum_node) {
- return -1;
- }
- ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
- ast_data_add_int(enum_node, "value", chan->hangupcause);
-
- /* amaflags */
- enum_node = ast_data_add_node(tree, "amaflags");
- if (!enum_node) {
- return -1;
- }
- ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
- ast_data_add_int(enum_node, "value", chan->amaflags);
-
- /* transfercapability */
- enum_node = ast_data_add_node(tree, "transfercapability");
- if (!enum_node) {
- return -1;
- }
- ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability));
- ast_data_add_int(enum_node, "value", chan->transfercapability);
-
- /* _softphangup */
- data_softhangup = ast_data_add_node(tree, "softhangup");
- if (!data_softhangup) {
- return -1;
- }
- ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV);
- ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO);
- ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN);
- ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT);
- ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD);
- ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT);
- ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE);
-
- /* channel flags */
- data_flags = ast_data_add_node(tree, "flags");
- if (!data_flags) {
- return -1;
- }
- channel_data_add_flags(data_flags, chan);
-
- ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec);
-
-#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
- /* callerid */
- data_callerid = ast_data_add_node(tree, "callerid");
- if (!data_callerid) {
- return -1;
- }
- ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));
- /* insert the callerid ton */
- enum_node = ast_data_add_node(data_callerid, "cid_ton");
- if (!enum_node) {
- return -1;
- }
- ast_data_add_int(enum_node, "value", chan->cid.cid_ton);
- snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",
- party_number_ton2str(chan->cid.cid_ton),
- party_number_plan2str(chan->cid.cid_ton));
- ast_data_add_str(enum_node, "text", value_str);
-#endif
-
- /* tone zone */
- if (chan->zone) {
- data_zones = ast_data_add_node(tree, "zone");
- if (!data_zones) {
- return -1;
- }
- ast_tone_zone_data_add_structure(data_zones, chan->zone);
- }
-
- /* insert cdr */
- data_cdr = ast_data_add_node(tree, "cdr");
- if (!data_cdr) {
- return -1;
- }
-
- ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
-
- return 0;
-}
-
-int ast_channel_data_cmp_structure(const struct ast_data_search *tree,
- struct ast_channel *chan, const char *structure_name)
-{
- return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
-}
-
/*! \brief Show channel types - CLI command */
static char *handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
@@ -1264,8 +1058,8 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
* uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
* This new function was written so this can be accomplished.
*/
- ast_string_field_build_va(tmp, name, name_fmt, ap);
- tech = ast_strdupa(tmp->name);
+ ast_channel_name_set_va(tmp, name_fmt, ap);
+ tech = ast_strdupa(ast_channel_name(tmp));
if ((slash = strchr(tech, '/'))) {
if ((slash2 = strchr(slash + 1, '/'))) {
tech2 = slash + 1;
@@ -1278,7 +1072,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
* Start the string with '-' so it becomes an empty string
* in the destructor.
*/
- ast_string_field_set(tmp, name, "-**Unknown**");
+ ast_channel_name_set(tmp, "-**Unknown**");
}
/* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
@@ -1342,7 +1136,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
"Exten: %s\r\n"
"Context: %s\r\n"
"Uniqueid: %s\r\n",
- tmp->name,
+ ast_channel_name(tmp),
state,
ast_state2str(state),
S_OR(cid_num, ""),
@@ -1484,7 +1278,7 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
int count = 0;
- ast_log(LOG_WARNING, "Exceptionally long %squeue length queuing to %s\n", queued_frames + new_frames > 128 ? "" : "voice ", chan->name);
+ ast_log(LOG_WARNING, "Exceptionally long %squeue length queuing to %s\n", queued_frames + new_frames > 128 ? "" : "voice ", ast_channel_name(chan));
AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, cur, frame_list) {
/* Save the most recent frame */
if (!AST_LIST_NEXT(cur, frame_list)) {
@@ -1516,7 +1310,7 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
memset(blah, 1, sizeof(blah));
if (write(chan->alertpipe[1], &blah, sizeof(blah)) != (sizeof(blah))) {
ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %d): %s!\n",
- chan->name, queued_frames, strerror(errno));
+ ast_channel_name(chan), queued_frames, strerror(errno));
}
} else if (chan->timingfd > -1) {
ast_timer_enable_continuous(chan->timer);
@@ -1549,7 +1343,7 @@ int ast_queue_hangup(struct ast_channel *chan)
manager_event(EVENT_FLAG_CALL, "HangupRequest",
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
- chan->name,
+ ast_channel_name(chan),
chan->uniqueid);
ast_channel_unlock(chan);
}
@@ -1574,7 +1368,7 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
"Cause: %d\r\n",
- chan->name,
+ ast_channel_name(chan),
chan->uniqueid,
cause);
ast_channel_unlock(chan);
@@ -1623,6 +1417,71 @@ struct ast_channel *ast_channel_callback(ao2_callback_data_fn *cb_fn, void *arg,
return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data);
}
+static int ast_channel_by_name_cb(void *obj, void *arg, void *data, int flags)
+{
+ struct ast_channel *chan = obj;
+ const char *name = (flags & OBJ_KEY) ? arg : ast_channel_name((struct ast_channel *)arg);
+ size_t name_len = *(size_t *)data;
+ int ret = CMP_MATCH;
+
+ if (ast_strlen_zero(name)) {
+ ast_log(LOG_ERROR, "BUG! Must supply a name, or a channel with a name to match on!\n");
+ return CMP_STOP;
+ }
+
+ ast_channel_lock(chan);
+ if (!name_len && (strcasecmp(ast_channel_name(chan), name) || (name_len && strncasecmp(ast_channel_name(chan), name, name_len)))) {
+ ret = 0; /* name match failed, keep looking */
+ }
+ ast_channel_unlock(chan);
+
+ return ret;
+}
+
+static int ast_channel_by_exten_cb(void *obj, void *arg, void *data, int flags)
+{
+ struct ast_channel *chan = obj;
+ char *context = arg, *exten = data;
+ int ret = CMP_MATCH;
+
+ if (ast_strlen_zero(exten) || ast_strlen_zero(context)) {
+ ast_log(LOG_ERROR, "BUG! Must have a context and extension to match!\n");
+ return CMP_STOP;
+ }
+
+ ast_channel_lock(chan);
+ if (strcasecmp(chan->context, context) && strcasecmp(chan->macrocontext, context)) {
+ ret = 0; /* Context match failed, continue */
+ } else if (strcasecmp(chan->exten, exten) && strcasecmp(chan->macroexten, exten)) {
+ ret = 0; /* Extension match failed, continue */
+ }
+ ast_channel_unlock(chan);
+
+ return ret;
+}
+
+static int ast_channel_by_uniqueid_cb(void *obj, void *arg, void *data, int flags)
+{
+ struct ast_channel *chan = obj;
+ char *uniqueid = arg;
+ size_t name_len = *(size_t *) data;
+ int ret = CMP_MATCH;
+
+ if (ast_strlen_zero(uniqueid)) {
+ ast_log(LOG_ERROR, "BUG! Must have a uniqueid to match!\n");
+ return CMP_STOP;
+ }
+
+ ast_channel_lock(chan);
+ if (!name_len && (strcasecmp(chan->uniqueid, uniqueid) ||
+ (name_len && strncasecmp(chan->uniqueid, uniqueid, name_len)))) {
+ ret = 0;
+ }
+ ast_channel_unlock(chan);
+
+ return ret;
+}
+
struct ast_channel_iterator {
/* storage for non-dynamically allocated iterator */
struct ao2_iterator simple_iterator;
@@ -1645,30 +1504,18 @@ static struct ast_channel_iterator *channel_iterator_search(const char *name,
const char *context)
{
struct ast_channel_iterator *i;
- struct ast_channel tmp_chan = {
- .name = name,
- /* This is sort of a hack. Basically, we're using an arbitrary field
- * in ast_channel to pass the name_len for a prefix match. If this
- * gets changed, then the compare callback must be changed, too. */
- .rings = name_len,
- };
if (!(i = ast_calloc(1, sizeof(*i)))) {
return NULL;
}
- if (exten) {
- ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten));
- }
-
- if (context) {
- ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context));
- }
-
- if (!(i->active_iterator = ao2_find(channels, &tmp_chan,
- OBJ_MULTIPLE | ((!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0)))) {
- ast_free(i);
- return NULL;
+ if (ast_strlen_zero(name) && !(i->active_iterator = (void *) ast_channel_callback(ast_channel_by_exten_cb, (void *) context, (void *) exten, OBJ_MULTIPLE))) {
+ ast_free(i);
+ return NULL;
+ } else if (!(i->active_iterator = (void *) ast_channel_callback(ast_channel_by_name_cb, (void *) name, &name_len,
+ OBJ_MULTIPLE | (name_len == 0 /* match the whole word, so optimize */ ? OBJ_KEY : 0)))) {
+ ast_free(i);
+ return NULL;
}
return i;
@@ -1703,9 +1550,10 @@ struct ast_channel *ast_channel_iterator_next(struct ast_channel_iterator *i)
return ao2_iterator_next(i->active_iterator);
}
+/* Legacy function, not currently used for lookups, but we need a cmp_fn */
static int ast_channel_cmp_cb(void *obj, void *arg, int flags)
{
- struct ast_channel *chan = obj, *cmp_args = arg;
+ struct ast_channel *cmp_args = arg;
size_t name_len;
int ret = CMP_MATCH;
@@ -1714,76 +1562,39 @@ static int ast_channel_cmp_cb(void *obj, void *arg, int flags)
* gets changed, then the uses of ao2_find() must be changed, too. */
name_len = cmp_args->rings;
- ast_channel_lock(chan);
-
- if (!ast_strlen_zero(cmp_args->name)) { /* match by name */
- if ((!name_len && strcasecmp(chan->name, cmp_args->name)) ||
- (name_len && strncasecmp(chan->name, cmp_args->name, name_len))) {
- ret = 0; /* name match failed */
- }
+ if (!ast_strlen_zero(ast_channel_name(cmp_args))) { /* match by name */
+ ret = ast_channel_by_name_cb(obj, arg, &name_len, flags);
} else if (!ast_strlen_zero(cmp_args->exten)) {
- if (cmp_args->context && strcasecmp(chan->context, cmp_args->context) &&
- strcasecmp(chan->macrocontext, cmp_args->context)) {
- ret = 0; /* context match failed */
- }
- if (ret && strcasecmp(chan->exten, cmp_args->exten) &&
- strcasecmp(chan->macroexten, cmp_args->exten)) {
- ret = 0; /* exten match failed */
- }
+ ret = ast_channel_by_exten_cb(obj, cmp_args->context, cmp_args->exten, flags);
} else if (!ast_strlen_zero(cmp_args->uniqueid)) {
- if ((!name_len && strcasecmp(chan->uniqueid, cmp_args->uniqueid)) ||
- (name_len && strncasecmp(chan->uniqueid, cmp_args->uniqueid, name_len))) {
- ret = 0; /* uniqueid match failed */
- }
+ ret = ast_channel_by_uniqueid_cb(obj, (void *) cmp_args->uniqueid, &name_len, flags);
} else {
ret = 0;
}
- ast_channel_unlock(chan);
-
return ret;
}
static struct ast_channel *ast_channel_get_full(const char *name, size_t name_len,
const char *exten, const char *context)
{
- struct ast_channel tmp_chan = {
- .name = name,
- /* This is sort of a hack. Basically, we're using an arbitrary field
- * in ast_channel to pass the name_len for a prefix match. If this
- * gets changed, then the compare callback must be changed, too. */
- .rings = name_len,
- };
struct ast_channel *chan;
- if (exten) {
- ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten));
- }
-
- if (context) {
- ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context));
- }
-
- if ((chan = ao2_find(channels, &tmp_chan,
- (!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0))) {
+ if (ast_strlen_zero(name) && (chan = ast_channel_callback(ast_channel_by_exten_cb, (void *) context, (void *) exten, 0))) {
+ return chan;
+ } else if ((chan = ast_channel_callback(ast_channel_by_name_cb, (void *) name, &name_len,
+ (name_len == 0) /* optimize if it is a complete name match */ ? OBJ_KEY : 0))) {
return chan;
}
+ /* If we haven't found by name or context yet and don't have a name, give up. */
if (!name) {
return NULL;
}
/* If name was specified, but the result was NULL,
* try a search on uniqueid, instead. */
-
- {
- struct ast_channel tmp_chan2 = {
- .uniqueid = name,
- .rings = name_len,
- };
-
- return ao2_find(channels, &tmp_chan2, 0);
- }
+ return ast_channel_callback(ast_channel_by_uniqueid_cb, (void *) name, &name_len, 0);
}
struct ast_channel *ast_channel_get_by_name(const char *name)
@@ -2392,7 +2203,7 @@ static void ast_channel_destructor(void *obj)
struct ast_datastore *datastore;
char device_name[AST_CHANNEL_NAME];
- if (chan->name) {
+ if (ast_channel_name(chan)) {
/* The string fields were initialized. */
ast_cel_report_event(chan, AST_CEL_CHANNEL_END, NULL, NULL, NULL);
ast_cel_check_retire_linkedid(chan);
@@ -2411,7 +2222,7 @@ static void ast_channel_destructor(void *obj)
ast_channel_unlock(chan);
if (chan->tech_pvt) {
- ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
+ ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", ast_channel_name(chan));
ast_free(chan->tech_pvt);
}
@@ -2419,11 +2230,11 @@ static void ast_channel_destructor(void *obj)
ast_sched_context_destroy(chan->sched);
}
- if (chan->name) {
+ if (ast_channel_name(chan)) {
char *dashptr;
/* The string fields were initialized. */
- ast_copy_string(device_name, chan->name, sizeof(device_name));
+ ast_copy_string(device_name, ast_channel_name(chan), sizeof(device_name));
if ((dashptr = strrchr(device_name, '-'))) {
*dashptr = '\0';
}
@@ -2445,7 +2256,7 @@ static void ast_channel_destructor(void *obj)
if (chan->writetrans)
ast_translator_free_path(chan->writetrans);
if (chan->pbx)
- ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
+ ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", ast_channel_name(chan));
ast_party_dialed_free(&chan->dialed);
ast_party_caller_free(&chan->caller);
@@ -2705,7 +2516,7 @@ void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
/*! \brief Softly hangup a channel, don't lock */
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
{
- ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Soft-Hanging up channel '%s'\n", ast_channel_name(chan));
/* Inform channel driver that we need to be hung up, if it cares */
chan->_softhangup |= cause;
ast_queue_frame(chan, &ast_null_frame);
@@ -2726,7 +2537,7 @@ int ast_softhangup(struct ast_channel *chan, int cause)
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
"Cause: %d\r\n",
- chan->name,
+ ast_channel_name(chan),
chan->uniqueid,
cause);
ast_channel_unlock(chan);
@@ -2855,11 +2666,11 @@ int ast_hangup(struct ast_channel *chan)
if (ast_test_flag(chan, AST_FLAG_BLOCKING)) {
ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd "
"is blocked by thread %ld in procedure %s! Expect a failure\n",
- (long) pthread_self(), chan->name, (long)chan->blocker, chan->blockproc);
+ (long) pthread_self(), ast_channel_name(chan), (long)chan->blocker, chan->blockproc);
ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0);
}
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
- ast_debug(1, "Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Hanging up channel '%s'\n", ast_channel_name(chan));
/*
* This channel is now dead so mark it as a zombie so anyone
@@ -2870,7 +2681,7 @@ int ast_hangup(struct ast_channel *chan)
chan->tech->hangup(chan);
}
} else {
- ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
+ ast_debug(1, "Hanging up zombie '%s'\n", ast_channel_name(chan));
}
ast_channel_unlock(chan);
@@ -2885,7 +2696,7 @@ int ast_hangup(struct ast_channel *chan)
"ConnectedLineName: %s\r\n"
"Cause: %d\r\n"
"Cause-txt: %s\r\n",
- chan->name,
+ ast_channel_name(chan),
chan->uniqueid,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"),
@@ -2989,12 +2800,12 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
for (;;) {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno));
+ ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
res = -1;
break;
}
if (ms == 0) {
- ast_debug(2, "Didn't receive a media frame from %s within %d ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500));
+ ast_debug(2, "Didn't receive a media frame from %s within %d ms of answering. Continuing anyway\n", ast_channel_name(chan), MAX(delay, 500));
break;
}
cur = ast_read(chan);
@@ -3004,7 +2815,7 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer)
ast_frfree(cur);
}
res = -1;
- ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name);
+ ast_debug(2, "Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
break;
}
@@ -3324,7 +3135,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
/* See if this channel needs to be masqueraded */
if (chan->masq && ast_do_masquerade(chan)) {
- ast_log(LOG_WARNING, "Failed to perform masquerade on %s\n", chan->name);
+ ast_log(LOG_WARNING, "Failed to perform masquerade on %s\n", ast_channel_name(chan));
*ms = -1;
return NULL;
}
@@ -3654,7 +3465,7 @@ static void send_dtmf_event(struct ast_channel *chan, const char *direction, con
"Direction: %s\r\n"
"Begin: %s\r\n"
"End: %s\r\n",
- chan->name, chan->uniqueid, digit, direction, begin, end);
+ ast_channel_name(chan), chan->uniqueid, digit, direction, begin, end);
}
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
@@ -3821,7 +3632,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (chan->fdno == -1) {
ast_log(LOG_ERROR,
"ast_read() on chan '%s' called with no recorded file descriptor.\n",
- chan->name);
+ ast_channel_name(chan));
}
#endif
}
@@ -3835,7 +3646,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* For some odd reason, the alertpipe occasionally loses nonblocking status,
* which immediately causes a deadlock scenario. Detect and prevent this. */
if ((flags & O_NONBLOCK) == 0) {
- ast_log(LOG_ERROR, "Alertpipe on channel %s lost O_NONBLOCK?!!\n", chan->name);
+ ast_log(LOG_ERROR, "Alertpipe on channel %s lost O_NONBLOCK?!!\n", ast_channel_name(chan));
if (fcntl(chan->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
ast_log(LOG_WARNING, "Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
f = &ast_null_frame;
@@ -3951,7 +3762,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (chan->tech->exception)
f = chan->tech->exception(chan);
else {
- ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name);
+ ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", ast_channel_name(chan));
f = &ast_null_frame;
}
/* Clear the exception flag */
@@ -3959,7 +3770,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
} else if (chan->tech && chan->tech->read)
f = chan->tech->read(chan);
else
- ast_log(LOG_WARNING, "No read routine on channel %s\n", chan->name);
+ ast_log(LOG_WARNING, "No read routine on channel %s\n", ast_channel_name(chan));
}
/* Perform the framehook read event here. After the frame enters the framehook list
@@ -4028,7 +3839,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
break;
case AST_FRAME_DTMF_END:
send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes");
- ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len);
+ ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, ast_channel_name(chan), f->len);
/* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
queue_dtmf_readq(chan, f);
@@ -4054,7 +3865,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
} else
chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
- ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, ast_channel_name(chan));
}
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
@@ -4068,7 +3879,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
} else {
struct timeval now = ast_tvnow();
if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
- ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
ast_clear_flag(chan, AST_FLAG_IN_DTMF);
if (!f->len)
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
@@ -4083,21 +3894,21 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
*/
if (ast_tvdiff_ms(now, chan->dtmf_tv) < AST_MIN_DTMF_DURATION) {
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
- 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, chan->name);
+ 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));
}
} else if (!f->len) {
- ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
f->len = AST_MIN_DTMF_DURATION;
}
if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
- ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
+ ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, ast_channel_name(chan));
ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = f->subclass.integer;
chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
ast_frfree(f);
f = &ast_null_frame;
} else {
- ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
if (f->len < AST_MIN_DTMF_DURATION) {
f->len = AST_MIN_DTMF_DURATION;
}
@@ -4113,17 +3924,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
break;
case AST_FRAME_DTMF_BEGIN:
send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
- ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, ast_channel_name(chan));
if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) ||
(!ast_tvzero(chan->dtmf_tv) &&
ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) {
- ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
ast_frfree(f);
f = &ast_null_frame;
} else {
ast_set_flag(chan, AST_FLAG_IN_DTMF);
chan->dtmf_tv = ast_tvnow();
- ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
}
break;
case AST_FRAME_NULL:
@@ -4146,7 +3957,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
chan->dtmf_tv = now;
ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
chan->emulate_dtmf_digit = 0;
- ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
if (chan->audiohooks) {
struct ast_frame *old_frame = f;
f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
@@ -4190,7 +4001,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (old_frame != f)
ast_frfree(old_frame);
}
- ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
+ ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
} else {
/* Drop voice frames while we're still in the middle of the digit */
ast_frfree(f);
@@ -4200,7 +4011,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* This frame is not one of the current native formats -- drop it on the floor */
char to[200];
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
- chan->name, ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
+ ast_channel_name(chan), ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
@@ -4281,7 +4092,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* High bit prints debugging */
if (chan->fin & DEBUGCHAN_FLAG)
- ast_frame_dump(chan->name, f, "<<");
+ ast_frame_dump(ast_channel_name(chan), f, "<<");
chan->fin = FRAMECOUNT_INC(chan->fin);
done:
@@ -4544,14 +4355,14 @@ int ast_indicate_data(struct ast_channel *chan, int _condition,
if (ts) {
/* We have a tone to play, yay. */
- ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
+ ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", ast_channel_name(chan), condition);
res = ast_playtones_start(chan, 0, ts->data, 1);
ts = ast_tone_zone_sound_unref(ts);
}
if (res) {
/* not handled */
- ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name);
+ ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, ast_channel_name(chan));
}
indicate_cleanup:
@@ -4678,7 +4489,7 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
- ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, ast_channel_name(chan));
}
return 0;
@@ -4714,12 +4525,12 @@ int ast_prod(struct ast_channel *chan)
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
- ast_debug(1, "Prodding channel '%s'\n", chan->name);
+ ast_debug(1, "Prodding channel '%s'\n", ast_channel_name(chan));
ast_format_copy(&a.subclass.format, &chan->rawwriteformat);
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod"; /* this better match check in ast_write */
if (ast_write(chan, &a))
- ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name);
+ ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", ast_channel_name(chan));
}
return 0;
}
@@ -4849,7 +4660,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
while(ast_channel_trylock(chan)) {
/*cannot goto done since the channel is not locked*/
if(count++ > 10) {
- ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name);
+ ast_debug(1, "Deadlock avoided for write to channel '%s'\n", ast_channel_name(chan));
return 0;
}
usleep(1);
@@ -4903,7 +4714,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
}
/* High bit prints debugging */
if (chan->fout & DEBUGCHAN_FLAG)
- ast_frame_dump(chan->name, fr, ">>");
+ ast_frame_dump(ast_channel_name(chan), fr, ">>");
CHECK_BLOCKING(chan);
switch (fr->frametype) {
case AST_FRAME_CONTROL:
@@ -4984,7 +4795,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
(ast_format_cmp(&chan->writeformat, &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
char nf[512];
ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
- chan->name, ast_getformatname(&fr->subclass.format), ast_getformatname(&chan->writeformat),
+ ast_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(&chan->writeformat),
ast_getformatname_multiple(nf, sizeof(nf), chan->nativeformats));
ast_set_write_format_by_id(chan, fr->subclass.format.id);
}
@@ -5160,7 +4971,7 @@ static int set_format(struct ast_channel *chan,
/* See if the underlying channel driver is capable of performing transcoding for us */
if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &best_set_fmt, sizeof(best_set_fmt), 0)) {
- ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name,
+ ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", ast_channel_name(chan),
direction ? "write" : "read", ast_getformatname(&best_set_fmt));
ast_channel_lock(chan);
@@ -5239,7 +5050,7 @@ static int set_format(struct ast_channel *chan,
ast_channel_unlock(chan);
ast_debug(1, "Set channel %s to %s format %s\n",
- chan->name,
+ ast_channel_name(chan),
direction ? "write" : "read",
ast_getformatname(&best_set_fmt));
@@ -5989,7 +5800,7 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
return 0;
if (ast_translator_best_choice(dst_cap, src_cap, &best_src_fmt, &best_dst_fmt) < 0) {
- ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name);
+ ast_log(LOG_WARNING, "No path to translate from %s to %s\n", ast_channel_name(from), ast_channel_name(to));
return -1;
}
@@ -6012,11 +5823,11 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
}
if (ast_set_read_format(from, &best_dst_fmt) < 0) {
- ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(&best_dst_fmt));
+ ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", ast_channel_name(from), ast_getformatname(&best_dst_fmt));
return -1;
}
if (ast_set_write_format(to, &best_dst_fmt) < 0) {
- ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(&best_dst_fmt));
+ ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", ast_channel_name(to), ast_getformatname(&best_dst_fmt));
return -1;
}
return 0;
@@ -6055,7 +5866,7 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
/* Zombies! Run! */
ast_log(LOG_WARNING,
"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
- original->name, clonechan->name);
+ ast_channel_name(original), ast_channel_name(clonechan));
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return -1;
@@ -6112,7 +5923,7 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
/* Zombies! Run! */
ast_log(LOG_WARNING,
"Can't setup masquerade. One or both channels is dead. (%s <-- %s)\n",
- original->name, clonechan->name);
+ ast_channel_name(original), ast_channel_name(clonechan));
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return -1;
@@ -6122,14 +5933,14 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
}
if (original == clonechan) {
- ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name);
+ ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", ast_channel_name(original));
ast_channel_unlock(clonechan);
ast_channel_unlock(original);
return -1;
}
ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
- clonechan->name, original->name);
+ ast_channel_name(clonechan), ast_channel_name(original));
if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) {
original->masq = clonechan;
@@ -6139,21 +5950,21 @@ static int __ast_channel_masquerade(struct ast_channel *original, struct ast_cha
}
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clonechan, &ast_null_frame);
- ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name);
+ ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", ast_channel_name(clonechan), ast_channel_name(original));
res = 0;
} else if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- original->masq->name, original->name);
+ ast_channel_name(original->masq), ast_channel_name(original));
} else if (original->masqr) {
/* not yet as a previously planned masq hasn't yet happened */
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- original->name, original->masqr->name);
+ ast_channel_name(original), ast_channel_name(original->masqr));
} else if (clonechan->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- clonechan->masq->name, clonechan->name);
+ ast_channel_name(clonechan->masq), ast_channel_name(clonechan));
} else { /* (clonechan->masqr) */
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
- clonechan->name, clonechan->masqr->name);
+ ast_channel_name(clonechan), ast_channel_name(clonechan->masqr));
}
ast_channel_unlock(clonechan);
@@ -6277,8 +6088,8 @@ int ast_channel_transfer_masquerade(
*/
static void __ast_change_name_nolink(struct ast_channel *chan, const char *newname)
{
- ast_manager_event(chan, EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
- ast_string_field_set(chan, name, newname);
+ ast_manager_event(chan, EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", ast_channel_name(chan), newname, chan->uniqueid);
+ ast_channel_name_set(chan, newname);
}
void ast_change_name(struct ast_channel *chan, const char *newname)
@@ -6483,32 +6294,32 @@ static void ast_set_owners_and_peers(struct ast_channel *chan1,
{
if (!ast_strlen_zero(chan1->accountcode) && ast_strlen_zero(chan2->peeraccount)) {
ast_debug(1, "setting peeraccount to %s for %s from data on channel %s\n",
- chan1->accountcode, chan2->name, chan1->name);
+ chan1->accountcode, ast_channel_name(chan2), ast_channel_name(chan1));
ast_string_field_set(chan2, peeraccount, chan1->accountcode);
}
if (!ast_strlen_zero(chan2->accountcode) && ast_strlen_zero(chan1->peeraccount)) {
ast_debug(1, "setting peeraccount to %s for %s from data on channel %s\n",
- chan2->accountcode, chan1->name, chan2->name);
+ chan2->accountcode, ast_channel_name(chan1), ast_channel_name(chan2));
ast_string_field_set(chan1, peeraccount, chan2->accountcode);
}
if (!ast_strlen_zero(chan1->peeraccount) && ast_strlen_zero(chan2->accountcode)) {
ast_debug(1, "setting accountcode to %s for %s from data on channel %s\n",
- chan1->peeraccount, chan2->name, chan1->name);
+ chan1->peeraccount, ast_channel_name(chan2), ast_channel_name(chan1));
ast_string_field_set(chan2, accountcode, chan1->peeraccount);
}
if (!ast_strlen_zero(chan2->peeraccount) && ast_strlen_zero(chan1->accountcode)) {
ast_debug(1, "setting accountcode to %s for %s from data on channel %s\n",
- chan2->peeraccount, chan1->name, chan2->name);
+ chan2->peeraccount, ast_channel_name(chan1), ast_channel_name(chan2));
ast_string_field_set(chan1, accountcode, chan2->peeraccount);
}
if (0 != strcmp(chan1->accountcode, chan2->peeraccount)) {
ast_debug(1, "changing peeraccount from %s to %s on %s to match channel %s\n",
- chan2->peeraccount, chan1->peeraccount, chan2->name, chan1->name);
+ chan2->peeraccount, chan1->peeraccount, ast_channel_name(chan2), ast_channel_name(chan1));
ast_string_field_set(chan2, peeraccount, chan1->accountcode);
}
if (0 != strcmp(chan2->accountcode, chan1->peeraccount)) {
ast_debug(1, "changing peeraccount from %s to %s on %s to match channel %s\n",
- chan1->peeraccount, chan2->peeraccount, chan1->name, chan2->name);
+ chan1->peeraccount, chan2->peeraccount, ast_channel_name(chan1), ast_channel_name(chan2));
ast_string_field_set(chan1, peeraccount, chan2->accountcode);
}
}
@@ -6527,7 +6338,7 @@ static void report_new_callerid(struct ast_channel *chan)
"CallerIDName: %s\r\n"
"Uniqueid: %s\r\n"
"CID-CallingPres: %d (%s)\r\n",
- chan->name,
+ ast_channel_name(chan),
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
chan->uniqueid,
@@ -6703,7 +6514,7 @@ int ast_do_masquerade(struct ast_channel *original)
ao2_unlink(channels, clonechan);
ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
- clonechan->name, clonechan->_state, original->name, original->_state);
+ ast_channel_name(clonechan), clonechan->_state, ast_channel_name(original), original->_state);
/*
* Stop any visible indiction on the original channel so we can
@@ -6719,7 +6530,7 @@ int ast_do_masquerade(struct ast_channel *original)
"CloneState: %s\r\n"
"Original: %s\r\n"
"OriginalState: %s\r\n",
- clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state));
+ ast_channel_name(clonechan), ast_state2str(clonechan->_state), ast_channel_name(original), ast_state2str(original->_state));
/* Having remembered the original read/write formats, we turn off any translation on either
one */
@@ -6727,9 +6538,9 @@ int ast_do_masquerade(struct ast_channel *original)
free_translation(original);
/* Save the original name */
- ast_copy_string(orig, original->name, sizeof(orig));
+ ast_copy_string(orig, ast_channel_name(original), sizeof(orig));
/* Save the new name */
- ast_copy_string(newn, clonechan->name, sizeof(newn));
+ ast_copy_string(newn, ast_channel_name(clonechan), sizeof(newn));
/* Create the masq name */
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
@@ -6813,7 +6624,7 @@ int ast_do_masquerade(struct ast_channel *original)
clonechan->_state = origstate;
if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) {
- ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clonechan->name);
+ ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", ast_channel_name(clonechan));
}
/* Start by disconnecting the original's physical side */
@@ -6926,7 +6737,7 @@ int ast_do_masquerade(struct ast_channel *original)
ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL);
}
- ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name,
+ ast_debug(1, "Putting channel %s in %s/%s formats\n", ast_channel_name(original),
ast_getformatname(&wformat), ast_getformatname(&rformat));
/* Okay. Last thing is to let the channel driver know about all this mess, so he
@@ -6934,13 +6745,13 @@ int ast_do_masquerade(struct ast_channel *original)
if (original->tech->fixup) {
if (original->tech->fixup(clonechan, original)) {
ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
- original->tech->type, original->name);
+ original->tech->type, ast_channel_name(original));
res = -1;
goto done;
}
} else
ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n",
- original->tech->type, original->name);
+ original->tech->type, ast_channel_name(original));
/*
* If an indication is currently playing, maintain it on the channel
@@ -6958,21 +6769,21 @@ int ast_do_masquerade(struct ast_channel *original)
a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */
if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) {
- ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name);
+ ast_debug(1, "Destroying channel clone '%s'\n", ast_channel_name(clonechan));
ast_channel_unlock(clonechan);
ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n"
"Uniqueid: %s\r\n"
"Cause: %d\r\n"
"Cause-txt: %s\r\n",
- clonechan->name,
+ ast_channel_name(clonechan),
clonechan->uniqueid,
clonechan->hangupcause,
ast_cause2str(clonechan->hangupcause)
);
clonechan = ast_channel_release(clonechan);
} else {
- ast_debug(1, "Released clone lock on '%s'\n", clonechan->name);
+ ast_debug(1, "Released clone lock on '%s'\n", ast_channel_name(clonechan));
ast_set_flag(clonechan, AST_FLAG_ZOMBIE);
ast_queue_frame(clonechan, &ast_null_frame);
}
@@ -6980,7 +6791,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
- ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state);
+ ast_debug(1, "Done Masquerading %s (%d)\n", ast_channel_name(original), original->_state);
if ((bridged = ast_bridged_channel(original))) {
ast_channel_lock(bridged);
@@ -7094,7 +6905,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
if (oldstate == state)
return 0;
- ast_copy_string(name, chan->name, sizeof(name));
+ ast_copy_string(name, ast_channel_name(chan), sizeof(name));
if ((dashptr = strrchr(name, '-'))) {
*dashptr = '\0';
}
@@ -7116,7 +6927,7 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n"
"Uniqueid: %s\r\n",
- chan->name, chan->_state, ast_state2str(chan->_state),
+ ast_channel_name(chan), chan->_state, ast_state2str(chan->_state),
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
@@ -7283,7 +7094,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if (!f) {
*fo = NULL;
*rc = who;
- ast_debug(1, "Didn't get a frame from channel: %s\n", who->name);
+ ast_debug(1, "Didn't get a frame from channel: %s\n", ast_channel_name(who));
break;
}
@@ -7325,7 +7136,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*fo = f;
*rc = who;
bridge_exit = 1;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, ast_channel_name(who));
break;
}
if (bridge_exit)
@@ -7349,7 +7160,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*rc = who;
ast_debug(1, "Got DTMF %s on channel (%s)\n",
f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
- who->name);
+ ast_channel_name(who));
break;
}
@@ -7410,7 +7221,7 @@ static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, st
"CallerID2: %s\r\n",
onoff ? "Link" : "Unlink",
type == 1 ? "core" : "native",
- c0->name, c1->name,
+ ast_channel_name(c0), ast_channel_name(c1),
c0->uniqueid, c1->uniqueid,
S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, ""),
S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, ""));
@@ -7424,7 +7235,7 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
const char *c1_pvtid = NULL;
ast_channel_lock(c1);
- c1_name = ast_strdupa(c1->name);
+ c1_name = ast_strdupa(ast_channel_name(c1));
if (c1->tech->get_pvt_uniqueid) {
c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1));
}
@@ -7437,7 +7248,7 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1)
if (c1_pvtid) {
pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid);
}
- c0_name = ast_strdupa(c0->name);
+ c0_name = ast_strdupa(ast_channel_name(c0));
if (c0->tech->get_pvt_uniqueid) {
c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0));
}
@@ -7495,12 +7306,12 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (c0->_bridge) {
ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
- c0->name, c0->_bridge->name);
+ ast_channel_name(c0), ast_channel_name(c0->_bridge));
return -1;
}
if (c1->_bridge) {
ast_log(LOG_WARNING, "%s is already in a bridge with %s\n",
- c1->name, c1->_bridge->name);
+ ast_channel_name(c1), ast_channel_name(c1->_bridge));
return -1;
}
@@ -7640,7 +7451,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
*fo = NULL;
res = 0;
ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
- c0->name, c1->name,
+ ast_channel_name(c0), ast_channel_name(c1),
ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
ast_check_hangup(c0) ? "Yes" : "No",
ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
@@ -7666,7 +7477,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
ast_set_flag(c1, AST_FLAG_NBRIDGE);
if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) {
manager_bridge_event(0, 1, c0, c1);
- ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
+ ast_debug(1, "Returning from native bridge, channels: %s, %s\n", ast_channel_name(c0), ast_channel_name(c1));
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
@@ -7691,7 +7502,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
}
continue;
default:
- ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name);
+ ast_verb(3, "Native bridging %s and %s ended\n", ast_channel_name(c0), ast_channel_name(c1));
/* fallthrough */
case AST_BRIDGE_FAILED_NOWARN:
break;
@@ -7704,7 +7515,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
!ast_format_cap_identical(c1->nativeformats, o1nativeformats)) &&
!(c0->generator || c1->generator)) {
if (ast_channel_make_compatible(c0, c1)) {
- ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name);
+ ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", ast_channel_name(c0), ast_channel_name(c1));
manager_bridge_event(0, 1, c0, c1);
ast_format_cap_destroy(o0nativeformats);
ast_format_cap_destroy(o1nativeformats);
@@ -7737,7 +7548,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
c1->_bridge = NULL;
manager_bridge_event(0, 1, c0, c1);
- ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
+ ast_debug(1, "Bridge stops bridging channels %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
ast_format_cap_destroy(o0nativeformats);
ast_format_cap_destroy(o1nativeformats);
@@ -7828,7 +7639,7 @@ static void *tonepair_alloc(struct ast_channel *chan, void *params)
return NULL;
ast_format_copy(&ts->origwfmt, &chan->writeformat);
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
- ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
+ ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
tonepair_release(NULL, ts);
ts = NULL;
} else {
@@ -8015,15 +7826,15 @@ void ast_moh_cleanup(struct ast_channel *chan)
static int ast_channel_hash_cb(const void *obj, const int flags)
{
- const struct ast_channel *chan = obj;
+ const char *name = (flags & OBJ_KEY) ? obj : ast_channel_name((struct ast_channel *) obj);
/* If the name isn't set, return 0 so that the ao2_find() search will
* start in the first bucket. */
- if (ast_strlen_zero(chan->name)) {
+ if (ast_strlen_zero(name)) {
return 0;
}
- return ast_str_case_hash(chan->name);
+ return ast_str_case_hash(name);
}
int ast_plc_reload(void)
@@ -8064,7 +7875,7 @@ static int data_channels_provider_handler(const struct ast_data_search *search,
}
if (ast_channel_data_add_structure(data_channel, c, 1) < 0) {
- ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", c->name);
+ ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", ast_channel_name(c));
}
ast_channel_unlock(c);
@@ -8265,7 +8076,7 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha
ast_activate_generator(chan, &silence_generator, state);
- ast_debug(1, "Started silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Started silence generator on '%s'\n", ast_channel_name(chan));
return state;
}
@@ -8277,7 +8088,7 @@ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_sil
ast_deactivate_generator(chan);
- ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Stopped silence generator on '%s'\n", ast_channel_name(chan));
if (ast_set_write_format(chan, &state->old_write_format) < 0)
ast_log(LOG_ERROR, "Could not return write format to its original state\n");
@@ -9689,7 +9500,7 @@ int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, siz
}
/* Dang. Do it the old-fashioned way */
- ast_copy_string(device_name, chan->name, name_buffer_length);
+ ast_copy_string(device_name, ast_channel_name(chan), name_buffer_length);
if ((dash = strrchr(device_name, '-'))) {
*dash = '\0';
}
@@ -9706,7 +9517,7 @@ int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, si
return 0;
}
- ast_copy_string(agent_type, chan->name, size);
+ ast_copy_string(agent_type, ast_channel_name(chan), size);
if ((slash = strchr(agent_type, '/'))) {
*slash = '\0';
}
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
new file mode 100644
index 000000000..0e624dfb3
--- /dev/null
+++ b/main/channel_internal_api.c
@@ -0,0 +1,261 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2012, Digium, Inc.
+ *
+ * Mark Spencer <markster@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Channel Accessor API
+ *
+ * This file is intended to be the only file that ever accesses the
+ * internals of an ast_channel. All other files should use the
+ * accessor functions defined here.
+ *
+ * \author Terry Wilson
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/channel.h"
+#include "asterisk/stringfields.h"
+#include "asterisk/data.h"
+#include "asterisk/indications.h"
+
+/* AST_DATA definitions, which will probably have to be re-thought since the channel will be opaque */
+
+#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
+#define DATA_EXPORT_CALLERID(MEMBER) \
+ MEMBER(ast_callerid, cid_dnid, AST_DATA_STRING) \
+ MEMBER(ast_callerid, cid_num, AST_DATA_STRING) \
+ MEMBER(ast_callerid, cid_name, AST_DATA_STRING) \
+ MEMBER(ast_callerid, cid_ani, AST_DATA_STRING) \
+ MEMBER(ast_callerid, cid_pres, AST_DATA_INTEGER) \
+ MEMBER(ast_callerid, cid_ani2, AST_DATA_INTEGER) \
+ MEMBER(ast_callerid, cid_tag, AST_DATA_STRING)
+
+AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);
+#endif
+
+#define DATA_EXPORT_CHANNEL(MEMBER) \
+ MEMBER(ast_channel, blockproc, AST_DATA_STRING) \
+ MEMBER(ast_channel, appl, AST_DATA_STRING) \
+ MEMBER(ast_channel, data, AST_DATA_STRING) \
+ MEMBER(ast_channel, __do_not_use_name, AST_DATA_STRING) \
+ MEMBER(ast_channel, language, AST_DATA_STRING) \
+ MEMBER(ast_channel, musicclass, AST_DATA_STRING) \
+ MEMBER(ast_channel, accountcode, AST_DATA_STRING) \
+ MEMBER(ast_channel, peeraccount, AST_DATA_STRING) \
+ MEMBER(ast_channel, userfield, AST_DATA_STRING) \
+ MEMBER(ast_channel, call_forward, AST_DATA_STRING) \
+ MEMBER(ast_channel, uniqueid, AST_DATA_STRING) \
+ MEMBER(ast_channel, linkedid, AST_DATA_STRING) \
+ MEMBER(ast_channel, parkinglot, AST_DATA_STRING) \
+ MEMBER(ast_channel, hangupsource, AST_DATA_STRING) \
+ MEMBER(ast_channel, dialcontext, AST_DATA_STRING) \
+ MEMBER(ast_channel, rings, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, priority, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, macropriority, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER) \
+ MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER) \
+ MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER) \
+ MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER) \
+ MEMBER(ast_channel, context, AST_DATA_STRING) \
+ MEMBER(ast_channel, exten, AST_DATA_STRING) \
+ MEMBER(ast_channel, macrocontext, AST_DATA_STRING) \
+ MEMBER(ast_channel, macroexten, AST_DATA_STRING)
+
+AST_DATA_STRUCTURE(ast_channel, DATA_EXPORT_CHANNEL);
+
+static void channel_data_add_flags(struct ast_data *tree,
+ struct ast_channel *chan)
+{
+ ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF));
+ ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT));
+ ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING));
+ ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE));
+ ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION));
+ ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH));
+ ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING));
+ ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE));
+ ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP));
+ ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING));
+ ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF));
+ ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF));
+ ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY));
+ ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE));
+ ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM));
+ ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN));
+ ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT));
+ ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS));
+}
+
+int ast_channel_data_add_structure(struct ast_data *tree,
+ struct ast_channel *chan, int add_bridged)
+{
+ struct ast_channel *bc;
+ struct ast_data *data_bridged;
+ struct ast_data *data_cdr;
+ struct ast_data *data_flags;
+ struct ast_data *data_zones;
+ struct ast_data *enum_node;
+ struct ast_data *data_softhangup;
+#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
+ struct ast_data *data_callerid;
+ char value_str[100];
+#endif
+
+ if (!tree) {
+ return -1;
+ }
+
+ ast_data_add_structure(ast_channel, tree, chan);
+
+ if (add_bridged) {
+ bc = ast_bridged_channel(chan);
+ if (bc) {
+ data_bridged = ast_data_add_node(tree, "bridged");
+ if (!data_bridged) {
+ return -1;
+ }
+ ast_channel_data_add_structure(data_bridged, bc, 0);
+ }
+ }
+
+ ast_data_add_codec(tree, "oldwriteformat", &chan->oldwriteformat);
+ ast_data_add_codec(tree, "readformat", &chan->readformat);
+ ast_data_add_codec(tree, "writeformat", &chan->writeformat);
+ ast_data_add_codec(tree, "rawreadformat", &chan->rawreadformat);
+ ast_data_add_codec(tree, "rawwriteformat", &chan->rawwriteformat);
+ ast_data_add_codecs(tree, "nativeformats", chan->nativeformats);
+
+ /* state */
+ enum_node = ast_data_add_node(tree, "state");
+ if (!enum_node) {
+ return -1;
+ }
+ ast_data_add_str(enum_node, "text", ast_state2str(chan->_state));
+ ast_data_add_int(enum_node, "value", chan->_state);
+
+ /* hangupcause */
+ enum_node = ast_data_add_node(tree, "hangupcause");
+ if (!enum_node) {
+ return -1;
+ }
+ ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause));
+ ast_data_add_int(enum_node, "value", chan->hangupcause);
+
+ /* amaflags */
+ enum_node = ast_data_add_node(tree, "amaflags");
+ if (!enum_node) {
+ return -1;
+ }
+ ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags));
+ ast_data_add_int(enum_node, "value", chan->amaflags);
+
+ /* transfercapability */
+ enum_node = ast_data_add_node(tree, "transfercapability");
+ if (!enum_node) {
+ return -1;
+ }
+ ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability));
+ ast_data_add_int(enum_node, "value", chan->transfercapability);
+
+ /* _softphangup */
+ data_softhangup = ast_data_add_node(tree, "softhangup");
+ if (!data_softhangup) {
+ return -1;
+ }
+ ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV);
+ ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO);
+ ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN);
+ ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT);
+ ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD);
+ ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT);
+ ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE);
+
+ /* channel flags */
+ data_flags = ast_data_add_node(tree, "flags");
+ if (!data_flags) {
+ return -1;
+ }
+ channel_data_add_flags(data_flags, chan);
+
+ ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec);
+
+#if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */
+ /* callerid */
+ data_callerid = ast_data_add_node(tree, "callerid");
+ if (!data_callerid) {
+ return -1;
+ }
+ ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));
+ /* insert the callerid ton */
+ enum_node = ast_data_add_node(data_callerid, "cid_ton");
+ if (!enum_node) {
+ return -1;
+ }
+ ast_data_add_int(enum_node, "value", chan->cid.cid_ton);
+ snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",
+ party_number_ton2str(chan->cid.cid_ton),
+ party_number_plan2str(chan->cid.cid_ton));
+ ast_data_add_str(enum_node, "text", value_str);
+#endif
+
+ /* tone zone */
+ if (chan->zone) {
+ data_zones = ast_data_add_node(tree, "zone");
+ if (!data_zones) {
+ return -1;
+ }
+ ast_tone_zone_data_add_structure(data_zones, chan->zone);
+ }
+
+ /* insert cdr */
+ data_cdr = ast_data_add_node(tree, "cdr");
+ if (!data_cdr) {
+ return -1;
+ }
+
+ ast_cdr_data_add_structure(data_cdr, chan->cdr, 1);
+
+ return 0;
+}
+
+int ast_channel_data_cmp_structure(const struct ast_data_search *tree,
+ struct ast_channel *chan, const char *structure_name)
+{
+ return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);
+}
+
+/* ACCESSORS */
+
+const char *ast_channel_name(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_name;
+}
+
+void ast_channel_name_set(struct ast_channel *chan, const char *name)
+{
+ ast_string_field_set(chan, __do_not_use_name, name);
+}
+
+void ast_channel_name_set_va(struct ast_channel *chan, const char *name_fmt, va_list ap)
+{
+ ast_string_field_build_va(chan, __do_not_use_name, name_fmt, ap);
+}
diff --git a/main/cli.c b/main/cli.c
index c35b941d1..1923dd3d3 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -914,7 +914,7 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
}
}
if (concise) {
- ast_cli(a->fd, CONCISE_FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
+ ast_cli(a->fd, CONCISE_FORMAT_STRING, ast_channel_name(c), c->context, c->exten, c->priority, ast_state2str(c->_state),
c->appl ? c->appl : "(None)",
S_OR(c->data, ""), /* XXX different from verbose ? */
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
@@ -922,17 +922,17 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
S_OR(c->peeraccount, ""),
c->amaflags,
durbuf,
- bc ? bc->name : "(None)",
+ bc ? ast_channel_name(bc) : "(None)",
c->uniqueid);
} else if (verbose) {
- ast_cli(a->fd, VERBOSE_FORMAT_STRING, c->name, c->context, c->exten, c->priority, ast_state2str(c->_state),
+ ast_cli(a->fd, VERBOSE_FORMAT_STRING, ast_channel_name(c), c->context, c->exten, c->priority, ast_state2str(c->_state),
c->appl ? c->appl : "(None)",
c->data ? S_OR(c->data, "(Empty)" ): "(None)",
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
durbuf,
S_OR(c->accountcode, ""),
S_OR(c->peeraccount, ""),
- bc ? bc->name : "(None)");
+ bc ? ast_channel_name(bc) : "(None)");
} else {
char locbuf[40] = "(None)";
char appdata[40] = "(None)";
@@ -941,7 +941,7 @@ static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", c->exten, c->context, c->priority);
if (c->appl)
snprintf(appdata, sizeof(appdata), "%s(%s)", c->appl, S_OR(c->data, ""));
- ast_cli(a->fd, FORMAT_STRING, c->name, locbuf, ast_state2str(c->_state), appdata);
+ ast_cli(a->fd, FORMAT_STRING, ast_channel_name(c), locbuf, ast_state2str(c->_state), appdata);
}
}
ast_channel_unlock(c);
@@ -1002,14 +1002,14 @@ static char *handle_softhangup(struct ast_cli_entry *e, int cmd, struct ast_cli_
}
for (; iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {
ast_channel_lock(c);
- ast_cli(a->fd, "Requested Hangup on channel '%s'\n", c->name);
+ ast_cli(a->fd, "Requested Hangup on channel '%s'\n", ast_channel_name(c));
ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
ast_channel_unlock(c);
}
ast_channel_iterator_destroy(iter);
} else if ((c = ast_channel_get_by_name(a->argv[3]))) {
ast_channel_lock(c);
- ast_cli(a->fd, "Requested Hangup on channel '%s'\n", c->name);
+ ast_cli(a->fd, "Requested Hangup on channel '%s'\n", ast_channel_name(c));
ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
ast_channel_unlock(c);
c = ast_channel_unref(c);
@@ -1289,7 +1289,7 @@ static int channel_set_debug(void *obj, void *arg, void *data, int flags)
chan->fout |= DEBUGCHAN_FLAG;
}
ast_cli(args->fd, "Debugging %s on channel %s\n", args->is_off ? "disabled" : "enabled",
- chan->name);
+ ast_channel_name(chan));
}
ast_channel_unlock(chan);
@@ -1475,7 +1475,7 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
" Application: %s\n"
" Data: %s\n"
" Blocking in: %s\n",
- c->name, c->tech->type, c->uniqueid, c->linkedid,
+ ast_channel_name(c), c->tech->type, c->uniqueid, c->linkedid,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
@@ -1494,7 +1494,7 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
(long)c->whentohangup.tv_sec,
- cdrtime, c->_bridge ? c->_bridge->name : "<none>", ast_bridged_channel(c) ? ast_bridged_channel(c)->name : "<none>",
+ cdrtime, c->_bridge ? ast_channel_name(c->_bridge) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
c->context, c->exten, c->priority, c->callgroup, c->pickupgroup, ( c->appl ? c->appl : "(N/A)" ),
( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
@@ -1565,7 +1565,7 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta
while (ret == &notfound && (c = ast_channel_iterator_next(iter))) {
if (++which > state) {
ast_channel_lock(c);
- ret = ast_strdup(c->name);
+ ret = ast_strdup(ast_channel_name(c));
ast_channel_unlock(c);
}
ast_channel_unref(c);
@@ -1614,7 +1614,7 @@ static char *group_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cl
gi = ast_app_group_list_head();
while (gi) {
if (!havepattern || !regexec(&regexbuf, gi->group, 0, NULL, 0)) {
- ast_cli(a->fd, FORMAT_STRING, gi->chan->name, gi->group, (ast_strlen_zero(gi->category) ? "(default)" : gi->category));
+ ast_cli(a->fd, FORMAT_STRING, ast_channel_name(gi->chan), gi->group, (ast_strlen_zero(gi->category) ? "(default)" : gi->category));
numchans++;
}
gi = AST_LIST_NEXT(gi, group_list);
diff --git a/main/dial.c b/main/dial.c
index 420ce1995..7fe49be33 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -395,7 +395,7 @@ static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel
if (fr->frametype == AST_FRAME_CONTROL) {
switch (fr->subclass.integer) {
case AST_CONTROL_ANSWER:
- ast_verb(3, "%s answered %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s answered %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
AST_LIST_LOCK(&dial->channels);
AST_LIST_REMOVE(&dial->channels, channel, list);
AST_LIST_INSERT_HEAD(&dial->channels, channel, list);
@@ -403,61 +403,61 @@ static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel
set_state(dial, AST_DIAL_RESULT_ANSWERED);
break;
case AST_CONTROL_BUSY:
- ast_verb(3, "%s is busy\n", channel->owner->name);
+ ast_verb(3, "%s is busy\n", ast_channel_name(channel->owner));
ast_hangup(channel->owner);
channel->owner = NULL;
break;
case AST_CONTROL_CONGESTION:
- ast_verb(3, "%s is circuit-busy\n", channel->owner->name);
+ ast_verb(3, "%s is circuit-busy\n", ast_channel_name(channel->owner));
ast_hangup(channel->owner);
channel->owner = NULL;
break;
case AST_CONTROL_INCOMPLETE:
- ast_verb(3, "%s dialed Incomplete extension %s\n", channel->owner->name, channel->owner->exten);
+ ast_verb(3, "%s dialed Incomplete extension %s\n", ast_channel_name(channel->owner), channel->owner->exten);
ast_indicate(chan, AST_CONTROL_INCOMPLETE);
break;
case AST_CONTROL_RINGING:
- ast_verb(3, "%s is ringing\n", channel->owner->name);
+ ast_verb(3, "%s is ringing\n", ast_channel_name(channel->owner));
if (!dial->options[AST_DIAL_OPTION_MUSIC])
ast_indicate(chan, AST_CONTROL_RINGING);
set_state(dial, AST_DIAL_RESULT_RINGING);
break;
case AST_CONTROL_PROGRESS:
- ast_verb(3, "%s is making progress, passing it to %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s is making progress, passing it to %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
ast_indicate(chan, AST_CONTROL_PROGRESS);
set_state(dial, AST_DIAL_RESULT_PROGRESS);
break;
case AST_CONTROL_VIDUPDATE:
- ast_verb(3, "%s requested a video update, passing it to %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s requested a video update, passing it to %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
break;
case AST_CONTROL_SRCUPDATE:
- ast_verb(3, "%s requested a source update, passing it to %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s requested a source update, passing it to %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
ast_indicate(chan, AST_CONTROL_SRCUPDATE);
break;
case AST_CONTROL_CONNECTED_LINE:
- ast_verb(3, "%s connected line has changed, passing it to %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s connected line has changed, passing it to %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
if (ast_channel_connected_line_macro(channel->owner, chan, fr, 1, 1)) {
ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, fr->data.ptr, fr->datalen);
}
break;
case AST_CONTROL_REDIRECTING:
- ast_verb(3, "%s redirecting info has changed, passing it to %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s redirecting info has changed, passing it to %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
if (ast_channel_redirecting_macro(channel->owner, chan, fr, 1, 1)) {
ast_indicate_data(chan, AST_CONTROL_REDIRECTING, fr->data.ptr, fr->datalen);
}
break;
case AST_CONTROL_PROCEEDING:
- ast_verb(3, "%s is proceeding, passing it to %s\n", channel->owner->name, chan->name);
+ ast_verb(3, "%s is proceeding, passing it to %s\n", ast_channel_name(channel->owner), ast_channel_name(chan));
ast_indicate(chan, AST_CONTROL_PROCEEDING);
set_state(dial, AST_DIAL_RESULT_PROCEEDING);
break;
case AST_CONTROL_HOLD:
- ast_verb(3, "Call on %s placed on hold\n", chan->name);
+ ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(chan));
ast_indicate(chan, AST_CONTROL_HOLD);
break;
case AST_CONTROL_UNHOLD:
- ast_verb(3, "Call on %s left from hold\n", chan->name);
+ ast_verb(3, "Call on %s left from hold\n", ast_channel_name(chan));
ast_indicate(chan, AST_CONTROL_UNHOLD);
break;
case AST_CONTROL_OFFHOOK:
@@ -484,7 +484,7 @@ static void handle_frame_ownerless(struct ast_dial *dial, struct ast_dial_channe
switch (fr->subclass.integer) {
case AST_CONTROL_ANSWER:
- ast_verb(3, "%s answered\n", channel->owner->name);
+ ast_verb(3, "%s answered\n", ast_channel_name(channel->owner));
AST_LIST_LOCK(&dial->channels);
AST_LIST_REMOVE(&dial->channels, channel, list);
AST_LIST_INSERT_HEAD(&dial->channels, channel, list);
@@ -492,25 +492,25 @@ static void handle_frame_ownerless(struct ast_dial *dial, struct ast_dial_channe
set_state(dial, AST_DIAL_RESULT_ANSWERED);
break;
case AST_CONTROL_BUSY:
- ast_verb(3, "%s is busy\n", channel->owner->name);
+ ast_verb(3, "%s is busy\n", ast_channel_name(channel->owner));
ast_hangup(channel->owner);
channel->owner = NULL;
break;
case AST_CONTROL_CONGESTION:
- ast_verb(3, "%s is circuit-busy\n", channel->owner->name);
+ ast_verb(3, "%s is circuit-busy\n", ast_channel_name(channel->owner));
ast_hangup(channel->owner);
channel->owner = NULL;
break;
case AST_CONTROL_RINGING:
- ast_verb(3, "%s is ringing\n", channel->owner->name);
+ ast_verb(3, "%s is ringing\n", ast_channel_name(channel->owner));
set_state(dial, AST_DIAL_RESULT_RINGING);
break;
case AST_CONTROL_PROGRESS:
- ast_verb(3, "%s is making progress\n", channel->owner->name);
+ ast_verb(3, "%s is making progress\n", ast_channel_name(channel->owner));
set_state(dial, AST_DIAL_RESULT_PROGRESS);
break;
case AST_CONTROL_PROCEEDING:
- ast_verb(3, "%s is proceeding\n", channel->owner->name);
+ ast_verb(3, "%s is proceeding\n", ast_channel_name(channel->owner));
set_state(dial, AST_DIAL_RESULT_PROCEEDING);
break;
default:
diff --git a/main/dsp.c b/main/dsp.c
index ec25f96c6..d934c9cf5 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1442,7 +1442,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
dsp->f.frametype = AST_FRAME_CONTROL;
dsp->f.subclass.integer = AST_CONTROL_BUSY;
ast_frfree(af);
- ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
+ ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", ast_channel_name(chan));
return ast_frisolate(&dsp->f);
}
diff --git a/main/features.c b/main/features.c
index 7b595fb49..5f9e2857f 100644
--- a/main/features.c
+++ b/main/features.c
@@ -669,7 +669,7 @@ static void set_kill_chan_tech(struct ast_channel *chan)
}
if (chan->tech_pvt) {
ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n",
- chan->name);
+ ast_channel_name(chan));
ast_free(chan->tech_pvt);
chan->tech_pvt = NULL;
}
@@ -714,9 +714,9 @@ static void set_new_chan_name(struct ast_channel *chan)
/* Create the new channel name string. */
ast_channel_lock(chan);
seq_num = ast_atomic_fetchadd_int(&seq_num_last, +1);
- len = snprintf(dummy, sizeof(dummy), "%s<XFER_%x>", chan->name, seq_num) + 1;
+ len = snprintf(dummy, sizeof(dummy), "%s<XFER_%x>", ast_channel_name(chan), seq_num) + 1;
chan_name = alloca(len);
- snprintf(chan_name, len, "%s<XFER_%x>", chan->name, seq_num);
+ snprintf(chan_name, len, "%s<XFER_%x>", ast_channel_name(chan), seq_num);
ast_channel_unlock(chan);
ast_change_name(chan, chan_name);
@@ -858,10 +858,10 @@ static void check_goto_on_transfer(struct ast_channel *chan)
goto_on_transfer = ast_strdupa(val);
ast_channel_unlock(chan);
- ast_debug(1, "Attempting GOTO_ON_BLINDXFR=%s for %s.\n", val, chan->name);
+ ast_debug(1, "Attempting GOTO_ON_BLINDXFR=%s for %s.\n", val, ast_channel_name(chan));
xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", chan->linkedid, 0,
- "%s", chan->name);
+ "%s", ast_channel_name(chan));
if (!xferchan) {
return;
}
@@ -911,25 +911,25 @@ static void *bridge_call_thread(void *data)
int res;
tobj->chan->appl = !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge";
- tobj->chan->data = tobj->peer->name;
+ tobj->chan->data = ast_channel_name(tobj->peer);
tobj->peer->appl = !tobj->return_to_pbx ? "Transferred Call" : "ManagerBridge";
- tobj->peer->data = tobj->chan->name;
+ tobj->peer->data = ast_channel_name(tobj->chan);
ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig);
if (tobj->return_to_pbx) {
if (!ast_check_hangup(tobj->peer)) {
- ast_log(LOG_VERBOSE, "putting peer %s into PBX again\n", tobj->peer->name);
+ ast_log(LOG_VERBOSE, "putting peer %s into PBX again\n", ast_channel_name(tobj->peer));
res = ast_pbx_start(tobj->peer);
if (res != AST_PBX_SUCCESS)
- ast_log(LOG_WARNING, "FAILED continuing PBX on peer %s\n", tobj->peer->name);
+ ast_log(LOG_WARNING, "FAILED continuing PBX on peer %s\n", ast_channel_name(tobj->peer));
} else
ast_hangup(tobj->peer);
if (!ast_check_hangup(tobj->chan)) {
- ast_log(LOG_VERBOSE, "putting chan %s into PBX again\n", tobj->chan->name);
+ ast_log(LOG_VERBOSE, "putting chan %s into PBX again\n", ast_channel_name(tobj->chan));
res = ast_pbx_start(tobj->chan);
if (res != AST_PBX_SUCCESS)
- ast_log(LOG_WARNING, "FAILED continuing PBX on chan %s\n", tobj->chan->name);
+ ast_log(LOG_WARNING, "FAILED continuing PBX on chan %s\n", ast_channel_name(tobj->chan));
} else
ast_hangup(tobj->chan);
} else {
@@ -1240,7 +1240,7 @@ static struct parkeduser *park_space_reserve(struct ast_channel *park_me, struct
}
if (!parkinglot) {
- ast_log(LOG_WARNING, "Parking lot not available to park %s.\n", park_me->name);
+ ast_log(LOG_WARNING, "Parking lot not available to park %s.\n", ast_channel_name(park_me));
return NULL;
}
@@ -1428,20 +1428,20 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
char other_side[AST_CHANNEL_NAME];
char *c;
- ast_copy_string(other_side, S_OR(args->orig_chan_name, peer->name), sizeof(other_side));
+ ast_copy_string(other_side, S_OR(args->orig_chan_name, ast_channel_name(peer)), sizeof(other_side));
if ((c = strrchr(other_side, ';'))) {
*++c = '1';
}
if ((tmpchan = ast_channel_get_by_name(other_side))) {
ast_channel_lock(tmpchan);
if ((base_peer = ast_bridged_channel(tmpchan))) {
- ast_copy_string(pu->peername, base_peer->name, sizeof(pu->peername));
+ ast_copy_string(pu->peername, ast_channel_name(base_peer), sizeof(pu->peername));
}
ast_channel_unlock(tmpchan);
tmpchan = ast_channel_unref(tmpchan);
}
} else {
- ast_copy_string(pu->peername, S_OR(args->orig_chan_name, peer->name), sizeof(pu->peername));
+ ast_copy_string(pu->peername, S_OR(args->orig_chan_name, ast_channel_name(peer)), sizeof(pu->peername));
}
}
@@ -1478,13 +1478,13 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
/* Wake up the (presumably select()ing) thread */
pthread_kill(parking_thread, SIGURG);
ast_verb(2, "Parked %s on %d (lot %s). Will timeout back to extension [%s] %s, %d in %d seconds\n",
- pu->chan->name, pu->parkingnum, pu->parkinglot->name,
+ ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name,
pu->context, pu->exten, pu->priority, (pu->parkingtime / 1000));
ast_cel_report_event(pu->chan, AST_CEL_PARK_START, NULL, pu->parkinglot->name, peer);
if (peer) {
- event_from = peer->name;
+ event_from = ast_channel_name(peer);
} else {
event_from = pbx_builtin_getvar_helper(chan, "BLINDTRANSFER");
}
@@ -1500,7 +1500,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n"
"Uniqueid: %s\r\n",
- pu->parkingexten, pu->chan->name, pu->parkinglot->name, event_from ? event_from : "",
+ pu->parkingexten, ast_channel_name(pu->chan), pu->parkinglot->name, event_from ? event_from : "",
(long)pu->start.tv_sec + (long)(pu->parkingtime/1000) - (long)time(NULL),
S_COR(pu->chan->caller.id.number.valid, pu->chan->caller.id.number.str, "<unknown>"),
S_COR(pu->chan->caller.id.name.valid, pu->chan->caller.id.name.str, "<unknown>"),
@@ -1528,7 +1528,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, st
/* Only say number if it's a number and the channel hasn't been masqueraded away */
if (peer && !ast_test_flag(args, AST_PARK_OPT_SILENCE)
- && (ast_strlen_zero(args->orig_chan_name) || !strcasecmp(peer->name, args->orig_chan_name))) {
+ && (ast_strlen_zero(args->orig_chan_name) || !strcasecmp(ast_channel_name(peer), args->orig_chan_name))) {
/*
* If a channel is masqueraded into peer while playing back the
* parking space number do not continue playing it back. This
@@ -1628,7 +1628,7 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
/* Make a new, channel that we'll use to masquerade in the real one */
chan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, rchan->accountcode, rchan->exten,
- rchan->context, rchan->linkedid, rchan->amaflags, "Parked/%s", rchan->name);
+ rchan->context, rchan->linkedid, rchan->amaflags, "Parked/%s", ast_channel_name(rchan));
if (!chan) {
ast_log(LOG_WARNING, "Unable to create parked channel\n");
if (!ast_test_flag(args, AST_PARK_OPT_SILENCE)) {
@@ -1712,7 +1712,7 @@ int ast_masq_park_call_exten(struct ast_channel *park_me, struct ast_channel *pa
};
if (parker) {
- args.orig_chan_name = ast_strdupa(parker->name);
+ args.orig_chan_name = ast_strdupa(ast_channel_name(parker));
}
if (!park_exten || !park_context) {
return masq_park_call(park_me, parker, &args);
@@ -1761,7 +1761,7 @@ int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int
};
if (peer) {
- args.orig_chan_name = ast_strdupa(peer->name);
+ args.orig_chan_name = ast_strdupa(ast_channel_name(peer));
}
return masq_park_call(rchan, peer, &args);
}
@@ -2057,9 +2057,9 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
} else {
caller_chan_id = ast_strdupa(S_COR(caller_chan->caller.id.number.valid,
- caller_chan->caller.id.number.str, caller_chan->name));
+ caller_chan->caller.id.number.str, ast_channel_name(caller_chan)));
callee_chan_id = ast_strdupa(S_COR(callee_chan->caller.id.number.valid,
- callee_chan->caller.id.number.str, callee_chan->name));
+ callee_chan->caller.id.number.str, ast_channel_name(callee_chan)));
len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
args = alloca(len);
touch_filename = alloca(len);
@@ -2173,9 +2173,9 @@ static int builtin_automixmonitor(struct ast_channel *chan, struct ast_channel *
snprintf(args, len, "%s.%s,b", touch_filename, (touch_format) ? touch_format : "wav");
} else {
caller_chan_id = ast_strdupa(S_COR(caller_chan->caller.id.number.valid,
- caller_chan->caller.id.number.str, caller_chan->name));
+ caller_chan->caller.id.number.str, ast_channel_name(caller_chan)));
callee_chan_id = ast_strdupa(S_COR(callee_chan->caller.id.number.valid,
- callee_chan->caller.id.number.str, callee_chan->name));
+ callee_chan->caller.id.number.str, ast_channel_name(callee_chan)));
len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
args = alloca(len);
touch_filename = alloca(len);
@@ -2254,7 +2254,7 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
char xferto[256] = "";
int res;
- ast_debug(1, "Executing Blind Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
+ ast_debug(1, "Executing Blind Transfer %s, %s (sense=%d) \n", ast_channel_name(chan), ast_channel_name(peer), sense);
set_peers(&transferer, &transferee, peer, chan, sense);
transferer_real_context = real_ctx(transferer, transferee);
@@ -2298,10 +2298,10 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
/* Do blind transfer. */
ast_verb(3, "Blind transferring %s to '%s' (context %s) priority 1\n",
- transferee->name, xferto, transferer_real_context);
+ ast_channel_name(transferee), xferto, transferer_real_context);
ast_cel_report_event(transferer, AST_CEL_BLINDTRANSFER, NULL, xferto, transferee);
- pbx_builtin_setvar_helper(transferer, "BLINDTRANSFER", transferee->name);
- pbx_builtin_setvar_helper(transferee, "BLINDTRANSFER", transferer->name);
+ pbx_builtin_setvar_helper(transferer, "BLINDTRANSFER", ast_channel_name(transferee));
+ pbx_builtin_setvar_helper(transferee, "BLINDTRANSFER", ast_channel_name(transferer));
finishup(transferee);
ast_channel_lock(transferer);
if (!transferer->cdr) { /* this code should never get called (in a perfect world) */
@@ -2317,7 +2317,7 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
ast_debug(1,
"transferer=%s; transferee=%s; lastapp=%s; lastdata=%s; chan=%s; dstchan=%s\n",
- transferer->name, transferee->name, transferer->cdr->lastapp,
+ ast_channel_name(transferer), ast_channel_name(transferee), transferer->cdr->lastapp,
transferer->cdr->lastdata, transferer->cdr->channel,
transferer->cdr->dstchannel);
ast_debug(1, "TRANSFEREE; lastapp=%s; lastdata=%s, chan=%s; dstchan=%s\n",
@@ -2331,7 +2331,7 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
}
if (!transferee->pbx) {
/* Doh! Use our handy async_goto functions */
- ast_debug(1, "About to ast_async_goto %s.\n", transferee->name);
+ ast_debug(1, "About to ast_async_goto %s.\n", ast_channel_name(transferee));
if (ast_async_goto(transferee, transferer_real_context, xferto, 1)) {
ast_log(LOG_WARNING, "Async goto failed :-(\n");
}
@@ -2340,7 +2340,7 @@ static int builtin_blindtransfer(struct ast_channel *chan, struct ast_channel *p
res = -1;
} else {
/* Set the transferee's new extension, since it exists, using transferer context */
- ast_debug(1, "About to explicit goto %s, it has a PBX.\n", transferee->name);
+ ast_debug(1, "About to explicit goto %s, it has a PBX.\n", ast_channel_name(transferee));
ast_set_flag(transferee, AST_FLAG_BRIDGE_HANGUP_DONT); /* don't let the after-bridge code run the h-exten */
set_c_e_p(transferee, transferer_real_context, xferto, 0);
@@ -2365,7 +2365,7 @@ static int check_compat(struct ast_channel *c, struct ast_channel *newchan)
{
if (ast_channel_make_compatible(c, newchan) < 0) {
ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n",
- c->name, newchan->name);
+ ast_channel_name(c), ast_channel_name(newchan));
ast_hangup(newchan);
return -1;
}
@@ -2438,7 +2438,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
char *transferer_name_orig;
char *dash;
- ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
+ ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", ast_channel_name(chan), ast_channel_name(peer), sense);
set_peers(&transferer, &transferee, peer, chan, sense);
transferer_real_context = real_ctx(transferer, transferee);
@@ -2500,7 +2500,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
}
/* Extract redial transferer information from the channel name. */
- transferer_name_orig = ast_strdupa(transferer->name);
+ transferer_name_orig = ast_strdupa(ast_channel_name(transferer));
transferer_name = ast_strdupa(transferer_name_orig);
transferer_tech = strsep(&transferer_name, "/");
dash = strrchr(transferer_name, '-');
@@ -2702,7 +2702,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
/* Initiate the channel transfer of party A to party C (or recalled party B). */
ast_cel_report_event(transferee, AST_CEL_ATTENDEDTRANSFER, NULL, NULL, newchan);
- xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", transferee->linkedid, 0, "Transfered/%s", transferee->name);
+ xferchan = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", "", "", transferee->linkedid, 0, "Transfered/%s", ast_channel_name(transferee));
if (!xferchan) {
ast_hangup(newchan);
ast_party_connected_line_free(&connected_line);
@@ -3071,8 +3071,8 @@ static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer,
ast_autoservice_ignore(idle, AST_FRAME_DTMF_END);
if(work && idle) {
- pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", idle->name);
- pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", work->name);
+ pbx_builtin_setvar_helper(work, "DYNAMIC_PEERNAME", ast_channel_name(idle));
+ pbx_builtin_setvar_helper(idle, "DYNAMIC_PEERNAME", ast_channel_name(work));
pbx_builtin_setvar_helper(work, "DYNAMIC_FEATURENAME", feature->sname);
pbx_builtin_setvar_helper(idle, "DYNAMIC_FEATURENAME", feature->sname);
}
@@ -3269,7 +3269,7 @@ static int feature_interpret(struct ast_channel *chan, struct ast_channel *peer,
snprintf(dynamic_features_buf, sizeof(dynamic_features_buf), "%s%s%s", S_OR(chan_dynamic_features, ""), chan_dynamic_features && peer_dynamic_features ? "#" : "", S_OR(peer_dynamic_features,""));
- ast_debug(3, "Feature interpret: chan=%s, peer=%s, code=%s, sense=%d, features=%d, dynamic=%s\n", chan->name, peer->name, code, sense, features.flags, dynamic_features_buf);
+ ast_debug(3, "Feature interpret: chan=%s, peer=%s, code=%s, sense=%d, features=%d, dynamic=%s\n", ast_channel_name(chan), ast_channel_name(peer), code, sense, features.flags, dynamic_features_buf);
return feature_interpret_helper(chan, peer, config, code, sense, dynamic_features_buf, &features, FEATURE_INTERPRET_DO, &feature);
}
@@ -3509,7 +3509,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
/* see if the timeout has been violated */
if (ast_tvdiff_ms(ast_tvnow(), started) > timeout) {
state = AST_CONTROL_UNHOLD;
- ast_log(LOG_NOTICE, "We exceeded our AT-timeout for %s\n", chan->name);
+ ast_log(LOG_NOTICE, "We exceeded our AT-timeout for %s\n", ast_channel_name(chan));
break; /*doh! timeout*/
}
@@ -3565,19 +3565,19 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
if (f->frametype == AST_FRAME_CONTROL) {
if (f->subclass.integer == AST_CONTROL_RINGING) {
- ast_verb(3, "%s is ringing\n", chan->name);
+ ast_verb(3, "%s is ringing\n", ast_channel_name(chan));
ast_indicate(caller, AST_CONTROL_RINGING);
} else if (f->subclass.integer == AST_CONTROL_BUSY) {
state = f->subclass.integer;
- ast_verb(3, "%s is busy\n", chan->name);
+ ast_verb(3, "%s is busy\n", ast_channel_name(chan));
ast_indicate(caller, AST_CONTROL_BUSY);
ast_frfree(f);
break;
} else if (f->subclass.integer == AST_CONTROL_INCOMPLETE) {
- ast_verb(3, "%s dialed incomplete extension %s; ignoring\n", chan->name, chan->exten);
+ ast_verb(3, "%s dialed incomplete extension %s; ignoring\n", ast_channel_name(chan), chan->exten);
} else if (f->subclass.integer == AST_CONTROL_CONGESTION) {
state = f->subclass.integer;
- ast_verb(3, "%s is congested\n", chan->name);
+ ast_verb(3, "%s is congested\n", ast_channel_name(chan));
ast_indicate(caller, AST_CONTROL_CONGESTION);
ast_frfree(f);
break;
@@ -3691,7 +3691,7 @@ void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this i
{
ast_log(LOG_NOTICE, "______ %s (%lx)______\n", title, (unsigned long)chan);
ast_log(LOG_NOTICE, "CHAN: name: %s; appl: %s; data: %s; contxt: %s; exten: %s; pri: %d;\n",
- chan->name, chan->appl, chan->data, chan->context, chan->exten, chan->priority);
+ ast_channel_name(chan), chan->appl, chan->data, chan->context, chan->exten, chan->priority);
ast_log(LOG_NOTICE, "CHAN: acctcode: %s; dialcontext: %s; amaflags: %x; maccontxt: %s; macexten: %s; macpri: %d;\n",
chan->accountcode, chan->dialcontext, chan->amaflags, chan->macrocontext, chan->macroexten, chan->macropriority);
ast_log(LOG_NOTICE, "CHAN: masq: %p; masqr: %p; _bridge: %p; uniqueID: %s; linkedID:%s\n",
@@ -3699,9 +3699,9 @@ void ast_channel_log(char *title, struct ast_channel *chan) /* for debug, this i
chan->_bridge, chan->uniqueid, chan->linkedid);
if (chan->masqr)
ast_log(LOG_NOTICE, "CHAN: masquerading as: %s; cdr: %p;\n",
- chan->masqr->name, chan->masqr->cdr);
+ ast_channel_name(chan->masqr), chan->masqr->cdr);
if (chan->_bridge)
- ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", chan->_bridge->name);
+ ast_log(LOG_NOTICE, "CHAN: Bridged to %s\n", ast_channel_name(chan->_bridge));
ast_log(LOG_NOTICE, "===== done ====\n");
}
@@ -3817,7 +3817,7 @@ static void clear_dialed_interfaces(struct ast_channel *chan)
ast_channel_lock(chan);
if ((di_datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL))) {
if (option_debug) {
- ast_log(LOG_DEBUG, "Removing dialed interfaces datastore on %s since we're bridging\n", chan->name);
+ ast_log(LOG_DEBUG, "Removing dialed interfaces datastore on %s since we're bridging\n", ast_channel_name(chan));
}
if (!ast_channel_datastore_remove(chan, di_datastore)) {
ast_datastore_free(di_datastore);
@@ -3865,8 +3865,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
const char *h_context;
if (chan && peer) {
- pbx_builtin_setvar_helper(chan, "BRIDGEPEER", peer->name);
- pbx_builtin_setvar_helper(peer, "BRIDGEPEER", chan->name);
+ pbx_builtin_setvar_helper(chan, "BRIDGEPEER", ast_channel_name(peer));
+ pbx_builtin_setvar_helper(peer, "BRIDGEPEER", ast_channel_name(chan));
} else if (chan) {
pbx_builtin_setvar_helper(chan, "BLINDTRANSFER", NULL);
}
@@ -3931,8 +3931,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
ast_set_flag(peer->cdr, AST_CDR_FLAG_POST_DISABLED);
we_disabled_peer_cdr = 1;
}
- ast_copy_string(orig_channame,chan->name,sizeof(orig_channame));
- ast_copy_string(orig_peername,peer->name,sizeof(orig_peername));
+ ast_copy_string(orig_channame,ast_channel_name(chan),sizeof(orig_channame));
+ ast_copy_string(orig_peername,ast_channel_name(peer),sizeof(orig_peername));
if (!chan_cdr || (chan_cdr && !ast_test_flag(chan_cdr, AST_CDR_FLAG_POST_DISABLED))) {
ast_channel_lock_both(chan, peer);
@@ -3953,8 +3953,8 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
} else {
/* better yet, in a xfer situation, find out why the chan cdr got zapped (pun unintentional) */
bridge_cdr = ast_cdr_alloc(); /* this should be really, really rare/impossible? */
- ast_copy_string(bridge_cdr->channel, chan->name, sizeof(bridge_cdr->channel));
- ast_copy_string(bridge_cdr->dstchannel, peer->name, sizeof(bridge_cdr->dstchannel));
+ ast_copy_string(bridge_cdr->channel, ast_channel_name(chan), sizeof(bridge_cdr->channel));
+ ast_copy_string(bridge_cdr->dstchannel, ast_channel_name(peer), sizeof(bridge_cdr->dstchannel));
ast_copy_string(bridge_cdr->uniqueid, chan->uniqueid, sizeof(bridge_cdr->uniqueid));
ast_copy_string(bridge_cdr->lastapp, S_OR(chan->appl, ""), sizeof(bridge_cdr->lastapp));
ast_copy_string(bridge_cdr->lastdata, S_OR(chan->data, ""), sizeof(bridge_cdr->lastdata));
@@ -4103,7 +4103,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
}
if (res < 0) {
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_test_flag(peer, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan) && !ast_check_hangup(peer)) {
- ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", chan->name, peer->name);
+ ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", ast_channel_name(chan), ast_channel_name(peer));
}
goto before_you_go;
}
@@ -4347,8 +4347,8 @@ before_you_go:
}
if (found && spawn_error) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, chan->name);
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, ast_channel_name(chan));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", chan->context, chan->exten, chan->priority, ast_channel_name(chan));
}
/* swap it back */
@@ -4413,7 +4413,7 @@ before_you_go:
if (new_chan_cdr) {
struct ast_channel *chan_ptr = NULL;
- if (strcasecmp(orig_channame, chan->name) != 0) {
+ if (strcasecmp(orig_channame, ast_channel_name(chan)) != 0) {
/* old channel */
if ((chan_ptr = ast_channel_get_by_name(orig_channame))) {
ast_channel_lock(chan_ptr);
@@ -4443,7 +4443,7 @@ before_you_go:
new_peer_cdr = pick_unlocked_cdr(peer->cdr); /* the proper chan cdr, if there are forked cdrs */
if (new_chan_cdr && ast_test_flag(new_chan_cdr, AST_CDR_FLAG_POST_DISABLED) && new_peer_cdr && !ast_test_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED))
ast_set_flag(new_peer_cdr, AST_CDR_FLAG_POST_DISABLED); /* DISABLED is viral-- it will propagate across a bridge */
- if (strcasecmp(orig_peername, peer->name) != 0) {
+ if (strcasecmp(orig_peername, ast_channel_name(peer)) != 0) {
/* old channel */
if ((chan_ptr = ast_channel_get_by_name(orig_peername))) {
ast_channel_lock(chan_ptr);
@@ -4489,7 +4489,7 @@ static void post_manager_event(const char *s, struct parkeduser *pu)
"ConnectedLineName: %s\r\n"
"UniqueID: %s\r\n",
pu->parkingexten,
- pu->chan->name,
+ ast_channel_name(pu->chan),
pu->parkinglot->name,
S_COR(pu->chan->caller.id.number.valid, pu->chan->caller.id.number.str, "<unknown>"),
S_COR(pu->chan->caller.id.name.valid, pu->chan->caller.id.name.str, "<unknown>"),
@@ -4620,7 +4620,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
&(dialfeatures->features_caller), buf, sizeof(buf)));
} else { /* Existing default */
ast_log(LOG_NOTICE, "Dial features not found on %s, using default!\n",
- chan->name);
+ ast_channel_name(chan));
snprintf(returnexten, sizeof(returnexten), "%s,30,t", peername);
}
ast_channel_unlock(chan);
@@ -4660,14 +4660,14 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
ast_cel_report_event(pu->chan, AST_CEL_PARK_END, NULL, "ParkedCallTimeOut", NULL);
ast_verb(2, "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n",
- pu->chan->name, pu->parkingnum, pu->parkinglot->name, pu->chan->context,
+ ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, pu->chan->context,
pu->chan->exten, pu->chan->priority);
/* Start up the PBX, or hang them up */
if (ast_pbx_start(chan)) {
ast_log(LOG_WARNING,
"Unable to restart the PBX for user on '%s', hanging them up...\n",
- pu->chan->name);
+ ast_channel_name(pu->chan));
ast_hangup(chan);
}
@@ -4718,7 +4718,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
NULL);
/* There's a problem, hang them up */
- ast_verb(2, "%s got tired of being parked\n", chan->name);
+ ast_verb(2, "%s got tired of being parked\n", ast_channel_name(chan));
ast_hangup(chan);
/* And take them out of the parking lot */
@@ -4732,7 +4732,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
&& !chan->generatordata) {
ast_debug(1,
"MOH on parked call stopped by outside source. Restarting on channel %s.\n",
- chan->name);
+ ast_channel_name(chan));
ast_indicate_data(chan, AST_CONTROL_HOLD,
S_OR(pu->parkinglot->cfg.mohclass, NULL),
(!ast_strlen_zero(pu->parkinglot->cfg.mohclass)
@@ -4897,7 +4897,7 @@ static int park_call_exec(struct ast_channel *chan, const char *data)
/* Cache the original channel name in case we get masqueraded in the middle
* of a park--it is still theoretically possible for a transfer to happen before
* we get here, but it is _really_ unlikely */
- char *orig_chan_name = ast_strdupa(chan->name);
+ char *orig_chan_name = ast_strdupa(ast_channel_name(chan));
struct ast_park_call_args args = {
.orig_chan_name = orig_chan_name,
};
@@ -5040,11 +5040,11 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
}
if (ast_stream_and_wait(chan, "pbx-invalidpark", "")) {
ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n",
- "pbx-invalidpark", chan->name);
+ "pbx-invalidpark", ast_channel_name(chan));
}
ast_log(LOG_WARNING,
"Channel %s tried to retrieve parked call from unknown parking lot '%s'\n",
- chan->name, pl_name);
+ ast_channel_name(chan), pl_name);
return -1;
}
}
@@ -5082,7 +5082,7 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
"CallerIDName: %s\r\n"
"ConnectedLineNum: %s\r\n"
"ConnectedLineName: %s\r\n",
- pu->parkingexten, pu->chan->name, chan->name,
+ pu->parkingexten, ast_channel_name(pu->chan), ast_channel_name(chan),
S_COR(pu->chan->caller.id.number.valid, pu->chan->caller.id.number.str, "<unknown>"),
S_COR(pu->chan->caller.id.name.valid, pu->chan->caller.id.name.str, "<unknown>"),
S_COR(pu->chan->connected.id.number.valid, pu->chan->connected.id.number.str, "<unknown>"),
@@ -5176,17 +5176,17 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
res = ast_channel_make_compatible(chan, peer);
if (res < 0) {
- ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, peer->name);
+ ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", ast_channel_name(chan), ast_channel_name(peer));
ast_hangup(peer);
parkinglot_unref(parkinglot);
return -1;
}
/* This runs sorta backwards, since we give the incoming channel control, as if it
were the person called. */
- ast_verb(3, "Channel %s connected to parked call %d\n", chan->name, park);
+ ast_verb(3, "Channel %s connected to parked call %d\n", ast_channel_name(chan), park);
- pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
- ast_cdr_setdestchan(chan->cdr, peer->name);
+ pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", ast_channel_name(peer));
+ ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
memset(&config, 0, sizeof(struct ast_bridge_config));
/* Get datastore for peer and apply it's features to the callee side of the bridge config */
@@ -5235,18 +5235,18 @@ static int parked_call_exec(struct ast_channel *chan, const char *data)
res = ast_bridge_call(chan, peer, &config);
- pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", peer->name);
- ast_cdr_setdestchan(chan->cdr, peer->name);
+ pbx_builtin_setvar_helper(chan, "PARKEDCHANNEL", ast_channel_name(peer));
+ ast_cdr_setdestchan(chan->cdr, ast_channel_name(peer));
/* Simulate the PBX hanging up */
ast_hangup(peer);
} else {
if (ast_stream_and_wait(chan, "pbx-invalidpark", "")) {
ast_log(LOG_WARNING, "ast_streamfile of %s failed on %s\n", "pbx-invalidpark",
- chan->name);
+ ast_channel_name(chan));
}
ast_verb(3, "Channel %s tried to retrieve nonexistent parked call %d\n",
- chan->name, park);
+ ast_channel_name(chan), park);
}
parkinglot_unref(parkinglot);
@@ -6816,7 +6816,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
/* create the placeholder channels and grab the other channels */
if (!(tmpchana = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
- NULL, NULL, chana->linkedid, 0, "Bridge/%s", chana->name))) {
+ NULL, NULL, chana->linkedid, 0, "Bridge/%s", ast_channel_name(chana)))) {
astman_send_error(s, m, "Unable to create temporary channel!");
chana = ast_channel_unref(chana);
return 1;
@@ -6843,7 +6843,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
/* create the placeholder channels and grab the other channels */
if (!(tmpchanb = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
- NULL, NULL, chanb->linkedid, 0, "Bridge/%s", chanb->name))) {
+ NULL, NULL, chanb->linkedid, 0, "Bridge/%s", ast_channel_name(chanb)))) {
astman_send_error(s, m, "Unable to create temporary channels!");
ast_hangup(tmpchana);
chanb = ast_channel_unref(chanb);
@@ -6856,7 +6856,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
/* make the channels compatible, send error if we fail doing so */
if (ast_channel_make_compatible(tmpchana, tmpchanb)) {
- ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for manager bridge\n", tmpchana->name, tmpchanb->name);
+ ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for manager bridge\n", ast_channel_name(tmpchana), ast_channel_name(tmpchanb));
astman_send_error(s, m, "Could not make channels compatible for manager bridge");
ast_hangup(tmpchana);
ast_hangup(tmpchanb);
@@ -6865,7 +6865,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
/* setup the bridge thread object and start the bridge */
if (!(tobj = ast_calloc(1, sizeof(*tobj)))) {
- ast_log(LOG_WARNING, "Unable to spawn a new bridge thread on %s and %s: %s\n", tmpchana->name, tmpchanb->name, strerror(errno));
+ ast_log(LOG_WARNING, "Unable to spawn a new bridge thread on %s and %s: %s\n", ast_channel_name(tmpchana), ast_channel_name(tmpchanb), strerror(errno));
astman_send_error(s, m, "Unable to spawn a new bridge thread");
ast_hangup(tmpchana);
ast_hangup(tmpchanb);
@@ -6879,7 +6879,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
if (ast_true(playtone)) {
if (!ast_strlen_zero(xfersound) && !ast_streamfile(tmpchanb, xfersound, tmpchanb->language)) {
if (ast_waitstream(tmpchanb, "") < 0)
- ast_log(LOG_WARNING, "Failed to play a courtesy tone on chan %s\n", tmpchanb->name);
+ ast_log(LOG_WARNING, "Failed to play a courtesy tone on chan %s\n", ast_channel_name(tmpchanb));
}
}
@@ -6889,7 +6889,7 @@ static int action_bridge(struct mansession *s, const struct message *m)
ast_manager_event_multichan(EVENT_FLAG_CALL, "BridgeAction", 2, chans,
"Response: Success\r\n"
"Channel1: %s\r\n"
- "Channel2: %s\r\n", tmpchana->name, tmpchanb->name);
+ "Channel2: %s\r\n", ast_channel_name(tmpchana), ast_channel_name(tmpchanb));
bridge_call_thread_launch(tobj);
@@ -6944,7 +6944,7 @@ static char *handle_parkedcalls(struct ast_cli_entry *e, int cmd, struct ast_cli
AST_LIST_LOCK(&curlot->parkings);
AST_LIST_TRAVERSE(&curlot->parkings, cur, list) {
ast_cli(a->fd, "%-10.10s %-25s (%-15s %-12s %4d) %6lds\n",
- cur->parkingexten, cur->chan->name, cur->context, cur->exten,
+ cur->parkingexten, ast_channel_name(cur->chan), cur->context, cur->exten,
cur->priority,
(long) (cur->start.tv_sec + (cur->parkingtime / 1000) - time(NULL)));
++lotparked;
@@ -7010,7 +7010,7 @@ static int manager_parking_status(struct mansession *s, const struct message *m)
"%s"
"\r\n",
curlot->name,
- cur->parkingnum, cur->chan->name, cur->peername,
+ cur->parkingnum, ast_channel_name(cur->chan), cur->peername,
(long) cur->start.tv_sec + (long) (cur->parkingtime / 1000) - (long) time(NULL),
S_COR(cur->chan->caller.id.number.valid, cur->chan->caller.id.number.str, ""), /* XXX in other places it is <unknown> */
S_COR(cur->chan->caller.id.name.valid, cur->chan->caller.id.name.str, ""),
@@ -7184,12 +7184,12 @@ int ast_pickup_call(struct ast_channel *chan)
{
struct ast_channel *target;/*!< Potential pickup target */
int res = -1;
- ast_debug(1, "pickup attempt by %s\n", chan->name);
+ ast_debug(1, "pickup attempt by %s\n", ast_channel_name(chan));
/* The found channel is already locked. */
target = ast_channel_callback(find_channel_by_group, NULL, chan, 0);
if (target) {
- ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", target->name, chan->name);
+ ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", ast_channel_name(target), ast_channel_name(chan));
res = ast_do_pickup(chan, target);
ast_channel_unlock(target);
@@ -7198,13 +7198,13 @@ int ast_pickup_call(struct ast_channel *chan)
pbx_builtin_setvar_helper(target, "BRIDGE_PLAY_SOUND", pickupsound);
}
} else {
- ast_log(LOG_WARNING, "pickup %s failed by %s\n", target->name, chan->name);
+ ast_log(LOG_WARNING, "pickup %s failed by %s\n", ast_channel_name(target), ast_channel_name(chan));
}
target = ast_channel_unref(target);
}
if (res < 0) {
- ast_debug(1, "No call pickup possible... for %s\n", chan->name);
+ ast_debug(1, "No call pickup possible... for %s\n", ast_channel_name(chan));
if (!ast_strlen_zero(pickupfailsound)) {
ast_answer(chan);
ast_stream_and_wait(chan, pickupfailsound, "");
@@ -7223,8 +7223,8 @@ int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target)
const char *target_name;/*!< A masquerade changes channel names. */
int res = -1;
- target_name = ast_strdupa(target->name);
- ast_debug(1, "Call pickup on '%s' by '%s'\n", target_name, chan->name);
+ target_name = ast_strdupa(ast_channel_name(target));
+ ast_debug(1, "Call pickup on '%s' by '%s'\n", target_name, ast_channel_name(chan));
/* Mark the target to block any call pickup race. */
ds_pickup = ast_datastore_alloc(&pickup_active, NULL);
@@ -7245,7 +7245,7 @@ int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target)
ast_party_connected_line_free(&connected_caller);
ast_channel_lock(chan);
- chan_name = ast_strdupa(chan->name);
+ chan_name = ast_strdupa(ast_channel_name(chan));
ast_connected_line_copy_from_caller(&connected_caller, &chan->caller);
ast_channel_unlock(chan);
connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
@@ -7474,14 +7474,14 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
ast_app_parse_options(bridge_exec_options, &opts, opt_args, args.options);
/* avoid bridge with ourselves */
- if (!strcmp(chan->name, args.dest_chan)) {
- ast_log(LOG_WARNING, "Unable to bridge channel %s with itself\n", chan->name);
+ if (!strcmp(ast_channel_name(chan), args.dest_chan)) {
+ ast_log(LOG_WARNING, "Unable to bridge channel %s with itself\n", ast_channel_name(chan));
ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec",
"Response: Failed\r\n"
"Reason: Unable to bridge channel to itself\r\n"
"Channel1: %s\r\n"
"Channel2: %s\r\n",
- chan->name, args.dest_chan);
+ ast_channel_name(chan), args.dest_chan);
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP");
return 0;
}
@@ -7495,7 +7495,7 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
"Response: Failed\r\n"
"Reason: Cannot grab end point\r\n"
"Channel1: %s\r\n"
- "Channel2: %s\r\n", chan->name, args.dest_chan);
+ "Channel2: %s\r\n", ast_channel_name(chan), args.dest_chan);
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT");
return 0;
}
@@ -7507,13 +7507,13 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
/* try to allocate a place holder where current_dest_chan will be placed */
if (!(final_dest_chan = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL,
- NULL, NULL, current_dest_chan->linkedid, 0, "Bridge/%s", current_dest_chan->name))) {
+ NULL, NULL, current_dest_chan->linkedid, 0, "Bridge/%s", ast_channel_name(current_dest_chan)))) {
ast_log(LOG_WARNING, "Cannot create placeholder channel for chan %s\n", args.dest_chan);
ast_manager_event(chan, EVENT_FLAG_CALL, "BridgeExec",
"Response: Failed\r\n"
"Reason: cannot create placeholder\r\n"
"Channel1: %s\r\n"
- "Channel2: %s\r\n", chan->name, args.dest_chan);
+ "Channel2: %s\r\n", ast_channel_name(chan), args.dest_chan);
}
do_bridge_masquerade(current_dest_chan, final_dest_chan);
@@ -7524,12 +7524,12 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
/* now current_dest_chan is a ZOMBIE and with softhangup set to 1 and final_dest_chan is our end point */
/* try to make compatible, send error if we fail */
if (ast_channel_make_compatible(chan, final_dest_chan) < 0) {
- ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, final_dest_chan->name);
+ ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", ast_channel_name(chan), ast_channel_name(final_dest_chan));
ast_manager_event_multichan(EVENT_FLAG_CALL, "BridgeExec", 2, chans,
"Response: Failed\r\n"
"Reason: Could not make channels compatible for bridge\r\n"
"Channel1: %s\r\n"
- "Channel2: %s\r\n", chan->name, final_dest_chan->name);
+ "Channel2: %s\r\n", ast_channel_name(chan), ast_channel_name(final_dest_chan));
ast_hangup(final_dest_chan); /* may be we should return this channel to the PBX? */
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "INCOMPATIBLE");
current_dest_chan = ast_channel_unref(current_dest_chan);
@@ -7540,13 +7540,13 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
ast_manager_event_multichan(EVENT_FLAG_CALL, "BridgeExec", 2, chans,
"Response: Success\r\n"
"Channel1: %s\r\n"
- "Channel2: %s\r\n", chan->name, final_dest_chan->name);
+ "Channel2: %s\r\n", ast_channel_name(chan), ast_channel_name(final_dest_chan));
/* we have 2 valid channels to bridge, now it is just a matter of setting up the bridge config and starting the bridge */
if (ast_test_flag(&opts, BRIDGE_OPT_PLAYTONE) && !ast_strlen_zero(xfersound)) {
if (!ast_streamfile(final_dest_chan, xfersound, final_dest_chan->language)) {
if (ast_waitstream(final_dest_chan, "") < 0)
- ast_log(LOG_WARNING, "Failed to play courtesy tone on %s\n", final_dest_chan->name);
+ ast_log(LOG_WARNING, "Failed to play courtesy tone on %s\n", ast_channel_name(final_dest_chan));
}
}
@@ -7581,15 +7581,15 @@ static int bridge_exec(struct ast_channel *chan, const char *data)
if (!ast_check_hangup(final_dest_chan) && !ast_test_flag(&opts, OPT_CALLEE_KILL)) {
ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n",
final_dest_chan->context, final_dest_chan->exten,
- final_dest_chan->priority, final_dest_chan->name);
+ final_dest_chan->priority, ast_channel_name(final_dest_chan));
if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) {
- ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", final_dest_chan->name);
+ ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", ast_channel_name(final_dest_chan));
ast_hangup(final_dest_chan);
} else
- ast_debug(1, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name);
+ ast_debug(1, "SUCCESS continuing PBX on chan %s\n", ast_channel_name(final_dest_chan));
} else {
- ast_debug(1, "hangup chan %s since the other endpoint has hung up or the x flag was passed\n", final_dest_chan->name);
+ ast_debug(1, "hangup chan %s since the other endpoint has hung up or the x flag was passed\n", ast_channel_name(final_dest_chan));
ast_hangup(final_dest_chan);
}
done:
diff --git a/main/file.c b/main/file.c
index 70b971cb3..8591637c8 100644
--- a/main/file.c
+++ b/main/file.c
@@ -818,7 +818,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
while (!whennext) {
struct ast_frame *fr;
- if (s->orig_chan_name && strcasecmp(s->owner->name, s->orig_chan_name)) {
+ if (s->orig_chan_name && strcasecmp(ast_channel_name(s->owner), s->orig_chan_name)) {
goto return_failure;
}
@@ -1044,7 +1044,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
}
if (ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM))
- fs->orig_chan_name = ast_strdup(chan->name);
+ fs->orig_chan_name = ast_strdup(ast_channel_name(chan));
if (ast_applystream(chan, fs))
return -1;
if (vfs && ast_applystream(chan, vfs))
@@ -1052,7 +1052,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
res = ast_playstream(fs);
if (!res && vfs)
res = ast_playstream(vfs);
- ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", chan->name, filename, ast_getformatname(&chan->writeformat), preflang ? preflang : "default");
+ ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_getformatname(&chan->writeformat), preflang ? preflang : "default");
return res;
}
@@ -1258,13 +1258,13 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
ast_set_flag(c, AST_FLAG_END_DTMF_ONLY);
if (ast_test_flag(c, AST_FLAG_MASQ_NOSTREAM))
- orig_chan_name = ast_strdupa(c->name);
+ orig_chan_name = ast_strdupa(ast_channel_name(c));
while (c->stream) {
int res;
int ms;
- if (orig_chan_name && strcasecmp(orig_chan_name, c->name)) {
+ if (orig_chan_name && strcasecmp(orig_chan_name, ast_channel_name(c))) {
ast_stopstream(c);
err = 1;
break;
@@ -1424,7 +1424,7 @@ int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *
{
int res = 0;
if (!ast_strlen_zero(file)) {
- ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", file, chan->name);
+ ast_test_suite_event_notify("PLAYBACK", "Message: %s\r\nChannel: %s", file, ast_channel_name(chan));
res = ast_streamfile(chan, file, chan->language);
if (!res) {
res = ast_waitstream(chan, digits);
diff --git a/main/indications.c b/main/indications.c
index f93239380..ef98407f5 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -150,7 +150,7 @@ static void *playtones_alloc(struct ast_channel *chan, void *params)
ast_format_copy(&ps->origwfmt, &chan->writeformat);
if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
- ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name);
+ ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
playtones_release(NULL, ps);
ps = NULL;
} else {
diff --git a/main/manager.c b/main/manager.c
index d0729a8fc..f7144adc9 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3157,7 +3157,7 @@ static int action_hangup(struct mansession *s, const struct message *m)
ast_channel_lock(c);
if (causecode > 0) {
ast_debug(1, "Setting hangupcause of channel %s to %d (is %d now)\n",
- c->name, causecode, c->hangupcause);
+ ast_channel_name(c), causecode, c->hangupcause);
c->hangupcause = causecode;
}
ast_softhangup_nolock(c, AST_SOFTHANGUP_EXPLICIT);
@@ -3322,7 +3322,7 @@ static int action_status(struct mansession *s, const struct message *m)
channels++;
if (c->_bridge) {
- snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", c->_bridge->name, c->_bridge->uniqueid);
+ snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", ast_channel_name(c->_bridge), c->_bridge->uniqueid);
} else {
bridge[0] = '\0';
}
@@ -3350,7 +3350,7 @@ static int action_status(struct mansession *s, const struct message *m)
"%s"
"%s"
"\r\n",
- c->name,
+ ast_channel_name(c),
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "<unknown>"),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, "<unknown>"),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "<unknown>"),
@@ -3375,7 +3375,7 @@ static int action_status(struct mansession *s, const struct message *m)
"%s"
"%s"
"\r\n",
- c->name,
+ ast_channel_name(c),
S_COR(c->caller.id.number.valid, c->caller.id.number.str, "<unknown>"),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, "<unknown>"),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, "<unknown>"),
@@ -3742,7 +3742,7 @@ static void *fast_originate(void *data)
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n",
in->idtext, ast_strlen_zero(in->idtext) ? "" : "\r\n", res ? "Failure" : "Success",
- chan ? chan->name : requested_channel, in->context, in->exten, reason,
+ chan ? ast_channel_name(chan) : requested_channel, in->context, in->exten, reason,
chan ? chan->uniqueid : "<null>",
S_OR(in->cid_num, "<unknown>"),
S_OR(in->cid_name, "<unknown>")
@@ -4592,13 +4592,13 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
"AccountCode: %s\r\n"
"BridgedChannel: %s\r\n"
"BridgedUniqueID: %s\r\n"
- "\r\n", idText, c->name, c->uniqueid, c->context, c->exten, c->priority, c->_state,
+ "\r\n", idText, ast_channel_name(c), c->uniqueid, c->context, c->exten, c->priority, c->_state,
ast_state2str(c->_state), c->appl ? c->appl : "", c->data ? S_OR(c->data, "") : "",
S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""),
S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""),
S_COR(c->connected.id.number.valid, c->connected.id.number.str, ""),
S_COR(c->connected.id.name.valid, c->connected.id.name.str, ""),
- durbuf, S_OR(c->accountcode, ""), bc ? bc->name : "", bc ? bc->uniqueid : "");
+ durbuf, S_OR(c->accountcode, ""), bc ? ast_channel_name(bc) : "", bc ? bc->uniqueid : "");
ast_channel_unlock(c);
@@ -5174,7 +5174,7 @@ static void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
} else {
val = pbx_builtin_getvar_helper(chan, var->name);
}
- ast_str_append(pbuf, 0, "ChanVariable(%s): %s=%s\r\n", chan->name, var->name, val ? val : "");
+ ast_str_append(pbuf, 0, "ChanVariable(%s): %s=%s\r\n", ast_channel_name(chan), var->name, val ? val : "");
}
AST_RWLIST_UNLOCK(&channelvars);
}
diff --git a/main/pbx.c b/main/pbx.c
index dff45b813..d2a18fb64 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -3317,7 +3317,7 @@ const char *ast_str_retrieve_variable(struct ast_str **str, ssize_t maxlen, stru
ast_str_set(str, maxlen, "%d", c->priority);
s = ast_str_buffer(*str);
} else if (!strcmp(var, "CHANNEL")) {
- s = c->name;
+ s = ast_channel_name(c);
} else if (!strcmp(var, "UNIQUEID")) {
s = c->uniqueid;
} else if (!strcmp(var, "HANGUPCAUSE")) {
@@ -4374,7 +4374,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
ast_verb(3, "Executing [%s@%s:%d] %s(\"%s\", \"%s\") %s\n",
exten, context, priority,
term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)),
- term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)),
+ term_color(tmp2, ast_channel_name(c), COLOR_BRMAGENTA, 0, sizeof(tmp2)),
term_color(tmp3, passdata, COLOR_BRMAGENTA, 0, sizeof(tmp3)),
"in new stack");
}
@@ -4386,7 +4386,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
"Application: %s\r\n"
"AppData: %s\r\n"
"Uniqueid: %s\r\n",
- c->name, c->context, c->exten, c->priority, app->name, passdata, c->uniqueid);
+ ast_channel_name(c), c->context, c->exten, c->priority, app->name, passdata, c->uniqueid);
return pbx_exec(c, app, passdata); /* 0 on success, -1 on failure */
}
} else if (q.swo) { /* not found here, but in another switch */
@@ -5106,7 +5106,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
/* A little initial setup here */
if (c->pbx) {
- ast_log(LOG_WARNING, "%s already has PBX structure??\n", c->name);
+ ast_log(LOG_WARNING, "%s already has PBX structure??\n", ast_channel_name(c));
/* XXX and now what ? */
ast_free(c->pbx);
}
@@ -5121,7 +5121,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
if (ast_strlen_zero(c->exten)) {
/* If not successful fall back to 's' - but only if there is no given exten */
- ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", c->name, c->context, c->exten, c->priority);
+ ast_verb(2, "Starting %s at %s,%s,%d failed so falling back to exten 's'\n", ast_channel_name(c), c->context, c->exten, c->priority);
/* XXX the original code used the existing priority in the call to
* ast_exists_extension(), and reset it to 1 afterwards.
* I believe the correct thing is to set it to 1 immediately.
@@ -5190,8 +5190,8 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
dst_exten[pos++] = digit = res;
dst_exten[pos] = '\0';
} else if (res == AST_PBX_INCOMPLETE) {
- ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, c->name);
- ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, c->name);
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited INCOMPLETE on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
/* Don't cycle on incomplete - this will happen if the only extension that matches is our "incomplete" extension */
if (!ast_matchmore_extension(c, c->context, c->exten, 1,
@@ -5203,15 +5203,15 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
pos = strlen(dst_exten);
}
} else {
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
if ((res == AST_PBX_ERROR)
&& ast_exists_extension(c, c->context, "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
/* if we are already on the 'e' exten, don't jump to it again */
if (!strcmp(c->exten, "e")) {
- ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", c->context, c->exten, c->priority, c->name);
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited ERROR while already on 'e' exten on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
error = 1;
} else {
raise_exception(c, "ERROR", 1);
@@ -5268,7 +5268,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
*/
if (ast_exists_extension(c, c->context, "i", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
- ast_verb(3, "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, c->name);
+ ast_verb(3, "Sent into invalid extension '%s' in context '%s' on %s\n", c->exten, c->context, ast_channel_name(c));
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", c->exten);
set_ext_pri(c, "i", 1);
} else if (ast_exists_extension(c, c->context, "e", 1,
@@ -5276,7 +5276,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
raise_exception(c, "INVALID", 1);
} else {
ast_log(LOG_WARNING, "Channel '%s' sent into invalid extension '%s' in context '%s', but no invalid handler\n",
- c->name, c->exten, c->context);
+ ast_channel_name(c), c->exten, c->context);
error = 1; /* we know what to do with it */
break;
}
@@ -5293,7 +5293,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
const char *status = pbx_builtin_getvar_helper(c, "DIALSTATUS");
if (!status)
status = "UNKNOWN";
- ast_verb(3, "Auto fallthrough, channel '%s' status is '%s'\n", c->name, status);
+ ast_verb(3, "Auto fallthrough, channel '%s' status is '%s'\n", ast_channel_name(c), status);
if (!strcasecmp(status, "CONGESTION"))
res = pbx_builtin_congestion(c, "10");
else if (!strcasecmp(status, "CHANUNAVAIL"))
@@ -5318,7 +5318,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
/* An invalid extension */
if (ast_exists_extension(c, c->context, "i", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
- ast_verb(3, "Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->context, c->name);
+ ast_verb(3, "Invalid extension '%s' in context '%s' on %s\n", dst_exten, c->context, ast_channel_name(c));
pbx_builtin_setvar_helper(c, "INVALID_EXTEN", dst_exten);
set_ext_pri(c, "i", 1);
} else if (ast_exists_extension(c, c->context, "e", 1,
@@ -5335,7 +5335,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
/* A simple timeout */
if (ast_exists_extension(c, c->context, "t", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
- ast_verb(3, "Timeout on %s\n", c->name);
+ ast_verb(3, "Timeout on %s\n", ast_channel_name(c));
set_ext_pri(c, "t", 1);
} else if (ast_exists_extension(c, c->context, "e", 1,
S_COR(c->caller.id.number.valid, c->caller.id.number.str, NULL))) {
@@ -5351,7 +5351,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
ast_channel_lock(c);
if (c->cdr) {
- ast_verb(2, "CDR updated on %s\n",c->name);
+ ast_verb(2, "CDR updated on %s\n",ast_channel_name(c));
ast_cdr_update(c);
}
ast_channel_unlock(c);
@@ -5359,7 +5359,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
if (!found && !error) {
- ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", c->name);
+ ast_log(LOG_WARNING, "Don't know what to do with '%s'\n", ast_channel_name(c));
}
if (!args || !args->no_hangup_chan) {
@@ -5381,8 +5381,8 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
if (found && res) {
/* Something bad happened, or a hangup has been requested. */
- ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
- ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, c->name);
+ ast_debug(1, "Spawn extension (%s,%s,%d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
+ ast_verb(2, "Spawn extension (%s, %s, %d) exited non-zero on '%s'\n", c->context, c->exten, c->priority, ast_channel_name(c));
}
}
ast_set2_flag(c, autoloopflag, AST_FLAG_IN_AUTOLOOP);
@@ -5414,14 +5414,14 @@ static int increase_call_count(const struct ast_channel *c)
ast_mutex_lock(&maxcalllock);
if (option_maxcalls) {
if (countcalls >= option_maxcalls) {
- ast_log(LOG_WARNING, "Maximum call limit of %d calls exceeded by '%s'!\n", option_maxcalls, c->name);
+ ast_log(LOG_WARNING, "Maximum call limit of %d calls exceeded by '%s'!\n", option_maxcalls, ast_channel_name(c));
failed = -1;
}
}
if (option_maxload) {
getloadavg(&curloadavg, 1);
if (curloadavg >= option_maxload) {
- ast_log(LOG_WARNING, "Maximum loadavg limit of %f load exceeded by '%s' (currently %f)!\n", option_maxload, c->name, curloadavg);
+ ast_log(LOG_WARNING, "Maximum loadavg limit of %f load exceeded by '%s' (currently %f)!\n", option_maxload, ast_channel_name(c), curloadavg);
failed = -1;
}
}
@@ -8339,7 +8339,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
tmpvars.exten = ast_strdupa(chan->exten);
tmpvars.context = ast_strdupa(chan->context);
tmpvars.linkedid = ast_strdupa(chan->linkedid);
- tmpvars.name = ast_strdupa(chan->name);
+ tmpvars.name = ast_strdupa(ast_channel_name(chan));
tmpvars.amaflags = chan->amaflags;
tmpvars.state = chan->_state;
ast_format_copy(&tmpvars.writeformat, &chan->writeformat);
@@ -8380,7 +8380,7 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
ast_do_masquerade(tmpchan);
/* Start the PBX going on our stolen channel */
if (ast_pbx_start(tmpchan)) {
- ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name);
+ ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmpchan));
ast_hangup(tmpchan);
res = -1;
}
@@ -8877,7 +8877,7 @@ static void *async_wait(void *data)
if (!ast_strlen_zero(as->app)) {
app = pbx_findapp(as->app);
if (app) {
- ast_verb(3, "Launching %s(%s) on %s\n", as->app, as->appdata, chan->name);
+ ast_verb(3, "Launching %s(%s) on %s\n", as->app, as->appdata, ast_channel_name(chan));
pbx_exec(chan, app, as->appdata);
} else
ast_log(LOG_WARNING, "No such application '%s'\n", as->app);
@@ -8890,7 +8890,7 @@ static void *async_wait(void *data)
chan->priority = as->priority;
/* Run the PBX */
if (ast_pbx_run(chan)) {
- ast_log(LOG_ERROR, "Failed to start PBX on %s\n", chan->name);
+ ast_log(LOG_ERROR, "Failed to start PBX on %s\n", ast_channel_name(chan));
} else {
/* PBX will have taken care of this */
chan = NULL;
@@ -8960,13 +8960,13 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *d
if (chan) {
if (chan->_state == AST_STATE_UP) {
res = 0;
- ast_verb(4, "Channel %s was answered.\n", chan->name);
+ ast_verb(4, "Channel %s was answered.\n", ast_channel_name(chan));
if (synchronous > 1) {
if (channel)
ast_channel_unlock(chan);
if (ast_pbx_run(chan)) {
- ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name);
+ ast_log(LOG_ERROR, "Unable to run PBX on %s\n", ast_channel_name(chan));
if (channel)
*channel = NULL;
ast_hangup(chan);
@@ -8975,7 +8975,7 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *d
}
} else {
if (ast_pbx_start(chan)) {
- ast_log(LOG_ERROR, "Unable to start PBX on %s\n", chan->name);
+ ast_log(LOG_ERROR, "Unable to start PBX on %s\n", ast_channel_name(chan));
if (channel) {
*channel = NULL;
ast_channel_unlock(chan);
@@ -8986,7 +8986,7 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *d
chan = NULL;
}
} else {
- ast_verb(4, "Channel %s was never answered.\n", chan->name);
+ ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(chan));
if (chan->cdr) { /* update the cdr */
/* here we update the status of the call, which sould be busy.
@@ -9029,7 +9029,7 @@ int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, void *d
if (account)
ast_cdr_setaccount(chan, account);
if (ast_pbx_run(chan)) {
- ast_log(LOG_ERROR, "Unable to run PBX on %s\n", chan->name);
+ ast_log(LOG_ERROR, "Unable to run PBX on %s\n", ast_channel_name(chan));
ast_hangup(chan);
}
chan = NULL;
@@ -9093,7 +9093,7 @@ static void *ast_pbx_run_app(void *data)
struct ast_app *app;
app = pbx_findapp(tmp->app);
if (app) {
- ast_verb(4, "Launching %s(%s) on %s\n", tmp->app, tmp->data, tmp->chan->name);
+ ast_verb(4, "Launching %s(%s) on %s\n", tmp->app, tmp->data, ast_channel_name(tmp->chan));
pbx_exec(tmp->chan, app, tmp->data);
} else
ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app);
@@ -9128,7 +9128,7 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, void *dat
ast_cdr_setaccount(chan, account);
if (chan->_state == AST_STATE_UP) {
res = 0;
- ast_verb(4, "Channel %s was answered.\n", chan->name);
+ ast_verb(4, "Channel %s was answered.\n", ast_channel_name(chan));
tmp = ast_calloc(1, sizeof(*tmp));
if (!tmp || ast_string_field_init(tmp, 252)) {
if (tmp) {
@@ -9147,7 +9147,7 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, void *dat
if (locked_channel)
ast_channel_lock(chan);
if (ast_pthread_create_detached(&tmp->t, NULL, ast_pbx_run_app, tmp)) {
- ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
+ ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", ast_channel_name(chan), strerror(errno));
ast_string_field_free_memory(tmp);
ast_free(tmp);
if (locked_channel)
@@ -9161,7 +9161,7 @@ int ast_pbx_outgoing_app(const char *type, struct ast_format_cap *cap, void *dat
}
}
} else {
- ast_verb(4, "Channel %s was never answered.\n", chan->name);
+ ast_verb(4, "Channel %s was never answered.\n", ast_channel_name(chan));
if (chan->cdr) { /* update the cdr */
/* here we update the status of the call, which sould be busy.
* if that fails then we set the status to failed */
@@ -9850,10 +9850,10 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, const char *data)
res = -1;
} else if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
- ast_verb(3, "Timeout on %s, continuing...\n", chan->name);
+ ast_verb(3, "Timeout on %s, continuing...\n", ast_channel_name(chan));
} else if (ast_exists_extension(chan, chan->context, "t", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
- ast_verb(3, "Timeout on %s, going to 't'\n", chan->name);
+ ast_verb(3, "Timeout on %s, going to 't'\n", ast_channel_name(chan));
set_ext_pri(chan, "t", 0); /* 0 will become 1, next time through the loop */
} else if (ast_exists_extension(chan, chan->context, "e", 1,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL))) {
@@ -9938,7 +9938,7 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
/* Stream the list of files */
while (!res && (front = strsep(&back, "&")) ) {
if ( (res = ast_streamfile(chan, front, args.lang)) ) {
- ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char*)data);
+ ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", ast_channel_name(chan), (char*)data);
res = 0;
mres = 1;
break;
@@ -10150,7 +10150,7 @@ int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const
"Variable: %s\r\n"
"Value: %s\r\n"
"Uniqueid: %s\r\n",
- chan ? chan->name : "none", name, value,
+ chan ? ast_channel_name(chan) : "none", name, value,
chan ? chan->uniqueid : "none");
}
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 4f28bb9da..c5540b168 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -807,13 +807,13 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
/* Start locally bridging both instances */
if (instance0->engine->local_bridge && instance0->engine->local_bridge(instance0, instance1)) {
- ast_debug(1, "Failed to locally bridge %s to %s, backing out.\n", c0->name, c1->name);
+ ast_debug(1, "Failed to locally bridge %s to %s, backing out.\n", ast_channel_name(c0), ast_channel_name(c1));
ast_channel_unlock(c0);
ast_channel_unlock(c1);
return AST_BRIDGE_FAILED_NOWARN;
}
if (instance1->engine->local_bridge && instance1->engine->local_bridge(instance1, instance0)) {
- ast_debug(1, "Failed to locally bridge %s to %s, backing out.\n", c1->name, c0->name);
+ ast_debug(1, "Failed to locally bridge %s to %s, backing out.\n", ast_channel_name(c1), ast_channel_name(c0));
if (instance0->engine->local_bridge) {
instance0->engine->local_bridge(instance0, NULL);
}
@@ -929,7 +929,7 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
} else {
*fo = fr;
*rc = who;
- ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name);
+ ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, ast_channel_name(who));
res = AST_BRIDGE_COMPLETE;
break;
}
@@ -1011,7 +1011,7 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
ast_rtp_instance_get_remote_address(tinstance1, &tac1);
}
} else {
- ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", ast_channel_name(c0), ast_channel_name(c1));
}
/* Test the second channel */
@@ -1024,7 +1024,7 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
ast_rtp_instance_get_remote_address(instance0, &tac0);
}
} else {
- ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c1->name, c0->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", ast_channel_name(c1), ast_channel_name(c0));
}
ast_channel_unlock(c0);
@@ -1082,29 +1082,29 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
(!ast_format_cap_identical(cap1, oldcap1))) {
char tmp_buf[512] = { 0, };
ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n",
- c1->name, ast_sockaddr_stringify(&t1),
+ ast_channel_name(c1), ast_sockaddr_stringify(&t1),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), cap1));
ast_debug(1, "Oooh, '%s' changed end vaddress to %s (format %s)\n",
- c1->name, ast_sockaddr_stringify(&vt1),
+ ast_channel_name(c1), ast_sockaddr_stringify(&vt1),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), cap1));
ast_debug(1, "Oooh, '%s' changed end taddress to %s (format %s)\n",
- c1->name, ast_sockaddr_stringify(&tt1),
+ ast_channel_name(c1), ast_sockaddr_stringify(&tt1),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), cap1));
ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
- c1->name, ast_sockaddr_stringify(&ac1),
+ ast_channel_name(c1), ast_sockaddr_stringify(&ac1),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), oldcap1));
ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
- c1->name, ast_sockaddr_stringify(&vac1),
+ ast_channel_name(c1), ast_sockaddr_stringify(&vac1),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), oldcap1));
ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
- c1->name, ast_sockaddr_stringify(&tac1),
+ ast_channel_name(c1), ast_sockaddr_stringify(&tac1),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), oldcap1));
if (glue0->update_peer(c0,
ast_sockaddr_isnull(&t1) ? NULL : instance1,
ast_sockaddr_isnull(&vt1) ? NULL : vinstance1,
ast_sockaddr_isnull(&tt1) ? NULL : tinstance1,
cap1, 0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", ast_channel_name(c0), ast_channel_name(c1));
}
ast_sockaddr_copy(&ac1, &t1);
ast_sockaddr_copy(&vac1, &vt1);
@@ -1117,16 +1117,16 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
(!ast_format_cap_identical(cap0, oldcap0))) {
char tmp_buf[512] = { 0, };
ast_debug(1, "Oooh, '%s' changed end address to %s (format %s)\n",
- c0->name, ast_sockaddr_stringify(&t0),
+ ast_channel_name(c0), ast_sockaddr_stringify(&t0),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), cap0));
ast_debug(1, "Oooh, '%s' was %s/(format %s)\n",
- c0->name, ast_sockaddr_stringify(&ac0),
+ ast_channel_name(c0), ast_sockaddr_stringify(&ac0),
ast_getformatname_multiple(tmp_buf, sizeof(tmp_buf), oldcap0));
if (glue1->update_peer(c1, t0.len ? instance0 : NULL,
vt0.len ? vinstance0 : NULL,
tt0.len ? tinstance0 : NULL,
cap0, 0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", ast_channel_name(c1), ast_channel_name(c0));
}
ast_sockaddr_copy(&ac0, &t0);
ast_sockaddr_copy(&vac0, &vt0);
@@ -1218,7 +1218,7 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
} else {
*fo = fr;
*rc = who;
- ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, ast_channel_name(who));
res = AST_BRIDGE_COMPLETE;
goto remote_bridge_cleanup;
}
@@ -1242,22 +1242,22 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0,
}
if (ast_test_flag(c0, AST_FLAG_ZOMBIE)) {
- ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", c0->name);
+ ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c0));
} else if (c0->tech_pvt != pvt0) {
- ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", c0->name, c1->name);
+ ast_debug(1, "Channel c0->'%s' pvt changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1));
} else if (glue0 != ast_rtp_instance_get_glue(c0->tech->type)) {
- ast_debug(1, "Channel c0->'%s' technology changed, in bridge with c1->'%s'\n", c0->name, c1->name);
+ ast_debug(1, "Channel c0->'%s' technology changed, in bridge with c1->'%s'\n", ast_channel_name(c0), ast_channel_name(c1));
} else if (glue0->update_peer(c0, NULL, NULL, NULL, 0, 0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c0));
}
if (ast_test_flag(c1, AST_FLAG_ZOMBIE)) {
- ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", c1->name);
+ ast_debug(1, "Channel '%s' Zombie cleardown from bridge\n", ast_channel_name(c1));
} else if (c1->tech_pvt != pvt1) {
- ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", c1->name, c0->name);
+ ast_debug(1, "Channel c1->'%s' pvt changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0));
} else if (glue1 != ast_rtp_instance_get_glue(c1->tech->type)) {
- ast_debug(1, "Channel c1->'%s' technology changed, in bridge with c0->'%s'\n", c1->name, c0->name);
+ ast_debug(1, "Channel c1->'%s' technology changed, in bridge with c0->'%s'\n", ast_channel_name(c1), ast_channel_name(c0));
} else if (glue1->update_peer(c1, NULL, NULL, NULL, 0, 0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", ast_channel_name(c1));
}
instance0->bridged = NULL;
@@ -1313,13 +1313,13 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
/* Ensure neither channel got hungup during lock avoidance */
if (ast_check_hangup(c0) || ast_check_hangup(c1)) {
- ast_log(LOG_WARNING, "Got hangup while attempting to bridge '%s' and '%s'\n", c0->name, c1->name);
+ ast_log(LOG_WARNING, "Got hangup while attempting to bridge '%s' and '%s'\n", ast_channel_name(c0), ast_channel_name(c1));
goto done;
}
/* Grab glue that binds each channel to something using the RTP engine */
if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
- ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? c1->name : c0->name);
+ ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
goto done;
}
@@ -1396,10 +1396,10 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as
/* Depending on the end result for bridging either do a local bridge or remote bridge */
if (audio_glue0_res == AST_RTP_GLUE_RESULT_LOCAL || audio_glue1_res == AST_RTP_GLUE_RESULT_LOCAL) {
- ast_verb(3, "Locally bridging %s and %s\n", c0->name, c1->name);
+ ast_verb(3, "Locally bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
res = local_bridge_loop(c0, c1, instance0, instance1, timeoutms, flags, fo, rc, c0->tech_pvt, c1->tech_pvt);
} else {
- ast_verb(3, "Remotely bridging %s and %s\n", c0->name, c1->name);
+ ast_verb(3, "Remotely bridging %s and %s\n", ast_channel_name(c0), ast_channel_name(c1));
res = remote_bridge_loop(c0, c1, instance0, instance1, vinstance0, vinstance1,
tinstance0, tinstance1, glue0, glue1, cap0, cap1, timeoutms, flags,
fo, rc, c0->tech_pvt, c1->tech_pvt);
@@ -1461,7 +1461,7 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc
/* Grab glue that binds each channel to something using the RTP engine */
if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
- ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? c1->name : c0->name);
+ ast_debug(1, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
goto done;
}
@@ -1521,7 +1521,7 @@ done:
unref_instance_cond(&tinstance1);
if (!res) {
- ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+ ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
}
}
@@ -1558,7 +1558,7 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1
/* Grab glue that binds each channel to something using the RTP engine */
if (!(glue0 = ast_rtp_instance_get_glue(c0->tech->type)) || !(glue1 = ast_rtp_instance_get_glue(c1->tech->type))) {
- ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? c1->name : c0->name);
+ ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
goto done;
}
@@ -1594,7 +1594,7 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1
/* Bridge media early */
if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+ ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
}
res = 0;
@@ -1614,7 +1614,7 @@ done:
unref_instance_cond(&tinstance1);
if (!res) {
- ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", c0->name, c1 ? c1->name : "<unspecified>");
+ ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
}
return res;
diff --git a/main/say.c b/main/say.c
index f5d8f8bd9..dbeb8ba9c 100644
--- a/main/say.c
+++ b/main/say.c
@@ -434,7 +434,7 @@ static int wait_file(struct ast_channel *chan, const char *ints, const char *fil
\note Called from AGI */
static int say_number_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
- ast_test_suite_event_notify("SAYNUM", "Message: saying number %d\r\nNumber: %d\r\nChannel: %s", num, num, chan->name);
+ ast_test_suite_event_notify("SAYNUM", "Message: saying number %d\r\nNumber: %d\r\nChannel: %s", num, num, ast_channel_name(chan));
if (!strncasecmp(language, "en_GB", 5)) { /* British syntax */
return ast_say_number_full_en_GB(chan, num, ints, language, audiofd, ctrlfd);
} else if (!strncasecmp(language, "en", 2)) { /* English syntax */
diff --git a/main/udptl.c b/main/udptl.c
index 3fc5b5b9e..943cd286a 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1158,13 +1158,13 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
pr0 = get_proto(c0);
pr1 = get_proto(c1);
if (!pr0) {
- ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name);
+ ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", ast_channel_name(c0));
ast_channel_unlock(c0);
ast_channel_unlock(c1);
return -1;
}
if (!pr1) {
- ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name);
+ ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", ast_channel_name(c1));
ast_channel_unlock(c0);
ast_channel_unlock(c1);
return -1;
@@ -1180,14 +1180,14 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
return -2;
}
if (pr0->set_udptl_peer(c0, p1)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", ast_channel_name(c0), ast_channel_name(c1));
memset(&ac1, 0, sizeof(ac1));
} else {
/* Store UDPTL peer */
ast_udptl_get_peer(p1, &ac1);
}
if (pr1->set_udptl_peer(c1, p0)) {
- ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name);
+ ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", ast_channel_name(c1), ast_channel_name(c0));
memset(&ac0, 0, sizeof(ac0));
} else {
/* Store UDPTL peer */
@@ -1211,16 +1211,16 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
ast_udptl_get_peer(p0, &t0);
if (ast_sockaddr_cmp(&t1, &ac1)) {
ast_debug(1, "Oooh, '%s' changed end address to %s\n",
- c1->name, ast_sockaddr_stringify(&t1));
+ ast_channel_name(c1), ast_sockaddr_stringify(&t1));
ast_debug(1, "Oooh, '%s' was %s\n",
- c1->name, ast_sockaddr_stringify(&ac1));
+ ast_channel_name(c1), ast_sockaddr_stringify(&ac1));
ast_sockaddr_copy(&ac1, &t1);
}
if (ast_sockaddr_cmp(&t0, &ac0)) {
ast_debug(1, "Oooh, '%s' changed end address to %s\n",
- c0->name, ast_sockaddr_stringify(&t0));
+ ast_channel_name(c0), ast_sockaddr_stringify(&t0));
ast_debug(1, "Oooh, '%s' was %s\n",
- c0->name, ast_sockaddr_stringify(&ac0));
+ ast_channel_name(c0), ast_sockaddr_stringify(&ac0));
ast_sockaddr_copy(&ac0, &t0);
}
who = ast_waitfor_n(cs, 2, &to);