/*****************************************************************************
 * 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.
 * 
 *****************************************************************************/


/******************************************************************
 *
 *  SpiderTCP/X25 Generic Module Configuration File
 *
 *  Copyright 1991  Spider Systems Limited
 *
 *  SYSTEM.H
 *
 *    Global system include file to build SpiderTCP/X25.
 *
 *    PR/IPH
 *
 ******************************************************************/

/*
 *	 /projects/common/PBRAIN/SCCS/pbrainF/dev/embed/common/68/s.system.h
 *	@(#)system.h	1.1
 *
 *	Last delta created	12:42:01 6/25/92
 *	This file extracted	21:52:04 11/19/92
 *
 */

#ifndef _SNET_SYSTEM
/*
 * Stream IDs - one per kernel/driver - used by strlog
 */

#define ECHO_STID	100

/*  X.25 Stream Modules IDs. */
#define	X25_STID	200
#define	LAPB_STID	201
#define	LLC_STID 	202
#define	XXX_STID	203
#define	XTY_STID	204
#define	XIN_STID	205
#define	XOUT_STID	206
#define	NPI_STID	207
#define	IXE_STID	208
#define	SLD_STID	209
#define	WAN_STID	210
#define	WLOOP_STID	211
#define NLI1_STID	212
#define FR_STID		213
#define IFRE_STID	214
#define STAC_STID	215
#define FSTF_STID	216
#define	T1_STID		217

/*
 * - Redefined - PR
 * was typedef queue_t *Q_PTR;
 */
#define Q_PTR queue_t *

/*
 * And now all the usual guff that's never
 * defined
 */

#ifndef NULL
#define NULL 0
#endif

#ifndef	TRUE
#define TRUE 1
#endif
#ifndef	FALSE
#define FALSE 0
#endif
#ifndef	true
#define true 1
#endif
#ifndef false
#define false 0
#endif

#ifndef MIN
#define MIN(a,b)	((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b)	((a)<(b)?(b):(a))
#endif

#ifndef	bool
#define bool int
#endif

/*
 * Word & Half-Word swapping macros
 */
#ifdef POWERPC
#define	SWAP16_COPY(src, dst)	_swap16_copy(&src, &dst)
#define	SWAP32_COPY(src, dst)	_swap32_copy(&src, &dst)
#define	SWAPPTR_COPY(src, dst)	_swap32_copy(&src, &dst)
#define	SWAP16(hword)		_swap16(&hword)
#define	SWAP32(word)		_swap32(&word)
#define	SWAPPTR(ptr)		_swap32(&ptr)
#else
#define SWAP16(hword)   hword = (((hword) >> 8) & 0x00FF) | \
                                (((hword) << 8) & 0xFF00)

#define SWAP32(word)    word = (((word) >> 24) & 0x000000FF) | \
                               (((word) >>  8) & 0x0000FF00) | \
                               (((word) <<  8) & 0x00FF0000) | \
                               (((word) << 24) & 0xFF000000)

#define SWAPPTR(ptr)    ptr = (void *) \
                            ( (((ptr) >> 24) & 0x000000FF) | \
                              (((ptr) >>  8) & 0x0000FF00) | \
                              (((ptr) <<  8) & 0x00FF0000) | \
                              (((ptr) << 24) & 0xFF000000) )

#define SWAP16_COPY(src, dst)  dst = (((src) >> 8) & 0x00FF) | \
                                     (((src) << 8) & 0xFF00)

#define SWAP32_COPY(src, dst)  dst = (((src) >> 24) & 0x000000FF) | \
                                     (((src) >>  8) & 0x0000FF00) | \
                                     (((src) <<  8) & 0x00FF0000) | \
                                     (((src) << 24) & 0xFF000000)

#define SWAPPTR_COPY(src, dst) dst = (void *) \
                             ( ((((unsigned int) src) >> 24) & 0x000000FF) | \
                               ((((unsigned int) src) >>  8) & 0x0000FF00) | \
                               ((((unsigned int) src) <<  8) & 0x00FF0000) | \
                               ((((unsigned int) src) << 24) & 0xFF000000) )
#endif

/*
 * Streams macros
 */


/* 
 * some useful defines
 */
#define MLEN(x)	(((x)->b_wptr) - ((x)->b_rptr))
#define CLEN(x)	(((x)->b_cont->b_wptr) - ((x)->b_cont->b_rptr))
#define CMSG(x)	((x)->b_rptr = (x)->b_wptr = (x)->b_datap->db_base)
#define LBSIZE	sizeof(struct linkblk)
#define SZ_OK(m,t) (((m)->b_wptr - (m)->b_rptr) >= sizeof(t))
#define L(mp) ((mp)->b_wptr - (mp)->b_rptr)
#define RL(mp) ((mp)->b_datap->db_lim - (mp)->b_datap->db_base)
#define CRB(mp)	((mp)->b_cont->b_rptr)
#define CWB(mp)	((mp)->b_cont->b_wptr)


#define _SNET_SYSTEM
#endif /* _SNET_SYSTEM */
