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

/*
 * $Id: ixe_control.h,v 1.3 1996/10/25 19:00:07 gary Exp $
 */

/******************************************************************
 *
 *  Spider-X25 Interface Primitives
 *
 *  Copyright (C) 1991  Spider Systems Limited
 *
 *  IXE_CONTROL.H
 *
 *  IXE Streams control primitives for IP and X.25 on V.3
 *
 ******************************************************************/

/*
 * M_IOCTL message type constants
 *
 */

#define	IXE_MSG		('E' << 8)	/* prim_class for IXE msgs	 */

#define	IXE_SNREG	(IXE_MSG + 1)	/* register/configure subnetwork */
#define IXE_ENT		(IXE_MSG + 2)	/* put entry into table		 */
#define IXE_DEL		(IXE_MSG + 3)	/* delete entry from table	 */
#define IXE_GET		(IXE_MSG + 4)	/* return table entry		 */
#define IXE_MGET	(IXE_MSG + 5)	/* return all table entries	 */
#define IXE_RESET	(IXE_MSG + 8)	/* reset address table		 */
#define	IXE_STATS	(IXE_MSG + 6)	/* get statistics counts	 */
#define	IXE_STATINIT	(IXE_MSG + 7)	/* reset statistics counters	 */

/*
 * Error Messages
 */

#define	EIXREG	6			/* Subnet registration err (?)	 */

/*
 * Exception handling action codes (for rst_action & exp_action)
 */

#define	DO_ACK		0
#define	DO_DISC		1
#define	DO_RESET	2		/* For exp_action only	*/

/* NSAP Flag values
 */

#define	THIS_NSAP	0	/* Use NSAP given			*/
#define	IP_NSAP		1	/* (not yet supported)			*/

/* Constants for defining timeouts
 */

#define	IX_TICK		(HZ)		/* IXE timer goes off once per sec. */
#define	IX_RATE		(HZ / IX_TICK)	/* No. of IXE timer events per sec. */


/******************************************************************
 *
 * M_IOCTL message type definitions 
 *
 */

typedef struct ixe_sninfo {
	uint32 nsdu_hwm;	/* NSDU High Water Mark		*/
	uint32 idle_ticks;	/* Connection idle timeout	*/
	uint32 durn_ticks;	/* Min conn. duration		*/
	uint8  conform84;	/* X.25 mode to use (TRUE = 84)	*/
	uint8  addr_ddn;	/* Use DDN, not CCITT if true	*/
	uint8  rst_action;	/* Action to take on reset	*/
	uint8  exp_action;	/* Action to take on expedited	*/
	struct xaddrf	my_xaddr;	/* Own X.25 address - used as	*/
					/* calling addr, and for net id	*/
	uint16 lpc;            /* Lower PVC range              */
	uint16 hpc;            /* Higher PVC range             */
} S_IXE_SNINFO;

typedef struct ixe_snreg {
	int8		prim_class;	/* Always IXE_MSG		*/
	int8		op;		/* Always IXE_SNREG		*/
	int32		my_inaddr;	/* Own IP address for this net	*/
	struct ixe_sninfo sn_info;	/* Config params for this net	*/
					/* X25 address(es) to listen on	*/
					/* follow in here		*/
} S_IXE_SNREG;
	
/*
 * Address table manipulation primitives
 */

struct ixe_ent {
	int8	prim_class;	/* Always IXE_MSG			*/
	int8	op;		/* Always IXE_ENT			*/
	int32	in_addr;	/* Remote node's IP address		*/
	struct xaddrf x_addr;	/* X.25 address (includes network id)	*/
	uint8 nsap_flag;/* How to interpret X.25 address	*/
	uint8 pkt_siz;	/* (Optional) X.25 packet and window 	*/
	uint8 win_siz;	/*  sizes to request for this node 	*/
	uint8 num_vcs;	/* (No. of Virtual Circuits to open)	*/
	uint8 cug_type; /* Whether Bilateral CUG or not		*/
	uint8 cug_field[MAX_CUG_LEN]; /* CUG     or not		*/
};

struct ixe_del {
	int8	prim_class;	/* Always IXE_MSG			*/
	int8	op;		/* Always IXE_DEL			*/
	int32 	in_addr;	/* IP address of entry to delete	*/
};

struct ixe_get {
	int8	prim_class;	/* Always IXE_MSG			*/
	int8	op;		/* Always IXE_GET			*/
	int32 	in_addr;	/* IP address of entry to get		*/

/* Following fields filled in in reply: (as for IXE_ENT)	*/

	struct xaddrf x_addr;
	uint8 nsap_flag;
	uint8 pkt_siz;
	uint8 win_siz;
	uint8 num_vcs;
	uint8 cug_type; /* Whether Bilateral CUG or not		*/
	uint8 cug_field[MAX_CUG_LEN]; /* CUG          		*/
};

struct ixe_reset {
	int8		prim_class;	/* Always IXE_MSG	*/
	int8		op;		/* Always IXE_RESET	*/
};

/*
 *  Table entry structure - used for mget
 */

typedef struct ix_addr {
	int32 		in_addr;	/* IP address			*/
	struct xaddrf	x_addr;		/* X.25 addr (includes net id)	*/
	uint8		nsap_flag;	/* NSAP flag			*/
	uint8		pkt_siz;	/* X.25 packet and window	*/
	uint8		win_siz;	/*  sizes to request 		*/
	uint8		num_vcs;	/* (No. of VCs to open)		*/
	uint8		cug_type;	/* Whether Bilateral CUG or not */
	uint8		cug_field[MAX_CUG_LEN];	/* CUG         		*/
	uint8 status;			/* temporary entry or permanent */
	int32     	next_free;	/* Next free entry              */
} IX_ADDR;

#define IX_ADDR_SIZE	(sizeof(IX_ADDR) - sizeof(unsigned char) - sizeof(int))

#define IX_TEMPORARY	1	/* temporary address entry status	*/
#define IX_PERMANENT	2	/* permanent address entry status	*/

/*
 *  Defines for the Multiple Get IOCTL
 *
 *  NOTE: This size of structure "ixe_mget" must not
 *	  exceed MAXIOCBSZ byte (as defined in stream.h).
 *	  Thus if other fields are added to "ixe_mget"
 *	  then MGET_BUFSIZE must decrease to cope
 *	  with any changes made.
 */
 
#define MGET_BUFSIZE	(MAXIOCBSZ - 20)	/*
						 * Take into account the
						 * other 5 fields by reducing
						 * the buffer size by 20
						 */
#define MGET_MAXENT	(MGET_BUFSIZE / sizeof(IX_ADDR) ) 


struct ixe_mget {
	int8	prim_class;	   /* Always IXE_MSG			*/
	int8	op;		   /* Always IXE_MGET			*/
	uint32	first_ent;	   /* First entry required		*/
	uint32	last_ent; 	   /* Last entry required		*/
	uint32	num_ent;	   /* Number of entries required	*/
	int8 	buf[MGET_BUFSIZE]; /* Data Buffer			*/
};

typedef union ixe_adrop {
	int8	prim_class;		/* Always IXE_MSG		*/
	struct	ixe_ent   ixe_ent;
	struct	ixe_del   ixe_del;
	struct	ixe_get   ixe_get;
	struct	ixe_mget  ixe_mget;
	struct	ixe_reset ixe_reset;
} S_IXE_ADROP;

/*
 *  Statistics gathering interface primitives
 */

/* Message to request/return counters	*/

struct ixe_stats {
	int8		prim_class;	/* Always IXE_MSG		*/
	int8		op;		/* Always IXE_STATS		*/
	uint32		ixcons_active;	/* No of current IXE conns open	*/
	uint32		dgs_out,	/* Datagrams passed down by IP	*/
			dgs_in,		/* Datagrams passed up to IP	*/
			nsdus_in,	/* NSDUs passed up from X.25	*/
			nsdus_out;	/* NDUSs passed down to X.25	*/
};

/* Message to reset counters inside IXE	*/

struct ixe_statinit {
	int8		prim_class;	/* Always IXE_MSG	*/
	int8		op;		/* Always IXE_STATINIT	*/
};
