fix caller id (MODAPP-77)

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@404 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2008-02-18 18:16:58 +00:00
parent 722d812aee
commit 77c2ce76bd
2 changed files with 64 additions and 26 deletions

View File

@ -752,6 +752,8 @@ L3INT Q931Pie_CalledNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf,
/* Octet 1 */
OBuf[(*Octet)++] = Q931ie_CALLED_PARTY_NUMBER;
/* Octet 2 */
li=(*Octet)++;
/* Octet 3 */
@ -814,7 +816,7 @@ L3INT Q931Uie_CallingNum(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHA
}
Octet++;
/* Octet 4a*/
/* Octet 4*/
x=0;
do{
pie->Digit[x] = IBuf[Octet+Off] & 0x7f;
@ -848,38 +850,31 @@ L3INT Q931Uie_CallingNum(Q931_TrunkInfo_t *pTrunk, Q931mes_Generic *pMsg, L3UCHA
*****************************************************************************/
L3INT Q931Pie_CallingNum(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT *Octet)
{
Q931ie_CallingSub * pIE = (Q931ie_CallingSub*)IBuf;
Q931ie_CallingNum * pIE = (Q931ie_CallingNum*)IBuf;
L3INT rc=0;
L3INT Beg=*Octet;
L3INT li;
L3INT sN = pIE->Size - sizeof(Q931ie_CalledSub) + 1;
L3INT sN = pIE->Size - sizeof(Q931ie_CallingNum);
L3INT x;
/* Octet 1 */
OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_SUBADDRESS;
OBuf[(*Octet)++] = Q931ie_CALLING_PARTY_NUMBER;
/* Octet 2 */
li=(*Octet)++;
/* Octet 3 */
OBuf[(*Octet)++] = 0x80 | (pIE->TypNum << 4) | (pIE->OddEvenInd << 3);
OBuf[(*Octet)++] = 0x00 | (pIE->TypNum << 4) | (pIE->NumPlanID);
/* 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 */
OBuf[(*Octet)++] = 0x80;
/* Octet 5 */
for(x=0;x<sN;x++)
{
OBuf[(*Octet)++] = pIE->Digit[x];
}
OBuf[(*Octet)-1] |= 0x80; /* Terminate bit */
OBuf[li] = (L3UCHAR)((*Octet)-Beg) - 2;
return rc;
}
@ -1528,7 +1523,7 @@ L3INT Q931Pie_Display(Q931_TrunkInfo_t *pTrunk, L3UCHAR *IBuf, L3UCHAR *OBuf, L3
OBuf[(*Octet)++] = Q931ie_DISPLAY;
li=(*Octet)++;
DSize = pIE->Size - sizeof(Q931ie_Display) + 1;
DSize = pIE->Size - sizeof(Q931ie_Display);
for(x=0; x< DSize; x++)
{

View File

@ -360,13 +360,16 @@ static __inline__ void state_advance(zap_channel_t *zchan)
Q931ie_BearerCap BearerCap;
Q931ie_ChanID ChanID;
Q931ie_CallingNum CallingNum;
Q931ie_CallingNum *ptrCallingNum;
Q931ie_CalledNum CalledNum;
Q931ie_CalledNum *ptrCalledNum;
Q931ie_Display Display, *ptrDisplay;
Q931InitIEBearerCap(&BearerCap);
Q931InitIEChanID(&ChanID);
Q931InitIECallingNum(&CallingNum);
Q931InitIECalledNum(&CalledNum);
Q931InitIEDisplay(&Display);
Q931InitMesGeneric(gen);
gen->MesType = Q931mes_SETUP;
@ -411,15 +414,56 @@ static __inline__ void state_advance(zap_channel_t *zchan)
ChanID.ChanMapType = 3; /* B-Chan */
ChanID.ChanSlot = (unsigned char)zchan->chan_id;
gen->ChanID = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &ChanID);
#if 0
CallingNum.Size += strlen(zchan->caller_data.cid_num);
Display.Size = Display.Size + (unsigned char)strlen(zchan->caller_data.cid_name);
gen->Display = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &Display);
ptrDisplay = Q931GetIEPtr(gen->Display, gen->buf);
zap_copy_string((char *)ptrDisplay->Display, zchan->caller_data.cid_name, strlen(zchan->caller_data.cid_name)+1);
/* TypNum: Type of number */
/* Bits 7 6 5 */
/* 000 Unknown */
/* 001 International number */
/* 010 National number */
/* 011 Network Specific number */
/* 100 Subscriber mumber */
/* 110 Abbreviated number */
/* 111 Reserved for extension */
/* All other values are reserved */
CallingNum.TypNum = 2;
/* NumPlanID */
/* Bits 4 3 2 1 */
/* 0000 Unknown */
/* 0001 ISDN/telephony numbering plan (E.164) */
/* 0011 Data numbering plan (X.121) */
/* 0100 Telex numbering plan (F.69) */
/* 1000 National standard numbering plan */
/* 1001 Private numbering plan */
/* 1111 Reserved for extension */
/* All other valures are reserved */
CallingNum.NumPlanID = 1;
/* Presentation indicator */
/* Bits 7 6 */
/* 00 Presenation Allowed */
/* 01 Presentation Restricted */
/* 10 Number not available due to internetworking */
/* 11 Reserved */
CallingNum.PresInd = 0;
/* Screening Indicator */
/* Bits 2 1 */
/* 00 User-provided, not screened */
/* 01 User-provided, verified and passed */
/* 10 User-provided, verified and failed */
/* 11 Network provided */
CallingNum.ScreenInd = 0;
CallingNum.Size = CallingNum.Size + (unsigned char)strlen(zchan->caller_data.cid_num);
gen->CallingNum = Q931AppendIE((L3UCHAR *) gen, (L3UCHAR *) &CallingNum);
zap_set_string((char *)CallingNum.Digit, zchan->caller_data.cid_num);
gen->Size += strlen(zchan->caller_data.cid_num);
ptrCallingNum = Q931GetIEPtr(gen->CallingNum, gen->buf);
zap_copy_string((char *)ptrCallingNum->Digit, zchan->caller_data.cid_num, strlen(zchan->caller_data.cid_num)+1);
//zap_set_string(zchan->caller_data.dnis, (char *)callednum->Digit);
#endif
CalledNum.TypNum = 2;
CalledNum.NumPlanID = 1;
CalledNum.Size = CalledNum.Size + (unsigned char)strlen(zchan->caller_data.ani);
@ -427,7 +471,6 @@ static __inline__ void state_advance(zap_channel_t *zchan)
ptrCalledNum = Q931GetIEPtr(gen->CalledNum, gen->buf);
zap_copy_string((char *)ptrCalledNum->Digit, zchan->caller_data.ani, strlen(zchan->caller_data.ani)+1);
//gen->Size += strlen(zchan->caller_data.ani);
Q931Rx43(&isdn_data->q931, (L3UCHAR *) gen, gen->Size);
zchan->span->channels_local_crv[gen->CRV] = zchan;
}