提交 70f5fc61 authored 作者: Michael Jerris's avatar Michael Jerris

checkin q931/q932/q921 code.

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@65 a93c3328-9c30-0410-af19-c9cd2b2d52af
上级 5ab3190c
/*****************************************************************************
FileName: EuroISDNStateNT.c
Contents: EuroISDN State Engine for NT (Network Mode).
The controlling state engine for Q.931 is the state engine
on the NT side. The state engine on the TE side is a slave
of this. The TE side maintain it's own states as described in
ITU-T Q931, but will in raise conditions be overridden by
the NT side.
License/Copyright:
Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
email:janvb@caselaboratories.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Case Labs, Ltd nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "Q931.h"
/*****************************************************************************
FileName: EuroISDNStateTE.c
Contents: EuroISDN State Engine for TE (User Mode).
The controlling state engine for Q.931 is the state engine
on the NT side. The state engine on the TE side is a slave
of this. The TE side maintain it's own states as described in
ITU-T Q931, but will in raise conditions be overridden by
the NT side.
License/Copyright:
Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
email:janvb@caselaboratories.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Case Labs, Ltd nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "Q931.h"
/*
EuroISDN is a sub-set of Q.931. Q.931 is very generic as it embrase a lot,
while EuroISDN is more exact and make decitions on some of the
'implementation options' in the original standard. EuroISDN will
however run smoothly under the generic space, so these functions are more
for show
*/
void EuroISDNCreateTE(L3UCHAR i)
{
Q931CreateTE(i);
}
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
/*****************************************************************************
FileName: Q932mes.c
Contents: Q.932 Message Encoders/Decoders
License/Copyright:
Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
email:janvb@caselaboratories.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Case Labs, Ltd nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include "Q931.h"
/*****************************************************************************
Function: Q932Umes_Facility
*****************************************************************************/
L3INT Q932Umes_Facility(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
L3INT rc=Q931E_NO_ERROR;
Q932mes_Facility *mes = (Q932mes_Facility*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_Facility) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_Facility
*****************************************************************************/
L3INT Q932Pmes_Facility(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_Hold
*****************************************************************************/
L3INT Q932Umes_Hold(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_Hold *mes = (Q932mes_Hold*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_Hold) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_Hold
*****************************************************************************/
L3INT Q932Pmes_Hold(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_HoldAck
*****************************************************************************/
L3INT Q932Umes_HoldAck(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_HoldAck *mes = (Q932mes_HoldAck*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_HoldAck) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_HoldAck
*****************************************************************************/
L3INT Q932Pmes_HoldAck(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_HoldReject
*****************************************************************************/
L3INT Q932Umes_HoldReject(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_HoldReject *mes = (Q932mes_HoldReject*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_HoldReject) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_HoldReject
*****************************************************************************/
L3INT Q932Pmes_HoldReject(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_Register
*****************************************************************************/
L3INT Q932Umes_Register(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_Register *mes = (Q932mes_Register*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_Register) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_Register
*****************************************************************************/
L3INT Q932Pmes_Register(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_Retrieve
*****************************************************************************/
L3INT Q932Umes_Retrieve(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_Retrieve *mes = (Q932mes_Retrieve*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_Retrieve) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_Retrieve
*****************************************************************************/
L3INT Q932Pmes_Retrieve(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_RetrieveAck
*****************************************************************************/
L3INT Q932Umes_RetrieveAck(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_RetrieveAck *mes = (Q932mes_RetrieveAck*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_RetrieveAck) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_RetrieveAck
*****************************************************************************/
L3INT Q932Pmes_RetrieveAck(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
Function: Q932Umes_RetrieveReject
*****************************************************************************/
L3INT Q932Umes_RetrieveReject(Q931_TrunkInfo *pTrunk,L3UCHAR *IBuf, L3UCHAR *OBuf, L3INT IOff, L3INT Size)
{
L3INT i = IOff;
L3INT ir=0;
L3INT OOff=0;
Q932mes_RetrieveReject *mes = (Q932mes_RetrieveReject*)IBuf;
//TODO
mes->Size = sizeof(Q932mes_RetrieveReject) - 1 + OOff;
return Q931E_NO_ERROR;
}
/*****************************************************************************
Function: Q931Pmes_RetrieveReject
*****************************************************************************/
L3INT Q932Pmes_RetrieveReject(Q931_TrunkInfo *pTrunk, L3UCHAR *IBuf, L3INT ISize, L3UCHAR *OBuf, L3INT *OSize)
{
L3BOOL RetCode = L3FALSE;
NoWarning(OBuf);
NoWarning(IBuf);
return RetCode;
}
/*****************************************************************************
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.
Note: This header file is the only include file that should be
acessed by users of the Q.921 stack.
Interface: The Q.921 stack contains 2 layers.
- One interface layer.
- One driver layer.
The interface layer contains the interface functions required
for a layer 3 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.
Q921TimeTick The Q.921 like any other blackbox
modules contains no thread by it's own
and must therefore be called regularly
by an external 'thread' to do maintenance
etc.
Q921Rx32 Receive message from layer 3. Called by
the layer 3 stack to send a message.
Q921Tx23 Send a message to layer 3.
OnQ921Error Function called every if an error is
deteceted.
OnQ921Log Function called if logging is active.
<TODO> Maintenance/Configuration interface
Created: 27.dec.2000/JVB
License/Copyright:
Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
email:janvb@caselaboratories.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Case Labs, Ltd nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef _Q921
#define _Q921
#define Q921MAXTRUNK 4
#define Q921MAXHDLCSPACE 3000
typedef struct
{
char HDLCInQueue[Q921MAXHDLCSPACE];
unsigned char vs;
unsigned char vr;
int state;
}Q921Data;
void Q921Init();
void Q921SetHeaderSpace(int hspace);
void Q921SetTx21CB(int (*callback)(int dev, unsigned char *, int));
void Q921SetTx23CB(int (*callback)(int dev, unsigned char *, int));
int Q921QueueHDLCFrame(int trunk, char *b, int size);
int Q921Rx12(long trunk);
#endif
差异被折叠。
差异被折叠。
/*****************************************************************************
Filename: mfifo.h
Contents: header for MFIFO
License/Copyright:
Copyright (c) 2007, Jan Vidar Berger, Case Labs, Ltd. All rights reserved.
email:janvb@caselaboratories.com
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Case Labs, Ltd nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#ifndef _MFIFO
#define _MFIFO
/*****************************************************************************
Struct: MINDEX
Description: Message Index used to index a dynamic size Message FIFO.
*****************************************************************************/
typedef struct _mindex
{
int offset; /* offset to message in buf */
int size; /* size of message in bytes */
}MINDEX;
/*****************************************************************************
Struct: MFIFO
Description: Message FIFO. Provides a dynamic sized message based FIFO
queue.
*****************************************************************************/
typedef struct _mfifo
{
int first; /* first out */
int last; /* last in + 1 */
int bsize; /* buffer size */
char *buf; /* ptr to start of buffer */
int ixsize; /* index size */
MINDEX ix[1]; /* message index */
}MFIFO;
/*****************************************************************************
Function prototypes.
*****************************************************************************/
int MFIFOCreate(char *buf, int size, int index);
void MFIFOClear(char * buf);
int MFIFOGetLBOffset(char *buf);
int MFIFOGetFBOffset(char *buf);
void MFIFOWriteIX(char *buf, char *mes, int size, int ix, int off);
int MFIFOWriteMes(char *buf, char *mes, int size);
char * MFIFOGetMesPtr(char *buf, int *size);
void MFIFOKillNext(char *buf);
#endif
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论