/*++
*******************************************************************************
* Copyright (c) 1990-2000 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 copyrighted work of Digi International	  *
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly	  *
* prohibited.																  *
* 																			  *
* Restricted Rights Legend													  *
*																			  *
* Use, duplication, or disclosure by the Government is subject to			  *
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in		  *
* Technical Data and Computer Software clause at DFARS 252.227-7031 or		  *
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -		  *
* Restricted Rights at 48 CFR 52.227-19, as applicable.						  *
*																			  *
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343		  *
*																			  *
*******************************************************************************

Module Name:

   x25sxb.h

Abstract:

    Frame Relay Layer MIB SNMP Extension Agent for Windows NT.

    This files provides the definitions and structures used in collecting
    the frame-relay specific information from the SXB driver interface. This data
    is used by the X25 SNMP MIB extension agent DLL.

Author:

   Carl Caldwell

--*/
#ifndef SNMP_X25_MIB_SXB_DEFS
#define SNMP_X25_MIB_SXB_DEFS 1

#include "dxbtypes.h"
#include "ll_proto.h"
#include "x25_proto.h"
#include "x25_control.h"
#include "DsIoctl.h"
			 
#define MAXIOCBSZ   1024    /* max ioctl data block size */

// Use DS_GETMSG and DS_IOCTL to get data from, and
// communicate with the adapter
//

#define X_IOCTL_DATA_SIZE               512
#define X_GETMSG_CTRL_SIZE              sizeof(SNMP_trace_t)
#define X_GETMSG_DATA_SIZE              sizeof(SNMP_trace_t)

typedef struct X_IOCTL
{
	DS_IOCTL DsIoctl;
	UCHAR Data[ X_IOCTL_DATA_SIZE ]; // Data buffer for DsIoctl
} X_IOCTL, FAR *PX_IOCTL;

typedef struct X_GETMSG
{
	DS_GETMSG DsGetMsg;
	UCHAR Control[ X_GETMSG_CTRL_SIZE ]; // Ctrl buffer for DsGetMsg
	UCHAR Data[ X_GETMSG_DATA_SIZE ];    // Ctrl buffer for DsGetMsg
} X_GETMSG, FAR *PX_GETMSG;

#define SXB_DEVICE_NAME_SIZE	32

// This structure is used on each port to collect the data associated with each port
// It is created as a linked list that will contin all the port information
typedef struct X25_SXB_IOCTL_INFO
{
	INT		IoctlType;		//It's either stats, or config in this mib
    CHAR	AdapterId;      //Dll internal adapter identifier 
    ULONG	PortId;         //Dll internal adapter port identifier 
    ULONG	Snid;           //Used as port identifier in ioctl calls
    CHAR	DeviceName[SXB_DEVICE_NAME_SIZE]; //Name of SXB device opened
    HANDLE	hSxbPort;       //Handle returned on open to access the device
    HANDLE	VCX25Device;   //SXB internal handle used to manipulate firmware structs
    ULONG	dwBytesWritten; //Returned by GetStats request to SXB indicating data size
    WCHAR	X25Name[SXB_DEVICE_NAME_SIZE];   //SXB internal name of WAN device
	short	Channel;		//Used only in circuit Ioctls
    X_IOCTL XIoctl;         //Ioctl used to communicate with SXB 
    union {
		rfc_1382_admn_t *		pX25AdmnOperData;	// Pointer to the error statistics area
		rfc_1382_stat_t *		pX25StatData;		// Pointer to the dlcmi config area
		rfc_1382_channel_t *	pX25ChannelData;	// Pointer to the circuit config area
		rfc_1382_circuit_t *	pX25CircuitData;	// Pointer to the circuit config table
		} upData;
    struct X25_SXB_IOCTL_INFO *  pNextX25SxbIoctlInfo; //Next struct in list
    struct X25_SXB_IOCTL_INFO *  pPreviousX25SxbIoctlInfo; //Previous struct in list

} X25_SXB_IOCTL_INFO, FAR * PX25_SXB_IOCTL_INFO;

// This structure is used on each port to collect the trace info associated with each port
// It is created as a linked list that will contin all the port information
typedef struct X25_SXB_EVENT_IOCTL_INFO
{
	INT			IoctlType;				//It's either stats, or config in this mib
    CHAR		AdapterId;				//Dll internal adapter identifier 
    ULONG		PortId;					//Dll internal adapter port identifier 
    ULONG		Snid;					//Used as port identifier in ioctl calls
    CHAR		DeviceName[SXB_DEVICE_NAME_SIZE]; //Name of SXB device opened
    HANDLE		hSxbPort;				//Handle returned on open to access the device
    HANDLE		VCX25Device;			//SXB internal handle used to manipulate firmware structs
    ULONG		dwBytesWritten;			//Returned by GetStats request to SXB indicating data size
    WCHAR		X25Name[SXB_DEVICE_NAME_SIZE];   //SXB internal name of WAN device
	OVERLAPPED	OverLappedIo;			//Overlapped structure for async IO
    struct X25_SXB_EVENT_IOCTL_INFO *  pNextX25SxbIoctlInfo; //Next struct in list
    struct X25_SXB_EVENT_IOCTL_INFO *  pPreviousX25SxbIoctlInfo; //Previous struct in list
	X_GETMSG	XGetMsg;				//Ioctl used to communicate with SXB 
} X25_SXB_EVENT_IOCTL_INFO, FAR * PX25_SXB_EVENT_IOCTL_INFO;

//SXB device name constants for SXB_USER_GET_MSG ioctl
#define ID_STR_SXB_X25_STATS    "X250"

//Index into the linked list of ioctls for SXB
#define PORT_IOCTL_NDX_ADMN_OPER		0	//The first port ioctl is admn
#define PORT_IOCTL_NDX_STATS			1	//The second port ioctl is stats
#define PORT_IOCTL_NDX_CHANNEL			2	//The first ckt ioctl is channel
#define PORT_IOCTL_NDX_CIRCUIT			3	//The second ckt ioctl is circuit
#define PORT_IOCTL_NDX_CLEARED_CIRCUIT	4	//The first event ioctl is cleared circuit
#define PORT_IOCTL_NDX_CALL_PARM		5	//The second event ioctl is call parm
#define PORT_IOCTL_NDX_RESTART			6	//The first event is restart
#define PORT_IOCTL_NDX_RESET			7	//The second event is reset

// This structure is used on each port to list the circuits present on each port
// It is created as a linked list that will contin all the port information
typedef struct SXB_CIRCUIT_INFO
{
	short  Channel;
    struct SXB_CIRCUIT_INFO * pNextSxbCircuitInfo; //Previous struct in list
    struct SXB_CIRCUIT_INFO * pPreviousSxbCircuitInfo; //Previous struct in list
} SXB_CIRCUIT_INFO, FAR *PSXB_CIRCUIT_INFO;

// This structure is used on each port to collect the data associated with each port
// It is created as a linked list that will contin all the port information
typedef struct SXB_PORT_INFO
{
    CHAR	DeviceName[32];		//Name of SXB device opened
	INT     ProtocolId;
    ULONG	Snid;				//Used as port identifier in ioctl calls
	BOOL    firstPortOnAdapter;	// Mark the first port for adapter specific data xfer
	INT		ChannelCount;
	UINT	WANLinksPortId;
	struct SXB_CIRCUIT_INFO *		pCircuitList;
    struct SXB_PORT_INFO *			pNextSxbPortInfo; //Next struct in list
    struct SXB_PORT_INFO *			pPreviousSxbPortInfo; //Previous struct in list
	struct X25_SXB_IOCTL_INFO *		firstPortIoctl;
} SXB_PORT_INFO, FAR *PSXB_PORT_INFO;

#define SXB_PROTOCOL_ID_NONE		0
#define SXB_PROTOCOL_ID_FRAME_RELAY	1
#define SXB_PROTOCOL_ID_X25			2

#define MAX_VALUE_NAME              128
#define MAX_DATA_LEN                1024

//Values for the LMI value in the Flags of DLCMI config IOCTL
#define FRS_LINK_FLAGS_LMI_REV1		0x0004	// Only 1 of these may be set
#define FRS_LINK_FLAGS_GANG_OF_4	0x0008	// Only 1 of these may be set
#define FRS_LINK_FLAGS_ANNEX_D		0x0010	// Only 1 of these may be set
#define FRS_LINK_FLAGS_ANNEX_A		0x4000	// Only 1 of these may be set
#define FRS_LINK_FLAGS_LMI_MASK		0x401C  // Combination of the above 4 bits

// This structure contains the nexssary parameters for the data collector thread 
typedef struct SXB_COLLECTOR_PARM_STRUCT
{
	PSXB_PORT_INFO				pSxbPortInfoParm;
	PX25_SXB_EVENT_IOCTL_INFO	pSxbEventIoctlInfoParm;
} SXB_COLLECTOR_PARM_STRUCT, * PSXB_COLLECTOR_PARM_STRUCT;
#endif
