#ident "$Id: x25_inc.h,v 1.5 1997/10/21 20:48:45 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.
 * 
 *****************************************************************************/

/*******************************************************************
 *
 *  SpiderX25 X25 PLP Driver
 *
 *  Copyright 1991 Spider Systems Limited
 *
 *  X25_INC.H
 *
 *
 *******************************************************************/

/*
 *	x25_inc.h
 *	 /projects/common/PBRAIN/SCCS/pbrainF/dev/sys/x25/0/s.x25_inc.h
 *	@(#)x25_inc.h	1.22
 *
 *	Last delta created	13:29:17 2/27/92
 *	This file extracted	18:32:48 11/19/92
 *
 */

#include "types.h"
#include "param.h"
#include "ll_proto.h"
#include "stream.h"
#include "strlog.h"
#include "system.h"
#include "x25_proto.h"
#include "x25_control.h"
#include "x25trace.h"
#include "x25db.h"


extern	struct x25vcformat FAR *iso_vc[];
extern	struct x25vcformat  xisovc[];

extern	struct lsformat FAR *iso_lsap[];
extern	struct lsformat     linklsaps[];
extern	struct xgldbf       xgldb[];
extern	struct xsndbf       xsndb[];
extern	struct x25cfgformat xcfg[];

extern mblk_t *listen_requestQ;

/* ---- Declare the externally visible limits ---- */

extern int	iMAXXVCS;		/* Vc db usable limits		 */
extern int	iMAXXLSAPS;		/* Link db usable limits	 */
extern int	iMAXXDEVS;		/* X.25 devices			 */
extern int	iMAXXCONFIG;		/* X.25 configured networks	 */
extern int	iMAXXSUBNETS;		/* Subnetwork number attached	 */

extern int	isovcmax;		/* Vc db usable limits		 */
extern int	isolsapmax;		/* Link db usable limits	 */
extern int	x25devmax;		/* X.25 devices			 */
extern int	x25cfgmax;		/* X.25 configured networks	 */
extern int	x25submax;		/* Subnetwork number attached	 */

/* MONARRAYSIZE: size (in bytes) of the stats array for a single subnet */
#define		MONARRAYSIZE	(sizeof(int) * mon_size)

/* Direction for x25apiswap() function */
#define	DOWNWARD	0
#define	UPWARD		1

void L3monitor(int, unsigned long);

/* Prototypes */
void IND_toNS(unsigned int,mblk_t *);
void N_enableinput(int, int);
int att_PVC(struct xgldbf *, mblk_t *);
mblk_t *mb_frag(mblk_t *);
void queue_listen(mblk_t *,int);
int mb_nxtbyte(mblk_t *,unsigned char FAR *);
int user_on_NSAP(struct xaddrf FAR *, mblk_t *, int, int FAR * ,int *, ushort);
int N_rstrsp(int);
void map_dbit_control(struct x25vcformat FAR *);
int SNMP_callparm_event(struct x25vcformat *, mblk_t *);
void sh_disc_facilities(int,struct x25vcformat FAR *,struct qosformat   FAR *);
static void sh_facilities(int,struct x25vcformat FAR *,struct qosformat   FAR *);
static void rq_facilities(int,struct x25vcformat FAR *,struct qosformat   FAR *);
static void request_NRS(struct x25vcformat FAR *);
void OK_wneg(unsigned char,unsigned char,struct x25vcformat FAR *);
void OK_pneg(unsigned char,unsigned char,struct x25vcformat FAR *);
static void OK_tcneg(unsigned char,unsigned char,struct x25vcformat FAR *);
void x25vccall(struct x25vcformat FAR *);
void xusrerror(struct x25vcformat FAR *,unsigned char);
void m_freem(mblk_t *);
void xusrerror(struct x25vcformat FAR *,unsigned char);
void det_PVC(struct x25vcformat FAR *,int);
void slot_in(struct lsformat FAR *, struct x25vcformat FAR *);
void to_link_level(struct x25vcformat FAR *,mblk_t *);
void Tx_DIAG(register struct lsformat FAR *,unsigned char,unsigned char,unsigned char,unsigned char,unsigned char);
void confirm_restart(struct lsformat FAR *,mblk_t *);
mblk_t *make_c_packet(struct x25vcformat FAR *,unsigned char);
void maybe_ack(struct x25vcformat FAR *);
int buffs_status();
void system_error(int);
void Tx_Qdata(struct x25vcformat FAR *);
void FL_touser(struct x25vcformat FAR *);
void delete_NRS_request();
int qos_available(struct x25vcformat FAR *,int);
void fix_def_facilities(struct x25vcformat FAR *,int);
void x_exam_user(struct lsformat FAR *,struct x25vcformat FAR *);
void map_tclass(struct x25vcformat FAR *, int, int);
int disconnect_user(struct x25vcformat FAR *,unsigned char, unsigned char, mblk_t *);
int disc_confirm_user(struct x25vcformat FAR *);
void reset_confirm_user(struct x25vcformat FAR *,mblk_t *);
int redisconnect_user(struct x25vcformat FAR *);           
int reset_user(struct x25vcformat FAR *,unsigned char, unsigned char);
void send_sqrl_data(struct x25vcformat FAR *);
int Tx_RSC(struct x25vcformat FAR *);
void del_sqrl_data(struct x25vcformat FAR *);
int short_out(struct x25vcformat FAR *,unsigned char);
int Tx_EDdata(struct x25vcformat FAR *);
int LL_datareq(struct lsformat FAR *,mblk_t *);
int LL_conreq(struct lsformat FAR *,struct lsapformat FAR *,struct lsapformat FAR *,unsigned int);
void fetch_NUI_fac(struct x25vcformat FAR *);
static void puta(unsigned char *,int *,struct lsapformat *,struct lsapformat *);
int x25cmp(char FAR *, char FAR *, int);
void hunt_PVC_user(struct x25vcformat FAR *);
void join_pvc_to_glue(struct x25vcformat FAR *,struct xgldbf *,struct pvcattf FAR *);
void rmPVCusr(struct xgldbf *);
void make_pvcdbs(struct wlcfg *);
void pvc_fn_err(struct xgldbf *);
void go_frozen(queue_t *,mblk_t  *);
void rmXLDAT(queue_t *);
void abort_vc(struct xgldbf *);
void rmCIDI(struct xgldbf *);
int N_datack(int);
int N_putexpdata(int, mblk_t *);
int N_expack(int);
int N_conreq(int,int *,unsigned char, struct xaddrf FAR *, struct xaddrf FAR *, struct qosformat FAR *, mblk_t *);
int N_conrsp(int,int,unsigned char, struct xaddrf FAR *, struct qosformat FAR *, mblk_t *);
int N_rstreq(int, unsigned char, unsigned char);
int N_disreq(int, unsigned char, unsigned char, struct qosformat *, struct xaddrf FAR *, struct xaddrf FAR *, mblk_t  *); 
int N_putdata(int, mblk_t *);
void bcd_to_str(uint8 *, int, uint8 *);
void x25tick();
void get_xvc_circuit_info(struct x25vcformat *, rfc_1382_circuit_t *);
int nuifac_dump(Q_PTR, mblk_t *);
int nuifac_del(char	*, unsigned char);
int nuifac_put(struct nui_put *, unsigned char);
void putNbytes(mblk_t *,int,unsigned char *);
void getNbytes(mblk_t *,int,unsigned char *);
int	mb_bulen(mblk_t *);
void mb_gset(struct x25vcformat FAR *,mblk_t *);
void mb_pset(struct x25vcformat FAR *,mblk_t *);
int x25clock(caddr_t);
void kill_subnet(int);
int close_x25_tracestrm(queue_t *);
static void xfreeglue(struct xgldbf *);
void purge_listens(int);
void x25init();
unsigned long map_snident(unsigned long);
void DA_touser(struct x25vcformat FAR *);
void EDA_touser(struct x25vcformat FAR *,mblk_t *);
void ED_touser(struct x25vcformat FAR *,mblk_t *);
int N_CCdetails(int,unsigned char FAR *,struct qosformat FAR *);
void CC_touser(struct x25vcformat FAR *,mblk_t *);
void CI_touser(struct  x25vcformat FAR *,mblk_t *);
static void xint_err(struct x25vcformat FAR *,unsigned char);
int N_CIdetails(int,unsigned char FAR *,unsigned char FAR *,struct qosformat FAR *);
int N_RIdetails(int,unsigned char FAR *,unsigned char FAR *);
void flush_user(struct x25vcformat FAR *,int);
mblk_t *scan_ears(int, struct xgldbf * );
int N_DIdetails(int,unsigned char FAR *,unsigned char FAR *,struct xaddrf FAR *,struct qosformat FAR *);
int SNMP_trace_clear_event(struct x25vcformat *);
void xpurgeQ(struct Q FAR *);
mblk_t *OFF(struct Q FAR *);
void sqrl_PVC_data(struct x25vcformat FAR *,mblk_t *,int);
void xuser_gone(struct x25vcformat FAR *,unsigned char);
void ON(struct Q FAR *,mblk_t *);
void Rx_DATA(struct x25vcformat FAR *, unsigned char, unsigned char, int, mblk_t *);
int DT_touser(struct x25vcformat FAR *,mblk_t *,int);
void Rx_CLC(struct lsformat FAR *,struct x25vcformat FAR *,unsigned char,int,mblk_t *);
void Rx_CLR(struct lsformat FAR *,struct x25vcformat FAR *,unsigned char,int,mblk_t *);
void xfreedb(struct x25vcformat FAR *);
void dec_ls_concount(struct lsformat FAR *,struct x25vcformat FAR *);
void Rx_INT(struct x25vcformat FAR *,int,mblk_t *);
void Rx_INC(struct x25vcformat FAR *,int,mblk_t *);
void Rx_RR(struct x25vcformat FAR *,unsigned char,int);
void ERR_rstU(struct x25vcformat FAR *,int);
int vc_in_range(unsigned short,int *,register struct wlcfg *,int *);
struct x25vcformat FAR *lcitovc(struct lsformat FAR *, unsigned short,int);
struct x25vcformat FAR *x25allocvc(int *);
struct lsformat *x25alloclsap(int *);
int assign_lci(struct x25vcformat FAR *);
void tidy_user_side(struct x25vcformat FAR *);
void clr_procedure(struct x25vcformat FAR *,unsigned char,unsigned char,unsigned char,unsigned char,unsigned char);
void rst_procedure(struct x25vcformat FAR *,unsigned char,unsigned char,unsigned char,unsigned char,unsigned char);
void ERR_clrnoU(struct x25vcformat FAR *,int);
void ERR_clrU(struct x25vcformat FAR *,int);
void ERR_rstnoU(struct x25vcformat FAR *,int);
void state_matrix(struct x25vcformat FAR *,unsigned char);
void P4_FMT_error(struct x25vcformat FAR *,unsigned char);
void deqvc(struct lsformat FAR *,struct x25vcformat FAR *);
void lfreedb(struct lsformat  FAR *);
void to_P4D1(struct x25vcformat FAR *,int);
void to_Lconnected(struct lsformat FAR *);
void report_DIAG();
void CRs_pending(struct lsformat FAR *);
void dis_lsap_and_vcs(struct lsformat FAR *,unsigned char,unsigned char);
int Dsent_acked(struct x25vcformat FAR *, int);
int SNMP_reset_event(struct x25vcformat *);
void Rx_RNR(struct x25vcformat FAR *,unsigned char,int);
void Rx_REJ(struct x25vcformat FAR *);
void Rx_RSC(struct x25vcformat FAR *,int,mblk_t *);
void Rx_RST(struct x25vcformat FAR *,int,mblk_t *);
void Rx_CAA(struct lsformat FAR *l,struct x25vcformat FAR *,unsigned char,mblk_t *);
void Rx_CALL(struct lsformat FAR *l,struct x25vcformat FAR *,unsigned char,mblk_t *);
void x25_trace(queue_t *,struct lsformat *,mblk_t *,int);
void l_exam_user(struct lsformat FAR *);
void L2_rstind(struct lsformat FAR *);
void L2_discnf(struct lsformat FAR *);
void L2_disind(struct lsformat FAR *);
void L2_concnf(struct lsformat FAR *);
void x25lscall(struct lsformat FAR *);
void L2_conind(int,struct lsapformat FAR *,mblk_t *);
int LL_prtymsg(int,mblk_t *);
void L2_datind(struct lsformat FAR *,mblk_t *);
int restart_request(struct lsformat FAR *,unsigned char,unsigned char,mblk_t *);
void close_SVCs(struct lsformat FAR *, unsigned char,unsigned char,int);
int SNMP_restart_event(unsigned long);
void zap_pvc_rdata(struct x25vcformat FAR *,int,int);
void unhook_PVCs(struct lsformat FAR *,int);
void res_PVCs(struct lsformat FAR *, unsigned char, unsigned char);
int LL_disreq(struct lsformat FAR *);
void x_examtimer(struct x25vcformat FAR *);
void startT22(struct x25vcformat FAR *);
void startT23(struct x25vcformat FAR *);
void start_random_timer(struct lsformat FAR *);
void stop_vc_timers(struct x25vcformat FAR *);
void stop_ls_timers(struct lsformat FAR *);
void l_examtimer(struct lsformat FAR *);
void nuifac_init();
void beRCNpending(struct x25vcformat FAR *,int);
static void beWUNcpending(struct x25vcformat FAR *,int);
static void beWRCUpending(struct x25vcformat FAR *,int);
static void beWtgRCU(struct x25vcformat FAR *,int);
int Tx_RST(struct x25vcformat FAR *,unsigned char,unsigned char);
int clear_request(struct x25vcformat FAR *);
