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

   frelmib.h

Abstract:

    Frame Relay MIB SNMP Extension Agent for Windows NT.

    These files (freldll.c, frelmib.c, and frelmib.h) provide an 
    Extension Agent DLL which works in conjunction with the SNMP 
    Extendible Agent for Windows NT.

    This SNMP Extension Agent was derived from the sample on the Microsoft
    Developer's Toolkit. See the "Microsoft Windows/NT SNMP Programmer's Reference".

Author:

   Carl Caldwell

Revision History:

   $History: frelmib.h $
 * 
 * *****************  Version 6  *****************
 * User: Mikez        Date: 7/08/97    Time: 9:48a
 * Updated in $/Components/Windows/NT/Sync/SxbSnmp/fr
 * Updated to support DStreams API.

--*/
#ifndef FRELMIB_H
#define FRELMIB_H

#include "frelsxb.h"
#include <snmp.h>

// MIB Specifics.
#define MIB_PREFIX_LEN            MIB_OidPrefix.idLength
#define MAX_STRING_LEN            255

// Offsets used in initializing frame relay Mib dlcmi tables {frame-relay 1}
#define FRELMIB_FIRST_DLCMI_NDX                 0
#define FRELMIB_FIRST_DLCMI_STATE               1
#define FRELMIB_FIRST_DLCMI_ADDR                2
#define FRELMIB_FIRST_DLCMI_ADDR_LEN            3
#define FRELMIB_FIRST_DLCMI_POLL_INTERVAL       4
#define FRELMIB_FIRST_DLCMI_FULL_ENQ_INTERVAL   5
#define FRELMIB_FIRST_DLCMI_ERR_THRESHOLD       6
#define FRELMIB_FIRST_DLCMI_MON_EVENTS          7
#define FRELMIB_FIRST_DLCMI_MAX_SPT_VCS         8
#define FRELMIB_FIRST_DLCMI_MULTICAST           9

// Offsets used in initializing frame relay Mib circuit tables {frame-relay 2}
#define FRELMIB_FIRST_CKT_NDX                   10
#define FRELMIB_FIRST_CKT_DLCI_NDX              11
#define FRELMIB_FIRST_CKT_STATE_NDX             12
#define FRELMIB_FIRST_CKT_RCV_FECNS_NDX         13
#define FRELMIB_FIRST_CKT_RCV_BECNS_NDX         14
#define FRELMIB_FIRST_SENT_FRAMES_NDX           15
#define FRELMIB_FIRST_SENT_OCTETS_NDX           16
#define FRELMIB_FIRST_CKT_RCV_FRAMES_NDX        17
#define FRELMIB_FIRST_CKT_RCV_OCTETS_NDX        18
#define FRELMIB_FIRST_CKT_CREATE_TIME_NDX       19
#define FRELMIB_FIRST_CKT_LAST_TIME_CHANGE_NDX  20
#define FRELMIB_FIRST_CKT_COMMIT_BURST_NDX      21
#define FRELMIB_FIRST_CKT_EXCESS_BURST_NDX      22
#define FRELMIB_FIRST_CKT_THRUPUT_NDX           23
    
#define FRELMIB_FIRST_ERR_NDX                   24
#define FRELMIB_FIRST_ERR_TYPE_NDX              25
#define FRELMIB_FIRST_ERR_DATA_NDX              26
#define FRELMIB_FIRST_ERR_TIME_NDX              27

//// Ranges and limits for specific MIB variables.
//   Frame Relay DLCMI Table Constants

//   Frame Relay DLCMI State limits
#define FREL_DLCMI_STATE_NO_LMI_CONFIGURED      1
#define FREL_DLCMI_STATE_LMI_REV_1              2
#define FREL_DLCMI_STATE_ANSI_T1_617_D          3
#define FREL_DLCMI_STATE_ANSI_T1_617_B          4
#define FREL_DLCMI_STATE_MIN                    FREL_DLCMI_STATE_NO_LMI_CONFIGURED
#define FREL_DLCMI_STATE_MAX                    FREL_DLCMI_STATE_ANSI_T1_617_B 

//   Frame Relay DLCMI Address limits
#define FREL_DLCMI_ADDRESS_Q921                 1
#define FREL_DLCMI_ADDRESS_Q922_MARCH_90        2
#define FREL_DLCMI_ADDRESS_Q922_NOVEMBER_90     3
#define FREL_DLCMI_ADDRESS_Q922                 4
#define FREL_DLCMI_ADDRESS_MIN                  FREL_DLCMI_ADDRESS_Q921
#define FREL_DLCMI_ADDRESS_MAX                  FREL_DLCMI_ADDRESS_Q922

//   Frame Relay DLCMI Address Len limits
#define FREL_DLCMI_ADDRESS_LEN_2_OCTETS         2
#define FREL_DLCMI_ADDRESS_LEN_3_OCTETS         3
#define FREL_DLCMI_ADDRESS_LEN_4_OCTETS         4
#define FREL_DLCMI_ADDRESS_LEN_MIN              FREL_DLCMI_ADDRESS_LEN_2_OCTETS    
#define FREL_DLCMI_ADDRESS_LEN_MAX              FREL_DLCMI_ADDRESS_LEN_4_OCTETS

//   Frame Relay Polling Interval limits
#define FREL_DLCMI_POLLING_INTERVAL_MIN         5
#define FREL_DLCMI_POLLING_INTERVAL_MAX         30

//   Frame Relay Full Enquiry Interval limits
#define FREL_DLCMI_FULL_ENQUIRY_INTERVAL_MIN    1
#define FREL_DLCMI_FULL_ENQUIRY_INTERVAL_MAX    255

//   Frame Relay Error Threshold limits
#define FREL_DLCMI_ERROR_THRESHOLD_MIN          1
#define FREL_DLCMI_ERROR_THRESHOLD_MAX          10

//   Frame Relay DLCMI Multicast variable limits
#define FREL_DLCMI_MULTICAST_NON_BROADCAST      1
#define FREL_DLCMI_MULTICAST_BROADCAST          2
#define FREL_DLCMI_MULTICAST_MIN                FREL_DLCMI_MULTICAST_NON_BROADCAST
#define FREL_DLCMI_MULTICAST_MAX                FREL_DLCMI_MULTICAST_BROADCAST

//   Frame Relay Circuit Table Constants
#define FREL_CKT_STATE_INVALID                  1
#define FREL_CKT_STATE_ACTIVE                   2
#define FREL_CKT_STATE_INACTIVE                 3
#define FREL_CKT_STATE_MIN                      FREL_CKT_STATE_INVALID
#define FREL_CKT_STATE_MAX                      FREL_CKT_STATE_INACTIVE

//   Frame Relay Error Table Constants
#define FREL_ERR_TYPE_UNKNOWN_ERR               1
#define FREL_ERR_TYPE_RECEIVE_SHORT             2
#define FREL_ERR_TYPE_RECEIVE_LONG              3
#define FREL_ERR_TYPE_ILLEGAL_DLCI              4
#define FREL_ERR_TYPE_UNKNOWN_DLCI              5
#define FREL_ERR_TYPE_DLCMI_PROTO_ERR           6
#define FREL_ERR_TYPE_DLCMI_UNKNOWN_IE          7
#define FREL_ERR_TYPE_DLCMI_SEQUENCE_ERR        8
#define FREL_ERR_TYPE_DLCMI_UNKNOWN_RPT         9
#define FREL_ERR_TYPE_NO_ERR_SINCE_RESET        10
#define FREL_ERR_TYPE_MIN                       FREL_ERR_TYPE_UNKNOWN_ERR
#define FREL_ERR_TYPE_MAX                       FREL_ERR_TYPE_NO_ERR_SINCE_RESET

// MIB function actions.
#define MIB_ACTION_GET         ASN_RFC1157_GETREQUEST
#define MIB_ACTION_SET         ASN_RFC1157_SETREQUEST
#define MIB_ACTION_GETNEXT     ASN_RFC1157_GETNEXTREQUEST


// MIB Variable access privileges.
#define MIB_ACCESS_READ        0
#define MIB_ACCESS_WRITE       1
#define MIB_ACCESS_READWRITE   2


// Macro to determine number of sub-oid's in array.
#define OID_SIZEOF( Oid )      ( sizeof Oid / sizeof(UINT) )


// MIB variable ENTRY definition.  This structure defines the format for
// each entry in the MIB.
typedef struct mib_entry 
{
	AsnObjectIdentifier Oid;
	void *              Storage;
	void *              pSxbRawData;
	BYTE                Type;
	UINT                Access;
	UINT                (*MibFunc)(UINT, struct mib_entry *, RFC1157VarBind *);
	struct mib_entry *  MibNext;
} MIB_ENTRY, * PMIB_ENTRY;


// Internal MIB structure.
extern MIB_ENTRY Mib[];
extern UINT MIB_num_variables;


// Prefix to every variable in the MIB.
extern AsnObjectIdentifier MIB_OidPrefix;


// Function Prototypes.
UINT ResolveVarBind(
	IN OUT RFC1157VarBind *VarBind, // Variable Binding to resolve
	IN UINT PduAction );            // Action specified in PDU

UINT MIB_leaf_func(
    IN UINT Action,
	IN MIB_ENTRY *MibPtr,
	IN RFC1157VarBind *VarBind );

UINT MIB_short_to_int_leaf_func(
	IN UINT Action,
	IN MIB_ENTRY *MibPtr,
	IN RFC1157VarBind *VarBind );

UINT MIB_lmi_type_leaf_func(
	IN UINT Action,
	IN MIB_ENTRY *MibPtr,
	IN RFC1157VarBind *VarBind );

UINT MIB_err_type_leaf_func(
	IN UINT Action,
    IN MIB_ENTRY *MibPtr,
    IN RFC1157VarBind *VarBind );

UINT MIB_time_leaf_func(
	IN UINT Action,
	IN MIB_ENTRY *MibPtr,
	IN RFC1157VarBind *VarBind );

UINT MIB_multicast_leaf_func(
	IN UINT Action,
	IN MIB_ENTRY *MibPtr,
	IN RFC1157VarBind *VarBind );

UINT MIB_circuit_state_leaf_func(
	IN UINT Action,
	IN MIB_ENTRY *MibPtr,
	IN RFC1157VarBind *VarBind );

UINT InitCircuitTableMibEntries(
	IN PMIB_ENTRY pMibBase, 
	IN PFREL_SXB_INFO pFrelSxbInfo,
	IN PSXB_PORT_INFO pSxbPortInfo );

UINT InitDlcmiTableMibEntries(
	IN PMIB_ENTRY pMibBase, 
	IN PFREL_SXB_INFO pFrelSxbInfo,
	IN PSXB_PORT_INFO pSxbPortInfo );

UINT InitErrTableMibEntries(
	IN PMIB_ENTRY pMibBase, 
	IN PFREL_SXB_INFO pFrelSxbInfo,
	IN PSXB_PORT_INFO pSxbPortInfo );

UINT InitMibTableEntries(
	IN PFREL_SXB_INFO pFrelSxbInfo,
	IN PSXB_PORT_INFO pSxbPortInfo ); // Supervisor for Mib Initialization

PMIB_ENTRY CreateNextMibColFrom(
		IN OUT MIB_ENTRY FAR * pOldMibEntry );

// Update the raw data from the SXB driver
long WINAPI frel_Update_MIB_Data(
	IN long pFrelSxbInfo );

// Stop SXB driver data collection
void frel_Terminate_MIB_Data_Collection(
	IN PFREL_SXB_INFO pFrelSxbInfo,
	IN PSXB_PORT_INFO pBaseSxbPortInfo );

// Initialize the SXB driver data collection structures
long frel_Init_MIB_Data_Structures(
	IN PFREL_SXB_INFO pFrelSxbInfo,
	IN PSXB_PORT_INFO pSxbPortInfo );

// Initialize the SXB port information from the registry
long frel_Init_Sxb_Port_Info(
	IN PSXB_PORT_INFO pSxbPortInfo );

// Utilities to play games with unicode strings
USHORT WstrLength( 
	IN LPWSTR lpwStr );

int StrToWStr( 
	OUT LPWSTR lpwStr, 
	IN  LPSTR lpStr, 
	IN  LONG count );

#endif // FRELMIB_H
