diff --git a/libs/freetdm/src/isdn/Q931.c b/libs/freetdm/src/isdn/Q931.c index 6c0b65613c..e1606b0809 100644 --- a/libs/freetdm/src/isdn/Q931.c +++ b/libs/freetdm/src/isdn/Q931.c @@ -329,6 +329,7 @@ L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT Size) m->ProtDisc = Mes[IOff++]; /* CRV */ + m->CRVFlag = Mes[IOff + 1] & 0x80; m->CRV = Q931Uie_CRV(pTrunk, Mes, m->buf, &IOff, &ISize); /* Message Type */ diff --git a/libs/freetdm/src/isdn/Q931ie.c b/libs/freetdm/src/isdn/Q931ie.c index f3041b2b0e..ca3bb9640b 100644 --- a/libs/freetdm/src/isdn/Q931ie.c +++ b/libs/freetdm/src/isdn/Q931ie.c @@ -1307,12 +1307,12 @@ L3USHORT Q931Uie_CRV(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3I if(l == 1) /* One octet CRV */ { - CRV = IBuf[Octet]; + CRV = IBuf[Octet] & 0x7F; Octet++; } else if(l==2) /* two octet CRV */ { - CRV = IBuf[Octet] << 8; + CRV = (IBuf[Octet] << 8) & 0x7F; CRV = CRV + IBuf[Octet+1]; Octet += 2; } diff --git a/libs/freetdm/src/isdn/Q931mes.c b/libs/freetdm/src/isdn/Q931mes.c index bc2facd7cb..d4229fe958 100644 --- a/libs/freetdm/src/isdn/Q931mes.c +++ b/libs/freetdm/src/isdn/Q931mes.c @@ -92,7 +92,7 @@ L3INT Q931Pmes_Alerting(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT I OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -180,7 +180,7 @@ L3INT Q931Pmes_CallProceeding(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -299,7 +299,7 @@ L3INT Q931Pmes_Connect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT IS OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -395,7 +395,7 @@ L3INT Q931Pmes_ConnectAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -460,7 +460,7 @@ L3INT Q931Pmes_Disconnect(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -535,7 +535,7 @@ L3INT Q931Pmes_Information(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3IN OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -610,7 +610,7 @@ L3INT Q931Pmes_Notify(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISi OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -678,7 +678,7 @@ L3INT Q931Pmes_Progress(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT I OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -756,7 +756,7 @@ L3INT Q931Pmes_Release(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT IS OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -823,7 +823,7 @@ L3INT Q931Pmes_ReleaseComplete(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -890,7 +890,7 @@ L3INT Q931Pmes_Restart(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT IS OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -957,7 +957,7 @@ L3INT Q931Pmes_RestartAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1022,7 +1022,7 @@ L3INT Q931Pmes_Resume(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISi OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1081,7 +1081,7 @@ L3INT Q931Pmes_ResumeAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1143,7 +1143,7 @@ L3INT Q931Pmes_ResumeReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3I /* Q931 Message Header */ OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1258,7 +1258,7 @@ L3INT Q931Pmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISiz OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1406,7 +1406,7 @@ L3INT Q931Pmes_SetupAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT I OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1481,7 +1481,7 @@ L3INT Q931Pmes_Status(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT ISi OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1546,7 +1546,7 @@ L3INT Q931Pmes_StatusEnquiry(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3 OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1603,7 +1603,7 @@ L3INT Q931Pmes_Suspend(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT IS OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1661,7 +1661,7 @@ L3INT Q931Pmes_SuspendAck(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ @@ -1719,7 +1719,7 @@ L3INT Q931Pmes_SuspendReject(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3 OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */ diff --git a/libs/freetdm/src/isdn/include/Q931.h b/libs/freetdm/src/isdn/include/Q931.h index b0bb3f4275..1243c5a114 100644 --- a/libs/freetdm/src/isdn/include/Q931.h +++ b/libs/freetdm/src/isdn/include/Q931.h @@ -390,6 +390,7 @@ typedef struct L3UINT Size; /* Size of message in bytes */ L3UCHAR ProtDisc; /* Protocol Discriminator */ L3UCHAR MesType; /* Message type */ + L3UCHAR CRVFlag; /* Call reference value flag */ L3INT CRV; /* Call reference value */ }Q931mes_Header; @@ -406,6 +407,7 @@ typedef struct L3UINT Size; /* Size of message in bytes */ L3UCHAR ProtDisc; /* Protocol Discriminator */ L3UCHAR MesType; /* Message type */ + L3UCHAR CRVFlag; /* Call reference value flag */ L3INT CRV; /* Call reference value */ ie Shift; diff --git a/libs/freetdm/src/isdn/nationalmes.c b/libs/freetdm/src/isdn/nationalmes.c index 41de1531c6..7dc73989e4 100644 --- a/libs/freetdm/src/isdn/nationalmes.c +++ b/libs/freetdm/src/isdn/nationalmes.c @@ -158,7 +158,7 @@ L3INT nationalPmes_Setup(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *IBuf, L3INT OBuf[Octet++] = pMes->ProtDisc; /* Protocol discriminator */ OBuf[Octet++] = 2; /* length is 2 octets */ - OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8); /* msb */ + OBuf[Octet++] = (L3UCHAR)(pMes->CRV>>8) | (pMes->CRVFlag << 7); /* msb */ OBuf[Octet++] = (L3UCHAR)(pMes->CRV); /* lsb */ OBuf[Octet++] = pMes->MesType; /* message header */