#ident "$Id: ifre.h,v 1.7 1997/09/23 16:38:17 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.
 * 
 *****************************************************************************/

/******************************************************************
 *
 *
 *  Copyright 1995 Digi, Intl 
 *
 *  IFRE.H
 *
 *  Internal Definitions for IP-to-Frame Relay driver
 *
 ******************************************************************/

/*
 * cntarry Defines
 *
 */

#include "fr_cont.h"
#include "frs.h"

#define	IFRECNT_CANNOT_PUT1 0
#define IFRECNT_NO_BUFFERS  1
#define IFRECNT_RPROTO      2
#define IFRECNT_SENTUP      3
#define IFRECNT_NO_MAPENTRY 4
#define	IFRECNT_NO_TXCONC   5
#define IFRECNT_NO_TXPROTO  6
#define IFRECNT_PUT_TXSENT  7
#define IFRECNT_NETTX       8
#define MAX_IFRECNTS	    10

#define ESUBNET         152
#define ENETNOLNK       153
#define ERESOURCE       154
#define EBADIOCTL       155

/*
 * Maximum number of upper streams allowed to be open
 * at any time.  These entries map to a virtual Ethernet
 * device.
 */

#define	MAX_IFRENETS	64

/*
 * Maximum number of entries in address table, and 
 * size of hash tables into it.
 * Hash table size MUST be at least twice address
 * table size, and preferably prime.
 */

#define	MAX_IFREADDRS	25

/* 
 * Maximum number of lower Streams (one per virtual circuit)
 * for connection to Frame Relay.
 * Should not be greater than max number of connections
 * available to Frame Relay.
 */

#define	MAX_IFRECONS	64


/*
 * contab ifre_state values
 */
#define	IFRE_FREE	0		/* contab entry is available for use */
#define	IFRE_USED	1		/* contab entry has been mapped to a
					   lower queue, but PLL is not open */
#define	IFRE_ACTIVE	2		/* contab entry has been mapped, and
					   PLL is active */


/******************************************************************
 * Network table entry structure
 */

typedef struct ifre_netent {
	Q_PTR		q_ref;		/* STREAMS write queue for this net */
	u_long		my_src_addr;	/* Source IP Address */
	u_long		last_dst_addr;	/* Last Dest IP Address routed */
	struct ifre_con *last_index;	/* last match in contab table */
	int		held_count;	/* Count of messages held */
	int		blocked;	/* Upper stream is blocked */
} IFRE_NETENT;

/******************************************************************
 * Connection Table Definitions
 */

/*
 * Circuit State Values
 */

/*
 *  Table entry structure
 */

typedef struct ifre_con {
	int		ifre_state;	/* Connection State		*/
	Q_PTR   	l_qbot;		/* STREAMS lower write Q ptr	*/
	int     	l_index;	/* STREAMS lower mux id         */
	IFRE_NETENT	*net_ref;	/* Pointer to net table entry	*/
	u_long		rem_ipaddr;	/* Remote IP address		*/
	u_long		dlci;		/* DLCI of the connection	*/
	u_long		snid;		/* LINK of the connection	*/
	u_long		protocol_id;	/* Protocol ID of the connection*/
	u_long		ccb_handle;	/* CCB handle from the open	*/
} IFRE_CON;

/*
 * This is a MAP table element
 */
typedef struct ifre_addr {
	u_long	ip_addr ;
	u_long	dlci ;
	u_long	snid ;
} IFRE_ADDR ;   


/* 
 * IOCTL Map Table Entry Addition 
 */
 
typedef struct ifre_ent {
	u_long	ip_addr ;
	u_long	dlci ;
	u_long	snid ;
} IFRE_ENT_t ;


/*
 * IOCTL Map Table Deletion
 */

typedef struct ifre_del {
	u_long	ip_addr ;
} IFRE_DEL_t ;


/*
 * IOCTL Map Table Get Entry
 */

typedef struct ifre_get {
	u_long	ip_addr ;
	u_long	dlci ;
	u_long	snid ;
} IFRE_GET_t ;

/*
 * IOCTL Map Table Get Valid Entrys
 */

typedef struct ifre_mget {
	int	count ;
	int	pad ;
	IFRE_ENT_t map_ents[MAX_IFREADDRS] ;
} IFRE_MGET_t ;    


/*
 * IOCTL Statistics Get
 */

typedef struct ifre_stat_grp {
	int	ifrecons_active ;
	int	dgs_in ;
	int	dgs_out ;
	int	nsdus_in ;
	int	nsdus_out ;
} IFRE_STAT_GRP_t ;


/*
 * Stats Structure 
 */
typedef struct ifre_stats {
	u_long	ip_addr ;
	u_long	dlci ;
	u_long	snid ;
	IFRE_STAT_GRP_t stats ;
}IFRE_STATS_t  ;

/*
 * IOCTL Statistics Initialize
 */
typedef struct ifre_statinit {
	u_long	ip_addr ;
	u_long	dlci ;
	u_long	snid ;
	IFRE_STAT_GRP_t stats ;
} IFRE_STAT_INIT_t ;

/*
 * IOCTL SubNetwork Registration
 */
typedef struct ifre_snreg {
	u_long	ip_addr ;
	u_long	dlci ;
	u_long	snid ;
	u_long protocol_id ;
	FRS_PLL_CFG	pll_cfg ;
} S_IFRE_SNREG ;

/*
 *  M_PROTO's received
 */
typedef union ifre_proto {
	int type;
	S_NET_TX	net_tx;		/* Defined in DL_PROTO.H	*/
	S_IP_RX		ip_rx;		/* Defined in DL_PROTO.H	*/
	S_SN_FRGSZ	sn_frgsz;	/* Defined in DL_PROTO.H	*/
	IP_DL_REG	ip_reg;
} S_IFRE_PROTO;

