From 479628543d9ef998093642b2747352445dbc86a8 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Sat, 26 May 2007 01:02:43 +0000 Subject: [PATCH] better compliance with Q.931 on a few ie pack/unpack functions. Revert to using the corrected functions for national dialect. git-svn-id: http://svn.openzap.org/svn/openzap/trunk@154 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/freetdm/src/isdn/Q931ie.c | 10 +- libs/freetdm/src/isdn/include/national.h | 3 - libs/freetdm/src/isdn/nationalStateNT.c | 2 +- libs/freetdm/src/isdn/nationalStateTE.c | 2 +- libs/freetdm/src/isdn/nationalie.c | 113 ----------------------- 5 files changed, 7 insertions(+), 123 deletions(-) diff --git a/libs/freetdm/src/isdn/Q931ie.c b/libs/freetdm/src/isdn/Q931ie.c index 1435e3abc7..0e112675d2 100644 --- a/libs/freetdm/src/isdn/Q931ie.c +++ b/libs/freetdm/src/isdn/Q931ie.c @@ -453,7 +453,7 @@ L3INT Q931Uie_CallID(Q931_TrunkInfo_t *pTrunk, ie *pIE, L3UCHAR * IBuf, L3UCHAR pie->CallId[x] = IBuf[Octet+Off] & 0x7f; Off++; x++; - }while((IBuf[Octet+Off]&0x80) != 0 && x < 10); + }while(Q931MoreIE()); Q931IESizeTest(Q931E_CALLID); @@ -622,7 +622,7 @@ L3INT Q931Uie_CalledSub(Q931_TrunkInfo_t *pTrunk, ie *pIE,L3UCHAR * IBuf, L3UCHA pie->Digit[x] = IBuf[Octet+Off] & 0x7f; Off++; x++; - }while((IBuf[Octet+Off]&0x80) != 0 && x < 20); + }while(Q931MoreIE() && x < 20); Q931IESizeTest(Q931E_CALLEDSUB); @@ -713,7 +713,7 @@ L3INT Q931Uie_CalledNum(Q931_TrunkInfo_t *pTrunk, ie *pIE, L3UCHAR * IBuf, L3UCH Octet ++; /* Octet 4*/ - for (x = 0; x < IESize && x < 20; x++) + for (x = 0; x < IESize; x++) { pie->Digit[x] = IBuf[Octet+Off] & 0x7f; Off++; @@ -819,7 +819,7 @@ L3INT Q931Uie_CallingNum(Q931_TrunkInfo_t *pTrunk, ie *pIE, L3UCHAR * IBuf, L3UC pie->Digit[x] = IBuf[Octet+Off] & 0x7f; Off++; x++; - }while((IBuf[Octet+Off]&0x80) != 0 && x < 20); + }while((IBuf[Octet+Off]&0x80) == 0 && Q931MoreIE()); Q931IESizeTest(Q931E_CALLINGNUM); @@ -925,7 +925,7 @@ L3INT Q931Uie_CallingSub(Q931_TrunkInfo_t *pTrunk, ie *pIE,L3UCHAR * IBuf, L3UCH pie->Digit[x] = IBuf[Octet+Off] & 0x7f; Off++; x++; - }while((IBuf[Octet+Off]&0x80) != 0 && x < 20); + }while(Q931MoreIE() && x < 20); Q931IESizeTest(Q931E_CALLINGSUB); diff --git a/libs/freetdm/src/isdn/include/national.h b/libs/freetdm/src/isdn/include/national.h index 98ad07609b..1e9f5b1f8f 100644 --- a/libs/freetdm/src/isdn/include/national.h +++ b/libs/freetdm/src/isdn/include/national.h @@ -93,9 +93,6 @@ typedef struct *****************************************************************************/ L3INT nationalPie_GenericDigits(Q931_TrunkInfo_t *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); -L3INT nationalPie_CallingNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet); - -L3INT nationalUie_CallingNum(Q931_TrunkInfo_t *pTrunk, ie *pIE, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff); L3INT nationalUie_GenericDigits(Q931_TrunkInfo_t *pTrunk,ie *pIE, L3UCHAR * IBuf, L3UCHAR *OBuf, L3INT *IOff, L3INT *OOff); diff --git a/libs/freetdm/src/isdn/nationalStateNT.c b/libs/freetdm/src/isdn/nationalStateNT.c index c18e185b5a..2465853fe1 100644 --- a/libs/freetdm/src/isdn/nationalStateNT.c +++ b/libs/freetdm/src/isdn/nationalStateNT.c @@ -107,7 +107,7 @@ void nationalCreateNT(L3UCHAR i) Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,nationalPie_CallingNum, nationalUie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); diff --git a/libs/freetdm/src/isdn/nationalStateTE.c b/libs/freetdm/src/isdn/nationalStateTE.c index f8b8a9f90c..0f3186e288 100644 --- a/libs/freetdm/src/isdn/nationalStateTE.c +++ b/libs/freetdm/src/isdn/nationalStateTE.c @@ -114,7 +114,7 @@ void nationalCreateTE(L3UCHAR i) Q931SetIEProc(Q931ie_KEYPAD_FACILITY, i,Q931Pie_KeypadFac, Q931Uie_KeypadFac); Q931SetIEProc(Q931ie_SIGNAL, i,Q931Pie_Signal, Q931Uie_Signal); Q931SetIEProc(Q931ie_TRANSIT_DELAY_SELECTION_AND_IND, i,Q931Pie_TransNetSel, Q931Uie_TransNetSel); - Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,nationalPie_CallingNum, nationalUie_CallingNum); + Q931SetIEProc(Q931ie_CALLING_PARTY_NUMBER, i,Q931Pie_CallingNum, Q931Uie_CallingNum); Q931SetIEProc(Q931ie_CALLING_PARTY_SUBADDRESS, i,Q931Pie_CallingSub, Q931Uie_CallingSub); Q931SetIEProc(Q931ie_CALLED_PARTY_NUMBER, i,Q931Pie_CalledNum, Q931Uie_CalledNum); Q931SetIEProc(Q931ie_CALLED_PARTY_SUBADDRESS, i,Q931Pie_CalledSub, Q931Uie_CalledSub); diff --git a/libs/freetdm/src/isdn/nationalie.c b/libs/freetdm/src/isdn/nationalie.c index 184c11aa18..bf9afbad80 100644 --- a/libs/freetdm/src/isdn/nationalie.c +++ b/libs/freetdm/src/isdn/nationalie.c @@ -139,116 +139,3 @@ L3INT nationalPie_GenericDigits(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR return Q931E_NO_ERROR; } -/***************************************************************************** - - Function: nationalUie_CallingNum - - Parameters: pIE[OUT] ptr to Information Element id. - IBuf[IN] ptr to a packed ie. - OBuf[OUT] ptr to buffer for Unpacked ie. - IOff[IN\OUT] Input buffer offset - OOff[IN\OUT] Output buffer offset - - Ibuf and OBuf points directly to buffers. The IOff and OOff - must be updated, but are otherwise not used in the ie unpack. - - Return Value: Error Message - -*****************************************************************************/ -L3INT nationalUie_CallingNum(Q931_TrunkInfo_t *pTrunk, ie *pIE, L3UCHAR * IBuf, L3UCHAR * OBuf, L3INT *IOff, L3INT *OOff) -{ - Q931ie_CallingNum * pie = (Q931ie_CallingNum*)OBuf; - L3INT Off = 0; - L3INT Octet = 0; - L3INT x; - L3INT IESize; - - *pIE=0; - - /* Octet 1 */ - pie->IEId = IBuf[Octet]; - Octet ++; - - /* Octet 2 */ - IESize = IBuf[Octet ++]; - - /* Octet 3 */ - pie->TypNum = (IBuf[Octet+Off] >> 4) & 0x07; - pie->NumPlanID = IBuf[Octet+Off] & 0x0f; - - /* Octet 3a */ - if((IBuf[Octet+Off] & 0x80) != 0) - { - Off++; - pie->PresInd = (IBuf[Octet+Off] >> 5) & 0x03; - pie->ScreenInd = IBuf[Octet+Off] & 0x03; - } - Octet++; - - /* Octet 4a*/ - x=0; - do{ - pie->Digit[x] = IBuf[Octet+Off] & 0x7f; - Off++; - x++; - }while(Q931MoreIE()); - - Q931IESizeTest(Q931E_CALLINGNUM); - - Q931SetIE(*pIE, *OOff); - - *IOff = (*IOff) + Octet + Off; - *OOff = (*OOff) + sizeof(Q931ie_CallingNum) + x - 1; - pie->Size = (L3UCHAR)(sizeof(Q931ie_CallingNum) + x - 1); - - return Q931E_NO_ERROR; -} - -/***************************************************************************** - - Function: nationalPie_CallingNum - - Parameters: IBuf[IN] Ptr to struct. - OBuf[OUT] Ptr tp packed output buffer. - Octet[IN/OUT] Offset into OBuf. - - Return Value: Error code, 0 = OK - -*****************************************************************************/ -L3INT nationalPie_CallingNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet) -{ - Q931ie_CallingSub * pIE = (Q931ie_CallingSub*)IBuf; - L3INT rc=0; - L3INT Beg=*Octet; - L3INT li; - L3INT sN = pIE->Size - sizeof(Q931ie_CalledSub) + 1; - L3INT x; - - /* Octet 1 */ - OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_SUBADDRESS; - li=(*Octet)++; - - /* Octet 3 */ - OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3); - - /* Octet 3a */ - /* - - Details about the use and how to detect if Octet 3a is used - are very weak. Temp left out. - - Octet 3 msb is set to 1 to indicate that this is not present - - */ - - /* Octet 4 */ - for(x=0;xDigit[x]; - } - - OBuf[(*Octet)-1] |= 0x80; /* Terminate bit */ - - OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2; - return rc; -}