# rename the variable 'tmp' in mkintf() to 'zap_chan'. # This patch should have no functional effect. Index: trunk/channels/chan_zap.c =================================================================== --- trunk.orig/channels/chan_zap.c 2008-02-27 02:33:15.981777353 +0200 +++ trunk/channels/chan_zap.c 2008-02-27 02:35:52.490696495 +0200 @@ -8055,7 +8055,7 @@ static int sigtype_to_signalling(int sig static struct zt_pvt *mkintf(int channel, struct zt_chan_conf conf, struct zt_pri *pri, int reloading) { /* Make a zt_pvt structure for this interface (or CRV if "pri" is specified) */ - struct zt_pvt *tmp = NULL, *tmp2, *prev = NULL; + struct zt_pvt *zap_chan = NULL, *tmp2, *prev = NULL; char fn[80]; #if 1 struct zt_bufferinfo bi; @@ -8085,7 +8085,7 @@ static struct zt_pvt *mkintf(int channel while (tmp2) { if (!tmp2->destroy) { if (tmp2->channel == channel) { - tmp = tmp2; + zap_chan = tmp2; here = 1; break; } @@ -8098,46 +8098,46 @@ static struct zt_pvt *mkintf(int channel } if (!here && !reloading) { - if (!(tmp = ast_calloc(1, sizeof(*tmp)))) { - destroy_zt_pvt(&tmp); + if (!(zap_chan = ast_calloc(1, sizeof(*zap_chan)))) { + destroy_zt_pvt(&zap_chan); return NULL; } - ast_mutex_init(&tmp->lock); + ast_mutex_init(&zap_chan->lock); ifcount++; for (x = 0; x < 3; x++) - tmp->subs[x].zfd = -1; - tmp->channel = channel; + zap_chan->subs[x].zfd = -1; + zap_chan->channel = channel; } - if (tmp) { + if (zap_chan) { if (!here) { if ((channel != CHAN_PSEUDO) && !pri) { snprintf(fn, sizeof(fn), "%d", channel); /* Open non-blocking */ if (!here) - tmp->subs[SUB_REAL].zfd = zt_open(fn); + zap_chan->subs[SUB_REAL].zfd = zt_open(fn); /* Allocate a zapata structure */ - if (tmp->subs[SUB_REAL].zfd < 0) { - ast_log(LOG_ERROR, "Unable to open channel %d: %s\nhere = %d, tmp->channel = %d, channel = %d\n", channel, strerror(errno), here, tmp->channel, channel); - destroy_zt_pvt(&tmp); + if (zap_chan->subs[SUB_REAL].zfd < 0) { + ast_log(LOG_ERROR, "Unable to open channel %d: %s\nhere = %d, zap_chan->channel = %d, channel = %d\n", channel, strerror(errno), here, zap_chan->channel, channel); + destroy_zt_pvt(&zap_chan); return NULL; } memset(¶ms, 0, sizeof(params)); - res = ioctl(tmp->subs[SUB_REAL].zfd, ZT_GET_PARAMS, ¶ms); + res = ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_GET_PARAMS, ¶ms); if (res < 0) { ast_log(LOG_ERROR, "Unable to get parameters\n"); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (conf.is_sig_auto) conf.chan.sig = sigtype_to_signalling(params.sigtype); if (params.sigtype != (conf.chan.sig & 0x3ffff)) { ast_log(LOG_ERROR, "Signalling requested on channel %d is %s but line is in %s signalling\n", channel, sig2str(conf.chan.sig), sig2str(params.sigtype)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } - tmp->law = params.curlaw; - tmp->span = params.spanno; + zap_chan->law = params.curlaw; + zap_chan->span = params.spanno; span = params.spanno - 1; } else { if (channel == CHAN_PSEUDO) @@ -8151,32 +8151,32 @@ static struct zt_pvt *mkintf(int channel if (conf.chan.sig == SIG_SS7) { struct zt_ss7 *ss7; int clear = 0; - if (ioctl(tmp->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &clear)) { + if (ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &clear)) { ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d of span %d: %s\n", channel, params.spanno, strerror(errno)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } ss7 = ss7_resolve_linkset(cur_linkset); if (!ss7) { ast_log(LOG_ERROR, "Unable to find linkset %d\n", cur_linkset); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (cur_cicbeginswith < 0) { ast_log(LOG_ERROR, "Need to set cicbeginswith for the channels!\n"); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } - tmp->cic = cur_cicbeginswith++; + zap_chan->cic = cur_cicbeginswith++; /* DB: Add CIC's DPC information */ - tmp->dpc = cur_defaultdpc; + zap_chan->dpc = cur_defaultdpc; - tmp->ss7 = ss7; - tmp->ss7call = NULL; - ss7->pvts[ss7->numchans++] = tmp; + zap_chan->ss7 = ss7; + zap_chan->ss7call = NULL; + ss7->pvts[ss7->numchans++] = zap_chan; ast_copy_string(linksets[span].internationalprefix, conf.ss7.internationalprefix, sizeof(linksets[span].internationalprefix)); ast_copy_string(linksets[span].nationalprefix, conf.ss7.nationalprefix, sizeof(linksets[span].nationalprefix)); @@ -8195,28 +8195,28 @@ static struct zt_pvt *mkintf(int channel int x,y; offset = 0; if (((conf.chan.sig == SIG_PRI) || (conf.chan.sig == SIG_BRI) || (conf.chan.sig == SIG_BRI_PTMP)) - && ioctl(tmp->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &offset)) { + && ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &offset)) { ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d of span %d: %s\n", channel, params.spanno, strerror(errno)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (span >= NUM_SPANS) { ast_log(LOG_ERROR, "Channel %d does not lie on a span I know of (%d)\n", channel, span); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } else { si.spanno = 0; - if (ioctl(tmp->subs[SUB_REAL].zfd,ZT_SPANSTAT,&si) == -1) { + if (ioctl(zap_chan->subs[SUB_REAL].zfd,ZT_SPANSTAT,&si) == -1) { ast_log(LOG_ERROR, "Unable to get span status: %s\n", strerror(errno)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } /* Store the logical span first based upon the real span */ - tmp->logicalspan = pris[span].prilogicalspan; + zap_chan->logicalspan = pris[span].prilogicalspan; pri_resolve_span(&span, channel, (channel - params.chanpos), &si); if (span < 0) { ast_log(LOG_WARNING, "Channel %d: Unable to find locate channel/trunk group!\n", channel); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if ((conf.chan.sig == SIG_PRI) || @@ -8229,7 +8229,7 @@ static struct zt_pvt *mkintf(int channel matchesdchan=0; for (x = 0; x < NUM_SPANS; x++) { for (y = 0; y < NUM_DCHANS; y++) { - if (pris[x].dchannels[y] == tmp->channel) { + if (pris[x].dchannels[y] == zap_chan->channel) { matchesdchan = 1; break; } @@ -8239,43 +8239,43 @@ static struct zt_pvt *mkintf(int channel if (!matchesdchan) { if (pris[span].nodetype && (pris[span].nodetype != conf.pri.nodetype)) { ast_log(LOG_ERROR, "Span %d is already a %s node\n", span + 1, pri_node2str(pris[span].nodetype)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (pris[span].switchtype && (pris[span].switchtype != myswitchtype)) { ast_log(LOG_ERROR, "Span %d is already a %s switch\n", span + 1, pri_switch2str(pris[span].switchtype)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if ((pris[span].dialplan) && (pris[span].dialplan != conf.pri.dialplan)) { ast_log(LOG_ERROR, "Span %d is already a %s dialing plan\n", span + 1, dialplan2str(pris[span].dialplan)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, conf.pri.idledial)) { ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, conf.pri.idledial); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (!ast_strlen_zero(pris[span].idleext) && strcmp(pris[span].idleext, conf.pri.idleext)) { ast_log(LOG_ERROR, "Span %d already has idleext '%s'.\n", span + 1, conf.pri.idleext); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (pris[span].minunused && (pris[span].minunused != conf.pri.minunused)) { ast_log(LOG_ERROR, "Span %d already has minunused of %d.\n", span + 1, conf.pri.minunused); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (pris[span].minidle && (pris[span].minidle != conf.pri.minidle)) { ast_log(LOG_ERROR, "Span %d already has minidle of %d.\n", span + 1, conf.pri.minidle); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } if (pris[span].numchans >= MAX_CHANNELS) { ast_log(LOG_ERROR, "Unable to add channel %d: Too many channels in trunk group %d!\n", channel, pris[span].trunkgroup); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } @@ -8285,7 +8285,7 @@ static struct zt_pvt *mkintf(int channel pris[span].nsf = conf.pri.nsf; pris[span].dialplan = conf.pri.dialplan; pris[span].localdialplan = conf.pri.localdialplan; - pris[span].pvts[pris[span].numchans++] = tmp; + pris[span].pvts[pris[span].numchans++] = zap_chan; pris[span].minunused = conf.pri.minunused; pris[span].minidle = conf.pri.minidle; pris[span].overlapdial = conf.pri.overlapdial; @@ -8299,25 +8299,25 @@ static struct zt_pvt *mkintf(int channel ast_copy_string(pris[span].unknownprefix, conf.pri.unknownprefix, sizeof(pris[span].unknownprefix)); pris[span].resetinterval = conf.pri.resetinterval; - tmp->pri = &pris[span]; - tmp->prioffset = offset; - tmp->call = NULL; + zap_chan->pri = &pris[span]; + zap_chan->prioffset = offset; + zap_chan->call = NULL; } else { ast_log(LOG_ERROR, "Channel %d is reserved for D-channel.\n", offset); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } } } else { - tmp->prioffset = 0; + zap_chan->prioffset = 0; } #endif } else { - conf.chan.sig = tmp->sig; - conf.chan.radio = tmp->radio; + conf.chan.sig = zap_chan->sig; + conf.chan.radio = zap_chan->radio; memset(¶ms, 0, sizeof(params)); - if (tmp->subs[SUB_REAL].zfd > -1) - res = ioctl(tmp->subs[SUB_REAL].zfd, ZT_GET_PARAMS, ¶ms); + if (zap_chan->subs[SUB_REAL].zfd > -1) + res = ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_GET_PARAMS, ¶ms); } /* Adjust starttime on loopstart and kewlstart trunks to reasonable values */ if ((conf.chan.sig == SIG_FXSKS) || (conf.chan.sig == SIG_FXSLS) || @@ -8359,24 +8359,24 @@ static struct zt_pvt *mkintf(int channel } /* dont set parms on a pseudo-channel (or CRV) */ - if (tmp->subs[SUB_REAL].zfd >= 0) + if (zap_chan->subs[SUB_REAL].zfd >= 0) { - res = ioctl(tmp->subs[SUB_REAL].zfd, ZT_SET_PARAMS, ¶ms); + res = ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_SET_PARAMS, ¶ms); if (res < 0) { ast_log(LOG_ERROR, "Unable to set parameters\n"); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } } #if 1 - if (!here && (tmp->subs[SUB_REAL].zfd > -1)) { + if (!here && (zap_chan->subs[SUB_REAL].zfd > -1)) { memset(&bi, 0, sizeof(bi)); - res = ioctl(tmp->subs[SUB_REAL].zfd, ZT_GET_BUFINFO, &bi); + res = ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_GET_BUFINFO, &bi); if (!res) { bi.txbufpolicy = ZT_POLICY_IMMEDIATE; bi.rxbufpolicy = ZT_POLICY_IMMEDIATE; bi.numbufs = numbufs; - res = ioctl(tmp->subs[SUB_REAL].zfd, ZT_SET_BUFINFO, &bi); + res = ioctl(zap_chan->subs[SUB_REAL].zfd, ZT_SET_BUFINFO, &bi); if (res < 0) { ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d\n", channel); } @@ -8384,202 +8384,202 @@ static struct zt_pvt *mkintf(int channel ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d\n", channel); } #endif - tmp->immediate = conf.chan.immediate; - tmp->transfertobusy = conf.chan.transfertobusy; + zap_chan->immediate = conf.chan.immediate; + zap_chan->transfertobusy = conf.chan.transfertobusy; if (conf.chan.sig & __ZT_SIG_FXS) { - tmp->mwimonitor_fsk = conf.chan.mwimonitor_fsk; - tmp->mwimonitor_neon = conf.chan.mwimonitor_neon; + zap_chan->mwimonitor_fsk = conf.chan.mwimonitor_fsk; + zap_chan->mwimonitor_neon = conf.chan.mwimonitor_neon; } - tmp->sig = conf.chan.sig; - tmp->outsigmod = conf.chan.outsigmod; - tmp->radio = conf.chan.radio; - tmp->ringt_base = ringt_base; - tmp->firstradio = 0; + zap_chan->sig = conf.chan.sig; + zap_chan->outsigmod = conf.chan.outsigmod; + zap_chan->radio = conf.chan.radio; + zap_chan->ringt_base = ringt_base; + zap_chan->firstradio = 0; if ((conf.chan.sig == SIG_FXOKS) || (conf.chan.sig == SIG_FXOLS) || (conf.chan.sig == SIG_FXOGS)) - tmp->permcallwaiting = conf.chan.callwaiting; + zap_chan->permcallwaiting = conf.chan.callwaiting; else - tmp->permcallwaiting = 0; + zap_chan->permcallwaiting = 0; /* Flag to destroy the channel must be cleared on new mkif. Part of changes for reload to work */ - tmp->destroy = 0; - tmp->drings = conf.chan.drings; - tmp->usedistinctiveringdetection = usedistinctiveringdetection; - tmp->callwaitingcallerid = conf.chan.callwaitingcallerid; - tmp->threewaycalling = conf.chan.threewaycalling; - tmp->adsi = conf.chan.adsi; - tmp->use_smdi = conf.chan.use_smdi; - tmp->permhidecallerid = conf.chan.hidecallerid; - tmp->callreturn = conf.chan.callreturn; - tmp->echocancel = conf.chan.echocancel; - tmp->echotraining = conf.chan.echotraining; - tmp->pulse = conf.chan.pulse; + zap_chan->destroy = 0; + zap_chan->drings = conf.chan.drings; + zap_chan->usedistinctiveringdetection = usedistinctiveringdetection; + zap_chan->callwaitingcallerid = conf.chan.callwaitingcallerid; + zap_chan->threewaycalling = conf.chan.threewaycalling; + zap_chan->adsi = conf.chan.adsi; + zap_chan->use_smdi = conf.chan.use_smdi; + zap_chan->permhidecallerid = conf.chan.hidecallerid; + zap_chan->callreturn = conf.chan.callreturn; + zap_chan->echocancel = conf.chan.echocancel; + zap_chan->echotraining = conf.chan.echotraining; + zap_chan->pulse = conf.chan.pulse; #if defined(HAVE_ZAPTEL_ECHOCANPARAMS) - if (tmp->echocancel.head.tap_length) { + if (zap_chan->echocancel.head.tap_length) { #else - if (tmp->echocancel) { + if (zap_chan->echocancel) { #endif - tmp->echocanbridged = conf.chan.echocanbridged; + zap_chan->echocanbridged = conf.chan.echocanbridged; } else { if (conf.chan.echocanbridged) ast_log(LOG_NOTICE, "echocancelwhenbridged requires echocancel to be enabled; ignoring\n"); - tmp->echocanbridged = 0; + zap_chan->echocanbridged = 0; } - tmp->busydetect = conf.chan.busydetect; - tmp->busycount = conf.chan.busycount; - tmp->busy_tonelength = conf.chan.busy_tonelength; - tmp->busy_quietlength = conf.chan.busy_quietlength; - tmp->callprogress = conf.chan.callprogress; - tmp->cancallforward = conf.chan.cancallforward; - tmp->dtmfrelax = conf.chan.dtmfrelax; - tmp->callwaiting = tmp->permcallwaiting; - tmp->hidecallerid = tmp->permhidecallerid; - tmp->channel = channel; - tmp->stripmsd = conf.chan.stripmsd; - tmp->use_callerid = conf.chan.use_callerid; - tmp->cid_signalling = conf.chan.cid_signalling; - tmp->cid_start = conf.chan.cid_start; - tmp->zaptrcallerid = conf.chan.zaptrcallerid; - tmp->restrictcid = conf.chan.restrictcid; - tmp->use_callingpres = conf.chan.use_callingpres; - tmp->priindication_oob = conf.chan.priindication_oob; - tmp->priexclusive = conf.chan.priexclusive; - if (tmp->usedistinctiveringdetection) { - if (!tmp->use_callerid) { + zap_chan->busydetect = conf.chan.busydetect; + zap_chan->busycount = conf.chan.busycount; + zap_chan->busy_tonelength = conf.chan.busy_tonelength; + zap_chan->busy_quietlength = conf.chan.busy_quietlength; + zap_chan->callprogress = conf.chan.callprogress; + zap_chan->cancallforward = conf.chan.cancallforward; + zap_chan->dtmfrelax = conf.chan.dtmfrelax; + zap_chan->callwaiting = zap_chan->permcallwaiting; + zap_chan->hidecallerid = zap_chan->permhidecallerid; + zap_chan->channel = channel; + zap_chan->stripmsd = conf.chan.stripmsd; + zap_chan->use_callerid = conf.chan.use_callerid; + zap_chan->cid_signalling = conf.chan.cid_signalling; + zap_chan->cid_start = conf.chan.cid_start; + zap_chan->zaptrcallerid = conf.chan.zaptrcallerid; + zap_chan->restrictcid = conf.chan.restrictcid; + zap_chan->use_callingpres = conf.chan.use_callingpres; + zap_chan->priindication_oob = conf.chan.priindication_oob; + zap_chan->priexclusive = conf.chan.priexclusive; + if (zap_chan->usedistinctiveringdetection) { + if (!zap_chan->use_callerid) { ast_log(LOG_NOTICE, "Distinctive Ring detect requires 'usecallerid' be on\n"); - tmp->use_callerid = 1; + zap_chan->use_callerid = 1; } } - if (tmp->cid_signalling == CID_SIG_SMDI) { - if (!tmp->use_smdi) { + if (zap_chan->cid_signalling == CID_SIG_SMDI) { + if (!zap_chan->use_smdi) { ast_log(LOG_WARNING, "SMDI callerid requires SMDI to be enabled, enabling...\n"); - tmp->use_smdi = 1; + zap_chan->use_smdi = 1; } } - if (tmp->use_smdi) { - tmp->smdi_iface = ast_smdi_interface_find(conf.smdi_port); - if (!(tmp->smdi_iface)) { + if (zap_chan->use_smdi) { + zap_chan->smdi_iface = ast_smdi_interface_find(conf.smdi_port); + if (!(zap_chan->smdi_iface)) { ast_log(LOG_ERROR, "Invalid SMDI port specfied, disabling SMDI support\n"); - tmp->use_smdi = 0; + zap_chan->use_smdi = 0; } } - ast_copy_string(tmp->accountcode, conf.chan.accountcode, sizeof(tmp->accountcode)); - tmp->amaflags = conf.chan.amaflags; + ast_copy_string(zap_chan->accountcode, conf.chan.accountcode, sizeof(zap_chan->accountcode)); + zap_chan->amaflags = conf.chan.amaflags; if (!here) { - tmp->confno = -1; - tmp->propconfno = -1; + zap_chan->confno = -1; + zap_chan->propconfno = -1; } - tmp->canpark = conf.chan.canpark; - tmp->transfer = conf.chan.transfer; - ast_copy_string(tmp->defcontext,conf.chan.context,sizeof(tmp->defcontext)); - ast_copy_string(tmp->language, conf.chan.language, sizeof(tmp->language)); - ast_copy_string(tmp->mohinterpret, conf.chan.mohinterpret, sizeof(tmp->mohinterpret)); - ast_copy_string(tmp->mohsuggest, conf.chan.mohsuggest, sizeof(tmp->mohsuggest)); - ast_copy_string(tmp->context, conf.chan.context, sizeof(tmp->context)); - ast_copy_string(tmp->cid_num, conf.chan.cid_num, sizeof(tmp->cid_num)); - tmp->cid_ton = 0; - ast_copy_string(tmp->cid_name, conf.chan.cid_name, sizeof(tmp->cid_name)); - ast_copy_string(tmp->mailbox, conf.chan.mailbox, sizeof(tmp->mailbox)); - if (!ast_strlen_zero(tmp->mailbox)) { + zap_chan->canpark = conf.chan.canpark; + zap_chan->transfer = conf.chan.transfer; + ast_copy_string(zap_chan->defcontext,conf.chan.context,sizeof(zap_chan->defcontext)); + ast_copy_string(zap_chan->language, conf.chan.language, sizeof(zap_chan->language)); + ast_copy_string(zap_chan->mohinterpret, conf.chan.mohinterpret, sizeof(zap_chan->mohinterpret)); + ast_copy_string(zap_chan->mohsuggest, conf.chan.mohsuggest, sizeof(zap_chan->mohsuggest)); + ast_copy_string(zap_chan->context, conf.chan.context, sizeof(zap_chan->context)); + ast_copy_string(zap_chan->cid_num, conf.chan.cid_num, sizeof(zap_chan->cid_num)); + zap_chan->cid_ton = 0; + ast_copy_string(zap_chan->cid_name, conf.chan.cid_name, sizeof(zap_chan->cid_name)); + ast_copy_string(zap_chan->mailbox, conf.chan.mailbox, sizeof(zap_chan->mailbox)); + if (!ast_strlen_zero(zap_chan->mailbox)) { char *mailbox, *context; - mailbox = context = ast_strdupa(tmp->mailbox); + mailbox = context = ast_strdupa(zap_chan->mailbox); strsep(&context, "@"); if (ast_strlen_zero(context)) context = "default"; - tmp->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL, + zap_chan->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, NULL, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context, AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_EXISTS, AST_EVENT_IE_END); } - tmp->msgstate = -1; - tmp->group = conf.chan.group; - tmp->callgroup = conf.chan.callgroup; - tmp->pickupgroup= conf.chan.pickupgroup; + zap_chan->msgstate = -1; + zap_chan->group = conf.chan.group; + zap_chan->callgroup = conf.chan.callgroup; + zap_chan->pickupgroup= conf.chan.pickupgroup; if (conf.chan.vars) { - tmp->vars = conf.chan.vars; + zap_chan->vars = conf.chan.vars; conf.chan.vars = NULL; } - tmp->cid_rxgain = conf.chan.cid_rxgain; - tmp->rxgain = conf.chan.rxgain; - tmp->txgain = conf.chan.txgain; - tmp->tonezone = conf.chan.tonezone; - tmp->onhooktime = time(NULL); - if (tmp->subs[SUB_REAL].zfd > -1) { - set_actual_gain(tmp->subs[SUB_REAL].zfd, 0, tmp->rxgain, tmp->txgain, tmp->law); - if (tmp->dsp) - ast_dsp_digitmode(tmp->dsp, DSP_DIGITMODE_DTMF | tmp->dtmfrelax); - update_conf(tmp); + zap_chan->cid_rxgain = conf.chan.cid_rxgain; + zap_chan->rxgain = conf.chan.rxgain; + zap_chan->txgain = conf.chan.txgain; + zap_chan->tonezone = conf.chan.tonezone; + zap_chan->onhooktime = time(NULL); + if (zap_chan->subs[SUB_REAL].zfd > -1) { + set_actual_gain(zap_chan->subs[SUB_REAL].zfd, 0, zap_chan->rxgain, zap_chan->txgain, zap_chan->law); + if (zap_chan->dsp) + ast_dsp_digitmode(zap_chan->dsp, DSP_DIGITMODE_DTMF | zap_chan->dtmfrelax); + update_conf(zap_chan); if (!here) { if ((conf.chan.sig != SIG_BRI) && (conf.chan.sig != SIG_BRI_PTMP) && (conf.chan.sig != SIG_PRI) && (conf.chan.sig != SIG_SS7)) /* Hang it up to be sure it's good */ - zt_set_hook(tmp->subs[SUB_REAL].zfd, ZT_ONHOOK); + zt_set_hook(zap_chan->subs[SUB_REAL].zfd, ZT_ONHOOK); } - ioctl(tmp->subs[SUB_REAL].zfd,ZT_SETTONEZONE,&tmp->tonezone); + ioctl(zap_chan->subs[SUB_REAL].zfd,ZT_SETTONEZONE,&zap_chan->tonezone); #ifdef HAVE_PRI /* the dchannel is down so put the channel in alarm */ - if (tmp->pri && !pri_is_up(tmp->pri)) - tmp->inalarm = 1; + if (zap_chan->pri && !pri_is_up(zap_chan->pri)) + zap_chan->inalarm = 1; else - tmp->inalarm = 0; + zap_chan->inalarm = 0; #endif memset(&si, 0, sizeof(si)); - if (ioctl(tmp->subs[SUB_REAL].zfd,ZT_SPANSTAT,&si) == -1) { + if (ioctl(zap_chan->subs[SUB_REAL].zfd,ZT_SPANSTAT,&si) == -1) { ast_log(LOG_ERROR, "Unable to get span status: %s\n", strerror(errno)); - destroy_zt_pvt(&tmp); + destroy_zt_pvt(&zap_chan); return NULL; } - if (si.alarms) tmp->inalarm = 1; + if (si.alarms) zap_chan->inalarm = 1; } - tmp->polarityonanswerdelay = conf.chan.polarityonanswerdelay; - tmp->answeronpolarityswitch = conf.chan.answeronpolarityswitch; - tmp->hanguponpolarityswitch = conf.chan.hanguponpolarityswitch; - tmp->sendcalleridafter = conf.chan.sendcalleridafter; + zap_chan->polarityonanswerdelay = conf.chan.polarityonanswerdelay; + zap_chan->answeronpolarityswitch = conf.chan.answeronpolarityswitch; + zap_chan->hanguponpolarityswitch = conf.chan.hanguponpolarityswitch; + zap_chan->sendcalleridafter = conf.chan.sendcalleridafter; if (!here) { - tmp->locallyblocked = tmp->remotelyblocked = 0; + zap_chan->locallyblocked = zap_chan->remotelyblocked = 0; if ((conf.chan.sig == SIG_PRI) || (conf.chan.sig == SIG_BRI) || (conf.chan.sig == SIG_BRI_PTMP) || (conf.chan.sig == SIG_SS7)) - tmp->inservice = 0; + zap_chan->inservice = 0; else /* We default to in service on protocols that don't have a reset */ - tmp->inservice = 1; + zap_chan->inservice = 1; } } - if (tmp && !here) { + if (zap_chan && !here) { /* nothing on the iflist */ if (!*wlist) { - *wlist = tmp; - tmp->prev = NULL; - tmp->next = NULL; - *wend = tmp; + *wlist = zap_chan; + zap_chan->prev = NULL; + zap_chan->next = NULL; + *wend = zap_chan; } else { /* at least one member on the iflist */ struct zt_pvt *working = *wlist; /* check if we maybe have to put it on the begining */ - if (working->channel > tmp->channel) { - tmp->next = *wlist; - tmp->prev = NULL; - (*wlist)->prev = tmp; - *wlist = tmp; + if (working->channel > zap_chan->channel) { + zap_chan->next = *wlist; + zap_chan->prev = NULL; + (*wlist)->prev = zap_chan; + *wlist = zap_chan; } else { /* go through all the members and put the member in the right place */ while (working) { /* in the middle */ if (working->next) { - if (working->channel < tmp->channel && working->next->channel > tmp->channel) { - tmp->next = working->next; - tmp->prev = working; - working->next->prev = tmp; - working->next = tmp; + if (working->channel < zap_chan->channel && working->next->channel > zap_chan->channel) { + zap_chan->next = working->next; + zap_chan->prev = working; + working->next->prev = zap_chan; + working->next = zap_chan; break; } } else { /* the last */ - if (working->channel < tmp->channel) { - working->next = tmp; - tmp->next = NULL; - tmp->prev = working; - *wend = tmp; + if (working->channel < zap_chan->channel) { + working->next = zap_chan; + zap_chan->next = NULL; + zap_chan->prev = working; + *wend = zap_chan; break; } } @@ -8588,7 +8588,7 @@ static struct zt_pvt *mkintf(int channel } } } - return tmp; + return zap_chan; } static inline int available(struct zt_pvt *p, int channelmatch, ast_group_t groupmatch, int *busy, int *channelmatched, int *groupmatched)