#ident "$Id: frsproto.h,v 1.4 1997/09/23 16:38:20 gary Exp $"
/*****************************************************************************
 * Copyright (c) 1988-95 Digi International Inc., All Rights Reserved
 * 
 * This  software  contains  proprietary  and  confidential   information   of
 * Digi International  Inc.   By  accepting  transfer  of this copy, Recipient
 * agrees to retain this software in  confidence,  to  prevent  disclosure  to
 * others,  and  to make no  use of this software other than that for which it
 * was delivered.  This is an unpublished copyright work  Digi   International
 * Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is
 * strictly prohibited.
 * 
 * Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc.
 * Confidential  when   combined   with   the   aggregated  modules  for  this
 * product) OBJECT CODE ONLY SOURCE MATERIALS
 * 
 * (C) COPYRIGHT Digi International Inc. 1995
 * 
 * All Rights Reserved
 * 
 * US   Government   Users   Restricted   Rights   -   Use,   duplication   or
 * disclosure  restricted by GSA ADP Schedule Contract with Digi International
 * Inc.
 * 
 *****************************************************************************/

/*****************************************************************************
 *                                                                           *
 * (c) COPYRIGHT 1991, 1992 HARRIS & JEFFRIES, INC.                          *
 *                          888 WASHINGTON STREET                            *
 *                          SUITE 130                                        *
 *                          DEDHAM, MA  02026                                *
 * ALL RIGHTS RESERVED                                                       *
 *                                                                           *
 * This software is the property of Harris & Jeffries, Inc. and is furnished *
 * under license by Harris & Jeffries, Inc. and this software may be used    *
 * only in accordance with the terms of said license.  This copyright notice *
 * may not be removed, modified or obliterated without the prior written     *
 * permission of Harris & Jeffries, Inc.                                     *
 *                                                                           *
 * This software may not be copied, transmitted, provided to or otherwise    *
 * made available to any other person, company, corporation or other entiry  *
 * except as specified in the terms of said license.                         *
 *                                                                           *
 * No right, title, ownership or other interest in the software is hereby    *
 * granted or transferred.                                                   *
 *                                                                           *
 * The information contained herein is subject to change without notice and  *
 * should not be construed as a commitment by Harris & Jeffries, Inc.        *
 *                                                                           *
 *****************************************************************************

   MODULE NAME:   FRSPROTO.H

   REVISION HISTORY:

   Date     Version  Name          Description
   -------- -------  ------------  --------------------------------------------
   01-16-92 1.10A    H&J (DJ)      Original
   11-20-92 2.00E    H&J (DJ)      Change len argument in FRSLmiRcvStat()
                                   from u_short to short and change for-loop
                                   test to "len > 0", to catch invalid
                                   status format. 

   09/28/93 2.00H    H&J (GB)      Added function prototype for 
                                     new function encap_restore_frame.
                                   Changed encap function prototypes because
                                     some of the functions accept different/new
                                     arguments.
   $Revision: 1.4 $
   $Log: frsproto.h,v $
   Revision 1.4  1997/09/23 16:38:20  gary
   The Frame Relay and X.25 API's consist of 32-bit fields only.  This is
   to simplify structure alignment considerations, and make endian issues
   less cumbersome.

   In addition, the Frame Relay API now uses SNID's instead of links, thereby
   making it more compatible with the X.25 and ISDN API's.

   These changes span a large number of files.

   Revision 1.3  1996/10/24 20:02:17  gary
   1) Fixed bug in FRI_GetLinkParameters that would cause garbage to be
   returned.
   2) Removed support for old method of compression (per-packet basis).
   The API has not changed (yet).  The STAC parameters are simply ignored.
   3) FRF.9 activated.

   Revision 1.2  1995/03/20 11:31:26  garyp
   modified ENCAP_OpenPLL() prototype (not really necessary, since
   our wonderful compiler doesn't understand functional prototypes all that
   well, but just in case it does someday...)

 * Revision 1.14  1994/07/27  20:31:09  stavrosm
 * Release 2.2
 *
 * Revision 1.13  1994/06/28  14:07:17  stavrosm
 * Changes for IPX and ARP encapsulation support.
 *
 * Revision 1.12  1994/06/16  18:53:24  akullber
 * Added function prototype for FRSCONF_UnInitLink().
 *
 * Revision 1.11  1994/03/16  21:30:13  deepak
 * Changed prototype for FRSCONF_InitLink(); FRS_CFG ==> FRS_LINK_CFG.
 *
 * Revision 1.10  93/11/10  16:44:57  stavrosm
 * Release 2.1
 * 
 * Revision 1.9  93/11/10  16:39:27  stavrosm
 * Cleanup 
 * 
 * Revision 1.8  93/11/09  16:03:58  gregb
 * Changed prototypes for frstx and frsrx state machines.
 * 
 * Revision 1.7  93/11/02  11:14:42  stavrosm
 * 
..............................................................................

   DESCRIPTION:

   This module is an include file required by all frs modules. It contains the
   formal and informal prototype definitions for each function call.

..............................................................................
  REF DOCUMENTS:

  (a) U.S Sprint Frame Relay Service Interface Specification Doc #: 5136.02
  (b) Frame Relay Interface Specification, Stratacom Inc., Doc #: 001-207460
  (c) Frame Relay Stack Functional Specification Rel 1.2 Harris & Jeffries Inc.
  (d) Frame Relay Stack External Specification Rel 1.2 Harris & Jeffries Inc.
  (e) MIB for Frame Relay DTEs - RFC Draft from Internet Engr Task Force (IETF).
  (f) Multiprotocol Interconnect over Frame Relay Networks - T. Bradley, C.Brown
      Wellfleet Communications, Inc. A. Malis BBN Communications Oct 14, 1991.

..............................................................................

  SPECIAL COMPILE/LINK INSTRUCTIONS:
    see options in frs.h
  
..............................................................................
*/

#ifndef FRSPROTO_H
#define FRSPROTO_H

#ifdef SOH
#define strcpy	frstrcpy
#define tolower	frtolower
#endif

/*****************************************************************************
*                             PROTOTYPES
*****************************************************************************/

#if USE_PROTOTYPES

/** frdrvr.c ------------------------------------------------------------------
 **/
void		fr_trace();
int			close_fr_tracestrm();
int			InjectorOverrun(u_long);
char		tolower(char);
int			atoi(char *);
long		atol(char *);


/** frf9.c ------------------------------------------------------------------
 **/
uint32		StopFRF9Session(CCB *);
void		FRF9LaunchModeOne(u_long);
void		FRF9ResetCompleted(uint3264);
void		FRF9CompressFinished(uint32);
void		FRF9DecompressFinished(uint32);
void		FRF9RRTransmit(u_long);
void		FRF9RxControl(CCB *,mblk_t *);
uint32		StopFRF9OperationPhase(CCB *);
mblk_t      *ParseFRF9Frame(CCB *,mblk_t *);
mblk_t		*TxFRF9Frame(CCB *,mblk_t *);
uint32		InitFRF9Session(CCB *);

/** frsutil.c ------------------------------------------------------------------
 **/
EVENT   *FRSAllocEvent(void);
void           FRSFreeEvent(EVENT *);
LCB	*snid_to_pLCB(u_long) ;
u_long	snid_to_hLCB(u_long) ;
u_long  pLCB_to_snid(LCB *) ;

USRBUF      *FRSDequeueHead(queue *);
void        FRSQTEnqHead(USRBUF *,QTCB *);
USRBUF      *FRSQTDequeue(QTCB *);
int         FRSEnqueueTail(USRBUF *, queue *);
void        FRSQTEnqueue(USRBUF *, QTCB *);
USRBUF      *FRSQT_Peek(QTCB);
void        FRSQT_flush(QTCB *);

void        FRSUpdateStats(CCB *, USRBUF *, u_short);
void        FRSUnlinkCCB( CCB *);
CCB *FRSCreateCCB( LCB *, u_long, u_short);
u_long     FRSFetchCCBHandle(CCB *, u_long *);
CCB *FRSLocateCCB(LCB *, USRBUF *);
CCB *FRSLocateCCBbyDLCI(LCB *, u_long);
u_short     FRSUnMakeFrame( CCB *, USRBUF **);
u_short     FRSMakeFrame(CCB *, USRBUF *, u_short);
u_short     FRSGetFrameDLCI(char *);
void        FRS_CMPTimer(u_long);
void        FRSFallback(CCB *);
void        FRS_BECNReceived(CCB *);
void        FRSCheckCMP(CCB *);
void        FRSLogErr( LCB *, USRBUF *, u_short);
void        FRSUpdateStats( CCB *, USRBUF *, u_short);
u_long      FRSFrameSize( USRBUF * );
u_short     FRSCountUsrbufs( USRBUF *);

/** frstx.c -------------------------------------------------------------------
 **/
u_short FRSFR_SendData(u_long , USRBUF *);
u_short FRSFR_SendDataWait(u_long , USRBUF *);
u_short FRSLAPD_SendDataWait(u_long , USRBUF *);
u_short FRSLAPD_SendData(u_long , USRBUF *);
u_short FRSFR_GetWriteQueueDepth(u_long , u_long *, u_long *); 
u_short FRSTxFrameEvt(CCB *);

void     FRSTxDone(USRBUF *, LCB *, u_short); 
FRSstate frsTxState( LCB *, EVENT * );
FRSstate frsTx_LkDwn_LkUp(LCB *);
FRSstate frsTx_LkDwn_TxDone(LCB *, EVENT *);
FRSstate frsTx_LkUp_LkDwn(LCB *);
FRSstate frsTx_LkUp_Frame(EVENT *);
FRSstate frsTx_LkUp_TxDone(LCB *, EVENT *);

int     FRSInject(CCB *, USRBUF *);
void    FRSInjectForce(CCB *);
void    FRSInjectNormal(CCB *);
void    FRSInjectExcess(CCB *);
void    FRSInjectHold(CCB *);
void    FRSInjectTimeout(u_long);

#if USE_TASKING
void    FRSTransmit(u_int);
#else
void    FRSTransmit(LCB *, EVENT *);
#endif

/** frsrx.c ---------------------------------------------------------------
 **/
u_short FRSFR_RcvData(u_long , USRBUF **);
u_short FRSFR_RcvDataWait(u_long , USRBUF **);
u_short FRSLAPD_RcvData(u_long , USRBUF **);
u_short FRSLAPD_RcvDataWait(u_long, USRBUF **);

FRSstate frsRxState(LCB *, EVENT *);
FRSstate frsRx_LkDwn_LkUp(LCB *);
FRSstate frsRx_LkDwn_Frame(LCB *, EVENT *);
FRSstate frsRx_LkUp_LkDwn(LCB *);
FRSstate frsRx_LkUp_Frame(LCB *, EVENT *);

#if USE_TASKING
void    FRSReceive(u_int);
#else
void    FRSReceive(LCB *, EVENT *);
#endif

#if FRS_DCE_SUPPORT
/** frscmi.c --------------------------------------------------------------
 **/
u_short  FRSFR_CMI_Rcv(USRBUF *);
void     FRSCmiSendStat(CMICCB *);
void     FRSCmiHeartbeatPoll(u_short);
u_short  FRSCmiPLLCount(u_short);
void     FRSCmiInsertRemoteNode(u_short);
CCB *FRSLocateCCBbyRemoteDLCI(LCB *, u_short, u_short, u_short);
#endif

/** frslmi.c --------------------------------------------------------------
 **/
u_short  FRSLmiRcv(LMICCB *, USRBUF *);
void     FRSLmiRcvStat(LMICCB *, USRBUF *, short);
void     FRSLmiRcvUpdate(LMICCB *, USRBUF *, u_short);
u_short  FRSLmiSendStatEnq(LMICCB *);
void     FRSLmiRcvStatEnq(LMICCB *, USRBUF *, u_short);
u_short  FRSLmiSendStat( LMICCB *, u_char);
u_short  FRSLmiPerfThresh(LMICCB *, u_short, u_short);
void     FRSLmiHeartbeatPoll(u_long);
void     FRSLmiCleanupCCBs(LMICCB *);
void     FRSLmiLinkDown(LCB *);
void     FRSLmiLinkUp(LCB *);
void     FRSLmiMarkCCB(CCB *, u_char);
void     FRSLmiThrottleCCB(CCB *, u_char);
void     FRSLmiPollVer( u_long);
void     FRSLmiPollXcessChk(u_long);
void     FRSLmiMarkFrames( CCB * );

/** frsfr.c --------------------------------------------------------------
 **/
u_short  FRSFR_ClosePLL(u_long);
u_long   FRSFR_OpenPLL(LCB *, u_long, BFN_PTR, u_long *, queue_t *);
u_short  FRSFR_OpenPLLBlkIO(LCB *, u_long, BFN_PTR, u_short *,
                            BLK_FN_PTR, BLK_FN_PTR, BLK_FN_PTR, BLK_FN_PTR,
                            u_int);
u_long   FRSFR_XoffPLL(LCB *, u_long);
u_long   FRSFR_XonPLL(LCB *, u_long);

/** frscfg.c --------------------------------------------------------------
 **/
u_short  FRSCONF_Init(void);
u_short  FRSCONF_InitLink(FRS_LINK_CFG *, proc_id, LCB **);
u_short  FRSCONF_UnInitLink(u_long);
u_short  FRSCONF_Disable(void);
u_short  FRSCONF_GetStatistics(u_long, u_long, u_long, u_long, char *);
u_short  FRSCONF_GetResetStat(u_long, u_long, u_long, u_long, char *);
u_short  FRSCONF_GetConfig(u_long, u_long, u_long, char *);
u_short  FRSCONF_SetConfig(u_long, u_long, u_long, char *);
u_short  FRSCONF_SetLinkConfig(u_long, u_long, u_long, char *);
u_short  FRSCONF_SetPLLConfig(u_long, u_long, u_long, char *);
u_short  FRSCONF_FindFlag(u_long, char *);
u_short  FRSCONF_ValidParam( u_long, u_long, u_long, char *);
u_short  FRSCONF_SetFlags(u_short, u_short, u_short, void *);
u_short  FRSLocatePLLCfg(u_long, u_long, FRS_PLL_CFG **);
u_short  FRSCONF_InsertLink( u_long, FRS_LINK_CFG * );
u_short  FRSCONF_InsertPLL( u_long, u_long, FRS_PLL_CFG * );
u_short  FRSCONF_DeleteLink( u_long );
u_short  FRSCONF_DeletePLL( u_long, u_long );

#if(!(USE_CONTIGUOUS_DATA) || (FRS_DCE_SUPPORT))
    u_short  FRSCONF_SetSysConfig(u_long, u_long, u_long, char *);
#endif

/** frsencap.c --------------------------------------------------------------
 **/
u_short  ENCAP_ClosePLL(u_long, u_long );
u_short  ENCAP_SendData(u_long, USRBUF *, u_long);
u_short  ENCAP_SendDataWait(u_long, USRBUF *, u_char);
u_short  ENCAP_OpenPLL( LCB *, u_long, BFN_PTR, u_long *, u_long, queue_t *);
u_short  ENCAP_OpenPLLBlkIO(LCB *, u_long, BFN_PTR, u_long *,
                            BLK_FN_PTR, BLK_FN_PTR, BLK_FN_PTR, BLK_FN_PTR,
                            u_int, u_char);

u_short  encap_frame_error(CCB *, USRBUF *, u_short, u_short);
u_short  encap_parse_header(CCB *, USRBUF **, NPPARSE_HDR );

#ifndef	STREAM_MESSAGES
u_short  encap_set_framebounds(USRBUF *, u_short, u_short *, u_short);
#else
u_short  encap_set_framebounds(mblk_t *, u_short, u_short *, u_short, mblk_t **);
#endif

u_short  encap_api_pid2pid(u_char);
u_char   encap_pid2pid_api(u_short, u_char);
u_char   encap_apipid2frame(u_char);
void     encap_free_frame(USRBUF *);
u_short  encap_unmakeframe(CCB *, USRBUF **);
#ifndef	STREAM_MESSAGES
u_short  encap_makeframe(CCB *, USRBUF *, u_char);
#else
u_short  encap_makeframe(CCB *, USRBUF *, u_char, USRBUF **);
#endif
u_short  encap_fragment_handler( CCB *, USRBUF **, NPPARSE_HDR );
void     encap_frame_complete( CCB *, USRBUF *, u_short );
void     encap_assemble_frame( CCB *, USRBUF *, u_short );
void     encap_restore_frame(  USRBUF *, u_short );
u_short  encap_get_frmtype( NPPARSE_HDR );

/* ------------------------------------------------------------------------- */
#else
/* ------------------------------------------------------------------------- */

/** frsutil.c 
 **/
EVENT   *FRSAllocEvent();
void            FRSFreeEvent();
LCB	*snid_to_pLCB();
u_long	snid_to_hLCB();
u_long	pLCB_to_snid();

USRBUF      *FRSDequeueHead();
USRBUF      *FRSQTDequeue();
int         FRSEnqueueTail();
void        FRSQTEnqueue();
USRBUF      *FRSQT_Peek();
void        FRSQT_flush();

void        FRSUpdateStats();
void        FRSUnlinkCCB();
CCB *FRSCreateCCB();
u_long     FRSFetchCCBHandle();
CCB *FRSLocateCCB();
CCB *FRSLocateCCBbyDLCI();
u_short    FRSUnMakeFrame();
u_short    FRSMakeFrame();
u_short    FRSGetFrameDLCI();
void       FRS_CMPTimer();
void       FRSFallback();
void       FRS_BECNReceived();
void       FRSCheckCMP();
void       FRSLogErr();
u_long     FRSFrameSize();
u_short    FRSCountUsrbufs();

/** frstx.c 
 **/
u_short FRSFR_SendData();
u_short FRSFR_SendDataWait();
u_short FRSLAPD_SendDataWait();
u_short FRSLAPD_SendData();
u_short FRSFR_GetWriteQueueDepth();
u_short FRSTxFrameEvt();
/* void     FRSTxDone ();  */
FRSstate frsTxState();
FRSstate frsTx_LkDwn_LkUp();
FRSstate frsTx_LkDwn_TxDone();
FRSstate frsTx_LkUp_LkDwn();
FRSstate frsTx_LkUp_Frame();
FRSstate frsTx_LkUp_TxDone();

int     FRSInject();
void    FRSInjectForce();
void    FRSInjectNormal();
void    FRSInjectExcess();
void    FRSInjectHold();
void    FRSInjectTimeout();
void    FRSTransmit();

/** frsrx.c 
 **/
u_short FRSFR_RcvData();
u_short FRSFR_RcvDataWait();
u_short FRSLAPD_RcvData();
u_short FRSLAPD_RcvDataWait();
FRSstate frsRxState();
FRSstate frsRx_LkDwn_LkUp();
FRSstate frsRx_LkDwn_Frame();
FRSstate frsRx_LkUp_LkDwn();
FRSstate frsRx_LkUp_Frame();
void    FRSReceive();

#if FRS_DCE_SUPPORT
/** frscmi.c --------------------------------------------------------------
 **/
u_short  FRSFR_CMI_Rcv();
void     FRSCmiSendStat();
void     FRSCmiHeartbeatPoll();
u_short  FRSCmiPLLCount();
void     FRSCmiInsertRemoteNode();
CCB *FRSLocateCCBbyRemoteDLCI();
#endif

/** frslmi.c 
 **/
u_short    FRSLmiRcv();
void       FRSLmiRcvStat();
void       FRSLmiRcvUpdate();
u_short    FRSLmiSendStatEnq();
void       FRSLmiRcvStatEnq();
u_short    FRSLmiSendStat();
u_short    FRSLmiPerfThresh();
void       FRSLmiHeartbeatPoll();
void       FRSLmiCleanupCCBs();
void       FRSLmiLinkDown();
void       FRSLmiLinkUp();
void       FRSLmiMarkCCB();
void       FRSLmiThrottleCCB();
void       FRSLmiPollVer();
void       FRSLmiPollXcessChk();
void       FRSLmiMarkFrames();

/** frsfr.c 
 **/
u_short    FRSFR_ClosePLL();
u_long     FRSFR_OpenPLL();
u_long     FRSFR_XoffPLL();
u_long     FRSFR_XonPLL();

/** frscfg.c 
 **/
u_short    FRSCONF_Init();
u_short    FRSCONF_InitLink();
u_short    FRSCONF_UnInitLink();
u_short    FRSCONF_Disable();
u_short    FRSCONF_GetStatistics();
u_short    FRSCONF_GetResetStat();
u_short    FRSCONF_GetConfig();
u_short    FRSCONF_SetConfig();
u_short    FRSCONF_SetLinkConfig();
u_short    FRSCONF_SetPLLConfig();
u_short    FRSCONF_FindFlag();
u_short    FRSCONF_ValidParam();
u_short    FRSCONF_SetFlags();
u_short    FRSLocatePLLCfg();

#if(!(USE_CONTIGUOUS_DATA) || (FRS_DCE_SUPPORT))
    u_short    FRSCONF_SetSysConfig();
#endif

/** frsencap.c 
 **/
u_short  ENCAP_ClosePLL();
u_short  ENCAP_SendData();
u_short  ENCAP_SendDataWait();
u_short  ENCAP_OpenPLL();
u_short  ENCAP_OpenPLLBlkIO();

u_short  encap_frame_error();
u_short  encap_parse_header();
u_short  encap_set_framebounds();
u_short  encap_api_pid2pid();
u_char   encap_pid2pid_api();
u_char   encap_apipid2frame();
void     encap_free_frame();
u_short  encap_unmakeframe();
u_short  encap_makeframe();
u_short  encap_fragment_handler();
void     encap_frame_complete();
void     encap_assemble_frame();
void     encap_restore_frame();
u_short  encap_get_frmtype();
#endif /* USE_PROTOTYPES */

#endif /* ifndef FRSPROTO_H */
