summaryrefslogtreecommitdiff
path: root/channels/chan_phone.c
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 /channels/chan_phone.c
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 'channels/chan_phone.c')
-rw-r--r--channels/chan_phone.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 6acb7a184..1281f149a 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -204,7 +204,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
{
struct phone_pvt *p = chan->tech_pvt;
int res=-1;
- ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, ast_channel_name(chan));
switch(condition) {
case AST_CONTROL_FLASH:
ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
@@ -223,7 +223,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
res = 0;
break;
default:
- ast_log(LOG_WARNING, "Condition %d is not supported on channel %s\n", condition, chan->name);
+ ast_log(LOG_WARNING, "Condition %d is not supported on channel %s\n", condition, ast_channel_name(chan));
}
return res;
}
@@ -315,10 +315,10 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
p = ast->tech_pvt;
if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
- ast_log(LOG_WARNING, "phone_call called on %s, neither down nor reserved\n", ast->name);
+ ast_log(LOG_WARNING, "phone_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
return -1;
}
- ast_debug(1, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
+ ast_debug(1, "Ringing %s on %s (%d)\n", dest, ast_channel_name(ast), ast->fds[0]);
start = IXJ_PHONE_RING_START(cid);
if (start == -1)
@@ -343,7 +343,7 @@ static int phone_hangup(struct ast_channel *ast)
{
struct phone_pvt *p;
p = ast->tech_pvt;
- ast_debug(1, "phone_hangup(%s)\n", ast->name);
+ ast_debug(1, "phone_hangup(%s)\n", ast_channel_name(ast));
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -362,7 +362,7 @@ static int phone_hangup(struct ast_channel *ast)
/* If it's an FXO, hang them up */
if (p->mode == MODE_FXO) {
if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
- ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast_channel_name(ast), strerror(errno));
}
/* If they're off hook, give a busy signal */
@@ -379,7 +379,7 @@ static int phone_hangup(struct ast_channel *ast)
memset(p->ext, 0, sizeof(p->ext));
((struct phone_pvt *)(ast->tech_pvt))->owner = NULL;
ast_module_unref(ast_module_info->self);
- ast_verb(3, "Hungup '%s'\n", ast->name);
+ ast_verb(3, "Hungup '%s'\n", ast_channel_name(ast));
ast->tech_pvt = NULL;
ast_setstate(ast, AST_STATE_DOWN);
restart_monitor();
@@ -460,12 +460,12 @@ static int phone_answer(struct ast_channel *ast)
/* In case it's a LineJack, take it off hook */
if (p->mode == MODE_FXO) {
if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK))
- ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast_channel_name(ast), strerror(errno));
else
ast_debug(1, "Took linejack off hook\n");
}
phone_setup(ast);
- ast_debug(1, "phone_answer(%s)\n", ast->name);
+ ast_debug(1, "phone_answer(%s)\n", ast_channel_name(ast));
ast->rings = 0;
ast_setstate(ast, AST_STATE_UP);
return 0;
@@ -897,7 +897,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx,
i->cpt = 1;
}
if (ast_pbx_start(tmp)) {
- ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
+ ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
ast_hangup(tmp);
}
}