summaryrefslogtreecommitdiff
path: root/channels/chan_nbs.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_nbs.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_nbs.c')
-rw-r--r--channels/chan_nbs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 3ff97dde7..d9885c14e 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -90,16 +90,16 @@ static int nbs_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, "nbs_call called on %s, neither down nor reserved\n", ast->name);
+ ast_log(LOG_WARNING, "nbs_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
return -1;
}
/* When we call, it just works, really, there's no destination... Just
ring the phone and wait for someone to answer */
- ast_debug(1, "Calling %s on %s\n", dest, ast->name);
+ ast_debug(1, "Calling %s on %s\n", dest, ast_channel_name(ast));
/* If we can't connect, return congestion */
if (nbs_connect(p->nbs)) {
- ast_log(LOG_WARNING, "NBS Connection failed on %s\n", ast->name);
+ ast_log(LOG_WARNING, "NBS Connection failed on %s\n", ast_channel_name(ast));
ast_queue_control(ast, AST_CONTROL_CONGESTION);
} else {
ast_setstate(ast, AST_STATE_RINGING);
@@ -165,7 +165,7 @@ static int nbs_hangup(struct ast_channel *ast)
{
struct nbs_pvt *p;
p = ast->tech_pvt;
- ast_debug(1, "nbs_hangup(%s)\n", ast->name);
+ ast_debug(1, "nbs_hangup(%s)\n", ast_channel_name(ast));
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -191,7 +191,7 @@ static struct ast_frame *nbs_xread(struct ast_channel *ast)
p->fr.delivery.tv_sec = 0;
p->fr.delivery.tv_usec = 0;
- ast_debug(1, "Returning null frame on %s\n", ast->name);
+ ast_debug(1, "Returning null frame on %s\n", ast_channel_name(ast));
return &p->fr;
}
@@ -241,7 +241,7 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state, const char *lin
i->u = ast_module_user_add(tmp);
if (state != AST_STATE_DOWN) {
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);
}
}