add function to initialize a new trunk.

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@92 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2007-05-22 02:45:42 +00:00
parent 7eebf19e08
commit 36d6b40908
2 changed files with 77 additions and 33 deletions

View File

@ -68,28 +68,54 @@ L3INT Q931CreateIEIndex(L3INT iec)
}
*/
void Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk)
L3INT Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk, Q931Dialect_t Dialect, Q931NetUser_t NetUser, Q931_TrunkType_t TrunkType)
{
int y;
int y, dchannel, maxchans;
switch(TrunkType)
{
case Q931_TrType_E1:
dchannel = 16;
maxchans = 31;
break;
case Q931_TrType_T1:
case Q931_TrType_J1:
dchannel = 24;
maxchans = 24;
break;
case Q931_TrType_BRI:
dchannel = 3;
maxchans = 3;
break;
default:
return 0;
}
pTrunk->LastCRV = 0;
pTrunk->Dialect = 0;
pTrunk->Dialect = Dialect;
pTrunk->Enabled = 0;
pTrunk->TrunkType = Q931_TrType_E1;
pTrunk->NetUser = Q931_TE;
pTrunk->TrunkType = TrunkType;
pTrunk->NetUser = NetUser;
pTrunk->TrunkState = 0;
for(y=0; y < Q931MAXCHPERTRUNK; y++)
{
pTrunk->ch[y].Available = 1;
/* Set up E1 scheme by default */
if(y==0)
if(y == 0)
{
pTrunk->ch[y].ChanType = Q931_ChType_Sync;
}
else if(y==16)
else if(y == dchannel)
{
pTrunk->ch[y].ChanType = Q931_ChType_D;
}
else if(y > maxchans)
{
pTrunk->ch[y].ChanType = Q931_ChType_NotUsed;
}
else
{
pTrunk->ch[y].ChanType = Q931_ChType_B;
@ -101,6 +127,7 @@ void Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk)
pTrunk->call[y].InUse = 0;
}
return 1;
}
void Q931SetMesProc(L3UCHAR mes, L3UCHAR dialect,

View File

@ -1918,34 +1918,54 @@ typedef struct
*****************************************************************************/
typedef enum /* Network/User Mode. */
{
Q931_TE=0, /* 0 : User Mode */
Q931_NT=1 /* 1 : Network Mode */
} Q931NetUser_t;
typedef enum /* Dialect enum */
{
Q931_Dialect_Q931 = 0,
Q931_Dialect_Count
} Q931Dialect_t;
typedef enum /* Trunk Line Type. */
{
Q931_TrType_E1=0, /* 0 : E1 Trunk */
Q931_TrType_T1=1, /* 1 : T1 Trunk */
Q931_TrType_J1=2, /* 2 : J1 Trunk */
Q931_TrType_BRI=3 /* 3 : BRI Trunk */
} Q931_TrunkType_t;
typedef enum /* Trunk State */
{
Q931_TrState_NoAlignment=0, /* Trunk not aligned */
Q931_TrState_Aligning=1, /* Aligning in progress */
Q931_TrState_Aligned=2 /* Trunk Aligned */
} Q931_TrunkState_t;
typedef enum {
Q931_ChType_NotUsed=0, /* Unused Channel */
Q931_ChType_B=1, /* B Channel (Voice) */
Q931_ChType_D=2, /* D Channel (Signalling) */
Q931_ChType_Sync=3 /* Sync Channel */
} Q931_ChanType_t;
typedef struct
{
enum _NetUser /* Network/User Mode. */
{
Q931_TE=0, /* 0 : User Mode */
Q931_NT=1 /* 1 : Network Mode */
}NetUser;
Q931NetUser_t NetUser; /* Network/User Mode. */
L3UCHAR Dialect; /* Q.931 Based dielact index. */
Q931Dialect_t Dialect; /* Q.931 Based dielact index. */
enum _TrunkType /* Trunk Line Type. */
{
Q931_TrType_E1=0, /* 0 : E1 Trunk */
Q931_TrType_T1=1, /* 1 : T1 Trunk */
Q931_TrType_J1=2, /* 2 : J1 Trunk */
Q931_TrType_BRI=3 /* 3 : BRI Trunk */
}TrunkType;
Q931_TrunkType_t TrunkType; /* Trunk Line Type. */
L3UCHAR Enabled; /* Enabled/Disabled */
/* 0 = Disabled */
/* 1 = Enabled */
enum _TrState /* Trunk State */
{
Q931_TrState_NoAlignment=0, /* Trunk not aligned */
Q931_TrState_Aligning=1, /* Aligning in progress */
Q931_TrState_Aligned=2 /* Trunk Aligned */
}TrunkState;
Q931_TrunkState_t TrunkState;
L3INT LastCRV; /* Last used crv for the trunk. */
@ -1972,12 +1992,7 @@ typedef struct
/* channels to fit an E1 since T1/J1 and BRI will fit inside a E1. */
struct _charray
{
enum _ChanType{
Q931_ChType_NotUsed=0, /* Unused Channel */
Q931_ChType_B=1, /* B Channel (Voice) */
Q931_ChType_D=2, /* D Channel (Signalling) */
Q931_ChType_Sync=3 /* Sync Channel */
}ChanType;
Q931_ChanType_t ChanType; /* Unused, B, D, Sync */
L3UCHAR Available; /* Channel Available Flag */
/* 0 : Avaiabled */
@ -2409,4 +2424,6 @@ L3INT Q931InitIEHLComp(Q931ie_HLComp * pIE);
L3INT Q931Disconnect(Q931_TrunkInfo *pTrunk, L3INT iTo, L3INT iCRV, L3INT iCause);
L3INT Q931ReleaseComplete(Q931_TrunkInfo *pTrunk, L3INT iTo);
L3INT Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk, Q931Dialect_t Dialect, Q931NetUser_t NetUser, Q931_TrunkType_t TrunkType);
#endif /* _Q931_NL */