diff --git a/libs/freetdm/src/isdn/Q931.c b/libs/freetdm/src/isdn/Q931.c index 191797d01d..f57365ecda 100644 --- a/libs/freetdm/src/isdn/Q931.c +++ b/libs/freetdm/src/isdn/Q931.c @@ -337,6 +337,10 @@ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT Size) /* Starting Codeset */ m->codeset = Q931_CODESET_0; + if (m->ProtDisc != 8) { + return Q931E_UNKNOWN_MESSAGE; + } + /* Call table proc to unpack codec message */ RetCode = Q931Umes[pTrunk->Dialect][m->MesType](pTrunk, Mes, (Q931mes_Generic *)pTrunk->L3Buf, Q931L4HeaderSpace + IOff , Size - Q931L4HeaderSpace - IOff + 1); @@ -533,7 +537,7 @@ L3INT Q931GetCallState(Q931_TrunkInfo_t *pTrunk, L3INT iCRV) L3INT x; for(x=0; x < Q931MAXCALLPERTRUNK; x++) { - if(!pTrunk->call[x].InUse) + if(pTrunk->call[x].InUse) { if(pTrunk->call[x].CRV == iCRV) { @@ -601,7 +605,7 @@ L3INT Q931FindCRV(Q931_TrunkInfo_t *pTrunk, L3INT crv, L3INT *callindex) L3INT x; for(x=0; x < Q931MAXCALLPERTRUNK; x++) { - if(!pTrunk->call[x].InUse) + if(pTrunk->call[x].InUse) { if(pTrunk->call[x].CRV == crv) { diff --git a/libs/freetdm/src/isdn/Q931StateTE.c b/libs/freetdm/src/isdn/Q931StateTE.c index eb9c2a38fb..941d683710 100644 --- a/libs/freetdm/src/isdn/Q931StateTE.c +++ b/libs/freetdm/src/isdn/Q931StateTE.c @@ -793,15 +793,19 @@ L3INT Q931ProcRestartTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) - return ret; + + if (pMes->CRV) { + /* Find the call using CRV */ + ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); + if(ret != Q931E_NO_ERROR) + return ret; + + /* TODO - Set correct timer here */ + Q931StartTimer(pTrunk, callIndex, 303); + } /* TODO chack against state table for illegal or unexpected message here*/ - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); if(iFrom == 4) { /* TODO Add proc here*/ @@ -826,15 +830,17 @@ L3INT Q931ProcRestartAckTE(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT iFrom) L3INT ret=Q931E_NO_ERROR; Q931mes_Header *pMes = (Q931mes_Header *)&buf[Q931L4HeaderSpace]; - /* Find the call using CRV */ - ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); - if(ret != Q931E_NO_ERROR) - return ret; + if (pMes->CRV) { + /* Find the call using CRV */ + ret = Q931FindCRV(pTrunk, pMes->CRV, &callIndex); + if(ret != Q931E_NO_ERROR) + return ret; + /* TODO - Set correct timer here */ + Q931StartTimer(pTrunk, callIndex, 303); + } /* TODO chack against state table for illegal or unexpected message here*/ - /* TODO - Set correct timer here */ - Q931StartTimer(pTrunk, callIndex, 303); if(iFrom == 4) { /* TODO Add proc here*/