add functions to initialize a trunk, and a public function to receive from layer 3 that sends an I frame.

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@86 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2007-05-22 01:25:35 +00:00
parent 65bf12a048
commit 45268b86af
2 changed files with 586 additions and 541 deletions

View File

@ -71,12 +71,36 @@ void Q921Init()
for(x=0; x<Q921MAXTRUNK;x++)
{
MFIFOCreate(Q921DevSpace[x].HDLCInQueue, Q921MAXHDLCSPACE, 10);
Q921DevSpace[x].vr=0;
Q921DevSpace[x].vs=0;
Q921DevSpace[x].state=0;;
Q921DevSpace[x].vr = 0;
Q921DevSpace[x].vs = 0;
Q921DevSpace[x].state = 0;
Q921DevSpace[x].sapi = 0;
Q921DevSpace[x].tei = 0;
Q921DevSpace[x].NetUser = Q921_TE;
}
}
/*****************************************************************************
Function: Q921_InitTrunk
Decription: Initialize a Q.921 trunk so it is ready for use. This
function should be called before you call the rx functions
if your trunk will not use hardcoded tei and sapi of 0 or
if your trunk is not TE (user) mode (i.e. NET).
*****************************************************************************/
int Q921_InitTrunk(long trunk, int sapi, int tei, Q921NetUser_t NetUser)
{
if (trunk > Q921MAXTRUNK)
return 0;
Q921DevSpace[trunk].sapi = sapi;
Q921DevSpace[trunk].tei = tei;
Q921DevSpace[trunk].NetUser = NetUser;
return 1;
}
void Q921SetHeaderSpace(int hspace)
{
Q921HeaderSpace=hspace;
@ -146,6 +170,16 @@ int Q921SendI(int trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR *m
return Q921Tx21Proc(trunk, mes, size);
}
int Q921Rx32(long trunk, L2UCHAR * Mes, L2INT Size)
{
return Q921SendI(trunk,
Q921DevSpace[x].sapi,
Q921DevSpace[x].NetUser == Q921_TE ? 0 : 1;
Q921DevSpace[x].tei,
0,
Mes,
Size);
}
/*****************************************************************************
Function: Q921SendRR

View File

@ -98,15 +98,26 @@
#define L2UCHAR unsigned char /* Min 8 bit */
#define L2INT int /* Min 16 bit signed */
typedef enum /* Network/User Mode. */
{
Q921_TE=0, /* 0 : User Mode */
Q921_NT=1 /* 1 : Network Mode */
} Q921NetUser_t;
typedef struct
{
L2UCHAR HDLCInQueue[Q921MAXHDLCSPACE];
L2UCHAR vs;
L2UCHAR vr;
int state;
L2INT state;
L2INT sapi;
L2INT tei;
Q921NetUser_t NetUser;
}Q921Data;
void Q921Init();
int Q921_InitTrunk(long trunk, int sapi, int tei, Q921NetUser_t NetUser);
void Q921SetHeaderSpace(int hspace);
void Q921SetTx21CB(int (*callback)(int dev, L2UCHAR *, int));
void Q921SetTx23CB(int (*callback)(int dev, L2UCHAR *, int));