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);
}
}
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) {
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));
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);
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 */
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 */
}
/* 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)
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;
}
/* 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));
}
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));
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;
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,
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)"));
}
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));
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");
}
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;
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);
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));
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);
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;
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);
#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)
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;
}
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;
/* 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 */
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 {
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;
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) ||
} 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;
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)) {
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) {
}
}
} 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);
}
}
/* 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 {
} 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);
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));
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);
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))
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;
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);
}
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);
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;
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))
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);
} 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);
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];
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)
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)) {
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 */
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)) {
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) {
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)
}
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);
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);
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;
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
}
continue;
}
- fd = chan->alertpipe[1];
ast_channel_lock(chan);
/* AST_LIST_INSERT_TAIL is only good for one frame, cannot use here */
* 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));
}
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));
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 */
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);
}
}
/* 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 {
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]);
}
}
* 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 {
* 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",
"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,
"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,
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;
}
default:
break;
}
- chan->_softhangup |= AST_SOFTHANGUP_DEV;
+ ast_channel_softhangup_internal_flag_add(chan, AST_SOFTHANGUP_DEV);
res = 0;
break;
}
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);
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]);
}
}
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));
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);
* 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(
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 */
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 */
* 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) */
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);
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 */
/* 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;
}
/*! \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;
}
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;
* 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
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);
}
/*
}
/* 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));
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));
}
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",
/* 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);
static void ast_channel_destructor(void *obj)
{
struct ast_channel *chan = obj;
- int fd;
#ifdef HAVE_EPOLL
int i;
#endif
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
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 */
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;
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;
}
/* 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
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
{
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,
{
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))
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];
}
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]);
}
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];
}
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;
}
/* 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;
}
}
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];
}
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];
}
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;
* 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;
/* 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) {
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.
*/
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);
}
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 */
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:
}
} 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);
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,
/* 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)));
}
*/
int ast_do_masquerade(struct ast_channel *original)
{
- int x, i;
+ int x;
int res=0;
int origstate;
int visible_indication;
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:
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));
}
}
}
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
/* 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);
/* 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;
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;
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;
}
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#include <unistd.h>
+#include <fcntl.h>
+
#include "asterisk/channel.h"
#include "asterisk/stringfields.h"
#include "asterisk/data.h"
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");
{
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
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)"));
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;
* 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);
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;
}
} /* 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));
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)++;
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;
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)
/* 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 */
}
/* 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);
}
}
- 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);
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 */
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: