/*++
*******************************************************************************
* Copyright (c) 1990-99 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:

   frelsxb.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 FREL SNMP MIB extension agent DLL.

Author:

   Carl Caldwell

--*/
#ifndef FRELSXB_H
#define FRELSXB_H

// Protocol headers
#include "dxbtypes.h"
#include "fr_cont.h"

// DStreams Api
#include "DsIoctl.h"

#define MAXIOCBSZ   1024    /* max ioctl data block size */

// Use SXB_USER_GETMSG and SXB_USER_IOCTL to get data from, and
// communicate with the adapter

#define X_IOCTL_DATA_SIZE               512
#define X_GETMSG_CTRL_SIZE              512
#define X_GETMSG_DATA_SIZE              4096

typedef struct X_IOCTL
{
    DS_IOCTL DsIoctl;
    UCHAR Data[ X_IOCTL_DATA_SIZE ]; // Data buffer for DsIoctl
} X_IOCTL, *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 ];    // Data 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 FREL_SXB_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  VCFrelDevice;   //SXB internal handle used to manipulate firmware structs
    ULONG   dwBytesWritten; //Returned by GetStats request to SXB indicating data size
    WCHAR   FrelName[SXB_DEVICE_NAME_SIZE];   //SXB internal name of WAN device
    short   Dlci;           //Used only in circuit Ioctls
    X_IOCTL XIoctl;         //Ioctl used to communicate with SXB 
    union 
    {
        FRI_GetLinkStatistics_t *   pFrelErrStats;      // Pointer to the error statistics area
        rfc_1315_dlcmi_t        *   pFrelDlcmiData;     // Pointer to the dlcmi config area
        rfc_1315_circuit_t      *   pFrelCircuitData;   // Pointer to the circuit config area
    } upData;
    struct FREL_SXB_INFO * pNext; //Next struct in list
    struct FREL_SXB_INFO * pPrevious; //Previous struct in list
} FREL_SXB_INFO, FAR * PFREL_SXB_INFO;


//SXB device name constants for SXB_USER_GET_MSG ioctl
#define ID_STR_SXB_FREL_STATS    "FR"

//Index into the linked list of ioctls for SXB
#define PORT_IOCTL_NDX_ERROR_STATS      0   //The first port ioctl is stats
#define PORT_IOCTL_NDX_DLCMI_CONFIG     1   //The second port ioctl is config
#define PORT_IOCTL_NDX_CIRCUIT_STATS    2   //The next ioctl group is stats

// 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 circuit;
    struct SXB_CIRCUIT_INFO * pNext;     //Previous struct in list
    struct SXB_CIRCUIT_INFO * pPrevious; //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
    INT     CircuitCount;
    ULONG   WANLinksPortId;
    struct SXB_CIRCUIT_INFO * pCircuitList;
    struct SXB_PORT_INFO *    pNext;     //Next struct in list
    struct SXB_PORT_INFO *    pPrevious; //Previous struct in list
} 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

#endif // FRELSXB_H
