summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/chan_ooh323.c2
-rw-r--r--apps/app_dahdibarge.c10
-rw-r--r--apps/app_dahdiras.c10
-rw-r--r--apps/app_directed_pickup.c2
-rw-r--r--apps/app_dumpchan.c6
-rw-r--r--apps/app_flash.c6
-rw-r--r--apps/app_meetme.c12
-rw-r--r--apps/app_queue.c2
-rw-r--r--channels/chan_agent.c9
-rw-r--r--channels/chan_dahdi.c34
-rw-r--r--channels/chan_gtalk.c4
-rw-r--r--channels/chan_h323.c6
-rw-r--r--channels/chan_iax2.c4
-rw-r--r--channels/chan_jingle.c4
-rw-r--r--channels/chan_mgcp.c6
-rw-r--r--channels/chan_misdn.c4
-rw-r--r--channels/chan_phone.c4
-rw-r--r--channels/chan_sip.c6
-rw-r--r--channels/chan_skinny.c4
-rw-r--r--channels/chan_unistim.c24
-rw-r--r--channels/chan_vpb.cc4
-rw-r--r--channels/console_video.c6
-rw-r--r--channels/sig_analog.c2
-rw-r--r--channels/sig_pri.c26
-rw-r--r--channels/sig_ss7.c2
-rw-r--r--funcs/func_channel.c8
-rw-r--r--include/asterisk/channel.h60
-rw-r--r--main/autoservice.c2
-rw-r--r--main/channel.c182
-rw-r--r--main/channel_internal_api.c207
-rw-r--r--main/cli.c4
-rw-r--r--main/dsp.c2
-rw-r--r--main/features.c12
-rw-r--r--main/file.c2
-rw-r--r--main/pbx.c12
-rw-r--r--res/snmp/agent.c4
36 files changed, 434 insertions, 260 deletions
diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c
index dc465f095..129a916fa 100644
--- a/addons/chan_ooh323.c
+++ b/addons/chan_ooh323.c
@@ -2155,7 +2155,7 @@ int onCallCleared(ooCallData *call)
ast_set_flag(p, H323_ALREADYGONE);
ast_channel_hangupcause_set(p->owner, call->q931cause);
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
ast_queue_hangup_with_cause(p->owner,call->q931cause);
}
}
diff --git a/apps/app_dahdibarge.c b/apps/app_dahdibarge.c
index 4fde46687..cc05a63f8 100644
--- a/apps/app_dahdibarge.c
+++ b/apps/app_dahdibarge.c
@@ -129,7 +129,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
ast_indicate(chan, -1);
retrydahdi = strcasecmp(ast_channel_tech(chan)->type, "DAHDI");
dahdiretry:
- origfd = chan->fds[0];
+ origfd = ast_channel_fd(chan, 0);
if (retrydahdi) {
fd = open("/dev/dahdi/pseudo", O_RDWR);
if (fd < 0) {
@@ -162,7 +162,7 @@ dahdiretry:
nfds = 1;
} else {
/* XXX Make sure we're not running on a pseudo channel XXX */
- fd = chan->fds[0];
+ fd = ast_channel_fd(chan, 0);
nfds = 0;
}
memset(&dahdic, 0, sizeof(dahdic));
@@ -199,7 +199,7 @@ dahdiretry:
ms = -1;
c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
if (c) {
- if (c->fds[0] != origfd) {
+ if (ast_channel_fd(c, 0) != origfd) {
if (retrydahdi) {
/* Kill old pseudo */
close(fd);
@@ -215,7 +215,7 @@ dahdiretry:
ret = 0;
ast_frfree(f);
break;
- } else if (fd != chan->fds[0]) {
+ } else if (fd != ast_channel_fd(chan, 0)) {
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass.format.id == AST_FORMAT_ULAW) {
/* Carefully write */
@@ -243,7 +243,7 @@ dahdiretry:
ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno));
}
}
- if (fd != chan->fds[0])
+ if (fd != ast_channel_fd(chan, 0))
close(fd);
else {
/* Take out of conference */
diff --git a/apps/app_dahdiras.c b/apps/app_dahdiras.c
index e6b080f81..3724f0375 100644
--- a/apps/app_dahdiras.c
+++ b/apps/app_dahdiras.c
@@ -95,7 +95,7 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
}
/* Execute RAS on File handles */
- dup2(chan->fds[0], STDIN_FILENO);
+ dup2(ast_channel_fd(chan, 0), STDIN_FILENO);
/* Drop high priority */
if (ast_opt_high_priority)
@@ -139,7 +139,7 @@ static void run_ras(struct ast_channel *chan, char *args)
struct dahdi_bufferinfo savebi;
int x;
- res = ioctl(chan->fds[0], DAHDI_GET_BUFINFO, &savebi);
+ res = ioctl(ast_channel_fd(chan, 0), DAHDI_GET_BUFINFO, &savebi);
if(res) {
ast_log(LOG_WARNING, "Unable to check buffer policy on channel %s\n", ast_channel_name(chan));
return;
@@ -175,10 +175,10 @@ static void run_ras(struct ast_channel *chan, char *args)
}
/* Throw back into audio mode */
x = 1;
- ioctl(chan->fds[0], DAHDI_AUDIOMODE, &x);
+ ioctl(ast_channel_fd(chan, 0), DAHDI_AUDIOMODE, &x);
/* Restore saved values */
- res = ioctl(chan->fds[0], DAHDI_SET_BUFINFO, &savebi);
+ res = ioctl(ast_channel_fd(chan, 0), DAHDI_SET_BUFINFO, &savebi);
if (res < 0) {
ast_log(LOG_WARNING, "Unable to set buffer policy on channel %s\n", ast_channel_name(chan));
}
@@ -209,7 +209,7 @@ static int dahdiras_exec(struct ast_channel *chan, const char *data)
sleep(2);
} else {
memset(&dahdip, 0, sizeof(dahdip));
- if (ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip)) {
+ if (ioctl(ast_channel_fd(chan, 0), DAHDI_GET_PARAMS, &dahdip)) {
ast_log(LOG_WARNING, "Unable to get DAHDI parameters\n");
} else if (dahdip.sigtype != DAHDI_SIG_CLEAR) {
ast_verb(2, "Channel %s is not a clear channel\n", ast_channel_name(chan));
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index acdb572e3..fe0f421f1 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -241,7 +241,7 @@ static int find_channel_by_group(void *obj, void *arg, void *data, int flags)
struct ast_channel *chan = data;/*!< Channel wanting to pickup call */
ast_channel_lock(target);
- if (chan != target && (chan->pickupgroup & target->callgroup)
+ if (chan != target && (ast_channel_pickupgroup(chan) & ast_channel_callgroup(target))
&& ast_can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index 42f889926..403c9e079 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -151,7 +151,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
ast_channel_readtrans(c) ? "Yes" : "No",
ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath),
- c->fds[0],
+ ast_channel_fd(c, 0),
ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
(long)ast_channel_whentohangup(c)->tv_sec,
@@ -163,8 +163,8 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
ast_channel_context(c),
ast_channel_exten(c),
ast_channel_priority(c),
- ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
- ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
+ ast_print_group(cgrp, sizeof(cgrp), ast_channel_callgroup(c)),
+ ast_print_group(pgrp, sizeof(pgrp), ast_channel_pickupgroup(c)),
ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)",
ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)",
(ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
diff --git a/apps/app_flash.c b/apps/app_flash.c
index 1ee834bbf..dbbad3332 100644
--- a/apps/app_flash.c
+++ b/apps/app_flash.c
@@ -85,15 +85,15 @@ static int flash_exec(struct ast_channel *chan, const char *data)
}
memset(&dahdip, 0, sizeof(dahdip));
- res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip);
+ res = ioctl(ast_channel_fd(chan, 0), DAHDI_GET_PARAMS, &dahdip);
if (!res) {
if (dahdip.sigtype & __DAHDI_SIG_FXS) {
x = DAHDI_FLASH;
- res = ioctl(chan->fds[0], DAHDI_HOOK, &x);
+ res = ioctl(ast_channel_fd(chan, 0), DAHDI_HOOK, &x);
if (!res || (errno == EINPROGRESS)) {
if (res) {
/* Wait for the event to finish */
- dahdi_wait_event(chan->fds[0]);
+ dahdi_wait_event(ast_channel_fd(chan, 0));
}
res = ast_safe_sleep(chan, 1000);
ast_verb(3, "Flashed channel %s\n", ast_channel_name(chan));
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 1eb10a593..8c4dc3d73 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -1286,7 +1286,7 @@ static struct ast_conference *build_conf(const char *confno, const char *pin,
dahdic.chan = 0;
dahdic.confno = cnf->dahdiconf;
dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
- if (ioctl(cnf->chan->fds[0], DAHDI_SETCONF, &dahdic)) {
+ if (ioctl(ast_channel_fd(cnf->chan, 0), DAHDI_SETCONF, &dahdic)) {
if (test) {
ast_test_status_update(test, "Error setting conference on pseudo channel\n");
}
@@ -2439,7 +2439,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
dahdic.chan = 0;
dahdic.confno = conf->dahdiconf;
dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
- if (ioctl(conf->lchan->fds[0], DAHDI_SETCONF, &dahdic)) {
+ if (ioctl(ast_channel_fd(conf->lchan, 0), DAHDI_SETCONF, &dahdic)) {
ast_log(LOG_WARNING, "Error starting listen channel\n");
ast_hangup(conf->lchan);
conf->lchan = NULL;
@@ -2681,7 +2681,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
user->dahdichannel = !retrydahdi;
dahdiretry:
- origfd = chan->fds[0];
+ origfd = ast_channel_fd(chan, 0);
if (retrydahdi) {
/* open pseudo in non-blocking mode */
fd = open("/dev/dahdi/pseudo", O_RDWR | O_NONBLOCK);
@@ -2710,7 +2710,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
nfds = 1;
} else {
/* XXX Make sure we're not running on a pseudo channel XXX */
- fd = chan->fds[0];
+ fd = ast_channel_fd(chan, 0);
nfds = 0;
}
memset(&dahdic, 0, sizeof(dahdic));
@@ -3218,7 +3218,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
if (c) {
char dtmfstr[2] = "";
- if (c->fds[0] != origfd || (user->dahdichannel && (ast_channel_audiohooks(c) || ast_channel_monitor(c)))) {
+ if (ast_channel_fd(c, 0) != origfd || (user->dahdichannel && (ast_channel_audiohooks(c) || ast_channel_monitor(c)))) {
if (using_pseudo) {
/* Kill old pseudo */
close(fd);
@@ -3420,7 +3420,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
dahdic.chan = 0;
dahdic.confno = conf->dahdiconf;
dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
- if (ioctl(conf->lchan->fds[0], DAHDI_SETCONF, &dahdic)) {
+ if (ioctl(ast_channel_fd(conf->lchan, 0), DAHDI_SETCONF, &dahdic)) {
ast_log(LOG_WARNING, "Error starting listen channel\n");
ast_hangup(conf->lchan);
conf->lchan = NULL;
diff --git a/apps/app_queue.c b/apps/app_queue.c
index ea2dd54e1..b863f902b 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -5191,7 +5191,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
struct ast_datastore *tds;
/* detect a blind transfer */
- if (!(qe->chan->_softhangup | peer->_softhangup) && (strcasecmp(oldcontext, ast_channel_context(qe->chan)) || strcasecmp(oldexten, ast_channel_exten(qe->chan)))) {
+ if (!(ast_channel_softhangup_internal_flag(qe->chan) | ast_channel_softhangup_internal_flag(peer)) && (strcasecmp(oldcontext, ast_channel_context(qe->chan)) || strcasecmp(oldexten, ast_channel_exten(qe->chan)))) {
ast_queue_log(queuename, ast_channel_uniqueid(qe->chan), member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d",
ast_channel_exten(qe->chan), ast_channel_context(qe->chan), (long) (callstart - qe->start),
(long) (time(NULL) - callstart), qe->opos);
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 3c8073b81..4ce43a5a3 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -321,11 +321,12 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (l
#define CLEANUP(ast, p) do { \
int x; \
if (p->chan) { \
- for (x=0;x<AST_MAX_FDS;x++) {\
- if (x != AST_TIMING_FD) \
- ast_channel_set_fd(ast, x, p->chan->fds[x]); \
+ for (x = 0; x < AST_MAX_FDS; x++) { \
+ if (x != AST_TIMING_FD) { \
+ ast_channel_set_fd(ast, x, ast_channel_fd(p->chan, x)); \
+ } \
} \
- ast_channel_set_fd(ast, AST_AGENT_FD, p->chan->fds[AST_TIMING_FD]); \
+ ast_channel_set_fd(ast, AST_AGENT_FD, ast_channel_fd(p->chan, AST_TIMING_FD)); \
} \
} while(0)
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index c160ae8f1..59d65e395 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -3078,7 +3078,7 @@ static void my_pri_fixup_chans(void *chan_old, void *chan_new)
old_chan->owner = NULL;
if (new_chan->owner) {
ast_channel_tech_pvt_set(new_chan->owner, new_chan);
- new_chan->owner->fds[0] = new_chan->subs[SUB_REAL].dfd;
+ ast_channel_fd_set(new_chan->owner, 0, new_chan->subs[SUB_REAL].dfd);
new_chan->subs[SUB_REAL].owner = old_chan->subs[SUB_REAL].owner;
old_chan->subs[SUB_REAL].owner = NULL;
}
@@ -3936,7 +3936,7 @@ static void dahdi_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_er
ast_log(LOG_ERROR, "MFC/R2 protocol error on chan %d: %s\n", openr2_chan_get_number(r2chan), openr2_proto_get_error(reason));
if (p->owner) {
ast_channel_hangupcause_set(p->owner, AST_CAUSE_PROTOCOL_ERROR);
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
}
ast_mutex_lock(&p->lock);
p->mfcr2call = 0;
@@ -4110,7 +4110,7 @@ static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disco
/* when we have an owner we don't call dahdi_r2_disconnect_call here, that will
be done in dahdi_hangup */
if (ast_channel_state(p->owner) == AST_STATE_UP) {
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
ast_mutex_unlock(&p->lock);
} else if (openr2_chan_get_direction(r2chan) == OR2_DIR_FORWARD) {
/* being the forward side we must report what happened to the call to whoever requested it */
@@ -4127,7 +4127,7 @@ static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disco
p->subs[SUB_REAL].needcongestion = 1;
break;
default:
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
}
ast_mutex_unlock(&p->lock);
} else {
@@ -7297,8 +7297,8 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
op0 = p0 = ast_channel_tech_pvt(c0);
op1 = p1 = ast_channel_tech_pvt(c1);
- ofd0 = c0->fds[0];
- ofd1 = c1->fds[0];
+ ofd0 = ast_channel_fd(c0, 0);
+ ofd1 = ast_channel_fd(c1, 0);
oc0 = p0->owner;
oc1 = p1->owner;
@@ -7503,8 +7503,8 @@ static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_ch
if (!timeoutms ||
(op0 != p0) ||
(op1 != p1) ||
- (ofd0 != c0->fds[0]) ||
- (ofd1 != c1->fds[0]) ||
+ (ofd0 != ast_channel_fd(c0, 0)) ||
+ (ofd1 != ast_channel_fd(c1, 0)) ||
(p0->subs[SUB_REAL].owner && (os0 > -1) && (os0 != ast_channel_state(p0->subs[SUB_REAL].owner))) ||
(p1->subs[SUB_REAL].owner && (os1 > -1) && (os1 != ast_channel_state(p1->subs[SUB_REAL].owner))) ||
(oc0 != p0->owner) ||
@@ -7730,7 +7730,7 @@ static int attempt_transfer(struct dahdi_pvt *p)
} else {
ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
ast_channel_name(p->subs[SUB_REAL].owner), ast_channel_name(p->subs[SUB_THREEWAY].owner));
- p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_set(p->subs[SUB_THREEWAY].owner, ast_channel_softhangup_internal_flag(p->subs[SUB_THREEWAY].owner) | AST_SOFTHANGUP_DEV);
return -1;
}
return 0;
@@ -8208,7 +8208,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
hanging up. Hangup both channels now */
if (p->subs[SUB_THREEWAY].owner)
ast_queue_hangup_with_cause(p->subs[SUB_THREEWAY].owner, AST_CAUSE_NO_ANSWER);
- p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
} else if ((ast_channel_pbx(ast)) || (ast_channel_state(ast) == AST_STATE_UP)) {
@@ -8226,7 +8226,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
dahdi_ring_phone(p);
} else {
if ((res = attempt_transfer(p)) < 0) {
- p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
if (p->subs[SUB_THREEWAY].owner)
ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
} else if (res) {
@@ -8237,7 +8237,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
}
}
} else {
- p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
if (p->subs[SUB_THREEWAY].owner)
ast_channel_unlock(p->subs[SUB_THREEWAY].owner);
}
@@ -8614,7 +8614,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
}
/* Drop the last call and stop the conference */
ast_verb(3, "Dropping three-way call on %s\n", ast_channel_name(p->subs[SUB_THREEWAY].owner));
- p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
p->subs[SUB_REAL].inthreeway = 0;
p->subs[SUB_THREEWAY].inthreeway = 0;
} else {
@@ -8640,7 +8640,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
} else {
ast_verb(3, "Dumping incomplete call on on %s\n", ast_channel_name(p->subs[SUB_THREEWAY].owner));
swap_subs(p, SUB_THREEWAY, SUB_REAL);
- p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
p->owner = p->subs[SUB_REAL].owner;
if (p->subs[SUB_REAL].owner && ast_bridged_channel(p->subs[SUB_REAL].owner))
ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
@@ -8895,7 +8895,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
return f;
}
if (!(p->radio || (p->oprmode < 0)))
- ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+ ast_debug(1, "Exception on %d, channel %d\n", ast_channel_fd(ast, 0), p->channel);
/* If it's not us, return NULL immediately */
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner));
@@ -9738,8 +9738,8 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
ast_channel_tech_pvt_set(tmp, i);
if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS)) {
/* Only FXO signalled stuff can be picked up */
- tmp->callgroup = i->callgroup;
- tmp->pickupgroup = i->pickupgroup;
+ ast_channel_callgroup_set(tmp, i->callgroup);
+ ast_channel_pickupgroup_set(tmp, i->pickupgroup);
}
if (!ast_strlen_zero(i->parkinglot))
ast_channel_parkinglot_set(tmp, i->parkinglot);
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index 1f967adb5..9e8425692 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -1176,8 +1176,8 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, i);
- tmp->callgroup = client->callgroup;
- tmp->pickupgroup = client->pickupgroup;
+ ast_channel_callgroup_set(tmp, client->callgroup);
+ ast_channel_pickupgroup_set(tmp, client->pickupgroup);
ast_channel_caller(tmp)->id.name.presentation = client->callingpres;
ast_channel_caller(tmp)->id.number.presentation = client->callingpres;
if (!ast_strlen_zero(client->accountcode))
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 49a5e2029..5feb1e740 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -352,7 +352,7 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
if (pvt->needhangup) {
if (h323debug)
ast_debug(1, "Process pending hangup for %s\n", ast_channel_name(c));
- c->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(c, AST_SOFTHANGUP_DEV);
ast_channel_hangupcause_set(c, pvt->hangupcause);
ast_queue_hangup_with_cause(c, pvt->hangupcause);
pvt->needhangup = 0;
@@ -2456,7 +2456,7 @@ static void cleanup_connection(unsigned call_reference, const char *call_token)
pvt->alreadygone = 1;
/* Send hangup */
if (pvt->owner) {
- pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pvt->owner, AST_SOFTHANGUP_DEV);
ast_queue_hangup(pvt->owner);
ast_channel_unlock(pvt->owner);
}
@@ -2480,7 +2480,7 @@ static void hangup_connection(unsigned int call_reference, const char *token, in
return;
}
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
- pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pvt->owner, AST_SOFTHANGUP_DEV);
ast_channel_hangupcause_set(pvt->owner, pvt->hangupcause = cause);
ast_queue_hangup_with_cause(pvt->owner, cause);
ast_channel_unlock(pvt->owner);
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index b0b041645..ff95cd73f 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -5547,8 +5547,8 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
if (ast_tvzero(waittimer)) {
waittimer = now;
} else if (now.tv_sec - waittimer.tv_sec > IAX_LINGER_TIMEOUT) {
- c0->_softhangup |= AST_SOFTHANGUP_DEV;
- c1->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(c0, AST_SOFTHANGUP_DEV);
+ ast_channel_softhangup_internal_flag_add(c1, AST_SOFTHANGUP_DEV);
*fo = NULL;
*rc = c0;
res = AST_BRIDGE_COMPLETE;
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 8a1bfdc1a..32c53bb5e 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -888,8 +888,8 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
ast_channel_tech_pvt_set(tmp, i);
- tmp->callgroup = client->callgroup;
- tmp->pickupgroup = client->pickupgroup;
+ ast_channel_callgroup_set(tmp, client->callgroup);
+ ast_channel_pickupgroup_set(tmp, client->pickupgroup);
ast_channel_caller(tmp)->id.name.presentation = client->callingpres;
ast_channel_caller(tmp)->id.number.presentation = client->callingpres;
if (!ast_strlen_zero(client->accountcode))
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index be8ecbf39..ae7acedfc 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -1531,8 +1531,8 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
ast_channel_amaflags_set(tmp, i->amaflags);
sub->owner = tmp;
ast_module_ref(ast_module_info->self);
- tmp->callgroup = i->callgroup;
- tmp->pickupgroup = i->pickupgroup;
+ ast_channel_callgroup_set(tmp, i->callgroup);
+ ast_channel_pickupgroup_set(tmp, i->pickupgroup);
ast_channel_call_forward_set(tmp, i->call_forward);
ast_channel_context_set(tmp, i->context);
ast_channel_exten_set(tmp, i->exten);
@@ -3258,7 +3258,7 @@ static int attempt_transfer(struct mgcp_endpoint *p)
} else {
ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
ast_channel_name(p->sub->owner), ast_channel_name(p->sub->next->owner));
- p->sub->next->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->sub->next->owner, AST_SOFTHANGUP_DEV);
if (p->sub->next->owner) {
p->sub->next->alreadygone = 1;
mgcp_queue_hangup(p->sub->next);
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 62aa020d2..de807774a 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -5983,8 +5983,8 @@ static int read_config(struct chan_list *ch)
misdn_cfg_get(port, MISDN_CFG_PICKUPGROUP, &pg, sizeof(pg));
misdn_cfg_get(port, MISDN_CFG_CALLGROUP, &cg, sizeof(cg));
chan_misdn_log(5, port, " --> * CallGrp:%s PickupGrp:%s\n", ast_print_group(buf, sizeof(buf), cg), ast_print_group(buf2, sizeof(buf2), pg));
- ast->pickupgroup = pg;
- ast->callgroup = cg;
+ ast_channel_pickupgroup_set(ast, pg);
+ ast_channel_callgroup_set(ast, cg);
if (ch->originator == ORG_AST) {
char callerid[BUFFERSIZE + 1];
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index c071793ac..6926a7d4f 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -318,7 +318,7 @@ static int phone_call(struct ast_channel *ast, const char *dest, int timeout)
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_channel_name(ast), ast->fds[0]);
+ ast_debug(1, "Ringing %s on %s (%d)\n", dest, ast_channel_name(ast), ast_channel_fd(ast, 0));
start = IXJ_PHONE_RING_START(cid);
if (start == -1)
@@ -893,7 +893,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx,
ast_module_ref(ast_module_info->self);
if (state != AST_STATE_DOWN) {
if (state == AST_STATE_RING) {
- ioctl(tmp->fds[0], PHONE_RINGBACK);
+ ioctl(ast_channel_fd(tmp, 0), PHONE_RINGBACK);
i->cpt = 1;
}
if (ast_pbx_start(tmp)) {
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index b3bb4eb55..961c7f4de 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -5845,7 +5845,7 @@ void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
ast_debug(1, "Detaching from %s\n", ast_channel_name(p->owner));
ast_channel_tech_pvt_set(p->owner, NULL);
/* Make sure that the channel knows its backend is going away */
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
if (lockowner)
ast_channel_unlock(p->owner);
/* Give the channel a chance to react before deallocation */
@@ -7240,8 +7240,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i"));
- tmp->callgroup = i->callgroup;
- tmp->pickupgroup = i->pickupgroup;
+ ast_channel_callgroup_set(tmp, i->callgroup);
+ ast_channel_pickupgroup_set(tmp, i->pickupgroup);
ast_channel_caller(tmp)->id.name.presentation = i->callingpres;
ast_channel_caller(tmp)->id.number.presentation = i->callingpres;
if (!ast_strlen_zero(i->parkinglot)) {
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index cfa63eea5..0323237e3 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -4915,8 +4915,8 @@ static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subli
ast_channel_amaflags_set(tmp, l->amaflags);
ast_module_ref(ast_module_info->self);
- tmp->callgroup = l->callgroup;
- tmp->pickupgroup = l->pickupgroup;
+ ast_channel_callgroup_set(tmp, l->callgroup);
+ ast_channel_pickupgroup_set(tmp, l->pickupgroup);
/* XXX Need to figure out how to handle CFwdNoAnswer */
if (l->cfwdtype & SKINNY_CFWD_ALL) {
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index caee08670..fcde6e635 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -1916,13 +1916,13 @@ static void swap_subs(struct unistim_line *p, int a, int b)
p->subs[a]->rtp = p->subs[b]->rtp;
p->subs[b]->rtp = rtp;
- fds = p->subs[a]->owner->fds[0];
- p->subs[a]->owner->fds[0] = p->subs[b]->owner->fds[0];
- p->subs[b]->owner->fds[0] = fds;
+ fds = ast_channel_fd(p->subs[a]->owner, 0);
+ ast_channel_internal_fd_set(p->subs[a]->owner, 0, ast_channel_fd(p->subs[b]->owner, 0));
+ ast_channel_internal_fd_set(p->subs[b]->owner, 0, fds);
- fds = p->subs[a]->owner->fds[1];
- p->subs[a]->owner->fds[1] = p->subs[b]->owner->fds[1];
- p->subs[b]->owner->fds[1] = fds;
+ fds = ast_channel_fd(p->subs[a]->owner, 1);
+ ast_channel_internal_fd_set(p->subs[a]->owner, 1, ast_channel_fd(p->subs[b]->owner, 1));
+ ast_channel_internal_fd_set(p->subs[b]->owner, 1, fds);
}
static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
@@ -2113,8 +2113,8 @@ static void start_rtp(struct unistim_subchannel *sub)
}
ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
if (sub->owner) {
- sub->owner->fds[0] = ast_rtp_instance_fd(sub->rtp, 0);
- sub->owner->fds[1] = ast_rtp_instance_fd(sub->rtp, 1);
+ ast_channel_internal_fd_set(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
+ ast_channel_internal_fd_set(sub->owner, 1, ast_rtp_instance_fd(sub->rtp, 1));
}
ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "UNISTIM RTP");
ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, sub->parent->parent->nat);
@@ -4575,8 +4575,8 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
if ((sub->rtp) && (sub->subtype == 0)) {
if (unistimdebug)
ast_verb(0, "New unistim channel with a previous rtp handle ?\n");
- tmp->fds[0] = ast_rtp_instance_fd(sub->rtp, 0);
- tmp->fds[1] = ast_rtp_instance_fd(sub->rtp, 1);
+ ast_channel_internal_fd_set(tmp, 0, ast_rtp_instance_fd(sub->rtp, 0));
+ ast_channel_internal_fd_set(tmp, 1, ast_rtp_instance_fd(sub->rtp, 1));
}
if (sub->rtp)
ast_jb_configure(tmp, &global_jbconf);
@@ -4599,8 +4599,8 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
usecnt++;
ast_mutex_unlock(&usecnt_lock);
ast_update_use_count();
- tmp->callgroup = l->callgroup;
- tmp->pickupgroup = l->pickupgroup;
+ ast_channel_callgroup_set(tmp, l->callgroup);
+ ast_channel_pickupgroup_set(tmp, l->pickupgroup);
ast_channel_call_forward_set(tmp, l->parent->call_forward);
if (!ast_strlen_zero(l->cid_num)) {
char *name, *loc, *instr;
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index bca7e9be8..465c24408 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -2450,8 +2450,8 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
ast_channel_tech_set(tmp, &vpb_tech);
}
- tmp->callgroup = me->callgroup;
- tmp->pickupgroup = me->pickupgroup;
+ ast_channel_callgroup_set(tmp, me->callgroup);
+ ast_channel_pickupgroup_set(tmp, me->pickupgroup);
/* Linear is the preferred format. Although Voicetronix supports other formats
* they are all converted to/from linear in the vpb code. Best for us to use
diff --git a/channels/console_video.c b/channels/console_video.c
index db07fccee..d53e6ec27 100644
--- a/channels/console_video.c
+++ b/channels/console_video.c
@@ -972,7 +972,6 @@ static void *video_thread(void *arg)
}
continue;
}
- fd = chan->alertpipe[1];
ast_channel_lock(chan);
/* AST_LIST_INSERT_TAIL is only good for one frame, cannot use here */
@@ -986,10 +985,9 @@ static void *video_thread(void *arg)
* more or less same as ast_queue_frame, but extra
* write on the alertpipe to signal frames.
*/
- if (fd > -1) {
- int blah = 1, l = sizeof(blah);
+ if (ast_channel_alertable(chan)) {
for (p = f; p; p = AST_LIST_NEXT(p, frame_list)) {
- if (write(fd, &blah, l) != l)
+ if (ast_channel_alert(chan)) {
ast_log(LOG_WARNING, "Unable to write to alert pipe on %s, frametype/subclass %d/%d: %s!\n",
ast_channel_name(chan), f->frametype, f->subclass, strerror(errno));
}
diff --git a/channels/sig_analog.c b/channels/sig_analog.c
index 7f4d1a6da..78963bb56 100644
--- a/channels/sig_analog.c
+++ b/channels/sig_analog.c
@@ -3603,7 +3603,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
f = &p->subs[idx].f;
return f;
}
- ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+ ast_debug(1, "Exception on %d, channel %d\n", ast_channel_fd(ast, 0), p->channel);
/* If it's not us, return NULL immediately */
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner));
diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index b317284fd..f0a15d7ed 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -5550,7 +5550,7 @@ static void *pri_dchannel(void *vpri)
for (x = pri->numchans; x >= 0; x--) {
/* find a candidate channel */
if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall) {
- pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[x]->owner, AST_SOFTHANGUP_DEV);
haveidles++;
/* Stop if we have enough idle channels or
can't spare any more active idle ones */
@@ -5697,7 +5697,7 @@ static void *pri_dchannel(void *vpri)
p->call = NULL;
}
if (p->owner)
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
}
sig_pri_set_alarm(p, 1);
}
@@ -5740,7 +5740,7 @@ static void *pri_dchannel(void *vpri)
}
/* Force soft hangup if appropriate */
if (pri->pvts[chanpos]->owner)
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
sig_pri_unlock_private(pri->pvts[chanpos]);
}
} else {
@@ -5753,7 +5753,7 @@ static void *pri_dchannel(void *vpri)
pri->pvts[x]->call = NULL;
}
if (pri->pvts[x]->owner)
- pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[x]->owner, AST_SOFTHANGUP_DEV);
sig_pri_unlock_private(pri->pvts[x]);
}
}
@@ -6732,10 +6732,10 @@ static void *pri_dchannel(void *vpri)
* AST_CONTROL_HANGUP frame to guarantee that frame gets read before hangup */
pri_queue_control(pri, chanpos, AST_CONTROL_HANGUP);
} else {
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
}
#else
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
#endif /* defined(HAVE_PRI_AOC_EVENTS) */
}
} else {
@@ -6885,10 +6885,10 @@ static void *pri_dchannel(void *vpri)
* to guarantee that frame gets read before hangup */
pri_queue_control(pri, chanpos, AST_CONTROL_HANGUP);
} else {
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
}
#else
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
#endif /* defined(HAVE_PRI_AOC_EVENTS) */
}
ast_verb(3, "Span %d: Channel %d/%d got hangup request, cause %d\n",
@@ -6986,7 +6986,7 @@ static void *pri_dchannel(void *vpri)
"Span %d: Got restart ack on channel %d/%d with owner\n",
pri->span, pri->pvts[chanpos]->logicalspan,
pri->pvts[chanpos]->prioffset);
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
}
pri->pvts[chanpos]->resetting = 0;
ast_verb(3,
@@ -7012,7 +7012,7 @@ static void *pri_dchannel(void *vpri)
"Span %d: Got restart ack on channel %d/%d with owner\n",
pri->span, pri->pvts[chanpos]->logicalspan,
pri->pvts[chanpos]->prioffset);
- pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV);
}
pri->pvts[chanpos]->resetting = 0;
ast_verb(3,
@@ -7863,7 +7863,7 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
case AST_CONTROL_BUSY:
if (p->priindication_oob || p->no_b_channel) {
ast_channel_hangupcause_set(chan, AST_CAUSE_USER_BUSY);
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
res = 0;
break;
}
@@ -7956,7 +7956,7 @@ int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condi
default:
break;
}
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
res = 0;
break;
}
@@ -8788,7 +8788,7 @@ void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm)
p->call = NULL;
}
if (p->owner)
- p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
}
}
sig_pri_span_devstate_changed(p->pri);
diff --git a/channels/sig_ss7.c b/channels/sig_ss7.c
index 1a8a12b98..cebd6c808 100644
--- a/channels/sig_ss7.c
+++ b/channels/sig_ss7.c
@@ -444,7 +444,7 @@ static inline void ss7_hangup_cics(struct sig_ss7_linkset *linkset, int startcic
if (linkset->pvts[i] && (linkset->pvts[i]->dpc == dpc && ((linkset->pvts[i]->cic >= startcic) && (linkset->pvts[i]->cic <= endcic)))) {
sig_ss7_lock_private(linkset->pvts[i]);
if (linkset->pvts[i]->owner)
- linkset->pvts[i]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(linkset->pvts[i]->owner, AST_SOFTHANGUP_DEV);
sig_ss7_unlock_private(linkset->pvts[i]);
}
}
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 30bf63db9..80d57ded1 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -394,10 +394,10 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
locked_copy_string(chan, buf, transfercapability_table[ast_channel_transfercapability(chan) & 0x1f], len);
} else if (!strcasecmp(data, "callgroup")) {
char groupbuf[256];
- locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len);
+ locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), ast_channel_callgroup(chan)), len);
} else if (!strcasecmp(data, "pickupgroup")) {
char groupbuf[256];
- locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->pickupgroup), len);
+ locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), ast_channel_pickupgroup(chan)), len);
} else if (!strcasecmp(data, "amaflags")) {
char amabuf[256];
snprintf(amabuf,sizeof(amabuf), "%d", ast_channel_amaflags(chan));
@@ -486,9 +486,9 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
new_zone = ast_tone_zone_unref(new_zone);
}
} else if (!strcasecmp(data, "callgroup")) {
- chan->callgroup = ast_get_group(value);
+ ast_channel_callgroup_set(chan, ast_get_group(value));
} else if (!strcasecmp(data, "pickupgroup")) {
- chan->pickupgroup = ast_get_group(value);
+ ast_channel_pickupgroup_set(chan, ast_get_group(value));
} else if (!strcasecmp(data, "txgain")) {
sscanf(value, "%4hhd", &gainset);
ast_channel_setoption(chan, AST_OPTION_TXGAIN, &gainset, sizeof(gainset), 0);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 4d978b89d..c0ff89d86 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -807,7 +807,7 @@ struct ast_channel {
* in the CHANNEL dialplan function */
struct ast_channel_monitor *__do_not_use_monitor; /*!< Channel monitoring */
#ifdef HAVE_EPOLL
- struct ast_epoll_data *epfd_data[AST_MAX_FDS];
+ struct ast_epoll_data *__do_not_use_epfd_data[AST_MAX_FDS];
#endif
AST_DECLARE_STRING_FIELDS(
@@ -854,8 +854,8 @@ struct ast_channel {
struct ast_frame __do_not_use_dtmff; /*!< DTMF frame */
struct varshead __do_not_use_varshead; /*!< A linked list for channel variables. See \ref AstChanVar */
- ast_group_t callgroup; /*!< Call group for call pickups */
- ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
+ ast_group_t __do_not_use_callgroup; /*!< Call group for call pickups */
+ ast_group_t __do_not_use_pickupgroup; /*!< Pickup group - which calls groups can be picked up? */
struct ast_readq_list __do_not_use_readq;
struct ast_jb __do_not_use_jb; /*!< The jitterbuffer state */
struct timeval __do_not_use_dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */
@@ -864,10 +864,10 @@ struct ast_channel {
unsigned long __do_not_use_insmpl; /*!< Track the read/written samples for monitor use */
unsigned long __do_not_use_outsmpl; /*!< Track the read/written samples for monitor use */
- int fds[AST_MAX_FDS]; /*!< File descriptors for channel -- Drivers will poll on
+ int __do_not_use_fds[AST_MAX_FDS]; /*!< File descriptors for channel -- Drivers will poll on
* these file descriptors, so at least one must be non -1.
* See \arg \ref AstFileDesc */
- int _softhangup; /*!< Whether or not we have been hung up... Do not set this value
+ int __do_not_use_softhangup; /*!< Whether or not we have been hung up... Do not set this value
* directly, use ast_softhangup() */
int __do_not_use_fdno; /*!< Which fd had an event detected on */
int __do_not_use_streamid; /*!< For streaming playback, the schedule ID */
@@ -886,7 +886,7 @@ struct ast_channel {
* the counter is only in the remaining bits */
int __do_not_use_hangupcause; /*!< Why is the channel hanged up. See causes.h */
unsigned int flags; /*!< channel flags of AST_FLAG_ type */
- int alertpipe[2];
+ int __do_not_use_alertpipe[2];
struct ast_format_cap *__do_not_use_nativeformats; /*!< Kinds of data this channel can natively handle */
struct ast_format __do_not_use_readformat; /*!< Requested read format (after translation) */
struct ast_format __do_not_use_writeformat; /*!< Requested write format (after translation) */
@@ -3785,8 +3785,13 @@ void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tec
enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan);
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value);
enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
+
/* XXX Internal use only, make sure to move later */
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
+void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value);
+void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value);
+void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value);
+int ast_channel_softhangup_internal_flag(struct ast_channel * chan);
/* Format getters */
struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
@@ -3806,16 +3811,57 @@ struct timeval *ast_channel_dtmf_tv(struct ast_channel *chan);
struct timeval *ast_channel_whentohangup(struct ast_channel *chan);
struct varshead *ast_channel_varshead(struct ast_channel *chan);
-/* Other struct setters */
+void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value);
+void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value);
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value);
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value);
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value);
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value);
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value);
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value);
+void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value);
/* List getters */
struct ast_datastore_list *ast_channel_datastores(struct ast_channel *chan);
struct ast_autochan_list *ast_channel_autochans(struct ast_channel *chan);
struct ast_readq_list *ast_channel_readq(struct ast_channel *chan);
+
+/* Typedef accessors */
+ast_group_t ast_channel_callgroup(const struct ast_channel *chan);
+void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value);
+ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan);
+void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value);
+
+/* Alertpipe accessors--the "internal" functions for channel.c use only */
+typedef enum {
+ AST_ALERT_READ_SUCCESS = 0,
+ AST_ALERT_NOT_READABLE,
+ AST_ALERT_READ_FAIL,
+ AST_ALERT_READ_FATAL,
+} ast_alert_status_t;
+int ast_channel_alert_write(struct ast_channel *chan);
+int ast_channel_alert_writable(struct ast_channel *chan);
+ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan);
+int ast_channel_internal_alert_readable(struct ast_channel *chan);
+void ast_channel_internal_alertpipe_clear(struct ast_channel *chan);
+void ast_channel_internal_alertpipe_close(struct ast_channel *chan);
+int ast_channel_internal_alert_readfd(struct ast_channel *chan);
+int ast_channel_internal_alertpipe_init(struct ast_channel *chan);
+/*! \brief Swap the interal alertpipe between two channels
+ * \note Handle all of the necessary locking before calling this
+ */
+void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2);
+
+/* file descriptor array accessors */
+void ast_channel_internal_fd_clear(struct ast_channel *chan, int which);
+void ast_channel_internal_fd_clear_all(struct ast_channel *chan);
+void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value);
+int ast_channel_fd(const struct ast_channel *chan, int which);
+int ast_channel_fd_isset(const struct ast_channel *chan, int which);
+
+/* epoll data internal accessors */
+#ifdef HAVE_EPOLL
+struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which);
+void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value);
+#endif
#endif /* _ASTERISK_CHANNEL_H */
diff --git a/main/autoservice.c b/main/autoservice.c
index 35a66205a..fca180f5c 100644
--- a/main/autoservice.c
+++ b/main/autoservice.c
@@ -277,7 +277,7 @@ int ast_autoservice_stop(struct ast_channel *chan)
/* Now autoservice thread should have no references to our entry
and we can safely destroy it */
- if (!chan->_softhangup) {
+ if (!ast_channel_softhangup_internal_flag(chan)) {
res = 0;
}
diff --git a/main/channel.c b/main/channel.c
index 387b98bea..9222a33c6 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -583,14 +583,14 @@ int ast_channel_trace_disable(struct ast_channel *chan)
/*! \brief Checks to see if a channel is needing hang up */
int ast_check_hangup(struct ast_channel *chan)
{
- if (chan->_softhangup) /* yes if soft hangup flag set */
+ if (ast_channel_softhangup_internal_flag(chan)) /* yes if soft hangup flag set */
return 1;
if (ast_tvzero(*ast_channel_whentohangup(chan))) /* no if no hangup scheduled */
return 0;
if (ast_tvdiff_ms(*ast_channel_whentohangup(chan), ast_tvnow()) > 0) /* no if hangup time has not come yet. */
return 0;
ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(*ast_channel_whentohangup(chan), ast_tvnow()));
- chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_TIMEOUT); /* record event */
return 1;
}
@@ -921,8 +921,6 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
const char *function, const char *name_fmt, va_list ap)
{
struct ast_channel *tmp;
- int x;
- int flags;
struct varshead *headp;
char *tech = "", *tech2 = NULL;
struct ast_format_cap *nativeformats;
@@ -960,12 +958,9 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
* the destructor can know not to close them.
*/
ast_channel_timingfd_set(tmp, -1);
- for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) {
- tmp->alertpipe[x] = -1;
- }
- for (x = 0; x < ARRAY_LEN(tmp->fds); ++x) {
- tmp->fds[x] = -1;
- }
+ ast_channel_internal_alertpipe_clear(tmp);
+ ast_channel_internal_fd_clear_all(tmp);
+
#ifdef HAVE_EPOLL
ast_channel_epfd(tmp) = epoll_create(25);
#endif
@@ -1004,22 +999,8 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
ast_channel_timingfd_set(tmp, ast_timer_fd(ast_channel_timer(tmp)));
}
- if (needqueue) {
- if (pipe(tmp->alertpipe)) {
- ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe! Try increasing max file descriptors with ulimit -n\n");
- return ast_channel_unref(tmp);
- } else {
- flags = fcntl(tmp->alertpipe[0], F_GETFL);
- if (fcntl(tmp->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
- ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
- return ast_channel_unref(tmp);
- }
- flags = fcntl(tmp->alertpipe[1], F_GETFL);
- if (fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) {
- ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
- return ast_channel_unref(tmp);
- }
- }
+ if (needqueue && ast_channel_internal_alertpipe_init(tmp)) {
+ return ast_channel_unref(tmp);
}
/*
@@ -1034,7 +1015,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char
}
/* Always watch the alertpipe */
- ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]);
+ ast_channel_set_fd(tmp, AST_ALERT_FD, ast_channel_internal_alert_readfd(tmp));
/* And timing pipe */
ast_channel_set_fd(tmp, AST_TIMING_FD, ast_channel_timingfd(tmp));
@@ -1308,11 +1289,8 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in
AST_LIST_APPEND_LIST(ast_channel_readq(chan), &frames, frame_list);
}
- if (chan->alertpipe[1] > -1) {
- int blah[new_frames];
-
- memset(blah, 1, sizeof(blah));
- if (write(chan->alertpipe[1], &blah, sizeof(blah)) != (sizeof(blah))) {
+ if (ast_channel_alert_writable(chan)) {
+ if (ast_channel_alert_write(chan)) {
ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %d): %s!\n",
ast_channel_name(chan), queued_frames, strerror(errno));
}
@@ -1343,7 +1321,7 @@ int ast_queue_hangup(struct ast_channel *chan)
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
manager_event(EVENT_FLAG_CALL, "HangupRequest",
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
@@ -1364,7 +1342,7 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
/* Yeah, let's not change a lock-critical value without locking */
if (!ast_channel_trylock(chan)) {
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
if (cause < 0)
f.data.uint32 = ast_channel_hangupcause(chan);
@@ -2185,7 +2163,6 @@ void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
static void ast_channel_destructor(void *obj)
{
struct ast_channel *chan = obj;
- int fd;
#ifdef HAVE_EPOLL
int i;
#endif
@@ -2256,17 +2233,15 @@ static void ast_channel_destructor(void *obj)
ast_party_redirecting_free(ast_channel_redirecting(chan));
/* Close pipes if appropriate */
- if ((fd = chan->alertpipe[0]) > -1)
- close(fd);
- if ((fd = chan->alertpipe[1]) > -1)
- close(fd);
+ ast_channel_internal_alertpipe_close(chan);
if (ast_channel_timer(chan)) {
ast_timer_close(ast_channel_timer(chan));
}
#ifdef HAVE_EPOLL
for (i = 0; i < AST_MAX_FDS; i++) {
- if (chan->epfd_data[i])
- free(chan->epfd_data[i]);
+ if (ast_channel_internal_epfd_data(chan, i)) {
+ ast_free(ast_channel_internal_epfd_data(chan, i));
+ }
}
close(ast_channel_epfd(chan));
#endif
@@ -2410,9 +2385,9 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
struct epoll_event ev;
struct ast_epoll_data *aed = NULL;
- if (chan->fds[which] > -1) {
- epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_DEL, chan->fds[which], &ev);
- aed = chan->epfd_data[which];
+ if (ast_channel_fd_isset(chan, which)) {
+ epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_DEL, ast_channel_fd(chan, which), &ev);
+ aed = ast_channel_internal_epfd_data(chan, which);
}
/* If this new fd is valid, add it to the epoll */
@@ -2420,7 +2395,7 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
if (!aed && (!(aed = ast_calloc(1, sizeof(*aed)))))
return;
- chan->epfd_data[which] = aed;
+ ast_channel_internal_epfd_data_set(chan, which, aed);
aed->chan = chan;
aed->which = which;
@@ -2429,11 +2404,11 @@ void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
epoll_ctl(ast_channel_epfd(chan), EPOLL_CTL_ADD, fd, &ev);
} else if (aed) {
/* We don't have to keep around this epoll data structure now */
- free(aed);
- chan->epfd_data[which] = NULL;
+ ast_free(aed);
+ ast_channel_epfd_data_set(chan, which, NULL);
}
#endif
- chan->fds[which] = fd;
+ ast_channel_internal_fd_set(chan, which, fd);
return;
}
@@ -2449,11 +2424,12 @@ void ast_poll_channel_add(struct ast_channel *chan0, struct ast_channel *chan1)
/* Iterate through the file descriptors on chan1, adding them to chan0 */
for (i = 0; i < AST_MAX_FDS; i++) {
- if (chan1->fds[i] == -1)
+ if (!ast_channel_fd_isset(chan1, i)) {
continue;
+ }
ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP;
- ev.data.ptr = chan1->epfd_data[i];
- epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_ADD, chan1->fds[i], &ev);
+ ev.data.ptr = ast_channel_internal_epfd_data(chan1, i);
+ epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_ADD, ast_channel_fd(chan1, i), &ev);
}
#endif
@@ -2471,9 +2447,10 @@ void ast_poll_channel_del(struct ast_channel *chan0, struct ast_channel *chan1)
return;
for (i = 0; i < AST_MAX_FDS; i++) {
- if (chan1->fds[i] == -1)
+ if (!ast_channel_fd_isset(chan1, i)) {
continue;
- epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_DEL, chan1->fds[i], &ev);
+ }
+ epoll_ctl(ast_channel_epfd(chan0), EPOLL_CTL_DEL, ast_channel_fd(chan1, i), &ev);
}
#endif
@@ -2484,9 +2461,9 @@ void ast_channel_clear_softhangup(struct ast_channel *chan, int flag)
{
ast_channel_lock(chan);
- chan->_softhangup &= ~flag;
+ ast_channel_softhangup_internal_flag_clear(chan, flag);
- if (!chan->_softhangup) {
+ if (!ast_channel_softhangup_internal_flag(chan)) {
struct ast_frame *fr;
/* If we have completely cleared the softhangup flag,
@@ -2510,7 +2487,7 @@ int ast_softhangup_nolock(struct ast_channel *chan, int cause)
{
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_channel_softhangup_internal_flag_add(chan, cause);
ast_queue_frame(chan, &ast_null_frame);
/* Interrupt any poll call or such */
if (ast_test_flag(chan, AST_FLAG_BLOCKING))
@@ -3012,7 +2989,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
diff = ast_tvsub(*ast_channel_whentohangup(c[x]), now);
if (diff.tv_sec < 0 || ast_tvzero(diff)) {
/* Should already be hungup */
- c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+ ast_channel_softhangup_internal_flag_add(c[x], AST_SOFTHANGUP_TIMEOUT);
ast_channel_unlock(c[x]);
return c[x];
}
@@ -3043,7 +3020,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
for (y = 0; y < AST_MAX_FDS; y++) {
fdmap[max].fdno = y; /* fd y is linked to this pfds */
fdmap[max].chan = x; /* channel x is linked to this pfds */
- max += ast_add_fd(&pfds[max], c[x]->fds[y]);
+ max += ast_add_fd(&pfds[max], ast_channel_fd(c[x], y));
}
CHECK_BLOCKING(c[x]);
}
@@ -3079,7 +3056,7 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
now = ast_tvnow();
for (x = 0; x < n; x++) {
if (!ast_tvzero(*ast_channel_whentohangup(c[x])) && ast_tvcmp(*ast_channel_whentohangup(c[x]), now) <= 0) {
- c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+ ast_channel_softhangup_internal_flag_add(c[x], AST_SOFTHANGUP_TIMEOUT);
if (winner == NULL)
winner = c[x];
}
@@ -3144,7 +3121,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
if ((diff = ast_tvdiff_ms(*ast_channel_whentohangup(chan), ast_tvnow())) < 0) {
/* They should already be hungup! */
- chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_TIMEOUT);
ast_channel_unlock(chan);
return NULL;
}
@@ -3177,7 +3154,7 @@ static struct ast_channel *ast_waitfor_nandfds_simple(struct ast_channel *chan,
/* If this channel has a timeout see if it expired */
if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
if (ast_tvdiff_ms(ast_tvnow(), *ast_channel_whentohangup(chan)) >= 0) {
- chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_TIMEOUT);
winner = chan;
}
}
@@ -3226,7 +3203,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
if (whentohangup == 0)
now = ast_tvnow();
if ((diff = ast_tvdiff_ms(*ast_channel_whentohangup(c[i]), now)) < 0) {
- c[i]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+ ast_channel_softhangup_internal_flag_add(c[i], AST_SOFTHANGUP_TIMEOUT);
ast_channel_unlock(c[i]);
return c[i];
}
@@ -3262,7 +3239,7 @@ static struct ast_channel *ast_waitfor_nandfds_complex(struct ast_channel **c, i
now = ast_tvnow();
for (i = 0; i < n; i++) {
if (!ast_tvzero(*ast_channel_whentohangup(c[i])) && ast_tvdiff_ms(now, *ast_channel_whentohangup(c[i])) >= 0) {
- c[i]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+ ast_channel_softhangup_internal_flag_add(c[i], AST_SOFTHANGUP_TIMEOUT);
if (!winner)
winner = c[i];
}
@@ -3576,7 +3553,6 @@ static inline int calc_monitor_jump(int samples, int sample_rate, int seek_rate)
static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
{
struct ast_frame *f = NULL; /* the return value */
- int blah;
int prestate;
int cause = 0;
@@ -3609,7 +3585,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
* ast_queue_control() will be called repeatedly, but will only
* queue the first end-of-Q frame.
*/
- if (chan->_softhangup) {
+ if (ast_channel_softhangup_internal_flag(chan)) {
ast_queue_control(chan, AST_CONTROL_END_OF_Q);
} else {
goto done;
@@ -3640,22 +3616,9 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
/* Read and ignore anything on the alertpipe, but read only
one sizeof(blah) per frame that we send from it */
- if (chan->alertpipe[0] > -1) {
- int flags = fcntl(chan->alertpipe[0], F_GETFL);
- /* 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", 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;
- goto done;
- }
- }
- if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) {
- if (errno != EINTR && errno != EAGAIN)
- ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
- }
+ if (ast_channel_internal_alert_read(chan) == AST_ALERT_READ_FATAL) {
+ f = &ast_null_frame;
+ goto done;
}
if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) == AST_TIMING_FD) {
@@ -3693,7 +3656,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
break;
}
- } else if (chan->fds[AST_GENERATOR_FD] > -1 && ast_channel_fdno(chan) == AST_GENERATOR_FD) {
+ } else if (ast_channel_fd_isset(chan, AST_GENERATOR_FD) && ast_channel_fdno(chan) == AST_GENERATOR_FD) {
/* if the AST_GENERATOR_FD is set, call the generator with args
* set to -1 so it can do whatever it needs to.
*/
@@ -3704,7 +3667,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
f = &ast_null_frame;
ast_channel_fdno_set(chan, -1);
goto done;
- } else if (chan->fds[AST_JITTERBUFFER_FD] > -1 && ast_channel_fdno(chan) == AST_JITTERBUFFER_FD) {
+ } else if (ast_channel_fd_isset(chan, AST_JITTERBUFFER_FD) && ast_channel_fdno(chan) == AST_JITTERBUFFER_FD) {
ast_clear_flag(chan, AST_FLAG_EXCEPTION);
}
@@ -3729,14 +3692,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (!f) {
/* There were no acceptable frames on the readq. */
f = &ast_null_frame;
- if (chan->alertpipe[0] > -1) {
- int poke = 0;
- /* Restore the state of the alertpipe since we aren't ready for any
- * of the frames in the readq. */
- if (write(chan->alertpipe[1], &poke, sizeof(poke)) != sizeof(poke)) {
- ast_log(LOG_ERROR, "Failed to write to alertpipe: %s\n", strerror(errno));
- }
- }
+ ast_channel_alert_write(chan);
}
/* Interpret hangup and end-of-Q frames to return NULL */
@@ -3744,7 +3700,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
if (f->frametype == AST_FRAME_CONTROL) {
switch (f->subclass.integer) {
case AST_CONTROL_HANGUP:
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
cause = f->data.uint32;
/* Fall through */
case AST_CONTROL_END_OF_Q:
@@ -4084,8 +4040,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
}
} else {
/* Make sure we always return NULL in the future */
- if (!chan->_softhangup) {
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ if (!ast_channel_softhangup_internal_flag(chan)) {
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
}
if (cause)
ast_channel_hangupcause_set(chan, cause);
@@ -4908,7 +4864,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
AST_LIST_NEXT(cur, frame_list) = NULL;
if (!skip) {
if ((res = ast_channel_tech(chan)->write(chan, cur)) < 0) {
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
skip = 1;
} else if (next) {
/* don't do this for the last frame in the list,
@@ -4946,7 +4902,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
/* Consider a write failure to force a soft hangup */
if (res < 0) {
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
} else {
ast_channel_fout_set(chan, FRAMECOUNT_INC(ast_channel_fout(chan)));
}
@@ -6442,7 +6398,7 @@ static void masquerade_colp_transfer(struct ast_channel *transferee, struct xfer
*/
int ast_do_masquerade(struct ast_channel *original)
{
- int x, i;
+ int x;
int res=0;
int origstate;
int visible_indication;
@@ -6603,11 +6559,7 @@ int ast_do_masquerade(struct ast_channel *original)
ast_channel_tech_pvt_set(clonechan, t_pvt);
/* Swap the alertpipes */
- for (i = 0; i < 2; i++) {
- x = original->alertpipe[i];
- original->alertpipe[i] = clonechan->alertpipe[i];
- clonechan->alertpipe[i] = x;
- }
+ ast_channel_internal_alertpipe_swap(original, clonechan);
/*
* Swap the readq's. The end result should be this:
@@ -6629,12 +6581,8 @@ int ast_do_masquerade(struct ast_channel *original)
while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) {
AST_LIST_INSERT_TAIL(ast_channel_readq(original), current, frame_list);
- if (original->alertpipe[1] > -1) {
- int poke = 0;
-
- if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) {
- ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
- }
+ if (ast_channel_alert_write(original)) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
}
}
}
@@ -6648,7 +6596,7 @@ int ast_do_masquerade(struct ast_channel *original)
ast_format_copy(ast_channel_rawwriteformat(original), ast_channel_rawwriteformat(clonechan));
ast_format_copy(ast_channel_rawwriteformat(clonechan), &tmp_format);
- clonechan->_softhangup = AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_set(clonechan, AST_SOFTHANGUP_DEV);
/* And of course, so does our current state. Note we need not
call ast_setstate since the event manager doesn't really consider
@@ -6689,7 +6637,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Copy the FD's other than the generator fd */
for (x = 0; x < AST_MAX_FDS; x++) {
if (x != AST_GENERATOR_FD)
- ast_channel_set_fd(original, x, clonechan->fds[x]);
+ ast_channel_set_fd(original, x, ast_channel_fd(clonechan, x));
}
ast_app_group_update(clonechan, original);
@@ -7113,11 +7061,11 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
/* No frame received within the specified timeout - check if we have to deliver now */
if (jb_in_use)
ast_jb_get_and_deliver(c0, c1);
- if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
- if (c0->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
+ if ((ast_channel_softhangup_internal_flag(c0) | ast_channel_softhangup_internal_flag(c1)) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
+ if (ast_channel_softhangup_internal_flag(c0) & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE);
}
- if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
+ if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
}
c0->_bridge = c1;
@@ -7469,11 +7417,11 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE);
}
- if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
- if (c0->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
+ if ((ast_channel_softhangup_internal_flag(c0) | ast_channel_softhangup_internal_flag(c1)) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
+ if (ast_channel_softhangup_internal_flag(c0) & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c0, AST_SOFTHANGUP_UNBRIDGE);
}
- if (c1->_softhangup & AST_SOFTHANGUP_UNBRIDGE) {
+ if (ast_channel_softhangup_internal_flag(c1) & AST_SOFTHANGUP_UNBRIDGE) {
ast_channel_clear_softhangup(c1, AST_SOFTHANGUP_UNBRIDGE);
}
c0->_bridge = c1;
@@ -7519,7 +7467,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
- if ((c0->_softhangup | c1->_softhangup) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
+ if ((ast_channel_softhangup_internal_flag(c0) | ast_channel_softhangup_internal_flag(c1)) & AST_SOFTHANGUP_UNBRIDGE) {/* Bit operators are intentional. */
continue;
}
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index bec785fb5..0a7060e29 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -31,6 +31,9 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#include <unistd.h>
+#include <fcntl.h>
+
#include "asterisk/channel.h"
#include "asterisk/stringfields.h"
#include "asterisk/data.h"
@@ -181,13 +184,13 @@ int ast_channel_data_add_structure(struct ast_data *tree,
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);
+ ast_data_add_bool(data_softhangup, "dev", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_DEV);
+ ast_data_add_bool(data_softhangup, "asyncgoto", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO);
+ ast_data_add_bool(data_softhangup, "shutdown", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_SHUTDOWN);
+ ast_data_add_bool(data_softhangup, "timeout", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_TIMEOUT);
+ ast_data_add_bool(data_softhangup, "appunload", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_APPUNLOAD);
+ ast_data_add_bool(data_softhangup, "explicit", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_EXPLICIT);
+ ast_data_add_bool(data_softhangup, "unbridge", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_UNBRIDGE);
/* channel flags */
data_flags = ast_data_add_node(tree, "flags");
@@ -752,27 +755,205 @@ struct varshead *ast_channel_varshead(struct ast_channel *chan)
{
return &chan->__do_not_use_varshead;
}
+void ast_channel_dtmff_set(struct ast_channel *chan, struct ast_frame *value)
+{
+ memcpy(&chan->__do_not_use_dtmff, value, sizeof(chan->__do_not_use_dtmff));
+}
+void ast_channel_jb_set(struct ast_channel *chan, struct ast_jb *value)
+{
+ memcpy(&chan->__do_not_use_jb, value, sizeof(chan->__do_not_use_jb));
+}
void ast_channel_caller_set(struct ast_channel *chan, struct ast_party_caller *value)
{
- chan->__do_not_use_caller = *value;
+ memcpy(&chan->__do_not_use_caller, value, sizeof(chan->__do_not_use_caller));
}
void ast_channel_connected_set(struct ast_channel *chan, struct ast_party_connected_line *value)
{
- chan->__do_not_use_connected = *value;
+ memcpy(&chan->__do_not_use_connected, value, sizeof(chan->__do_not_use_connected));
}
void ast_channel_dialed_set(struct ast_channel *chan, struct ast_party_dialed *value)
{
- chan->__do_not_use_dialed = *value;
+ memcpy(&chan->__do_not_use_dialed, value, sizeof(chan->__do_not_use_dialed));
}
void ast_channel_redirecting_set(struct ast_channel *chan, struct ast_party_redirecting *value)
{
- chan->__do_not_use_redirecting = *value;
+ memcpy(&chan->__do_not_use_redirecting, value, sizeof(chan->__do_not_use_redirecting));
}
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
{
- chan->__do_not_use_dtmf_tv = *value;
+ memcpy(&chan->__do_not_use_dtmf_tv, value, sizeof(chan->__do_not_use_dtmf_tv));
}
void ast_channel_whentohangup_set(struct ast_channel *chan, struct timeval *value)
{
- chan->__do_not_use_whentohangup = *value;
+ memcpy(&chan->__do_not_use_whentohangup, value, sizeof(chan->__do_not_use_whentohangup));
+}
+void ast_channel_varshead_set(struct ast_channel *chan, struct varshead *value)
+{
+ memcpy(&chan->__do_not_use_varshead, value, sizeof(chan->__do_not_use_varshead));
+}
+
+/* Evil softhangup accessors */
+int ast_channel_softhangup_internal_flag(struct ast_channel * chan)
+{
+ return chan->__do_not_use_softhangup;
+}
+void ast_channel_softhangup_internal_flag_set(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_softhangup = value;
+}
+void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
+{
+ chan->__do_not_use_softhangup |= value;
+}
+void ast_channel_softhangup_internal_flag_clear(struct ast_channel *chan, int value)
+{
+ chan ->__do_not_use_softhangup &= ~value;
+}
+
+/* Typedef accessors */
+ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_callgroup;
+}
+void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
+{
+ chan->__do_not_use_callgroup = value;
+}
+ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
+{
+ return chan->__do_not_use_pickupgroup;
+}
+void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
+{
+ chan->__do_not_use_pickupgroup = value;
+}
+
+/* Alertpipe functions */
+int ast_channel_alert_write(struct ast_channel *chan)
+{
+ char blah = 0x7F;
+ return ast_channel_alert_writable(chan) && write(chan->__do_not_use_alertpipe[1], &blah, sizeof(blah)) != sizeof(blah);
+}
+
+ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
+{
+ int flags;
+ char blah;
+
+ if (!ast_channel_internal_alert_readable(chan)) {
+ return AST_ALERT_NOT_READABLE;
+ }
+
+ flags = fcntl(chan->__do_not_use_alertpipe[0], F_GETFL);
+ /* 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", ast_channel_name(chan));
+ if (fcntl(chan->__do_not_use_alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
+ ast_log(LOG_WARNING, "Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
+ return AST_ALERT_READ_FATAL;
+ }
+ }
+ if (read(chan->__do_not_use_alertpipe[0], &blah, sizeof(blah)) < 0) {
+ if (errno != EINTR && errno != EAGAIN) {
+ ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
+ return AST_ALERT_READ_FAIL;
+ }
+ }
+
+ return AST_ALERT_READ_SUCCESS;
+}
+
+int ast_channel_alert_writable(struct ast_channel *chan)
+{
+ return chan->__do_not_use_alertpipe[1] > -1;
+}
+
+int ast_channel_internal_alert_readable(struct ast_channel *chan)
+{
+ return chan->__do_not_use_alertpipe[0] > -1;
}
+
+void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
+{
+ chan->__do_not_use_alertpipe[0] = chan->__do_not_use_alertpipe[1] = -1;
+}
+
+void ast_channel_internal_alertpipe_close(struct ast_channel *chan)
+{
+ if (ast_channel_internal_alert_readable(chan)) {
+ close(chan->__do_not_use_alertpipe[0]);
+ }
+ if (ast_channel_alert_writable(chan)) {
+ close(chan->__do_not_use_alertpipe[1]);
+ }
+}
+
+int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
+{
+ if (pipe(chan->__do_not_use_alertpipe)) {
+ ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe! Try increasing max file descriptors with ulimit -n\n");
+ return -1;
+ } else {
+ int flags = fcntl(chan->__do_not_use_alertpipe[0], F_GETFL);
+ if (fcntl(chan->__do_not_use_alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) {
+ ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
+ return -1;
+ }
+ flags = fcntl(chan->__do_not_use_alertpipe[1], F_GETFL);
+ if (fcntl(chan->__do_not_use_alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) {
+ ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno));
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int ast_channel_internal_alert_readfd(struct ast_channel *chan)
+{
+ return chan->__do_not_use_alertpipe[0];
+}
+
+void ast_channel_internal_alertpipe_swap(struct ast_channel *chan1, struct ast_channel *chan2)
+{
+ int i;
+ for (i = 0; i < ARRAY_LEN(chan1->__do_not_use_alertpipe); i++) {
+ SWAP(chan1->__do_not_use_alertpipe[i], chan2->__do_not_use_alertpipe[i]);
+ }
+}
+
+/* file descriptor array accessors */
+void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
+{
+ chan->__do_not_use_fds[which] = value;
+}
+void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
+{
+ ast_channel_internal_fd_set(chan, which, -1);
+}
+void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
+{
+ int i;
+ for (i = 0; i < AST_MAX_FDS; i++) {
+ ast_channel_internal_fd_clear(chan, i);
+ }
+}
+int ast_channel_fd(const struct ast_channel *chan, int which)
+{
+ return chan->__do_not_use_fds[which];
+}
+int ast_channel_fd_isset(const struct ast_channel *chan, int which)
+{
+ return ast_channel_fd(chan, which) > -1;
+}
+
+#ifdef HAVE_EPOLL
+struct ast_epoll_data *ast_channel_internal_epfd_data(const struct ast_channel *chan, int which)
+{
+ return chan->__do_not_use_epfd_data[which];
+}
+void ast_channel_internal_epfd_data_set(struct ast_channel *chan, int which , struct ast_epoll_data *value)
+{
+ chan->__do_not_use_epfd_data[which] = value;
+}
+#endif
diff --git a/main/cli.c b/main/cli.c
index bfb4d6d07..591f6d556 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1490,12 +1490,12 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
ast_channel_readtrans(c) ? "Yes" : "No",
ast_translate_path_to_str(ast_channel_readtrans(c), &read_transpath),
- c->fds[0],
+ ast_channel_fd(c, 0),
ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
(long)ast_channel_whentohangup(c)->tv_sec,
cdrtime, c->_bridge ? ast_channel_name(c->_bridge) : "<none>", ast_bridged_channel(c) ? ast_channel_name(ast_bridged_channel(c)) : "<none>",
- ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), c->callgroup, c->pickupgroup, (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
+ ast_channel_context(c), ast_channel_exten(c), ast_channel_priority(c), ast_channel_callgroup(c), ast_channel_pickupgroup(c), (ast_channel_appl(c) ? ast_channel_appl(c) : "(N/A)" ),
(ast_channel_data(c) ? S_OR(ast_channel_data(c), "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? ast_channel_blockproc(c) : "(Not Blocking)"));
diff --git a/main/dsp.c b/main/dsp.c
index d934c9cf5..77f72c18e 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1437,7 +1437,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
return ast_frisolate(&dsp->f);
}
if ((dsp->features & DSP_FEATURE_BUSY_DETECT) && ast_dsp_busydetect(dsp)) {
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
dsp->f.subclass.integer = AST_CONTROL_BUSY;
diff --git a/main/features.c b/main/features.c
index aa2810d18..03627ee38 100644
--- a/main/features.c
+++ b/main/features.c
@@ -4138,7 +4138,7 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, struct a
* but it doesn't hurt to check AST_SOFTHANGUP_UNBRIDGE either.
*/
ast_channel_lock(chan);
- if (chan->_softhangup & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)) {
+ if (ast_channel_softhangup_internal_flag(chan) & (AST_SOFTHANGUP_ASYNCGOTO | AST_SOFTHANGUP_UNBRIDGE)) {
ast_set_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT);
}
ast_channel_unlock(chan);
@@ -4726,12 +4726,12 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
struct ast_frame *f;
int y;
- if (chan->fds[x] == -1) {
+ if (!ast_channel_fd_isset(chan, x)) {
continue; /* nothing on this descriptor */
}
for (y = 0; y < nfds; y++) {
- if (pfds[y].fd == chan->fds[x]) {
+ if (pfds[y].fd == ast_channel_fd(chan, x)) {
/* Found poll record! */
break;
}
@@ -4792,7 +4792,7 @@ static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds,
} /* End for */
if (x >= AST_MAX_FDS) {
std: for (x = 0; x < AST_MAX_FDS; x++) { /* mark fds for next round */
- if (chan->fds[x] > -1) {
+ if (ast_channel_fd_isset(chan, x)) {
void *tmp = ast_realloc(*new_pfds,
(*new_nfds + 1) * sizeof(struct pollfd));
@@ -4800,7 +4800,7 @@ std: for (x = 0; x < AST_MAX_FDS; x++) { /* mark fds for next round */
continue;
}
*new_pfds = tmp;
- (*new_pfds)[*new_nfds].fd = chan->fds[x];
+ (*new_pfds)[*new_nfds].fd = ast_channel_fd(chan, x);
(*new_pfds)[*new_nfds].events = POLLIN | POLLERR | POLLPRI;
(*new_pfds)[*new_nfds].revents = 0;
(*new_nfds)++;
@@ -7249,7 +7249,7 @@ static int find_channel_by_group(void *obj, void *arg, void *data, int flags)
struct ast_channel *chan = data;/*!< Channel wanting to pickup call */
ast_channel_lock(target);
- if (chan != target && (chan->pickupgroup & target->callgroup)
+ if (chan != target && (ast_channel_pickupgroup(chan) & ast_channel_callgroup(target))
&& ast_can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
diff --git a/main/file.c b/main/file.c
index 588dfe2f7..82f2aab86 100644
--- a/main/file.c
+++ b/main/file.c
@@ -1381,7 +1381,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon,
ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
- return (err || c->_softhangup) ? -1 : 0;
+ return (err || ast_channel_softhangup_internal_flag(c)) ? -1 : 0;
}
int ast_waitstream_fr(struct ast_channel *c, const char *breakon, const char *forward, const char *reverse, int ms)
diff --git a/main/pbx.c b/main/pbx.c
index a5a2c08fd..d848fc3b6 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5079,7 +5079,7 @@ static int collect_digits(struct ast_channel *c, int waittime, char *buf, int bu
/* As long as we're willing to wait, and as long as it's not defined,
keep reading digits until we can't possibly get a right answer anymore. */
digit = ast_waitfordigit(c, waittime);
- if (c->_softhangup & AST_SOFTHANGUP_ASYNCGOTO) {
+ if (ast_channel_softhangup_internal_flag(c) & AST_SOFTHANGUP_ASYNCGOTO) {
ast_channel_clear_softhangup(c, AST_SOFTHANGUP_ASYNCGOTO);
} else {
if (!digit) /* No entry */
@@ -5155,11 +5155,11 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
/* Check softhangup flags. */
- if (c->_softhangup & AST_SOFTHANGUP_ASYNCGOTO) {
+ if (ast_channel_softhangup_internal_flag(c) & AST_SOFTHANGUP_ASYNCGOTO) {
ast_channel_clear_softhangup(c, AST_SOFTHANGUP_ASYNCGOTO);
continue;
}
- if (c->_softhangup & AST_SOFTHANGUP_TIMEOUT) {
+ if (ast_channel_softhangup_internal_flag(c) & AST_SOFTHANGUP_TIMEOUT) {
if (ast_exists_extension(c, ast_channel_context(c), "T", 1,
S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, NULL))) {
set_ext_pri(c, "T", 1);
@@ -5222,11 +5222,11 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
}
}
- if (c->_softhangup & AST_SOFTHANGUP_ASYNCGOTO) {
+ if (ast_channel_softhangup_internal_flag(c) & AST_SOFTHANGUP_ASYNCGOTO) {
ast_channel_clear_softhangup(c, AST_SOFTHANGUP_ASYNCGOTO);
continue;
}
- if (c->_softhangup & AST_SOFTHANGUP_TIMEOUT) {
+ if (ast_channel_softhangup_internal_flag(c) & AST_SOFTHANGUP_TIMEOUT) {
if (ast_exists_extension(c, ast_channel_context(c), "T", 1,
S_COR(ast_channel_caller(c)->id.number.valid, ast_channel_caller(c)->id.number.str, NULL))) {
set_ext_pri(c, "T", 1);
@@ -5283,7 +5283,7 @@ static enum ast_pbx_result __ast_pbx_run(struct ast_channel *c,
error = 1; /* we know what to do with it */
break;
}
- } else if (c->_softhangup & AST_SOFTHANGUP_TIMEOUT) {
+ } else if (ast_channel_softhangup_internal_flag(c) & AST_SOFTHANGUP_TIMEOUT) {
/* If we get this far with AST_SOFTHANGUP_TIMEOUT, then we know that the "T" extension is next. */
ast_channel_clear_softhangup(c, AST_SOFTHANGUP_TIMEOUT);
} else { /* keypress received, get more digits for a full extension */
diff --git a/res/snmp/agent.c b/res/snmp/agent.c
index 7e713f8b3..9989ae17e 100644
--- a/res/snmp/agent.c
+++ b/res/snmp/agent.c
@@ -399,11 +399,11 @@ static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *le
ret = (u_char *)string_ret;
break;
case ASTCHANCALLGROUP:
- long_ret = chan->callgroup;
+ long_ret = ast_channel_callgroup(chan);
ret = (u_char *)&long_ret;
break;
case ASTCHANPICKUPGROUP:
- long_ret = chan->pickupgroup;
+ long_ret = ast_channel_pickupgroup(chan);
ret = (u_char *)&long_ret;
break;
case ASTCHANSTATE: