rework 921/931 api.

Move the Tx callbacks on each to be trunk specific, not global so that we can set them per trunk.
Change prototypes for the Tx callbacks so that they pass a trunk specific private pointer to the Tx callbacks so that 921 and 931 can call each other directly.
change 921 so that it doesn't use a static array for it's trunk structure to match 931
use more enums.
more to come....

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@96 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2007-05-22 08:03:20 +00:00
parent 5daa050cb5
commit f59812b19c
5 changed files with 2580 additions and 2606 deletions

View File

@ -2,13 +2,7 @@
FileName: q921.c
Description: Contains the implementation of a Q.921 protocol on top of the
Comet Driver.
Most of the work required to execute a Q.921 protocol is
taken care of by the Comet ship and it's driver. This layer
will simply configure and make use of these features to
complete a Q.921 implementation.
Description: Contains the implementation of a Q.921 protocol
Created: 27.dec.2000/JVB
@ -47,75 +41,48 @@
#include <stdlib.h>
#include "mfifo.h"
/*****************************************************************************
Global Tables & Variables.
*****************************************************************************/
#ifdef Q921_HANDLE_STATIC
Q921Data Q921DevSpace[Q921MAXTRUNK];
#endif
int Q921HeaderSpace={0};
int (*Q921Tx21Proc)(L2TRUNK dev, L2UCHAR *, int)={NULL};
int (*Q921Tx23Proc)(L2TRUNK dev, L2UCHAR *, int)={NULL};
/*****************************************************************************
Function: Q921Init
Decription: Initialize the Q.921 stack so it is ready for use. This
function MUST be called as part of initializing the
application.
*****************************************************************************/
void Q921Init()
{
#ifdef Q921_HANDLE_STATIC
int x;
for(x=0; x<Q921MAXTRUNK;x++)
{
Q921_InitTrunk(x, 0, 0, Q921_TE);
}
#endif
}
/*****************************************************************************
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).
function MUST be called before you call any other functions.
*****************************************************************************/
void Q921_InitTrunk(L2TRUNK trunk, L2UCHAR sapi, L2UCHAR tei, Q921NetUser_t NetUser)
void Q921_InitTrunk(L2TRUNK trunk,
L2UCHAR sapi,
L2UCHAR tei,
Q921NetUser_t NetUser,
L2INT hsize,
Q921TxCB_t cb21,
Q921TxCB_t cb23,
void *priv)
{
if (L2TRUNKHANDLE(trunk).initialized != INITIALIZED_MAGIC) {
MFIFOCreate(L2TRUNKHANDLE(trunk).HDLCInQueue, Q921MAXHDLCSPACE, 10);
L2TRUNKHANDLE(trunk).initialized = INITIALIZED_MAGIC;
if (trunk->initialized != INITIALIZED_MAGIC) {
MFIFOCreate(trunk->HDLCInQueue, Q921MAXHDLCSPACE, 10);
trunk->initialized = INITIALIZED_MAGIC;
}
L2TRUNKHANDLE(trunk).vr = 0;
L2TRUNKHANDLE(trunk).vs = 0;
L2TRUNKHANDLE(trunk).state = 0;
L2TRUNKHANDLE(trunk).sapi = sapi;
L2TRUNKHANDLE(trunk).tei = tei;
L2TRUNKHANDLE(trunk).NetUser = NetUser;
trunk->vr = 0;
trunk->vs = 0;
trunk->state = 0;
trunk->sapi = sapi;
trunk->tei = tei;
trunk->NetUser = NetUser;
trunk->Q921Tx21Proc = cb21;
trunk->Q921Tx23Proc = cb23;
trunk->PrivateData = priv;
trunk->Q921HeaderSpace = hsize;
}
void Q921SetHeaderSpace(int hspace)
static int Q921Tx21Proc(L2TRUNK trunk, L2UCHAR *Msg, L2INT size)
{
Q921HeaderSpace=hspace;
return trunk->Q921Tx21Proc(trunk->PrivateData, Msg, size);
}
void Q921SetTx21CB(int (*callback)(L2TRUNK dev, L2UCHAR *, int))
int Q921Tx23Proc(L2TRUNK trunk, L2UCHAR *Msg, L2INT size)
{
Q921Tx21Proc = callback;
}
return trunk->Q921Tx23Proc(trunk->PrivateData, Msg, size);
void Q921SetTx23CB(int (*callback)(L2TRUNK dev, L2UCHAR *, int))
{
Q921Tx23Proc = callback;
}
/*****************************************************************************
@ -137,9 +104,9 @@ void Q921SetTx23CB(int (*callback)(L2TRUNK dev, L2UCHAR *, int))
size size of frame in bytes
*****************************************************************************/
int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, int size)
int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, L2INT size)
{
return MFIFOWriteMes(L2TRUNKHANDLE(trunk).HDLCInQueue, b, size);
return MFIFOWriteMes(trunk->HDLCInQueue, b, size);
}
/*****************************************************************************
@ -161,13 +128,13 @@ int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, int size)
Return Value: 0 if failed, 1 if Send.
*****************************************************************************/
int Q921SendI(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR *mes, int size)
int Q921SendI(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHAR *mes, L2INT size)
{
mes[Q921HeaderSpace+0] = (Sapi&0xfc) | ((cr<<1)&0x02);
mes[Q921HeaderSpace+1] = (Tei<<1) | 0x01;
mes[Q921HeaderSpace+2] = L2TRUNKHANDLE(trunk).vs<<1;
mes[Q921HeaderSpace+3] = (L2TRUNKHANDLE(trunk).vr<<1) | (pf & 0x01);
L2TRUNKHANDLE(trunk).vs++;
mes[trunk->Q921HeaderSpace+0] = (Sapi&0xfc) | ((cr<<1)&0x02);
mes[trunk->Q921HeaderSpace+1] = (Tei<<1) | 0x01;
mes[trunk->Q921HeaderSpace+2] = trunk->vs<<1;
mes[trunk->Q921HeaderSpace+3] = (trunk->vr<<1) | (pf & 0x01);
trunk->vs++;
return Q921Tx21Proc(trunk, mes, size);
}
@ -175,9 +142,9 @@ int Q921SendI(L2TRUNK trunk, L2UCHAR Sapi, char cr, L2UCHAR Tei, char pf, L2UCHA
int Q921Rx32(L2TRUNK trunk, L2UCHAR * Mes, L2INT Size)
{
return Q921SendI(trunk,
L2TRUNKHANDLE(trunk).sapi,
L2TRUNKHANDLE(trunk).NetUser == Q921_TE ? 0 : 1,
L2TRUNKHANDLE(trunk).tei,
trunk->sapi,
trunk->NetUser == Q921_TE ? 0 : 1,
trunk->tei,
0,
Mes,
Size);
@ -202,12 +169,12 @@ int Q921SendRR(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)0x01;
mes[Q921HeaderSpace+3] = (L2UCHAR)((L2TRUNKHANDLE(trunk).vr<<1) | (pf & 0x01));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)0x01;
mes[trunk->Q921HeaderSpace+3] = (L2UCHAR)((trunk->vr<<1) | (pf & 0x01));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+4);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+4);
}
/*****************************************************************************
@ -229,12 +196,12 @@ int Q921SendRNR(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)0x05;
mes[Q921HeaderSpace+3] = (L2UCHAR)((L2TRUNKHANDLE(trunk).vr<<1) | (pf & 0x01));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)0x05;
mes[trunk->Q921HeaderSpace+3] = (L2UCHAR)((trunk->vr<<1) | (pf & 0x01));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+4);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+4);
}
/*****************************************************************************
@ -256,12 +223,12 @@ int Q921SendREJ(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)0x09;
mes[Q921HeaderSpace+3] = (L2UCHAR)((L2TRUNKHANDLE(trunk).vr<<1) | (pf & 0x01));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)0x09;
mes[trunk->Q921HeaderSpace+3] = (L2UCHAR)((trunk->vr<<1) | (pf & 0x01));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+4);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+4);
}
/*****************************************************************************
@ -283,11 +250,11 @@ int Q921SendSABME(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)(0x6f | ((pf<<4)&0x10));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)(0x6f | ((pf<<4)&0x10));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+3);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+3);
}
/*****************************************************************************
@ -309,11 +276,11 @@ int Q921SendDM(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)(0x0f | ((pf<<4)&0x10));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)(0x0f | ((pf<<4)&0x10));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+3);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+3);
}
/*****************************************************************************
@ -335,11 +302,11 @@ int Q921SendDISC(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)(0x43 | ((pf<<4)&0x10));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)(0x43 | ((pf<<4)&0x10));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+3);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+3);
}
/*****************************************************************************
@ -361,21 +328,21 @@ int Q921SendUA(L2TRUNK trunk, int Sapi, int cr, int Tei, int pf)
{
L2UCHAR mes[400];
mes[Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[Q921HeaderSpace+2] = (L2UCHAR)(0x63 | ((pf<<4)&0x10));
mes[trunk->Q921HeaderSpace+0] = (L2UCHAR)((Sapi&0xfc) | ((cr<<1)&0x02));
mes[trunk->Q921HeaderSpace+1] = (L2UCHAR)((Tei<<1) | 0x01);
mes[trunk->Q921HeaderSpace+2] = (L2UCHAR)(0x63 | ((pf<<4)&0x10));
return Q921Tx21Proc(trunk, mes, Q921HeaderSpace+3);
return Q921Tx21Proc(trunk, mes, trunk->Q921HeaderSpace+3);
}
int Q921ProcSABME(L2TRUNK trunk, L2UCHAR *mes, int size)
int Q921ProcSABME(L2TRUNK trunk, L2UCHAR *mes, L2INT size)
{
/* TODO: Do we need these paramaters? */
(void)mes;
(void)size;
L2TRUNKHANDLE(trunk).vr=0;
L2TRUNKHANDLE(trunk).vs=0;
trunk->vr=0;
trunk->vs=0;
return 1;
}
@ -401,18 +368,18 @@ int Q921ProcSABME(L2TRUNK trunk, L2UCHAR *mes, int size)
int Q921Rx12(L2TRUNK trunk)
{
L2UCHAR *mes;
int rs,size; /* receive size & Q921 frame size*/
L2UCHAR *smes = MFIFOGetMesPtr(L2TRUNKHANDLE(trunk).HDLCInQueue, &size);
L2INT rs,size; /* receive size & Q921 frame size*/
L2UCHAR *smes = MFIFOGetMesPtr(trunk->HDLCInQueue, &size);
if(smes != NULL)
{
rs = size - Q921HeaderSpace;
mes = &smes[Q921HeaderSpace];
rs = size - trunk->Q921HeaderSpace;
mes = &smes[trunk->Q921HeaderSpace];
/* check for I frame */
if((mes[2] & 0x01) == 0)
{
if(Q921Tx23Proc(trunk, smes, size-2)) /* -2 to clip away CRC */
{
L2TRUNKHANDLE(trunk).vr++;
trunk->vr++;
Q921SendRR(trunk, (mes[0]&0xfc)>>2, (mes[0]>>1)&0x01,mes[1]>>1, mes[3]&0x01);
}
else
@ -451,7 +418,7 @@ int Q921Rx12(L2TRUNK trunk)
/* todo: REJ or FRMR */
}
MFIFOKillNext(L2TRUNKHANDLE(trunk).HDLCInQueue);
MFIFOKillNext(trunk->HDLCInQueue);
return 1;
}

View File

@ -88,15 +88,7 @@ L3INT Q931L2HeaderSpace = {4}; /* Q921 header space, sapi, tei etc */
*****************************************************************************/
L3INT (*Q931Tx34Proc)(Q931_TrunkInfo *pTrunk, L3UCHAR *,L3INT);
/* callback for messages to be send to */
/* layer 4. */
L3INT (*Q931Tx32Proc)(Q931_TrunkInfo *pTrunk,L3UCHAR *,L3INT);
/* callback ptr for messages to be send */
/* to layer 2. */
L3INT (*Q931ErrorProc)(Q931_TrunkInfo *pTrunk, L3INT,L3INT,L3INT);
Q931ErrorCB_t Q931ErrorProc;
/* callback for error messages. */
L3ULONG (*Q931GetTimeProc) ()=NULL; /* callback for func reading time in ms */
@ -210,7 +202,7 @@ L3INT Q931TxDummy(Q931_TrunkInfo *pTrunk, L3UCHAR * b, L3INT n)
Description: Dummy function for error processing
*****************************************************************************/
L3INT Q931ErrorDummy(Q931_TrunkInfo *pTrunk,L3INT a, L3INT b, L3INT c)
L3INT Q931ErrorDummy(void *priv, L3INT a, L3INT b, L3INT c)
{
return 0;
}
@ -235,8 +227,6 @@ void Q931Initialize()
L3INT x,y;
/* Secure the callbacks to default procs */
Q931Tx34Proc = Q931TxDummy;
Q931Tx32Proc = Q931TxDummy;
Q931ErrorProc = Q931ErrorDummy;
/* The user will only add the message handlers and IE handlers he need, */
@ -360,7 +350,10 @@ L3INT Q931Rx23(Q931_TrunkInfo *pTrunk, L3UCHAR * buf, L3INT Size)
*****************************************************************************/
L3INT Q931Tx34(Q931_TrunkInfo *pTrunk, L3UCHAR * Mes, L3INT Size)
{
return Q931Tx34Proc(pTrunk, Mes, Size);
if (pTrunk->Q931Tx34CBProc) {
return pTrunk->Q931Tx34CBProc(pTrunk->PrivateData, Mes, Size);
}
return Q931E_MISSING_CB;
}
/*****************************************************************************
@ -415,7 +408,11 @@ L3INT Q931Tx32(Q931_TrunkInfo *pTrunk, L3UCHAR * Mes, L3INT Size)
RetCode = Q931Pmes[iDialect][ptr->MesType](pTrunk,Mes,Size,&pTrunk->L2Buf[Q931L2HeaderSpace], &OSize);
if(RetCode >= Q931E_NO_ERROR)
{
RetCode = Q931Tx32Proc(pTrunk, pTrunk->L2Buf, Size);
if (pTrunk->Q931Tx32CBProc) {
RetCode = pTrunk->Q931Tx32CBProc(pTrunk->PrivateData, pTrunk->L2Buf, Size);
} else {
RetCode = Q931E_MISSING_CB;
}
}
return RetCode;
@ -436,20 +433,14 @@ L3INT Q931Tx32(Q931_TrunkInfo *pTrunk, L3UCHAR * Mes, L3INT Size)
*****************************************************************************/
void Q931SetError(Q931_TrunkInfo *pTrunk,L3INT ErrID, L3INT ErrPar1, L3INT ErrPar2)
{
Q931ErrorProc(pTrunk,ErrID, ErrPar1, ErrPar2);
if (pTrunk->Q931ErrorCBProc) {
pTrunk->Q931ErrorCBProc(pTrunk->PrivateData, ErrID, ErrPar1, ErrPar2);
} else {
Q931ErrorProc(pTrunk->PrivateData, ErrID, ErrPar1, ErrPar2);
}
}
void Q931SetTx34CB(L3INT (*Q931Tx34Par)(Q931_TrunkInfo *pTrunk,L3UCHAR * Mes, L3INT Size))
{
Q931Tx34Proc = Q931Tx34Par;
}
void Q931SetTx32CB(L3INT (*Q931Tx32Par)(Q931_TrunkInfo *pTrunk,L3UCHAR * Mes, L3INT Size))
{
Q931Tx32Proc = Q931Tx32Par;
}
void Q931SetErrorCB(L3INT (*Q931ErrorPar)(Q931_TrunkInfo *pTrunk,L3INT,L3INT,L3INT))
void Q931SetDefaultErrorCB(Q931ErrorCB_t Q931ErrorPar)
{
Q931ErrorProc = Q931ErrorPar;
}

View File

@ -68,7 +68,14 @@ L3INT Q931CreateIEIndex(L3INT iec)
}
*/
L3INT Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk, Q931Dialect_t Dialect, Q931NetUser_t NetUser, Q931_TrunkType_t TrunkType)
L3INT Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk,
Q931Dialect_t Dialect,
Q931NetUser_t NetUser,
Q931_TrunkType_t TrunkType,
Q931TxCB_t Q931Tx34CBProc,
Q931TxCB_t Q931Tx32CBProc,
Q931ErrorCB_t Q931ErrorCBProc,
void *PrivateData)
{
int y, dchannel, maxchans, has_sync = 0;
@ -95,6 +102,11 @@ L3INT Q931Api_InitTrunk(Q931_TrunkInfo *pTrunk, Q931Dialect_t Dialect, Q931NetUs
return 0;
}
pTrunk->Q931Tx34CBProc = Q931Tx34CBProc;
pTrunk->Q931Tx32CBProc = Q931Tx32CBProc;
pTrunk->Q931ErrorCBProc = Q931ErrorCBProc;
pTrunk->PrivateData = PrivateData;
pTrunk->LastCRV = 0;
pTrunk->Dialect = Dialect;
pTrunk->Enabled = 0;

View File

@ -2,13 +2,7 @@
FileName: q921.h
Description: Contains headers of a Q.921 protocol on top of the Comet
Driver.
Most of the work required to execute a Q.921 protocol is
taken care of by the Comet ship and it's driver. This layer
will simply configure and make use of these features to
complete a Q.921 implementation.
Description: Contains headers of a Q.921 protocol.
Note: This header file is the only include file that should be
acessed by users of the Q.921 stack.
@ -19,7 +13,7 @@
- One driver layer.
The interface layer contains the interface functions required
for a layer 3 stack to be able to send and receive messages.
for a layer 2 stack to be able to send and receive messages.
The driver layer will simply feed bytes into the ship as
required and queue messages received out from the ship.
@ -33,7 +27,8 @@
Q921Rx32 Receive message from layer 3. Called by
the layer 3 stack to send a message.
Q921Tx23 Send a message to layer 3.
NOTE: The following are not yet implemented
OnQ921Error Function called every if an error is
deteceted.
@ -42,6 +37,10 @@
<TODO> Maintenance/Configuration interface
<TODO> Logging
<TODO> DL_ message passing to layer 3
<TODO> Timers
<TODO> Api commands to tell 921 to stop and start for a trunk
Created: 27.dec.2000/JVB
@ -80,31 +79,10 @@
#ifndef _Q921
#define _Q921
#define Q921MAXTRUNK 4
#define Q921MAXHDLCSPACE 3000
/*****************************************************************************
Some speed optimization can be achieved by changing all variables to the
word size of your processor. A 32 bit processor have to do a lot of extra
work to read a packed 8 bit integer. Changing all fields to 32 bit integer
will ressult in usage of some extra space, but speed up the stack.
The stack have been designed to allow L3UCHAR etc. to be any size of 8 bit
or larger.
*****************************************************************************/
#define L2UCHAR unsigned char /* Min 8 bit */
#define L2INT int /* Min 16 bit signed */
#ifdef Q921_HANDLE_STATIC
#define L2TRUNK long
#define L2TRUNKHANDLE(trunk) Q921DevSpace[trunk]
#else
#define L2TRUNK Q921Data *
#define L2TRUNKHANDLE(trunk) (*trunk)
#endif
#define L2TRUNK Q921Data_t *
typedef enum /* Network/User Mode. */
{
@ -112,8 +90,11 @@ typedef enum /* Network/User Mode. */
Q921_NT=1 /* 1 : Network Mode */
} Q921NetUser_t;
typedef struct Q921Data Q921Data_t;
typedef int (*Q921TxCB_t) (void *, L2UCHAR *, L2INT);
#define INITIALIZED_MAGIC 42
typedef struct
struct Q921Data
{
L2UCHAR HDLCInQueue[Q921MAXHDLCSPACE];
L2INT initialized;
@ -123,15 +104,22 @@ typedef struct
L2UCHAR sapi;
L2UCHAR tei;
Q921NetUser_t NetUser;
Q921TxCB_t Q921Tx21Proc;
Q921TxCB_t Q921Tx23Proc;
void *PrivateData;
L2INT Q921HeaderSpace;
}Q921Data;
};
void Q921Init();
void Q921_InitTrunk(L2TRUNK trunk, L2UCHAR sapi, L2UCHAR tei, Q921NetUser_t NetUser);
void Q921SetHeaderSpace(int hspace);
void Q921SetTx21CB(int (*callback)(L2TRUNK dev, L2UCHAR *, int));
void Q921SetTx23CB(int (*callback)(L2TRUNK dev, L2UCHAR *, int));
int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, int size);
void Q921_InitTrunk(L2TRUNK trunk,
L2UCHAR sapi,
L2UCHAR tei,
Q921NetUser_t NetUser,
L2INT hsize,
Q921TxCB_t cb21,
Q921TxCB_t cb23,
void *priv);
int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, L2INT size);
int Q921Rx12(L2TRUNK trunk);
int Q921Rx32(L2TRUNK trunk, L2UCHAR * Mes, L2INT Size);
#endif

File diff suppressed because it is too large Load Diff