/***************************************************************************** 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. 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. *****************************************************************************/ #include "Q921.h" #include #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>2, (mes[0]>>1)&0x01,mes[1]>>1, mes[3]&0x01); } else { /* todo: whatever*/ } } /* check for RR */ else if(mes[2] ==0x01) { /* todo: check if RR is responce to I */ Q921SendRR(trunk, (mes[0]&0xfc)>>2, (mes[0]>>1)&0x01,mes[1]>>1, mes[2]&0x01); } /* check for RNR */ /* check for REJ */ /* check for SABME */ else if((mes[2] & 0xef) == 0x6f) { Q921ProcSABME(trunk, mes, rs); Q921SendUA(trunk, (mes[0]&0xfc)>>2, (mes[0]>>1)&0x01,mes[1]>>1, (mes[2]&0x10)>>4); } /* check for DM */ /* check for UI */ /* check for DISC */ /* check for UA */ /* check for FRMR */ /* check for XID */ else { /* what the ? Issue an error */ /* Q921ErrorProc(trunk, Q921_UNKNOWNFRAME, mes, rs); */ /* todo: REJ or FRMR */ } MFIFOKillNext(L2TRUNKHANDLE(trunk).HDLCInQueue); return 1; } return 0; }