--- channels/chan_zap.c 2007-03-26 18:04:34.000000000 -0300 +++ channels/chan_zap.c.new 2007-03-26 16:57:14.000000000 -0300 @@ -625,6 +625,7 @@ struct isup_call *ss7call; int transcap; int cic; /*!< CIC associated with channel */ + unsigned int dpc; /*!< CIC's DPC */ #endif char begindigit; } *iflist = NULL, *ifend = NULL; @@ -2196,7 +2197,7 @@ return -1; } - isup_init_call(p->ss7->ss7, p->ss7call, p->cic, c + p->stripmsd, l); + isup_init_call(p->ss7->ss7, p->ss7call, p->cic, p->dpc, c + p->stripmsd, l); isup_iam(p->ss7->ss7, p->ss7call); ss7_rel(p->ss7); @@ -7573,6 +7574,9 @@ tmp->cic = cur_cicbeginswith++; + /* DB: Add CIC's DPC information */ + tmp->dpc = cur_defaultdpc; + tmp->ss7 = ss7; tmp->ss7call = NULL; ss7->pvts[ss7->numchans++] = tmp; @@ -8391,23 +8395,28 @@ static void ss7_reset_linkset(struct zt_ss7 *linkset) { - int i, startcic = -1, endcic; + int i, startcic = -1, endcic, dpc; if (linkset->numchans <= 0) return; startcic = linkset->pvts[0]->cic; + /* DB: CIC's DPC fix */ + dpc = linkset->pvts[0]->dpc; for (i = 0; i < linkset->numchans; i++) { - if (linkset->pvts[i+1] && ((linkset->pvts[i+1]->cic - linkset->pvts[i]->cic) == 1) && (linkset->pvts[i]->cic - startcic < 31)) { + if (linkset->pvts[i+1] && linkset->pvts[i+1]->dpc == dpc && ((linkset->pvts[i+1]->cic - linkset->pvts[i]->cic) == 1) && (linkset->pvts[i]->cic - startcic < 31)) { continue; } else { endcic = linkset->pvts[i]->cic; ast_verbose("Resetting CICs %d to %d\n", startcic, endcic); - isup_grs(linkset->ss7, startcic, endcic); + isup_grs(linkset->ss7, startcic, endcic, dpc); - if (linkset->pvts[i+1]) + /* DB: CIC's DPC fix */ + if (linkset->pvts[i+1]) { startcic = linkset->pvts[i+1]->cic; + dpc = linkset->pvts[i+1]->dpc; + } } } } @@ -8451,6 +8460,7 @@ ast_log(LOG_WARNING, "Unable to start PBX on CIC %d\n", p->cic); } + static void *ss7_linkset(void *data) { int res, i; @@ -8463,6 +8473,7 @@ pthread_attr_t attr; struct pollfd pollers[NUM_DCHANS]; int cic; + unsigned int dpc; int nextms = 0; pthread_attr_init(&attr); @@ -8614,12 +8625,20 @@ ast_mutex_lock(&p->lock); p->inservice = 1; p->remotelyblocked = 0; + dpc = p->dpc; + isup_set_call_dpc(e->rsc.call, dpc); ast_mutex_unlock(&p->lock); isup_rlc(ss7, e->rsc.call); break; case ISUP_EVENT_GRS: ast_log(LOG_DEBUG, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic); - isup_gra(ss7, e->grs.startcic, e->grs.endcic); + chanpos = ss7_find_cic(linkset, e->grs.startcic); + if (chanpos < 0) { + ast_log(LOG_WARNING, "GRS on unconfigured CIC %d\n", e->grs.startcic); + break; + } + p = linkset->pvts[chanpos]; + isup_gra(ss7, e->grs.startcic, e->grs.endcic, p->dpc); ss7_block_cics(linkset, e->grs.startcic, e->grs.endcic, NULL, 0); break; case ISUP_EVENT_GRA: @@ -8649,7 +8668,9 @@ } } + dpc = p->dpc; p->ss7call = e->iam.call; + isup_set_call_dpc(p->ss7call, dpc); if (p->use_callerid) ast_copy_string(p->cid_num, e->iam.calling_party_num, sizeof(p->cid_num)); @@ -8740,12 +8761,24 @@ } break; case ISUP_EVENT_CGB: + chanpos = ss7_find_cic(linkset, e->cgb.startcic); + if (chanpos < 0) { + ast_log(LOG_WARNING, "CGB on unconfigured CIC %d\n", e->cgb.startcic); + break; + } + p = linkset->pvts[chanpos]; ss7_block_cics(linkset, e->cgb.startcic, e->cgb.endcic, e->cgb.status, 1); - isup_cgba(linkset->ss7, e->cgb.startcic, e->cgb.endcic, e->cgb.status); + isup_cgba(linkset->ss7, e->cgb.startcic, e->cgb.endcic, p->dpc, e->cgb.status); break; case ISUP_EVENT_CGU: - ss7_block_cics(linkset, e->cgu.startcic, e->cgu.endcic, e->cgb.status, 0); - isup_cgua(linkset->ss7, e->cgu.startcic, e->cgu.endcic, e->cgb.status); + chanpos = ss7_find_cic(linkset, e->cgu.startcic); + if (chanpos < 0) { + ast_log(LOG_WARNING, "CGU on unconfigured CIC %d\n", e->cgu.startcic); + break; + } + p = linkset->pvts[chanpos]; + ss7_block_cics(linkset, e->cgu.startcic, e->cgu.endcic, e->cgu.status, 0); + isup_cgua(linkset->ss7, e->cgu.startcic, e->cgu.endcic, p->dpc, e->cgu.status); break; case ISUP_EVENT_BLO: chanpos = ss7_find_cic(linkset, e->blo.cic); @@ -8758,7 +8791,7 @@ ast_mutex_lock(&p->lock); p->remotelyblocked = 1; ast_mutex_unlock(&p->lock); - isup_bla(linkset->ss7, e->blo.cic); + isup_bla(linkset->ss7, e->blo.cic, p->dpc); break; case ISUP_EVENT_UBL: chanpos = ss7_find_cic(linkset, e->ubl.cic); @@ -8771,7 +8804,7 @@ ast_mutex_lock(&p->lock); p->remotelyblocked = 0; ast_mutex_unlock(&p->lock); - isup_uba(linkset->ss7, e->ubl.cic); + isup_uba(linkset->ss7, e->ubl.cic, p->dpc); break; case ISUP_EVENT_CON: case ISUP_EVENT_ANM: @@ -11546,7 +11579,7 @@ linksets[linkset-1].pvts[i]->locallyblocked = 1; ast_mutex_unlock(&linksets[linkset-1].pvts[i]->lock); ast_mutex_lock(&linksets[linkset-1].lock); - isup_blo(linksets[linkset-1].ss7, cic); + isup_blo(linksets[linkset-1].ss7, cic, linksets[linkset-1].pvts[i]->dpc); ast_mutex_unlock(&linksets[linkset-1].lock); } } @@ -11599,7 +11632,7 @@ linksets[linkset-1].pvts[i]->locallyblocked = 0; ast_mutex_unlock(&linksets[linkset-1].pvts[i]->lock); ast_mutex_lock(&linksets[linkset-1].lock); - isup_ubl(linksets[linkset-1].ss7, cic); + isup_ubl(linksets[linkset-1].ss7, cic, linksets[linkset-1].pvts[i]->dpc); ast_mutex_unlock(&linksets[linkset-1].lock); } }