From e4af9c444acc1fe8fc2afad2b435e8292d4de20b Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Wed, 30 Jan 2008 01:44:05 +0000 Subject: [PATCH] first hack at crv lookup table for zchan git-svn-id: http://svn.openzap.org/svn/openzap/trunk@378 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/include/openzap.h | 2 ++ libs/freetdm/src/zap_isdn.c | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/src/include/openzap.h b/libs/freetdm/src/include/openzap.h index d03ded222e..57a0081ab1 100644 --- a/libs/freetdm/src/include/openzap.h +++ b/libs/freetdm/src/include/openzap.h @@ -425,6 +425,8 @@ struct zap_span { teletone_tone_map_t tone_detect_map[ZAP_TONEMAP_INVALID+1]; teletone_multi_tone_t tone_finder[ZAP_TONEMAP_INVALID+1]; zap_channel_t channels[ZAP_MAX_CHANNELS_SPAN]; + zap_channel_t *channels_local_crv[32768]; + zap_channel_t *channels_remote_crv[32768]; zio_channel_outgoing_call_t outgoing_call; void *mod_data; char *type; diff --git a/libs/freetdm/src/zap_isdn.c b/libs/freetdm/src/zap_isdn.c index 4d10f8c555..9c22b96bda 100644 --- a/libs/freetdm/src/zap_isdn.c +++ b/libs/freetdm/src/zap_isdn.c @@ -67,10 +67,21 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen) zap_span_t *span = (zap_span_t *) pvt; zap_isdn_data_t *isdn_data = span->signal_data; Q931mes_Generic *gen = (Q931mes_Generic *) msg; - Q931ie_ChanID *chanid = Q931GetIEPtr(gen->ChanID, gen->buf); - int chan_id = chanid->ChanSlot; + int chan_id = 0; zap_channel_t *zchan = NULL; + if (Q931IsIEPresent(gen->ChanID)) { + Q931ie_ChanID *chanid = Q931GetIEPtr(gen->ChanID, gen->buf); + chan_id = chanid->ChanSlot; + zchan = &span->channels[chan_id]; + } else { + if (gen->CRVFlag) { + zchan = span->channels_local_crv[gen->CRV]; + } else { + zchan = span->channels_remote_crv[gen->CRV]; + } + } + assert(span != NULL); assert(isdn_data != NULL); @@ -129,6 +140,15 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen) } } else { switch(gen->MesType) { + case Q931mes_CALL_PROCEEDING: + { + if (zchan) { + zchan->span->channels_local_crv[gen->CRV] = zchan; + } else { + zap_log(ZAP_LOG_CRIT, "Received Release Complete with no matching channel %d\n", chan_id); + } + } + break; case Q931mes_RESTART: { if (zchan) { @@ -198,6 +218,7 @@ static L3INT zap_isdn_931_34(void *pvt, L2UCHAR *msg, L2INT mlen) if ((status = zap_channel_open(span->span_id, chan_id, &zchan) == ZAP_SUCCESS)) { if (zchan->state == ZAP_CHANNEL_STATE_DOWN) { + zchan->span->channels_remote_crv[gen->CRV] = zchan; memset(&zchan->caller_data, 0, sizeof(zchan->caller_data)); zap_set_string(zchan->caller_data.cid_num, (char *)callingnum->Digit);