/*++
*******************************************************************************
* 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:

	x25mib.c

Abstract:

    Physical Layer MIB SNMP Extension Agent for Windows NT.

    These files (x25dll.c, x25mib.c, and x25mib.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".

	This Extension Agent implements the Internet x25 MIB. It's definition is 
	found in the IETF RFC 1317.

Author:

   Carl Caldwell

--*/
#include <snmp.h>
#include "regnames.h"
#include "dxbreg.h"

// Contains definitions for the table structure describing the MIB.  This
// is used in conjunction with testmib.c where the MIB requests are resolved.
#include "x25mib.h"

// Contains definitions for the structures for collecting data from the SXB
// driver interface.
#include "x25sxb.h"

int my_atoi( const char * );

// Buffer for formatted Debug messages
#ifdef SNMP_DLL_DEBUG
char	DbgBuf[80];
#endif

// Extension Agent DLLs need access to elapsed time agent has been active.
// This is implemented by initializing the Extension Agent with a time zero
// reference, and allowing the agent to compute elapsed time by subtracting
// the time zero reference from the current system time.  This example
// Extension Agent implements this reference with dwTimeZero.

extern DWORD dwTimeZero;

// This structure ties a call parm mib entry to a circuit mib entry. This is used
// to track Call Parameter and Call Cleared events
extern PMIB_CircuitCallBindTable_t pCircuitCallBindTable;

// Handle used to control the data acquisition thread
extern HANDLE hSxbCollectionThread;
extern HANDLE hSxbTraceCollectionThread;

// Termination event handle
extern HANDLE	terminateEvent;

// Global Var that tells how many ports we are dealing with
AsnInteger portCount;

//Global var to shut down data collection
BOOL	done = FALSE;

// If an addition or deletion to the MIB is necessary, there are several
// places in the code that must be checked and possibly changed.
//
// The last field in each MIB entry is used to point to the NEXT
// leaf variable.  If an addition or deletetion is made, these pointers
// may need to be updated to reflect the modification.

// The prefix to all of these MIB variables is 1.3.6.1.2.1.10
// {.iso.org.dod.internet.mgmt.mib.transmission
UINT OID_Prefix[] = { 1, 3, 6, 1, 2, 1, 10, 5 };
AsnObjectIdentifier MIB_OidPrefix = { OID_SIZEOF(OID_Prefix), OID_Prefix };

//                         //
// OID definitions for MIB //
//                         //
// Definition of the x25 group

UINT MIB_X25[]  = { 5 };

// The following definitions are those of the X.25 Protocol Versions
//
UINT x25ProtocolVerion[]		= { 1, 3, 6, 1, 2, 1, 10, 5, 10 };
UINT x25protocolCcittV1976[]	= { 1, 3, 6, 1, 2, 1, 10, 5, 10, 1 };
UINT x25protocolCcittV1980[]	= { 1, 3, 6, 1, 2, 1, 10, 5, 10, 2 };
UINT x25protocolCcittV1984[]	= { 1, 3, 6, 1, 2, 1, 10, 5, 10, 3 };
UINT x25protocolCcittV1988[]	= { 1, 3, 6, 1, 2, 1, 10, 5, 10, 4 };
UINT x25protocolIso8208V1987[]	= { 1, 3, 6, 1, 2, 1, 10, 5, 10, 5 };
UINT x25protocolIso8208V1989[]	= { 1, 3, 6, 1, 2, 1, 10, 5, 10, 6 };

// Lapb connected to first x.25
//
UINT firstLapbObjectId[]		= { 1, 3, 6, 1, 2, 1, 10, 16, 1, 1, 1, 1 };

UINT firstX25CallParmIndex[]	= { 1, 3, 6, 1, 2, 1, 10,  5, 9, 1, 1, 1 };
UINT callParamOidLen = sizeof(firstX25CallParmIndex)/sizeof(UINT);

UINT X25NullIndex[]				= { 0, 0 };

// The following definitions are those of the x.25 Admin table
// The presence of the first configured port's parameters. If no ports are 
// configured, the DLL will fail to initialize. If more than one 
// port exists, they will be added during initialization by chaining
// columnwise to the previous port (i.e. port index 2 is the NEXT 
// MIB entry after port index 1, and port type 1 is the next MIB 
// entry after port index 2

UINT MIB_x25AdmnIndex[]						= { 1, 1, 1, 1 };
UINT MIB_x25AdmnInterfaceMode[]				= { 1, 1, 2, 1 };
UINT MIB_x25AdmnMaxActiveCircuits[]			= { 1, 1, 3, 1 };
UINT MIB_x25AdmnPacketSequencing[]			= { 1, 1, 4, 1 };
UINT MIB_x25AdmnRestartTimer[]				= { 1, 1, 5, 1 };
UINT MIB_x25AdmnCallTimer[]					= { 1, 1, 6, 1 };
UINT MIB_x25AdmnResetTimer[]				= { 1, 1, 7, 1 };
UINT MIB_x25AdmnClearTimer[]				= { 1, 1, 8, 1 };
UINT MIB_x25AdmnWindowTimer[]				= { 1, 1, 9, 1 };
UINT MIB_x25AdmnDataRxmtTimer[]				= { 1, 1, 10, 1 };
UINT MIB_x25AdmnInterruptTimer[]			= { 1, 1, 11, 1 };
UINT MIB_x25AdmnRejectTimer[]				= { 1, 1, 12, 1 };
UINT MIB_x25AdmnRegistrationRequestTimer[]	= { 1, 1, 13, 1 };
UINT MIB_x25AdmnMinimumRecallTimer[]		= { 1, 1, 14, 1 };
UINT MIB_x25AdmnRestartCount[]				= { 1, 1, 15, 1 };
UINT MIB_x25AdmnResetCount[]				= { 1, 1, 16, 1 };
UINT MIB_x25AdmnClearCount[]				= { 1, 1, 17, 1 };
UINT MIB_x25AdmnDataRxmtCount[]				= { 1, 1, 18, 1 };
UINT MIB_x25AdmnRejectCount[]				= { 1, 1, 19, 1 };
UINT MIB_x25AdmnRegistrationRequestCount[]	= { 1, 1, 20, 1 };
UINT MIB_x25AdmnNumberPVCs[]				= { 1, 1, 21, 1 };
UINT MIB_x25AdmnDefCallParamId[]			= { 1, 1, 22, 1 };
UINT MIB_x25AdmnLocalAddress[]				= { 1, 1, 23, 1 };
UINT MIB_x25AdmnProtocolVersionSupported[]	= { 1, 1, 24, 1 };

// Storage definitions for Admn Table MIBs	//
//											//
AsnInteger			MIB_x25AdmnIndexStor = 1;
AsnInteger			MIB_x25AdmnInterfaceModeStor = 1;
AsnInteger			MIB_x25AdmnMaxActiveCircuitsStor = 1;
AsnInteger			MIB_x25AdmnPacketSequencingStor = 1;
AsnInteger			MIB_x25AdmnRestartTimerStor = 1;
AsnInteger			MIB_x25AdmnCallTimerStor = 1;
AsnInteger			MIB_x25AdmnResetTimerStor = 1;
AsnInteger			MIB_x25AdmnClearTimerStor = 1;
AsnInteger			MIB_x25AdmnWindowTimerStor = 1;
AsnInteger			MIB_x25AdmnDataRxmtTimerStor = 1;
AsnInteger			MIB_x25AdmnInterruptTimerStor = 1;
AsnInteger			MIB_x25AdmnRejectTimerStor = 1;
AsnInteger			MIB_x25AdmnRegistrationRequestTimerStor = 1;
AsnInteger			MIB_x25AdmnMinimumRecallTimerStor = 1;
AsnInteger			MIB_x25AdmnRestartCountStor = 1;
AsnInteger			MIB_x25AdmnResetCountStor = 1;
AsnInteger			MIB_x25AdmnClearCountStor = 1;
AsnInteger			MIB_x25AdmnDataRxmtCountStor = 1;
AsnInteger			MIB_x25AdmnRejectCountStor = 1;
AsnInteger			MIB_x25AdmnRegistrationRequestCountStor = 1;
AsnInteger			MIB_x25AdmnNumberPVCsStor = 1;
AsnObjectIdentifier MIB_x25AdmnDefCallParamIdStor = {OID_SIZEOF(firstX25CallParmIndex), 
																firstX25CallParmIndex};
AsnOctetString		MIB_x25AdmnLocalAddressStor = {0,0};
AsnObjectIdentifier	MIB_x25AdmnProtocolVersionSupportedStor = { OID_SIZEOF(x25protocolCcittV1988),
																		x25protocolCcittV1988 };


// The following definitions are those of the Operations Table
//
UINT MIB_x25OperIndex[]						= { 2, 1, 1, 1 };
UINT MIB_x25OperInterfaceMode[]				= { 2, 1, 2, 1 };
UINT MIB_x25OperMaxActiveCircuits[]			= { 2, 1, 3, 1 };
UINT MIB_x25OperPacketSequencing[]			= { 2, 1, 4, 1 };
UINT MIB_x25OperRestartTimer[]				= { 2, 1, 5, 1 };
UINT MIB_x25OperCallTimer[]					= { 2, 1, 6, 1 };
UINT MIB_x25OperResetTimer[]				= { 2, 1, 7, 1 };
UINT MIB_x25OperClearTimer[]				= { 2, 1, 8, 1 };
UINT MIB_x25OperWindowTimer[]				= { 2, 1, 9, 1 };
UINT MIB_x25OperDataRxmtTimer[]				= { 2, 1, 10, 1 };
UINT MIB_x25OperInterruptTimer[]			= { 2, 1, 11, 1 };
UINT MIB_x25OperRejectTimer[]				= { 2, 1, 12, 1 };
UINT MIB_x25OperRegistrationRequestTimer[]	= { 2, 1, 13, 1 };
UINT MIB_x25OperMinimumRecallTimer[]		= { 2, 1, 14, 1 };
UINT MIB_x25OperRestartCount[]				= { 2, 1, 15, 1 };
UINT MIB_x25OperResetCount[]				= { 2, 1, 16, 1 };
UINT MIB_x25OperClearCount[]				= { 2, 1, 17, 1 };
UINT MIB_x25OperDataRxmtCount[]				= { 2, 1, 18, 1 };
UINT MIB_x25OperRejectCount[]				= { 2, 1, 19, 1 };
UINT MIB_x25OperRegistrationRequestCount[]	= { 2, 1, 20, 1 };
UINT MIB_x25OperNumberPVCs[]				= { 2, 1, 21, 1 };
UINT MIB_x25OperDefCallParamId[]			= { 2, 1, 22, 1 };
UINT MIB_x25OperLocalAddress[]				= { 2, 1, 23, 1 };
UINT MIB_x25OperDataLinkId[]				= { 2, 1, 24, 1 };
UINT MIB_x25OperProtocolVersionSupported[]	= { 2, 1, 25, 1 };

// Storage definitions for Operational Table MIBs	//
//											//
AsnInteger			MIB_x25OperIndexStor = 1;
AsnInteger			MIB_x25OperInterfaceModeStor = 1;
AsnInteger			MIB_x25OperMaxActiveCircuitsStor = 1;
AsnInteger			MIB_x25OperPacketSequencingStor = 1;
AsnInteger			MIB_x25OperRestartTimerStor = 1;
AsnInteger			MIB_x25OperCallTimerStor = 1;
AsnInteger			MIB_x25OperResetTimerStor = 1;
AsnInteger			MIB_x25OperClearTimerStor = 1;
AsnInteger			MIB_x25OperWindowTimerStor = 1;
AsnInteger			MIB_x25OperDataRxmtTimerStor = 1;
AsnInteger			MIB_x25OperInterruptTimerStor = 1;
AsnInteger			MIB_x25OperRejectTimerStor = 1;
AsnInteger			MIB_x25OperRegistrationRequestTimerStor = 1;
AsnInteger			MIB_x25OperMinimumRecallTimerStor = 1;
AsnInteger			MIB_x25OperRestartCountStor = 1;
AsnInteger			MIB_x25OperResetCountStor = 1;
AsnInteger			MIB_x25OperClearCountStor = 1;
AsnInteger			MIB_x25OperDataRxmtCountStor = 1;
AsnInteger			MIB_x25OperRejectCountStor = 1;
AsnInteger			MIB_x25OperRegistrationRequestCountStor = 1;
AsnInteger			MIB_x25OperNumberPVCsStor = 1;
AsnObjectIdentifier MIB_x25OperDefCallParamIdStor = {OID_SIZEOF(firstX25CallParmIndex), 
																firstX25CallParmIndex};
AsnOctetString		MIB_x25OperLocalAddressStor = {0,0,0};
AsnObjectIdentifier MIB_x25OperDataLinkIdStor = { OID_SIZEOF ( firstLapbObjectId ),
																firstLapbObjectId };
AsnObjectIdentifier	MIB_x25OperProtocolVersionSupportedStor = { OID_SIZEOF( x25protocolCcittV1988 ),
																x25protocolCcittV1988 };

// The following definitions are those of the Stats Table
//
UINT MIB_x25StatIndex[]						= { 3, 1, 1, 1 };
UINT MIB_x25StatInCalls[]					= { 3, 1, 2, 1 };
UINT MIB_x25StatInCallRefusals[]			= { 3, 1, 3, 1 };
UINT MIB_x25StatProviderInitiatedClears[]	= { 3, 1, 4, 1 };
UINT MIB_x25StatRemotelyInitiatedResets[]	= { 3, 1, 5, 1 };
UINT MIB_x25StatProviderInitiatedResets[]	= { 3, 1, 6, 1 };
UINT MIB_x25StatInRestarts[]				= { 3, 1, 7, 1 };
UINT MIB_x25StatInDataPackets[]				= { 3, 1, 8, 1 };
UINT MIB_x25StatInAccusedOfProtocolErrors[]	= { 3, 1, 9, 1 };
UINT MIB_x25StatInInterrupts[]				= { 3, 1, 10, 1 };
UINT MIB_x25StatOutCallAttempts[]			= { 3, 1, 11, 1 };
UINT MIB_x25StatOutCallFailures[]			= { 3, 1, 12, 1 };
UINT MIB_x25StatOutInterrupts[]				= { 3, 1, 13, 1 };
UINT MIB_x25StatOutDataPackets[]			= { 3, 1, 14, 1 };
UINT MIB_x25StatOutgoingCircuits[]			= { 3, 1, 15, 1 };
UINT MIB_x25StatIncomingCircuits[]			= { 3, 1, 16, 1 };
UINT MIB_x25StatTwoWayCircuits[]			= { 3, 1, 17, 1 };
UINT MIB_x25StatRestartTimeouts[]			= { 3, 1, 18, 1 };
UINT MIB_x25StatCallTimeouts[]				= { 3, 1, 19, 1 };
UINT MIB_x25StatResetTimeouts[]				= { 3, 1, 20, 1 };
UINT MIB_x25StatClearTimeouts[]				= { 3, 1, 21, 1 };
UINT MIB_x25StatRxmtTimeouts[]				= { 3, 1, 22, 1 };
UINT MIB_x25StatInterruptTimeouts[]			= { 3, 1, 23, 1 };
UINT MIB_x25StatRettryCountExceededs[]		= { 3, 1, 24, 1 };
UINT MIB_x25StatClearCountExceededs[]		= { 3, 1, 25, 1 };

// Storage definitions for Stat Table MIBs	//
//											//
AsnCounter	MIB_x25StatIndexStor = 0;
AsnCounter	MIB_x25StatInCallsStor = 0;
AsnCounter	MIB_x25StatInCallRefusalsStor = 0;
AsnCounter	MIB_x25StatProviderInitiatedClearsStor = 0;
AsnCounter	MIB_x25StatRemotelyInitiatedResetsStor = 0;
AsnCounter	MIB_x25StatProviderInitiatedResetsStor = 0;
AsnCounter	MIB_x25StatInRestartsStor = 0;
AsnCounter	MIB_x25StatInDataPacketsStor = 0;
AsnCounter	MIB_x25StatInAccusedOfProtocolErrorsStor = 0;
AsnCounter	MIB_x25StatInInterruptsStor = 0;
AsnCounter	MIB_x25StatOutCallAttemptsStor = 0;
AsnCounter	MIB_x25StatOutCallFailuresStor = 0;
AsnCounter	MIB_x25StatOutInterruptsStor = 0;
AsnCounter	MIB_x25StatOutDataPacketsStor = 0;
AsnGauge	MIB_x25StatOutgoingCircuitsStor = 0;
AsnGauge	MIB_x25StatIncomingCircuitsStor = 0;
AsnGauge	MIB_x25StatTwoWayCircuitsStor = 0;
AsnCounter	MIB_x25StatRestartTimeoutsStor = 0;
AsnCounter	MIB_x25StatCallTimeoutsStor = 0;
AsnCounter	MIB_x25StatResetTimeoutsStor = 0;
AsnCounter	MIB_x25StatClearTimeoutsStor = 0;
AsnCounter	MIB_x25StatRxmtTimeoutsStor = 0;
AsnCounter	MIB_x25StatInterruptTimeoutsStor = 0;
AsnCounter	MIB_x25StatRettryCountExceededsStor = 0;
AsnCounter	MIB_x25StatClearCountExceededsStor = 0;

// The following definitions are those of the Channel Table
//
UINT MIB_x25ChannelIndex[]	= { 4, 1, 1, 1 };
UINT MIB_x25ChannelLIC[]	= { 4, 1, 2, 1 };
UINT MIB_x25ChannelHIC[]	= { 4, 1, 3, 1 };
UINT MIB_x25ChannelLTC[]	= { 4, 1, 4, 1 };
UINT MIB_x25ChannelHTC[]	= { 4, 1, 5, 1 };
UINT MIB_x25ChannelLOC[]	= { 4, 1, 6, 1 };
UINT MIB_x25ChannelHOC[]	= { 4, 1, 7, 1 };

// Storage definitions for Channel Table MIBs	//
//											//
AsnInteger	MIB_x25ChannelIndexStor = 1;
AsnInteger	MIB_x25ChannelLICStor = 1;
AsnInteger	MIB_x25ChannelHICStor = 1;
AsnInteger	MIB_x25ChannelLTCStor = 1;
AsnInteger	MIB_x25ChannelHTCStor = 1;
AsnInteger	MIB_x25ChannelLOCStor = 1;
AsnInteger	MIB_x25ChannelHOCStor = 1;

// The following definitions are those of the Channel Table
//
UINT MIB_x25CircuitIndex[]						= { 5, 1, 1, 1 };
UINT MIB_x25CircuitChannel[]					= { 5, 1, 2, 1 };
UINT MIB_x25CircuitStatus[]						= { 5, 1, 3, 1 };
UINT MIB_x25CircuitEstablishTime[]				= { 5, 1, 4, 1 };
UINT MIB_x25CircuitDirection[]					= { 5, 1, 5, 1 };
UINT MIB_x25CircuitInOctets[]					= { 5, 1, 6, 1 };
UINT MIB_x25CircuitInPdus[]						= { 5, 1, 7, 1 };
UINT MIB_x25CircuitRemotelyInitiatedResets[]	= { 5, 1, 8, 1 };
UINT MIB_x25CircuitProviderInitiatedResets[]	= { 5, 1, 9, 1 };
UINT MIB_x25CircuitInInterrupts[]				= { 5, 1, 10, 1 };
UINT MIB_x25CircuitOutOctets[]					= { 5, 1, 11, 1 };
UINT MIB_x25CircuitOutPdus[]					= { 5, 1, 12, 1 };
UINT MIB_x25CircuitOutInterrupts[]				= { 5, 1, 13, 1 };
UINT MIB_x25CircuitDataRetransmissionTimeouts[]	= { 5, 1, 14, 1 };
UINT MIB_x25CircuitResetTimeouts[]				= { 5, 1, 15, 1 };
UINT MIB_x25CircuitInterruptTimeouts[]			= { 5, 1, 16, 1 };
UINT MIB_x25CircuitCallParamId[]				= { 5, 1, 17, 1 };
UINT MIB_x25CircuitCalledDteAddress[]			= { 5, 1, 18, 1 };
UINT MIB_x25CircuitCallingDteAddress[]			= { 5, 1, 19, 1 };
UINT MIB_x25CircuitOriginallyCalledAddress[]	= { 5, 1, 20, 1 };
UINT MIB_x25CircuitCircuitDescr[]				= { 5, 1, 21, 1 };

// Storage definitions for Circuit Table MIBs	//
//											//
AsnInteger			MIB_x25CircuitIndexStor = 1;
AsnInteger			MIB_x25CircuitChannelStor = 1;
AsnInteger			MIB_x25CircuitStatusStor = 1;
AsnTimeticks		MIB_x25CircuitEstablishTimeStor = 0;
AsnInteger			MIB_x25CircuitDirectionStor = 1;
AsnCounter			MIB_x25CircuitInOctetsStor = 0;
AsnCounter			MIB_x25CircuitInPdusStor = 0;
AsnCounter			MIB_x25CircuitRemotelyInitiatedResetsStor = 0;
AsnCounter			MIB_x25CircuitProviderInitiatedResetsStor = 0;
AsnCounter			MIB_x25CircuitInInterruptsStor = 0;
AsnCounter			MIB_x25CircuitOutOctetsStor = 0;
AsnCounter			MIB_x25CircuitOutPdusStor = 0;
AsnCounter			MIB_x25CircuitOutInterruptsStor = 0;
AsnCounter			MIB_x25CircuitDataRetransmissionTimeoutsStor = 0;
AsnCounter			MIB_x25CircuitResetTimeoutsStor = 0;
AsnCounter			MIB_x25CircuitInterruptTimeoutsStor = 0;
AsnObjectIdentifier	MIB_x25CircuitCallParamIdStor = {OID_SIZEOF(firstX25CallParmIndex), 
																firstX25CallParmIndex};
AsnOctetString		MIB_x25CircuitCalledDteAddressStor = {0,0};;
AsnOctetString		MIB_x25CircuitCallingDteAddressStor = {0,0};
AsnOctetString		MIB_x25CircuitOriginallyCalledAddressStor = {0,0};
AsnDisplayString	MIB_x25CircuitCircuitDescrStor = {0,0};

// The following definitions are those of the Cleared Channel Table
//
UINT MIB_x25ClearedCircuitEntriesRequested[]	= { 6, 0 };
UINT MIB_x25ClearedCircuitEntriesGranted[]		= { 7, 0 };

UINT MIB_x25ClearedCircuitIndex[]			= { 8, 1, 1, 1 };
UINT MIB_x25ClearedCircuitPleIndex[]		= { 8, 1, 2, 1 };
UINT MIB_x25ClearedCircuitTimeEstablished[]	= { 8, 1, 3, 1 };
UINT MIB_x25ClearedCircuitTimeCleared[]		= { 8, 1, 4, 1 };
UINT MIB_x25ClearedCircuitChannel[]			= { 8, 1, 5, 1 };
UINT MIB_x25ClearedCircuitClearingCause[]	= { 8, 1, 6, 1 };
UINT MIB_x25ClearedCircuitDiagnosticCode[]	= { 8, 1, 7, 1 };
UINT MIB_x25ClearedCircuitInPdus[]			= { 8, 1, 8, 1 };
UINT MIB_x25ClearedCircuitOutPdus[]			= { 8, 1, 9, 1 };
UINT MIB_x25ClearedCircuitCalledAddress[]	= { 8, 1, 10, 1 };
UINT MIB_x25ClearedCircuitCallingAddress[]	= { 8, 1, 11, 1 };
UINT MIB_x25ClearedCircuitFacilities[]		= { 8, 1, 12, 1 };

// Storage definitions for Cleared Channel Table MIBs	//
//														//
AsnInteger			MIB_x25ClearedCircuitEntriesRequestedStor = 0;
AsnInteger			MIB_x25ClearedCircuitEntriesGrantedStor = 0;

AsnInteger			MIB_x25ClearedCircuitIndexStor = 1;
AsnInteger			MIB_x25ClearedCircuitPleIndexStor = 1;
AsnTimeticks		MIB_x25ClearedCircuitTimeEstablishedStor = 0;
AsnTimeticks		MIB_x25ClearedCircuitTimeClearedStor = 0;
AsnInteger			MIB_x25ClearedCircuitChannelStor = 1;
AsnInteger			MIB_x25ClearedCircuitClearingCauseStor = 1;
AsnInteger			MIB_x25ClearedCircuitDiagnosticCodeStor = 1;
AsnCounter			MIB_x25ClearedCircuitInPdusStor = 1;
AsnInteger			MIB_x25ClearedCircuitOutPdusStor = 1;
AsnOctetString		MIB_x25ClearedCircuitCalledAddressStor = {0,0,0};
AsnOctetString		MIB_x25ClearedCircuitCallingAddressStor = {0,0,0};
AsnOctetString		MIB_x25ClearedCircuitFacilitiesStor = {0,0,0};

// The following definitions are those of the Call Parm Table
//
UINT MIB_x25CallParmIndex[]						= { 9, 1, 1,  1 };
UINT MIB_x25CallParmStatus[]					= { 9, 1, 2,  1 };
UINT MIB_x25CallParmRefCount[]					= { 9, 1, 3,  1 };
UINT MIB_x25CallParmInPacketSize[]				= { 9, 1, 4,  1 };
UINT MIB_x25CallParmOutPacketSize[]				= { 9, 1, 5,  1 };
UINT MIB_x25CallParmInWindowSize[]				= { 9, 1, 6,  1 };
UINT MIB_x25CallParmOutWindowSize[]				= {	9, 1, 7,  1 };
UINT MIB_x25CallParmAcceptReverseCharging[]		= { 9, 1, 8,  1 };
UINT MIB_x25CallParmProposeReverseCharging[]	= { 9, 1, 9,  1 };
UINT MIB_x25CallParmFastSelect[]				= { 9, 1, 10, 1 };
UINT MIB_x25CallParmInThruputClasSize[]			= { 9, 1, 11, 1 };
UINT MIB_x25CallParmOutThruputClasSize[]		= { 9, 1, 12, 1 };
UINT MIB_x25CallParmCug[]						= { 9, 1, 13, 1 };
UINT MIB_x25CallParmCugoa[]						= { 9, 1, 14, 1 };
UINT MIB_x25CallParmBcug[]						= { 9, 1, 15, 1 };
UINT MIB_x25CallParmNui[]						= { 9, 1, 16, 1 };
UINT MIB_x25CallParmChargingInfo[]				= { 9, 1, 17, 1 };
UINT MIB_x25CallParmRpoa[]						= { 9, 1, 18, 1 };
UINT MIB_x25CallParmTrnstDly[]					= { 9, 1, 19, 1 };
UINT MIB_x25CallParmCallingExt[]				= { 9, 1, 20, 1 };
UINT MIB_x25CallParmCalledExt[]					= { 9, 1, 21, 1 };
UINT MIB_x25CallParmInMinThuPutCls[]			= { 9, 1, 22, 1 };
UINT MIB_x25CallParmOutMinThuPutCls[]			= { 9, 1, 23, 1 };
UINT MIB_x25CallParmEndTrnsDly[]				= { 9, 1, 24, 1 };
UINT MIB_x25CallParmPriority[]					= { 9, 1, 25, 1 };
UINT MIB_x25CallParmProtection[]				= { 9, 1, 26, 1 };
UINT MIB_x25CallParmExcptData[]					= { 9, 1, 27, 1 };
UINT MIB_x25CallParmUserData[]					= { 9, 1, 28, 1 };
UINT MIB_x25CallParmCallingNetworkFacilities[]	= { 9, 1, 29, 1 };
UINT MIB_x25CallParmCalledNetworkFacilities[]	= { 9, 1, 30, 1 };

// Storage definitions for Cleared Channel Table MIBs	//
//														//
AsnInteger			MIB_x25CallParmIndexStor = 1;
AsnInteger			MIB_x25CallParmStatusStor = 1;
AsnInteger			MIB_x25CallParmRefCountStor = 1;
AsnInteger			MIB_x25CallParmInPacketSizeStor = 1;
AsnInteger			MIB_x25CallParmOutPacketSizeStor = 1;
AsnInteger			MIB_x25CallParmInWindowSizeStor = 1;
AsnInteger			MIB_x25CallParmOutWindowSizeStor = 1;
AsnInteger			MIB_x25CallParmAcceptReverseChargingStor = 1;
AsnInteger			MIB_x25CallParmProposeReverseChargingStor = 1;
AsnInteger			MIB_x25CallParmFastSelectStor = 1;
AsnInteger			MIB_x25CallParmInThruputClasSizeStor = 1;
AsnInteger			MIB_x25CallParmOutThruputClasSizeStor = 1;
AsnOctetString		MIB_x25CallParmCugStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmCugoaStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmBcugStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmNuiStor = {0, 0, 0};
AsnInteger			MIB_x25CallParmChargingInfoStor = 0;
AsnOctetString		MIB_x25CallParmRpoaStor = {0, 0, 0};
AsnInteger			MIB_x25CallParmTrnstDlyStor = 0;
AsnOctetString		MIB_x25CallParmCallingExtStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmCalledExtStor = {0, 0, 0};
AsnInteger			MIB_x25CallParmInMinThuPutClsStor = 0;
AsnInteger			MIB_x25CallParmOutMinThuPutClsStor = 0;
AsnOctetString		MIB_x25CallParmEndTrnsDlyStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmPriorityStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmProtectionStor = {0, 0, 0};
AsnInteger			MIB_x25CallParmExcptDataStor = 0;
AsnOctetString		MIB_x25CallParmUserDataStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmCallingNetworkFacilitiesStor = {0, 0, 0};
AsnOctetString		MIB_x25CallParmCalledNetworkFacilitiesStor = {0, 0, 0};

// General Notes about the X.25 MIB: This array has both static and dynamic
// entities. The Admn, Oper, Stat, Channel, and Circuit tables are static, and
// defined by the registry entries for the agent. The CallParm and ClearedCircuit
// tables are dynamic entities that change over the course of the life of the MIB.
// When first activated, these dynamic tables are not present. A separate thread is
// spawned that collects trace information from each board. When CallParm (indicating 
// that a call has been placed on a circuit), or ClearedCircuit (indicating that a Call
// has been released) events occur, these tables will shrink, or expand respectively.
// When a call is established, the CallParm MIB entry must be created, and added to the 
// table. Then it must be tied to the circuit carrying the call. When a ClearedCircuit
// event arrives, the circuit MIB entry must be modified, and it's Call Parm entry 
// nullified. When a CallParm is added, the addition routine must search for the first 
// available (nullified MIB entry, and place the CallParm entry there. This is pretty
// convoluted as a result of trying to marry dynamic tables to statically constructed tables.

// MIB definiton
MIB_ENTRY Mib[] = {

	    ///////////////////////////
		//// X.25 Admin Table /////
		///////////////////////////
      
	{ { OID_SIZEOF(MIB_x25AdmnIndex), MIB_x25AdmnIndex },
	    &MIB_x25AdmnIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func,
		&Mib[1],
		&Mib[1] },   //Index 0


      { { OID_SIZEOF(MIB_x25AdmnInterfaceMode), MIB_x25AdmnInterfaceMode },
	    &MIB_x25AdmnInterfaceModeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[2],
		&Mib[2] },   //Index 1

     { { OID_SIZEOF(MIB_x25AdmnMaxActiveCircuits), MIB_x25AdmnMaxActiveCircuits },
	    &MIB_x25AdmnMaxActiveCircuitsStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[3],
		&Mib[3] },   //Index 2

      { { OID_SIZEOF(MIB_x25AdmnPacketSequencing), MIB_x25AdmnPacketSequencing },
	    &MIB_x25AdmnPacketSequencingStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[4],
		&Mib[4] },   //Index 3

      { { OID_SIZEOF(MIB_x25AdmnRestartTimer), MIB_x25AdmnRestartTimer },
	    &MIB_x25AdmnRestartTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[5],
		&Mib[5] },   //Index 4

      { { OID_SIZEOF(MIB_x25AdmnCallTimer), MIB_x25AdmnCallTimer },
	    &MIB_x25AdmnCallTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[6],
		&Mib[6] },   //Index 5

      { { OID_SIZEOF(MIB_x25AdmnResetTimer), MIB_x25AdmnResetTimer },
	    &MIB_x25AdmnResetTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[7],
		&Mib[7] },   //Index 6

      { { OID_SIZEOF(MIB_x25AdmnClearTimer), MIB_x25AdmnClearTimer },
	    &MIB_x25AdmnClearTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[8],
		&Mib[8] },   //Index 7

      { { OID_SIZEOF(MIB_x25AdmnWindowTimer), MIB_x25AdmnWindowTimer },
	    &MIB_x25AdmnWindowTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[9],
		&Mib[9] },   //Index 8

      { { OID_SIZEOF(MIB_x25AdmnDataRxmtTimer), MIB_x25AdmnDataRxmtTimer },
	    &MIB_x25AdmnDataRxmtTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[10],
		&Mib[10] },   //Index 9

      { { OID_SIZEOF(MIB_x25AdmnInterruptTimer), MIB_x25AdmnInterruptTimer },
	    &MIB_x25AdmnInterruptTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[11],
		&Mib[11] },   //Index 10

      { { OID_SIZEOF(MIB_x25AdmnRejectTimer), MIB_x25AdmnRejectTimer },
	    &MIB_x25AdmnRejectTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[12],
		&Mib[12] },   //Index 11

      { { OID_SIZEOF(MIB_x25AdmnRegistrationRequestTimer), MIB_x25AdmnRegistrationRequestTimer },
	    &MIB_x25AdmnRegistrationRequestTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[13],
		&Mib[13] },   //Index 12

      { { OID_SIZEOF(MIB_x25AdmnMinimumRecallTimer), MIB_x25AdmnMinimumRecallTimer },
	    &MIB_x25AdmnMinimumRecallTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[14],
		&Mib[14] },   //Index 13

      { { OID_SIZEOF(MIB_x25AdmnRestartCount), MIB_x25AdmnRestartCount },
	    &MIB_x25AdmnRestartCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[15],
		&Mib[15] },   //Index 14

      { { OID_SIZEOF(MIB_x25AdmnResetCount), MIB_x25AdmnResetCount },
	    &MIB_x25AdmnResetCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[16],
		&Mib[16] },   //Index 15

      { { OID_SIZEOF(MIB_x25AdmnClearCount), MIB_x25AdmnClearCount},
	    &MIB_x25AdmnClearCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[17],
		&Mib[17] },   //Index 16
      
	  { { OID_SIZEOF(MIB_x25AdmnDataRxmtCount), MIB_x25AdmnDataRxmtCount },
	    &MIB_x25AdmnDataRxmtCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[18],
		&Mib[18] },   //Index 17

      { { OID_SIZEOF(MIB_x25AdmnRejectCount), MIB_x25AdmnRejectCount },
	    &MIB_x25AdmnRejectCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[19],
		&Mib[19] },   //Index 18

      { { OID_SIZEOF(MIB_x25AdmnRegistrationRequestCount), MIB_x25AdmnRegistrationRequestCount },
	    &MIB_x25AdmnRegistrationRequestCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[20],
		&Mib[20] },   //Index 19

      { { OID_SIZEOF(MIB_x25AdmnNumberPVCs), MIB_x25AdmnNumberPVCs },
	    &MIB_x25AdmnNumberPVCsStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[21],
		&Mib[21] },   //Index 20
      
      { { OID_SIZEOF(MIB_x25AdmnDefCallParamId), MIB_x25AdmnDefCallParamId },
	    &MIB_x25AdmnDefCallParamIdStor, NULL,
		ASN_OBJECTIDENTIFIER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		NULL,
		&Mib[22] },   //Index 21

      { { OID_SIZEOF(MIB_x25AdmnLocalAddress), MIB_x25AdmnLocalAddress },
	    &MIB_x25AdmnLocalAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[23],
		&Mib[23] },   //Index 22

      { { OID_SIZEOF(MIB_x25AdmnProtocolVersionSupported), MIB_x25AdmnProtocolVersionSupported },
	    &MIB_x25AdmnProtocolVersionSupportedStor, NULL,
		ASN_OBJECTIDENTIFIER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[24],
		&Mib[24] },   //Index 23

		///////////////////////////
		//// X.25  Oper Table /////
		///////////////////////////

      { { OID_SIZEOF(MIB_x25OperIndex), MIB_x25OperIndex },
	    &MIB_x25OperIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[25],
		&Mib[25] },   //Index 24

      { { OID_SIZEOF(MIB_x25OperInterfaceMode), MIB_x25OperInterfaceMode },
	    &MIB_x25OperInterfaceModeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[26],
		&Mib[26] },   //Index 25

      { { OID_SIZEOF(MIB_x25OperMaxActiveCircuits), MIB_x25OperMaxActiveCircuits },
	    &MIB_x25OperMaxActiveCircuitsStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[27],
		&Mib[27] },   //Index 26

      { { OID_SIZEOF(MIB_x25OperPacketSequencing), MIB_x25OperPacketSequencing },
	    &MIB_x25OperPacketSequencingStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[28],
		&Mib[28] },   //Index 27

      { { OID_SIZEOF(MIB_x25OperRestartTimer), MIB_x25OperRestartTimer },
	    &MIB_x25OperRestartTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[29],
		&Mib[29] },   //Index 28

      { { OID_SIZEOF(MIB_x25OperCallTimer), MIB_x25OperCallTimer },
	    &MIB_x25OperCallTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[30],
		&Mib[30] },   //Index 29

      { { OID_SIZEOF(MIB_x25OperResetTimer), MIB_x25OperResetTimer },
	    &MIB_x25OperResetTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[31],
		&Mib[31] },   //Index 30

      { { OID_SIZEOF(MIB_x25OperClearTimer), MIB_x25OperClearTimer },
	    &MIB_x25OperClearTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[32],
		&Mib[32] },   //Index 31

      { { OID_SIZEOF(MIB_x25OperWindowTimer), MIB_x25OperWindowTimer },
	    &MIB_x25OperWindowTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[33],
		&Mib[33] },   //Index 32

      { { OID_SIZEOF(MIB_x25OperDataRxmtTimer), MIB_x25OperDataRxmtTimer },
	    &MIB_x25OperDataRxmtTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[34],
		&Mib[34] },   //Index 33

      { { OID_SIZEOF(MIB_x25OperInterruptTimer), MIB_x25OperInterruptTimer },
	    &MIB_x25OperInterruptTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[35],
		&Mib[35] },   //Index 34

      { { OID_SIZEOF(MIB_x25OperRejectTimer), MIB_x25OperRejectTimer },
	    &MIB_x25OperRejectTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[36],
		&Mib[36] },   //Index 35

      { { OID_SIZEOF(MIB_x25OperRegistrationRequestTimer), MIB_x25OperRegistrationRequestTimer },
	    &MIB_x25OperRegistrationRequestTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[37],
		&Mib[37] },   //Index 36

      { { OID_SIZEOF(MIB_x25OperMinimumRecallTimer), MIB_x25OperMinimumRecallTimer },
	    &MIB_x25OperMinimumRecallTimerStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[38],
		&Mib[38] },   //Index 37

      { { OID_SIZEOF(MIB_x25OperRestartCount), MIB_x25OperRestartCount },
	    &MIB_x25OperRestartCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[39],
		&Mib[39] },   //Index 38

      { { OID_SIZEOF(MIB_x25OperResetCount), MIB_x25OperResetCount },
	    &MIB_x25OperResetCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[40],
		&Mib[40] },   //Index 39

      { { OID_SIZEOF(MIB_x25OperClearCount), MIB_x25OperClearCount},
	    &MIB_x25OperClearCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[41],
		&Mib[41] },   //Index 40

      { { OID_SIZEOF(MIB_x25OperDataRxmtCount), MIB_x25OperDataRxmtCount },
	    &MIB_x25OperDataRxmtCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[42],
		&Mib[42] },   //Index 41
      
      { { OID_SIZEOF(MIB_x25OperRejectCount), MIB_x25OperRejectCount },
	    &MIB_x25OperRejectCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[43],
		&Mib[43] },   //Index 42

      { { OID_SIZEOF(MIB_x25OperRegistrationRequestCount), MIB_x25OperRegistrationRequestCount },
	    &MIB_x25OperRegistrationRequestCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[44],
		&Mib[44] },   //Index 43
      
      { { OID_SIZEOF(MIB_x25OperNumberPVCs), MIB_x25OperNumberPVCs },
	    &MIB_x25OperNumberPVCsStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[45],
		&Mib[45] },   //Index 44
      
      { { OID_SIZEOF(MIB_x25OperDefCallParamId), MIB_x25OperDefCallParamId },
	    &MIB_x25OperDefCallParamIdStor, NULL,
		ASN_OBJECTIDENTIFIER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[46],
		&Mib[46] },   //Index 45
      
      { { OID_SIZEOF(MIB_x25OperLocalAddress), MIB_x25OperLocalAddress },
	    &MIB_x25OperLocalAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[47],
		&Mib[47] },   //Index 46
      
      { { OID_SIZEOF(MIB_x25OperDataLinkId), MIB_x25OperDataLinkId },
	    &MIB_x25OperDataLinkIdStor, NULL,
	    ASN_OBJECTIDENTIFIER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[48],
		&Mib[48] },   //Index 47
      
      { { OID_SIZEOF(MIB_x25OperProtocolVersionSupported), MIB_x25OperProtocolVersionSupported },
	    &MIB_x25OperProtocolVersionSupportedStor, NULL,
	    ASN_OBJECTIDENTIFIER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[49],
		&Mib[49] },   //Index 48
      
		///////////////////////////
		//// X.25 Stats Table /////
		///////////////////////////

      { { OID_SIZEOF(MIB_x25StatIndex), MIB_x25StatIndex },
	    &MIB_x25StatIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[50],
		&Mib[50] },   //Index 49
      
      { { OID_SIZEOF(MIB_x25StatInCalls), MIB_x25StatInCalls},
	    &MIB_x25StatInCallsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[51],
		&Mib[51] },   //Index 50
      
      { { OID_SIZEOF(MIB_x25StatInCallRefusals), MIB_x25StatInCallRefusals },
	    &MIB_x25StatInCallRefusalsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[52],
		&Mib[52] },   //Index 51
      
      { { OID_SIZEOF(MIB_x25StatProviderInitiatedClears),MIB_x25StatProviderInitiatedClears },
	    &MIB_x25StatProviderInitiatedClearsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[53],
		&Mib[53] },   //Index 52
      
      { { OID_SIZEOF(MIB_x25StatRemotelyInitiatedResets), MIB_x25StatRemotelyInitiatedResets },
	    &MIB_x25StatRemotelyInitiatedResetsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[54],
		&Mib[54] },   //Index 53
      
      { { OID_SIZEOF(MIB_x25StatProviderInitiatedResets), MIB_x25StatProviderInitiatedResets },
	    &MIB_x25StatProviderInitiatedResetsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[55],
		&Mib[55] },   //Index 54
      
      { { OID_SIZEOF(MIB_x25StatInRestarts), MIB_x25StatInRestarts },
	    &MIB_x25StatInRestartsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[56],
		&Mib[56] },   //Index 55
      
      { { OID_SIZEOF(MIB_x25StatInDataPackets), MIB_x25StatInDataPackets },
	    &MIB_x25StatInDataPacketsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[57],
		&Mib[57] },   //Index 56
      
      { { OID_SIZEOF(MIB_x25StatInAccusedOfProtocolErrors), MIB_x25StatInAccusedOfProtocolErrors },
	    &MIB_x25StatInAccusedOfProtocolErrorsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[58],
		&Mib[58] },   //Index 57
      
      { { OID_SIZEOF(MIB_x25StatInInterrupts), MIB_x25StatInInterrupts },
	    &MIB_x25StatInInterruptsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[59],
		&Mib[59] },   //Index 58
      
      { { OID_SIZEOF(MIB_x25StatOutCallAttempts), MIB_x25StatOutCallAttempts },
	    &MIB_x25StatOutCallAttemptsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[60],
		&Mib[60] },   //Index 59
      
      { { OID_SIZEOF(MIB_x25StatOutCallFailures), MIB_x25StatOutCallFailures },
	    &MIB_x25StatOutCallFailuresStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[61],
		&Mib[61] },   //Index 60
      
      { { OID_SIZEOF(MIB_x25StatOutInterrupts), MIB_x25StatOutInterrupts },
	    &MIB_x25StatOutInterruptsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[62],
		&Mib[62] },   //Index 61
      
      { { OID_SIZEOF(MIB_x25StatOutDataPackets), MIB_x25StatOutDataPackets },
	    &MIB_x25StatOutDataPacketsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[63],
		&Mib[63] },   //Index 62
      
      { { OID_SIZEOF(MIB_x25StatOutgoingCircuits), MIB_x25StatOutgoingCircuits },
	    &MIB_x25StatOutgoingCircuitsStor, NULL,
		ASN_RFC1155_GAUGE,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[64],
		&Mib[64] },   //Index 63
      
      { { OID_SIZEOF(MIB_x25StatIncomingCircuits), MIB_x25StatIncomingCircuits },
	    &MIB_x25StatIncomingCircuitsStor, NULL,
		ASN_RFC1155_GAUGE,
	    MIB_ACCESS_READ, 
		MIB_leaf_func,
		&Mib[65],
		&Mib[65] },   //Index 64
      
      { { OID_SIZEOF(MIB_x25StatTwoWayCircuits), MIB_x25StatTwoWayCircuits },
	    &MIB_x25StatTwoWayCircuitsStor, NULL,
		ASN_RFC1155_GAUGE,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[66],
		&Mib[66] },   //Index 65
      
      { { OID_SIZEOF(MIB_x25StatRestartTimeouts), MIB_x25StatRestartTimeouts },
	    &MIB_x25StatRestartTimeoutsStor, NULL,
	    ASN_RFC1155_COUNTER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[67],
		&Mib[67] },   //Index 66
      
      { { OID_SIZEOF(MIB_x25StatCallTimeouts), MIB_x25StatCallTimeouts },
	    &MIB_x25StatCallTimeoutsStor, NULL,
	    ASN_RFC1155_COUNTER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[68],
		&Mib[68] },   //Index 67
      
      { { OID_SIZEOF(MIB_x25StatResetTimeouts), MIB_x25StatResetTimeouts },
	    &MIB_x25StatResetTimeoutsStor, NULL,
	    ASN_RFC1155_COUNTER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[69],
		&Mib[69] },   //Index 68
      
      { { OID_SIZEOF(MIB_x25StatClearTimeouts), MIB_x25StatClearTimeouts },
	    &MIB_x25StatClearTimeoutsStor, NULL,
	    ASN_RFC1155_COUNTER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[70],
		&Mib[70] },   //Index 69
      
      { { OID_SIZEOF(MIB_x25StatRxmtTimeouts), MIB_x25StatRxmtTimeouts },
	    &MIB_x25StatRxmtTimeoutsStor, NULL,
	    ASN_RFC1155_COUNTER, 
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[71],
		&Mib[71] },   //Index 70
      
      { { OID_SIZEOF(MIB_x25StatInterruptTimeouts), MIB_x25StatInterruptTimeouts },
	    &MIB_x25StatInterruptTimeoutsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[72],
		&Mib[72] },   //Index 71
      
      { { OID_SIZEOF(MIB_x25StatRettryCountExceededs), MIB_x25StatRettryCountExceededs },
	    &MIB_x25StatRettryCountExceededsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[73],
		&Mib[73] },   //Index 72
      
      { { OID_SIZEOF(MIB_x25StatClearCountExceededs), MIB_x25StatClearCountExceededs },
	    &MIB_x25StatClearCountExceededsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[74],
		&Mib[74] },   //Index 73
      
		//////////////////////////////
		//// X.25  Channel Table /////
		//////////////////////////////

      { { OID_SIZEOF(MIB_x25ChannelIndex), MIB_x25ChannelIndex },
	    &MIB_x25ChannelIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[75],
		&Mib[75] },   //Index 74
      
      { { OID_SIZEOF(MIB_x25ChannelLIC), MIB_x25ChannelLIC},
	    &MIB_x25ChannelLICStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[76],
		&Mib[76] },   //Index 75
      
      { { OID_SIZEOF(MIB_x25ChannelHIC), MIB_x25ChannelHIC },
	    &MIB_x25ChannelHICStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[77],
		&Mib[77] },   //Index 76
      
      { { OID_SIZEOF(MIB_x25ChannelLTC), MIB_x25ChannelLTC },
	    &MIB_x25ChannelLTCStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[78],
		&Mib[78] },   //Index 77
      
      { { OID_SIZEOF(MIB_x25ChannelHTC), MIB_x25ChannelHTC },
	    &MIB_x25ChannelHTCStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[79],
		&Mib[79] },   //Index 78
      
      { { OID_SIZEOF(MIB_x25ChannelLOC), MIB_x25ChannelLOC },
	    &MIB_x25ChannelLOCStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[80],
		&Mib[80] },   //Index 79
      
      { { OID_SIZEOF(MIB_x25ChannelHOC), MIB_x25ChannelHOC },
	    &MIB_x25ChannelHOCStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[81],
		&Mib[81] },   //Index 80
      
		//////////////////////////////
		//// X.25  Circuit Table /////
		//////////////////////////////

      { { OID_SIZEOF(MIB_x25CircuitIndex), MIB_x25CircuitIndex },
	    &MIB_x25CircuitIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[82],
		&Mib[82] },   //Index 81
      
      { { OID_SIZEOF(MIB_x25CircuitChannel), MIB_x25CircuitChannel },
	    &MIB_x25CircuitChannelStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[83],
		&Mib[83] },   //Index 82
      
      { { OID_SIZEOF(MIB_x25CircuitStatus), MIB_x25CircuitStatus },
	    &MIB_x25CircuitStatusStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[84],
		&Mib[84] },   //Index 83
      
      { { OID_SIZEOF(MIB_x25CircuitEstablishTime), MIB_x25CircuitEstablishTime },
	    &MIB_x25CircuitEstablishTimeStor, NULL,
		ASN_RFC1155_TIMETICKS,
	    MIB_ACCESS_READ, 
		MIB_time_leaf_func, 
		&Mib[85],
		&Mib[85] },   //Index 84
      
      { { OID_SIZEOF(MIB_x25CircuitDirection), MIB_x25CircuitDirection },
	    &MIB_x25CircuitDirectionStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[86],
		&Mib[86] },   //Index 85
      
      { { OID_SIZEOF(MIB_x25CircuitInOctets), MIB_x25CircuitInOctets },
	    &MIB_x25CircuitInOctetsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[87],
		&Mib[87] },   //Index 86
      
      { { OID_SIZEOF(MIB_x25CircuitInPdus), MIB_x25CircuitInPdus },
	    &MIB_x25CircuitInPdusStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[88],
		&Mib[88] },   //Index 87
      
      { { OID_SIZEOF(MIB_x25CircuitRemotelyInitiatedResets), MIB_x25CircuitRemotelyInitiatedResets },
	    &MIB_x25CircuitRemotelyInitiatedResetsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[89],
		&Mib[89] },   //Index 88
      
      { { OID_SIZEOF(MIB_x25CircuitProviderInitiatedResets), MIB_x25CircuitProviderInitiatedResets },
	    &MIB_x25CircuitProviderInitiatedResetsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[90],
		&Mib[90] },   //Index 89
      
      { { OID_SIZEOF(MIB_x25CircuitInInterrupts), MIB_x25CircuitInInterrupts },
	    &MIB_x25CircuitInInterruptsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[91],
		&Mib[91] },   //Index 90
      
      { { OID_SIZEOF(MIB_x25CircuitOutOctets), MIB_x25CircuitOutOctets },
	    &MIB_x25CircuitOutOctetsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[92],
		&Mib[92] },   //Index 91

      { { OID_SIZEOF(MIB_x25CircuitOutPdus), MIB_x25CircuitOutPdus },
	    &MIB_x25CircuitOutPdusStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[93],
		&Mib[93] },   //Index 91

      { { OID_SIZEOF(MIB_x25CircuitOutInterrupts), MIB_x25CircuitOutInterrupts },
	    &MIB_x25CircuitOutInterruptsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[94],
		&Mib[94] },   //Index 92

      { { OID_SIZEOF(MIB_x25CircuitDataRetransmissionTimeouts), MIB_x25CircuitDataRetransmissionTimeouts },
	    &MIB_x25CircuitDataRetransmissionTimeoutsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[95],
		&Mib[95] },   //Index 93

      { { OID_SIZEOF(MIB_x25CircuitResetTimeouts), MIB_x25CircuitResetTimeouts },
	    &MIB_x25CircuitResetTimeoutsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[96],
		&Mib[96] },   //Index 94

      { { OID_SIZEOF(MIB_x25CircuitInterruptTimeouts), MIB_x25CircuitInterruptTimeouts },
	    &MIB_x25CircuitInterruptTimeoutsStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[97],
		&Mib[97] },   //Index 95

      { { OID_SIZEOF(MIB_x25CircuitCallParamId), MIB_x25CircuitCallParamId },
	    &MIB_x25CircuitCallParamIdStor, NULL,
		ASN_OBJECTIDENTIFIER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[98],
		&Mib[98] },   //Index 96

      { { OID_SIZEOF(MIB_x25CircuitCalledDteAddress), MIB_x25CircuitCalledDteAddress },
	    &MIB_x25CircuitCalledDteAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[99],
		&Mib[99] },   //Index 97

      { { OID_SIZEOF(MIB_x25CircuitCallingDteAddress), MIB_x25CircuitCallingDteAddress },
	    &MIB_x25CircuitCallingDteAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[100],
		&Mib[100] },   //Index 98

      { { OID_SIZEOF(MIB_x25CircuitOriginallyCalledAddress), MIB_x25CircuitOriginallyCalledAddress },
	    &MIB_x25CircuitOriginallyCalledAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[101],
		&Mib[101] },   //Index 99 

      { { OID_SIZEOF(MIB_x25CircuitCircuitDescr), MIB_x25CircuitCircuitDescr },
	    &MIB_x25CircuitCircuitDescrStor, NULL,
		ASN_RFC1213_DISPSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[102],
		&Mib[102] },   //NOTE: this is the last statically configured table //Index 100

		//
		// The following 2 tables are commented out. They must be added dynamically
		// as calls are established and released
		//
		//////////////////////////////
		//// X.25 Cleared Circuit Table /////
		//////////////////////////////

      { { OID_SIZEOF(MIB_x25ClearedCircuitEntriesRequested), MIB_x25ClearedCircuitEntriesRequested },
	    &MIB_x25ClearedCircuitEntriesRequestedStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[103],
		&Mib[103] },   //Index 101

      { { OID_SIZEOF(MIB_x25ClearedCircuitEntriesGranted), MIB_x25ClearedCircuitEntriesGranted },
	    &MIB_x25ClearedCircuitEntriesGrantedStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[104],
		&Mib[104] },   //Index 102

      { { OID_SIZEOF(MIB_x25ClearedCircuitIndex), MIB_x25ClearedCircuitIndex },
	    &MIB_x25ClearedCircuitIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[105],
		&Mib[105] },   //Index 103

      { { OID_SIZEOF(MIB_x25ClearedCircuitPleIndex), MIB_x25ClearedCircuitPleIndex },
	    &MIB_x25ClearedCircuitPleIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[106],
		&Mib[106] },   //Index 104

      { { OID_SIZEOF(MIB_x25ClearedCircuitTimeEstablished), MIB_x25ClearedCircuitTimeEstablished },
	    &MIB_x25ClearedCircuitTimeEstablishedStor, NULL,
		ASN_RFC1155_TIMETICKS,
	    MIB_ACCESS_READ, 
		MIB_time_leaf_func, 
		&Mib[107],
		&Mib[107] },   //Index 105

      { { OID_SIZEOF(MIB_x25ClearedCircuitTimeCleared), MIB_x25ClearedCircuitTimeCleared },
	    &MIB_x25ClearedCircuitTimeClearedStor, NULL,
		ASN_RFC1155_TIMETICKS,
	    MIB_ACCESS_READ, 
		MIB_time_leaf_func, 
		&Mib[108],
		&Mib[108] },   //Index 106

      { { OID_SIZEOF(MIB_x25ClearedCircuitChannel), MIB_x25ClearedCircuitChannel },
	    &MIB_x25ClearedCircuitChannelStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[109],
		&Mib[109] },   //Index 107

      { { OID_SIZEOF(MIB_x25ClearedCircuitClearingCause), MIB_x25ClearedCircuitClearingCause },
	    &MIB_x25ClearedCircuitClearingCauseStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[110],
		&Mib[110] },   //Index 108

      { { OID_SIZEOF(MIB_x25ClearedCircuitDiagnosticCode), MIB_x25ClearedCircuitDiagnosticCode },
	    &MIB_x25ClearedCircuitDiagnosticCodeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[111],
		&Mib[111] },   //Index 109

      { { OID_SIZEOF(MIB_x25ClearedCircuitInPdus), MIB_x25ClearedCircuitInPdus },
	    &MIB_x25ClearedCircuitInPdusStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[112],
		&Mib[112] },   //Index 110

      { { OID_SIZEOF(MIB_x25ClearedCircuitOutPdus), MIB_x25ClearedCircuitOutPdus },
	    &MIB_x25ClearedCircuitOutPdusStor, NULL,
		ASN_RFC1155_COUNTER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[113],
		&Mib[113] },   //Index 111

      { { OID_SIZEOF(MIB_x25ClearedCircuitCalledAddress), MIB_x25ClearedCircuitCalledAddress },
	    &MIB_x25ClearedCircuitCalledAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[114],
		&Mib[114] },   //Index 112

      { { OID_SIZEOF(MIB_x25ClearedCircuitCallingAddress), MIB_x25ClearedCircuitCallingAddress },
	    &MIB_x25ClearedCircuitCallingAddressStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[115],
		&Mib[115] },   //Index 113

      { { OID_SIZEOF(MIB_x25ClearedCircuitFacilities), MIB_x25ClearedCircuitFacilities },
	    &MIB_x25ClearedCircuitFacilitiesStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[116],
		&Mib[116] },   //Index 114

		////////////////////////////////
		//// X.25  Call Parm Table /////
		////////////////////////////////

      { { OID_SIZEOF(MIB_x25CallParmIndex), MIB_x25CallParmIndex },
	    &MIB_x25CallParmIndexStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[117],
		&Mib[117] },   //Index 115

      { { OID_SIZEOF(MIB_x25CallParmStatus), MIB_x25CallParmStatus },
	    &MIB_x25CallParmStatusStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[118],
		&Mib[118] },   //Index 116

      { { OID_SIZEOF(MIB_x25CallParmRefCount), MIB_x25CallParmRefCount },
	    &MIB_x25CallParmRefCountStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[119],
		&Mib[119] },   //Index 117

      { { OID_SIZEOF(MIB_x25CallParmInPacketSize), MIB_x25CallParmInPacketSize },
	    &MIB_x25CallParmInPacketSizeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[120],
		&Mib[120] },   //Index 118

      { { OID_SIZEOF(MIB_x25CallParmOutPacketSize), MIB_x25CallParmOutPacketSize },
	    &MIB_x25CallParmOutPacketSizeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[121],
		&Mib[121] },   //Index 119

      { { OID_SIZEOF(MIB_x25CallParmInWindowSize), MIB_x25CallParmInWindowSize },
	    &MIB_x25CallParmInWindowSizeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[122],
		&Mib[122] },   //Index 120

      { { OID_SIZEOF(MIB_x25CallParmOutWindowSize), MIB_x25CallParmOutWindowSize },
	    &MIB_x25CallParmOutWindowSizeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[123],
		&Mib[123] },   //Index 121

      { { OID_SIZEOF(MIB_x25CallParmAcceptReverseCharging), MIB_x25CallParmAcceptReverseCharging },
	    &MIB_x25CallParmAcceptReverseChargingStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[124],
		&Mib[124] },   //Index 122

      { { OID_SIZEOF(MIB_x25CallParmProposeReverseCharging), MIB_x25CallParmProposeReverseCharging },
	    &MIB_x25CallParmProposeReverseChargingStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[125],
		&Mib[125] },   //Index 123

      { { OID_SIZEOF(MIB_x25CallParmFastSelect), MIB_x25CallParmFastSelect },
	    &MIB_x25CallParmFastSelectStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[126],
		&Mib[126] },   //Index 124

      { { OID_SIZEOF(MIB_x25CallParmInThruputClasSize), MIB_x25CallParmInThruputClasSize },
	    &MIB_x25CallParmInThruputClasSizeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[127],
		&Mib[127] },   //Index 125

      { { OID_SIZEOF(MIB_x25CallParmOutThruputClasSize), MIB_x25CallParmOutThruputClasSize },
	    &MIB_x25CallParmOutThruputClasSizeStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[128],
		&Mib[128] },   //Index 126

      { { OID_SIZEOF(MIB_x25CallParmCug), MIB_x25CallParmCug },
	    &MIB_x25CallParmCugStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[129],
		&Mib[129] },   //Index 127

      { { OID_SIZEOF(MIB_x25CallParmCugoa), MIB_x25CallParmCugoa },
	    &MIB_x25CallParmCugoaStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[130],
		&Mib[130] },   //Index 128

      { { OID_SIZEOF(MIB_x25CallParmBcug), MIB_x25CallParmBcug },
	    &MIB_x25CallParmBcugStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[131],
		&Mib[131] },   //Index 129

      { { OID_SIZEOF(MIB_x25CallParmNui), MIB_x25CallParmNui },
	    &MIB_x25CallParmNuiStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[132],
		&Mib[132] },   //Index 130

      { { OID_SIZEOF(MIB_x25CallParmChargingInfo), MIB_x25CallParmChargingInfo },
	    &MIB_x25CallParmChargingInfoStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[133],
		&Mib[133] },   //Index 131

      { { OID_SIZEOF(MIB_x25CallParmRpoa), MIB_x25CallParmRpoa },
	    &MIB_x25CallParmRpoaStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[134],
		&Mib[134] },   //Index 132

      { { OID_SIZEOF(MIB_x25CallParmTrnstDly), MIB_x25CallParmTrnstDly },
	    &MIB_x25CallParmTrnstDlyStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[135],
		&Mib[135] },   //Index 133

      { { OID_SIZEOF(MIB_x25CallParmCallingExt), MIB_x25CallParmCallingExt },
	    &MIB_x25CallParmCallingExtStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[136],
		&Mib[136] },   //Index 134

      { { OID_SIZEOF(MIB_x25CallParmCalledExt), MIB_x25CallParmCalledExt },
	    &MIB_x25CallParmCalledExtStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[137],
		&Mib[137] },   //Index 135

      { { OID_SIZEOF(MIB_x25CallParmInMinThuPutCls), MIB_x25CallParmInMinThuPutCls },
	    &MIB_x25CallParmInMinThuPutClsStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[138],
		&Mib[138] },   //Index 136

      { { OID_SIZEOF(MIB_x25CallParmOutMinThuPutCls), MIB_x25CallParmOutMinThuPutCls },
	    &MIB_x25CallParmOutMinThuPutClsStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[139],
		&Mib[139] },   //Index 137

      { { OID_SIZEOF(MIB_x25CallParmEndTrnsDly), MIB_x25CallParmEndTrnsDly },
	    &MIB_x25CallParmEndTrnsDlyStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[140],
		&Mib[140] },   //Index 138

      { { OID_SIZEOF(MIB_x25CallParmPriority), MIB_x25CallParmPriority },
	    &MIB_x25CallParmPriorityStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[141],
		&Mib[141] },   //Index 139

      { { OID_SIZEOF(MIB_x25CallParmProtection), MIB_x25CallParmProtection },
	    &MIB_x25CallParmProtectionStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[142],
		&Mib[142] },   //Index 140

      { { OID_SIZEOF(MIB_x25CallParmExcptData), MIB_x25CallParmExcptData },
	    &MIB_x25CallParmExcptDataStor, NULL,
		ASN_INTEGER,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[143],
		&Mib[143] },   //Index 141

      { { OID_SIZEOF(MIB_x25CallParmUserData), MIB_x25CallParmUserData },
	    &MIB_x25CallParmUserDataStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[144],
		&Mib[144] },   //Index 142

      { { OID_SIZEOF(MIB_x25CallParmCallingNetworkFacilities), MIB_x25CallParmCallingNetworkFacilities },
	    &MIB_x25CallParmCallingNetworkFacilitiesStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		&Mib[145],
		&Mib[145] },   //Index 143

      { { OID_SIZEOF(MIB_x25CallParmCalledNetworkFacilities), MIB_x25CallParmCalledNetworkFacilities },
	    &MIB_x25CallParmCalledNetworkFacilitiesStor, NULL,
		ASN_OCTETSTRING,
	    MIB_ACCESS_READ, 
		MIB_leaf_func, 
		NULL,
		NULL },   //Index 144
};

// UINT MIB_num_variables = sizeof Mib / sizeof( MIB_ENTRY );
//
// InitMibTableEntries
//    Initializes the Table Entries in a Mib. 
//
// Notes:
//    
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitMibTableEntries(
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo
	)
{
    UINT    initStatus;


    initStatus = InitAdmnTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
    if (!initStatus)
    { 
        initStatus = InitOperTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
        if (!initStatus)
        { 
			initStatus = InitStatTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
			if (!initStatus)
			{
				// CALL PARM MUST BE INIT'ED BEFORE CIRCUIT
				initStatus = InitCallParmTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
				if (!initStatus)
				{ 
					initStatus = InitCircuitTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
					if (!initStatus)
					{ 
						initStatus = InitChannelTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
						if (!initStatus)
						{ 
							initStatus = InitClearedCircuitTableMibEntries(Mib, pX25SxbIoctlInfo, pSxbPortInfo);
						}
					}
				}
			}
        }
    }

    return initStatus;
}    

//
// InitOperTableMibEntries
//    Initializes the Operational Table Entries in the Mib 
//    The table is initialized by appending columns to the vector
//    of specfic Mib entries. In the initial data structuring stage,
//    The first table entry (port index) links to the second entry.
//    This will be the case when only one port is active. However, when 
//    a second port is added, the second index is chained to the first.
//    subsequently, the second row entry of the FIRST port becomes 
//    the NEXT mib entry of the first port. The table is contructed this way 
//    building and chaining columns (from the registry, initially) until all
//    port specific columns are intialized.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitOperTableMibEntries(
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{
    UINT			initStatus = SNMP_ERRORSTATUS_NOERROR;
	AsnInteger		portNdx;
	PX25_SXB_IOCTL_INFO	pCurX25SxbIoctlInfo = pX25SxbIoctlInfo;
	PSXB_PORT_INFO	pCurSxbPortInfo = pSxbPortInfo;
	int				ioctlNdx;

    // Pointers used to manipulate Mib table as it is built
    MIB_ENTRY FAR * pCurX25OperIndexMibEntry 
		= &Mib[X25_OPER_FIRST_Index];
    
	MIB_ENTRY FAR * pCurX25OperInterfaceModeMibEntry
		= &Mib[X25_OPER_FIRST_InterfaceMode];
    
	MIB_ENTRY FAR * pCurX25OperMaxActiveCircuitsMibEntry
		= &Mib[X25_OPER_FIRST_MaxActiveCircuits];
    
	MIB_ENTRY FAR * pCurX25OperPacketSequencingMibEntry
		= &Mib[X25_OPER_FIRST_PacketSequencing];
    
	MIB_ENTRY FAR * pCurX25OperRestartTimerMibEntry
		= &Mib[X25_OPER_FIRST_RestartTimer];
    
	MIB_ENTRY FAR * pCurX25OperCallTimerMibEntry
		= &Mib[X25_OPER_FIRST_CallTimer];
    
	MIB_ENTRY FAR * pCurX25OperResetTimerMibEntry
		= &Mib[X25_OPER_FIRST_ResetTimer];
    
	MIB_ENTRY FAR * pCurX25OperClearTimerMibEntry
		= &Mib[X25_OPER_FIRST_ClearTimer];
    
	MIB_ENTRY FAR * pCurX25OperWindowTimerMibEntry
		= &Mib[X25_OPER_FIRST_WindowTimer];
    
	MIB_ENTRY FAR * pCurX25OperDataRxmtTimerMibEntry
		= &Mib[X25_OPER_FIRST_DataRxmtTimer];
    
	MIB_ENTRY FAR * pCurX25OperInterruptTimerMibEntry
		= &Mib[X25_OPER_FIRST_InterruptTimer];
    
	MIB_ENTRY FAR * pCurX25OperRejectTimerMibEntry
		= &Mib[X25_OPER_FIRST_RejectTimer];
    
	MIB_ENTRY FAR * pCurX25OperRegistrationRequestTimerMibEntry
		= &Mib[X25_OPER_FIRST_RegistrationRequestTimer];
    
	MIB_ENTRY FAR * pCurX25OperMinimumRecallTimerMibEntry		
		= &Mib[X25_OPER_FIRST_MinimumRecallTimer];

	MIB_ENTRY FAR * pCurX25OperRestartCountMibEntry		
		= &Mib[X25_OPER_FIRST_RestartCount];

	MIB_ENTRY FAR * pCurX25OperResetCountMibEntry		
		= &Mib[X25_OPER_FIRST_ResetCount];

	MIB_ENTRY FAR * pCurX25OperClearCountMibEntry		
		= &Mib[X25_OPER_FIRST_ClearCount];

	MIB_ENTRY FAR * pCurX25OperDataRxmtCountMibEntry
		= &Mib[X25_OPER_FIRST_DataRxmtCount];

	MIB_ENTRY FAR * pCurX25OperRejectCountMibEntry
		= &Mib[X25_OPER_FIRST_RejectCount];

	MIB_ENTRY FAR * pCurX25OperRegistrationRequestCountMibEntry
		= &Mib[X25_OPER_FIRST_RegistrationRequestCount];

	MIB_ENTRY FAR * pCurX25OperNumberPVCsMibEntry
		= &Mib[X25_OPER_FIRST_NumberPVCs];

	MIB_ENTRY FAR * pCurX25OperDefCallParamIdMibEntry
		= &Mib[X25_OPER_FIRST_DefCallParamId];

	MIB_ENTRY FAR * pCurX25OperLocalAddressMibEntry
		= &Mib[X25_OPER_FIRST_LocalAddress];

	MIB_ENTRY FAR * pCurX25OperDataLinkIdMibEntry
		= &Mib[X25_OPER_FIRST_DataLinkId];

	MIB_ENTRY FAR * pCurX25OperProtocolVersionSupportedMibEntry
		= &Mib[X25_OPER_FIRST_ProtocolVersionSupported];

	if ((pCurSxbPortInfo = pSxbPortInfo) == NULL)
	{
		//DebugBreak();
		return 10;
	}

	for (portNdx=1; portNdx <= portCount; portNdx++)
    {
	    {
	    	char buf[256];
			wsprintf( buf, "OperTable: Port %d\n", portNdx );
			OutputDebugString( buf );
	    }
		// Each Port object knows it's first ioctl's address
		if ((pCurX25SxbIoctlInfo = pCurSxbPortInfo->firstPortIoctl) == NULL)
		{
			//DebugBreak();
			return 12;
		}

		// Locate the first circuit ioctl
		for ( ioctlNdx = PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx < PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx++)
		{
			if ((pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo) == NULL)
			{
				//DebugBreak();
				return 11;
			}
		}
		
		//// Initialize the Mib variables with the registry values
		// Initialize the Oper index
		*( (long *) pCurX25OperIndexMibEntry->Storage ) = pCurX25SxbIoctlInfo->PortId;

			pCurX25OperInterfaceModeMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnInterfaceMode ;	

			pCurX25OperMaxActiveCircuitsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnMaxActiveCircuits ;

			pCurX25OperPacketSequencingMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnPacketSequencing;

			pCurX25OperRestartTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRestartTimer;
	
			pCurX25OperCallTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnCallTimer;
	
			pCurX25OperResetTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnResetTimer;
	
			pCurX25OperClearTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnClearTimer;
	
			pCurX25OperWindowTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnWindowTimer;
	
			pCurX25OperDataRxmtTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnDataRxmtTimer;
	
			pCurX25OperInterruptTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnInterruptTimer;
	
			pCurX25OperRejectTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRejectTimer;
	
			pCurX25OperRegistrationRequestTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRegistrationRequestTimer;
	
			pCurX25OperMinimumRecallTimerMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnMinimumRecallTimer;
	
			pCurX25OperRestartCountMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRestartCount;
	
			pCurX25OperResetCountMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnResetCount;
	
			pCurX25OperClearCountMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnClearCount;
	
			pCurX25OperDataRxmtCountMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnDataRxmtCount;
	
			pCurX25OperRejectCountMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRejectCount;
	
			pCurX25OperRegistrationRequestCountMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRegistrationRequestCount;
	
			pCurX25OperNumberPVCsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnNumberPVCs;
	
			pCurX25OperDefCallParamIdMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnDefCallParamId;
	
			pCurX25OperLocalAddressMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnLocalAddress;	
	
			pCurX25OperDataLinkIdMibEntry->pSxbRawData = 
				NULL;	
	
			pCurX25OperProtocolVersionSupportedMibEntry->pSxbRawData = 
				NULL;
		
		// Create a new column for the next port if not the last one.
		// The new column element will chain itself in after the existing
		// one, and will increment the last digit in the oid to reflect the
		// next indexed element in a particular row.
		if (portNdx  < portCount)
		{
			pCurX25OperIndexMibEntry = CreateNextMibColFrom(pCurX25OperIndexMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25OperIndexMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}

			 pCurX25OperInterfaceModeMibEntry = CreateNextMibColFrom( 
													pCurX25OperInterfaceModeMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25OperInterfaceModeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			 pCurX25OperMaxActiveCircuitsMibEntry = CreateNextMibColFrom(
														pCurX25OperMaxActiveCircuitsMibEntry, 
														1, 
														TRUE,
														NULL);
			// Check for successful completion
			if ( pCurX25OperMaxActiveCircuitsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperPacketSequencingMibEntry = CreateNextMibColFrom(
													pCurX25OperPacketSequencingMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25OperPacketSequencingMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperRestartTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperRestartTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperRestartTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperCallTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperCallTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperCallTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperResetTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperResetTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperResetTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperClearTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperClearTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperClearTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}

			pCurX25OperWindowTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperWindowTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperWindowTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperDataRxmtTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperDataRxmtTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperDataRxmtTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperInterruptTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperInterruptTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperInterruptTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperRejectTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperRejectTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperRejectTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperRegistrationRequestTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperRegistrationRequestTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperRegistrationRequestTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperMinimumRecallTimerMibEntry = CreateNextMibColFrom(
												pCurX25OperMinimumRecallTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperMinimumRecallTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperRestartCountMibEntry	= CreateNextMibColFrom(
												pCurX25OperRestartCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperRestartCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperResetCountMibEntry = CreateNextMibColFrom(
												pCurX25OperResetCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperResetCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperClearCountMibEntry = CreateNextMibColFrom(
												pCurX25OperClearCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperClearCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperDataRxmtCountMibEntry = CreateNextMibColFrom(
													pCurX25OperDataRxmtCountMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25OperDataRxmtCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperRejectCountMibEntry = CreateNextMibColFrom(
												pCurX25OperRejectCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperRejectCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperRegistrationRequestCountMibEntry = CreateNextMibColFrom(
															pCurX25OperRegistrationRequestCountMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25OperRegistrationRequestCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperNumberPVCsMibEntry = CreateNextMibColFrom(
												pCurX25OperNumberPVCsMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperNumberPVCsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperDefCallParamIdMibEntry = CreateNextMibColFrom(
													pCurX25OperDefCallParamIdMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25OperDefCallParamIdMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperLocalAddressMibEntry = CreateNextMibColFrom(
												pCurX25OperLocalAddressMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperLocalAddressMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25OperDataLinkIdMibEntry = CreateNextMibColFrom(
												pCurX25OperDataLinkIdMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25OperDataLinkIdMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			
			pCurX25OperProtocolVersionSupportedMibEntry = CreateNextMibColFrom(
															pCurX25OperProtocolVersionSupportedMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25OperProtocolVersionSupportedMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
		} //end_if

		// Locate Next Port
		if ((pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo) == NULL)
		{
#ifdef SNMP_DLL_DEBUG
			OutputDebugString("***E*** X25: Config Circuit MIB table ran out of port structs!\n");
#endif
		}
    } //end_for

    return initStatus;
} // end InitOperTableMibEntries

//
// InitAdmnTableMibEntries
//    Initializes the Administrative Table Entries in the Mib 
//    The table is initialized by appending columns to the vector
//    of specfic Mib entries. In the initial data structuring stage,
//    The first table entry (port index) links to the second entry.
//    This will be the case when only one port is active. However, when 
//    a second port is added, the second index is chained to the first.
//    subsequently, the second row entry of the FIRST port becomes 
//    the NEXT mib entry of the first port. The table is contructed this way 
//    building and chaining columns (from the registry, initially) until all
//    port specific columns are intialized.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitAdmnTableMibEntries(
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{
    UINT			initStatus = SNMP_ERRORSTATUS_NOERROR;
	AsnInteger		portNdx;
	PX25_SXB_IOCTL_INFO	pCurX25SxbIoctlInfo = pX25SxbIoctlInfo;
	PSXB_PORT_INFO	pCurSxbPortInfo = pSxbPortInfo;
	int				ioctlNdx;

    // Pointers used to manipulate Mib table as it is built
    MIB_ENTRY FAR * pCurX25AdmnIndexMibEntry 
		= &Mib[X25_ADMN_FIRST_Index];
    
	MIB_ENTRY FAR * pCurX25AdmnInterfaceModeMibEntry
		= &Mib[X25_ADMN_FIRST_InterfaceMode];
    
	MIB_ENTRY FAR * pCurX25AdmnMaxActiveCircuitsMibEntry
		= &Mib[X25_ADMN_FIRST_MaxActiveCircuits];
    
	MIB_ENTRY FAR * pCurX25AdmnPacketSequencingMibEntry
		= &Mib[X25_ADMN_FIRST_PacketSequencing];
    
	MIB_ENTRY FAR * pCurX25AdmnRestartTimerMibEntry
		= &Mib[X25_ADMN_FIRST_RestartTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnCallTimerMibEntry
		= &Mib[X25_ADMN_FIRST_CallTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnResetTimerMibEntry
		= &Mib[X25_ADMN_FIRST_ResetTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnClearTimerMibEntry
		= &Mib[X25_ADMN_FIRST_ClearTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnWindowTimerMibEntry
		= &Mib[X25_ADMN_FIRST_WindowTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnDataRxmtTimerMibEntry
		= &Mib[X25_ADMN_FIRST_DataRxmtTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnInterruptTimerMibEntry
		= &Mib[X25_ADMN_FIRST_InterruptTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnRejectTimerMibEntry
		= &Mib[X25_ADMN_FIRST_RejectTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnRegistrationRequestTimerMibEntry
		= &Mib[X25_ADMN_FIRST_RegistrationRequestTimer];
    
	MIB_ENTRY FAR * pCurX25AdmnMinimumRecallTimerMibEntry		
		= &Mib[X25_ADMN_FIRST_MinimumRecallTimer];

	MIB_ENTRY FAR * pCurX25AdmnRestartCountMibEntry		
		= &Mib[X25_ADMN_FIRST_RestartCount];

	MIB_ENTRY FAR * pCurX25AdmnResetCountMibEntry		
		= &Mib[X25_ADMN_FIRST_ResetCount];

	MIB_ENTRY FAR * pCurX25AdmnClearCountMibEntry		
		= &Mib[X25_ADMN_FIRST_ClearCount];

	MIB_ENTRY FAR * pCurX25AdmnDataRxmtCountMibEntry
		= &Mib[X25_ADMN_FIRST_DataRxmtCount];

	MIB_ENTRY FAR * pCurX25AdmnRejectCountMibEntry
		= &Mib[X25_ADMN_FIRST_RejectCount];

	MIB_ENTRY FAR * pCurX25AdmnRegistrationRequestCountMibEntry
		= &Mib[X25_ADMN_FIRST_RegistrationRequestCount];

	MIB_ENTRY FAR * pCurX25AdmnNumberPVCsMibEntry
		= &Mib[X25_ADMN_FIRST_NumberPVCs];

	MIB_ENTRY FAR * pCurX25AdmnDefCallParamIdMibEntry
		= &Mib[X25_ADMN_FIRST_DefCallParamId];

	MIB_ENTRY FAR * pCurX25AdmnLocalAddressMibEntry
		= &Mib[X25_ADMN_FIRST_LocalAddress];

	MIB_ENTRY FAR * pCurX25AdmnProtocolVersionSupportedMibEntry
		= &Mib[X25_ADMN_FIRST_ProtocolVersionSupported];

	if ((pCurSxbPortInfo = pSxbPortInfo) == NULL)
	{
		//DebugBreak();
		return 10;
	}

	for (portNdx=1; portNdx <= portCount; portNdx++)
    {
	    {
	    	char buf[256];
			wsprintf( buf, "AdminTable: Port %d, portCount %d\n", portNdx, portCount );
			OutputDebugString( buf );
	    }
		// Each Port object knows it's first ioctl's address
		if ((pCurX25SxbIoctlInfo = pCurSxbPortInfo->firstPortIoctl) == NULL)
		{
			//DebugBreak();
			return 12;
		}

		// Locate the first circuit ioctl
		for ( ioctlNdx = PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx < PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx++)
		{
			if ((pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo) == NULL)
			{
				//DebugBreak();
				return 11;
			}
		}
		
		// Initialize the Object Storage Pointers for raw, and permanent data
		*( (long *) pCurX25AdmnIndexMibEntry->Storage ) = pCurX25SxbIoctlInfo->PortId;

		pCurX25AdmnInterfaceModeMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnInterfaceMode ;	

		pCurX25AdmnMaxActiveCircuitsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnMaxActiveCircuits ;

		pCurX25AdmnPacketSequencingMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnPacketSequencing;

		pCurX25AdmnRestartTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRestartTimer;

		pCurX25AdmnCallTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnCallTimer;

		pCurX25AdmnResetTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnResetTimer;

		pCurX25AdmnClearTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnClearTimer;

		pCurX25AdmnWindowTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnWindowTimer;

		pCurX25AdmnDataRxmtTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnDataRxmtTimer;

		pCurX25AdmnInterruptTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnInterruptTimer;

		pCurX25AdmnRejectTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRejectTimer;

		pCurX25AdmnRegistrationRequestTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRegistrationRequestTimer;

		pCurX25AdmnMinimumRecallTimerMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnMinimumRecallTimer;

		pCurX25AdmnRestartCountMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRestartCount;

		pCurX25AdmnResetCountMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnResetCount;

		pCurX25AdmnClearCountMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnClearCount;

		pCurX25AdmnDataRxmtCountMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnDataRxmtCount;

		pCurX25AdmnRejectCountMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRejectCount;

		pCurX25AdmnRegistrationRequestCountMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnRegistrationRequestCount;

		pCurX25AdmnNumberPVCsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnNumberPVCs;

		pCurX25AdmnDefCallParamIdMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnDefCallParamId;

		pCurX25AdmnLocalAddressMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25AdmnOperData->X25AdmnLocalAddress;	

		pCurX25AdmnProtocolVersionSupportedMibEntry->pSxbRawData = 
			NULL;
		
		// Create a new column for the next port if not the last one.
		// The new column element will chain itself in after the existing
		// one, and will increment the last digit in the oid to reflect the
		// next indexed element in a particular row.
		if (portNdx  < portCount)
		{
			pCurX25AdmnIndexMibEntry = CreateNextMibColFrom(pCurX25AdmnIndexMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25AdmnIndexMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}

			 pCurX25AdmnInterfaceModeMibEntry = CreateNextMibColFrom( 
													pCurX25AdmnInterfaceModeMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25AdmnInterfaceModeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			 pCurX25AdmnMaxActiveCircuitsMibEntry = CreateNextMibColFrom(
														pCurX25AdmnMaxActiveCircuitsMibEntry, 
														1, 
														TRUE,
														NULL);
			// Check for successful completion
			if ( pCurX25AdmnMaxActiveCircuitsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnPacketSequencingMibEntry = CreateNextMibColFrom(
													pCurX25AdmnPacketSequencingMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25AdmnPacketSequencingMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnRestartTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnRestartTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnRestartTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnCallTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnCallTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnCallTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnResetTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnResetTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnResetTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnClearTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnClearTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnClearTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			

			pCurX25AdmnWindowTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnWindowTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnWindowTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnDataRxmtTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnDataRxmtTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnDataRxmtTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnInterruptTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnInterruptTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnInterruptTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnRejectTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnRejectTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnRejectTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnRegistrationRequestTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnRegistrationRequestTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnRegistrationRequestTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnMinimumRecallTimerMibEntry = CreateNextMibColFrom(
												pCurX25AdmnMinimumRecallTimerMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnMinimumRecallTimerMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnRestartCountMibEntry	= CreateNextMibColFrom(
												pCurX25AdmnRestartCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnRestartCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnResetCountMibEntry = CreateNextMibColFrom(
												pCurX25AdmnResetCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnResetCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnClearCountMibEntry = CreateNextMibColFrom(
												pCurX25AdmnClearCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnClearCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnDataRxmtCountMibEntry = CreateNextMibColFrom(
													pCurX25AdmnDataRxmtCountMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25AdmnDataRxmtCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnRejectCountMibEntry = CreateNextMibColFrom(
												pCurX25AdmnRejectCountMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnRejectCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnRegistrationRequestCountMibEntry = CreateNextMibColFrom(
															pCurX25AdmnRegistrationRequestCountMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25AdmnRegistrationRequestCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnNumberPVCsMibEntry = CreateNextMibColFrom(
												pCurX25AdmnNumberPVCsMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnNumberPVCsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnDefCallParamIdMibEntry = CreateNextMibColFrom(
													pCurX25AdmnDefCallParamIdMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25AdmnDefCallParamIdMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnLocalAddressMibEntry = CreateNextMibColFrom(
												pCurX25AdmnLocalAddressMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25AdmnLocalAddressMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25AdmnProtocolVersionSupportedMibEntry = CreateNextMibColFrom(
															pCurX25AdmnProtocolVersionSupportedMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25AdmnProtocolVersionSupportedMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
		} //end_if
    	// Locate Next Port
		if ((pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo) == NULL)
		{
#ifdef SNMP_DLL_DEBUG
			OutputDebugString("***E*** X25: Config Circuit MIB table ran out of port structs!\n");
#endif
		}
    } //end_for

    return initStatus;
} //end InitAdmnTableEntries

//
// InitStatTableMibEntries
//    Initializes the Stat Table Entries in the Mib from the registry 
//    values, or SXB interface.
//    The table is initialized by appending columns to the vector
//    of specfic Mib entries. In the initial data structuring stage,
//    The first table entry (port index) links to the second entry.
//    This will be the case when only one port is active. However, when 
//    a second port is added, the second index is chained to the first.
//    subsequently, the second row entry of the FIRST port becomes 
//    the NEXT mib entry of the first port. The table is contructed this way 
//    building and chaining columns (from the registry, initially) until all
//    port specific columns are intialized.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitStatTableMibEntries(		
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{
    UINT			initStatus = SNMP_ERRORSTATUS_NOERROR;
	AsnInteger		portNdx;
	PX25_SXB_IOCTL_INFO	pCurX25SxbIoctlInfo = pX25SxbIoctlInfo;
	PSXB_PORT_INFO	pCurSxbPortInfo = pSxbPortInfo;
	int				ioctlNdx;

    // Pointers used to manipulate Mib table as it is built
    MIB_ENTRY FAR * pCurX25StatIndexMibEntry 
		= &Mib[X25_STAT_FIRST_Index];
    
	MIB_ENTRY FAR * pCurX25StatInCallsMibEntry 
		= &Mib[X25_STAT_FIRST_InCalls];
    
	MIB_ENTRY FAR * pCurX25StatInCallRefusalsMibEntry 
		= &Mib[X25_STAT_FIRST_InCallRefusals];
    	
	MIB_ENTRY FAR * pCurX25StatProviderInitiatedClearsMibEntry
		= &Mib[X25_STAT_FIRST_ProviderInitiatedClears];
    	
	MIB_ENTRY FAR * pCurX25StatRemotelyInitiatedResetsMibEntry
		= &Mib[X25_STAT_FIRST_RemotelyInitiatedResets];
    	
	MIB_ENTRY FAR * pCurX25StatProviderInitiatedResetsMibEntry
		= &Mib[X25_STAT_FIRST_ProviderInitiatedResets];
    
	MIB_ENTRY FAR * pCurX25StatInRestartsMibEntry
		= &Mib[X25_STAT_FIRST_InRestarts];
    	
	MIB_ENTRY FAR * pCurX25StatInDataPacketsMibEntry
		= &Mib[X25_STAT_FIRST_InDataPackets];
    
	MIB_ENTRY FAR * pCurX25StatInAccusedOfProtocolErrorsMibEntry
		= &Mib[X25_STAT_FIRST_InAccusedOfProtocolErrors];
    	
	MIB_ENTRY FAR * pCurX25StatInInterruptsMibEntry
		= &Mib[X25_STAT_FIRST_InInterrupts];
    	
	MIB_ENTRY FAR * pCurX25StatOutCallAttemptsMibEntry
		= &Mib[X25_STAT_FIRST_OutCallAttempts];
    	
	MIB_ENTRY FAR * pCurX25StatOutCallFailuresMibEntry
		= &Mib[X25_STAT_FIRST_OutCallFailures];
    
	MIB_ENTRY FAR * pCurX25StatOutInterruptsMibEntry
		= &Mib[X25_STAT_FIRST_OutInterrupts];

	MIB_ENTRY FAR * pCurX25StatOutDataPacketsMibEntry
		= &Mib[X25_STAT_FIRST_OutDataPackets];

	MIB_ENTRY FAR * pCurX25StatOutgoingCircuitsMibEntry
		= &Mib[X25_STAT_FIRST_OutgoingCircuits];

	MIB_ENTRY FAR * pCurX25StatIncomingCircuitsMibEntry
		= &Mib[X25_STAT_FIRST_IncomingCircuits];

	MIB_ENTRY FAR * pCurX25StatTwoWayCircuitsMibEntry
		= &Mib[X25_STAT_FIRST_TwoWayCircuits];

	MIB_ENTRY FAR * pCurX25StatRestartTimeoutsMibEntry
		= &Mib[X25_STAT_FIRST_RestartTimeouts];

	MIB_ENTRY FAR * pCurX25StatClearTimeoutsMibEntry
		= &Mib[X25_STAT_FIRST_ClearTimeouts];
	
	MIB_ENTRY FAR * pCurX25StatCallTimeoutsMibEntry
		= &Mib[X25_STAT_FIRST_CallTimeouts];
	
	MIB_ENTRY FAR * pCurX25StatResetTimeoutsMibEntry
		= &Mib[X25_STAT_FIRST_ResetTimeouts];
	
	MIB_ENTRY FAR * pCurX25StatRxmtTimeoutsMibEntry
		= &Mib[X25_STAT_FIRST_RxmtTimeouts];

	MIB_ENTRY FAR * pCurX25StatInterruptTimeoutsMibEntry
		= &Mib[X25_STAT_FIRST_InterruptTimeouts];

	MIB_ENTRY FAR * pCurX25StatRetryCountExceededsMibEntry
		= &Mib[X25_STAT_FIRST_RetryCountExceededs];

	MIB_ENTRY FAR * pCurX25StatClearCountExceededsMibEntry
		= &Mib[X25_STAT_FIRST_ClearCountExceededs];

	for (portNdx=1; portNdx <= portCount; portNdx++)
    {
	    {
	    	char buf[256];
			wsprintf( buf, "StatTable: Port %d\n", portNdx );
			OutputDebugString( buf );
	    }
		// Each Port object knows it's first ioctl's address
		if ((pCurX25SxbIoctlInfo = pCurSxbPortInfo->firstPortIoctl) == NULL)
		{
			//DebugBreak();
			return 12;
		}

		// Locate the first circuit ioctl
		for ( ioctlNdx = PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx < PORT_IOCTL_NDX_STATS; ioctlNdx++)
		{
			if ((pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo) == NULL)
			{
				//DebugBreak();
				return 11;
			}
		}
		
		// Initialize the Object Storage Pointers for raw, and permanent data
		*( (long *) pCurX25StatIndexMibEntry->Storage ) = pCurX25SxbIoctlInfo->PortId;

		pCurX25StatInCallsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInCalls;


		pCurX25StatInCallRefusalsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInCallRefusals;

		pCurX25StatProviderInitiatedClearsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInProviderInitiatedClears;

		pCurX25StatRemotelyInitiatedResetsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInRemotelyInitiatedResets;

		pCurX25StatProviderInitiatedResetsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInProviderInitiatedResets;

		pCurX25StatInRestartsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInRestarts;

		pCurX25StatInDataPacketsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInDataPackets;

		pCurX25StatInAccusedOfProtocolErrorsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInAccusedOfProtocolErrors;

		pCurX25StatInInterruptsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInInterrupts;

		pCurX25StatOutCallAttemptsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatOutCallAttempts ;

		pCurX25StatOutCallFailuresMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatOutCallFailures;

		pCurX25StatOutInterruptsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatOutInterrupts;

		pCurX25StatOutDataPacketsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatOutDataPackets;

		pCurX25StatOutgoingCircuitsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatOutgoingCircuits;

		pCurX25StatIncomingCircuitsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatIncomingCircuits;

		pCurX25StatTwoWayCircuitsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatTwoWayCircuits;

		pCurX25StatRestartTimeoutsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatRestartTimeouts;

		pCurX25StatCallTimeoutsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatCallTimeouts;

		pCurX25StatClearTimeoutsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatClearTimeouts;

		pCurX25StatResetTimeoutsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatResetTimeouts;

		pCurX25StatRxmtTimeoutsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatDataRxmtTimeouts;

		pCurX25StatInterruptTimeoutsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatInterruptTimeouts;

		pCurX25StatRetryCountExceededsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatRetryCountExceeds;

		pCurX25StatClearCountExceededsMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25StatData->X25StatClearCountExceeds;

		// Create a new column for the next port if not the last one.
		// The new column element will chain itself in after the existing
		// one, and will increment the last digit in the oid to reflect the
		// next indexed element in a particular row.
		if (portNdx  < portCount)
		{
			pCurX25StatIndexMibEntry = CreateNextMibColFrom(pCurX25StatIndexMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatIndexMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}

			 pCurX25StatInCallsMibEntry = CreateNextMibColFrom( 
													pCurX25StatInCallsMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25StatInCallsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			 pCurX25StatInCallRefusalsMibEntry = CreateNextMibColFrom(
														pCurX25StatInCallRefusalsMibEntry, 
														1, 
														TRUE,
														NULL);
			// Check for successful completion
			if ( pCurX25StatInCallRefusalsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatProviderInitiatedClearsMibEntry = CreateNextMibColFrom(
													pCurX25StatProviderInitiatedClearsMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25StatProviderInitiatedClearsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatRemotelyInitiatedResetsMibEntry = CreateNextMibColFrom(
												pCurX25StatRemotelyInitiatedResetsMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25StatRemotelyInitiatedResetsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatProviderInitiatedResetsMibEntry = CreateNextMibColFrom(
												pCurX25StatProviderInitiatedResetsMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25StatProviderInitiatedResetsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatInRestartsMibEntry = CreateNextMibColFrom(
													pCurX25StatInRestartsMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25StatInRestartsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatInDataPacketsMibEntry = CreateNextMibColFrom(
												pCurX25StatInDataPacketsMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25StatInDataPacketsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatInAccusedOfProtocolErrorsMibEntry = CreateNextMibColFrom(
															pCurX25StatInAccusedOfProtocolErrorsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatInAccusedOfProtocolErrorsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatInInterruptsMibEntry = CreateNextMibColFrom(
												pCurX25StatInInterruptsMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25StatInInterruptsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatOutCallAttemptsMibEntry = CreateNextMibColFrom(
													pCurX25StatOutCallAttemptsMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25StatOutCallAttemptsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatOutCallFailuresMibEntry = CreateNextMibColFrom(
															pCurX25StatOutCallFailuresMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatOutCallFailuresMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatOutInterruptsMibEntry = CreateNextMibColFrom(
															pCurX25StatOutInterruptsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatOutInterruptsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatOutDataPacketsMibEntry = CreateNextMibColFrom(
															pCurX25StatOutDataPacketsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatOutDataPacketsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatOutgoingCircuitsMibEntry = CreateNextMibColFrom(
															pCurX25StatOutgoingCircuitsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatOutgoingCircuitsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatIncomingCircuitsMibEntry = CreateNextMibColFrom(
															pCurX25StatIncomingCircuitsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatIncomingCircuitsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatTwoWayCircuitsMibEntry = CreateNextMibColFrom(
															pCurX25StatTwoWayCircuitsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatTwoWayCircuitsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatRestartTimeoutsMibEntry = CreateNextMibColFrom(
															pCurX25StatRestartTimeoutsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatRestartTimeoutsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatClearTimeoutsMibEntry = CreateNextMibColFrom(
															pCurX25StatClearTimeoutsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatClearTimeoutsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatResetTimeoutsMibEntry = CreateNextMibColFrom(
															pCurX25StatResetTimeoutsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatResetTimeoutsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatCallTimeoutsMibEntry = CreateNextMibColFrom(
															pCurX25StatCallTimeoutsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatCallTimeoutsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatRxmtTimeoutsMibEntry = CreateNextMibColFrom(
															pCurX25StatRxmtTimeoutsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatRxmtTimeoutsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatInterruptTimeoutsMibEntry = CreateNextMibColFrom(
															pCurX25StatInterruptTimeoutsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatInterruptTimeoutsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatRetryCountExceededsMibEntry = CreateNextMibColFrom(
															pCurX25StatRetryCountExceededsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatRetryCountExceededsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25StatClearCountExceededsMibEntry = CreateNextMibColFrom(
															pCurX25StatClearCountExceededsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25StatClearCountExceededsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
		} //end_if

		// Locate Next Port
		if ((pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo) == NULL)
		{
#ifdef SNMP_DLL_DEBUG
			OutputDebugString("***E*** X25: Config Circuit MIB table ran out of port structs!\n");
#endif
		}
    } //end_for

    return initStatus;
}    

//
// InitChannelTableMibEntries
//    Initializes the ChannelTable Entries in the Mib from the registry 
//    values, or SXB interface.
//    The table is initialized by appending columns to the vector
//    of specfic Mib entries. In the initial data structuring stage,
//    The first table entry (port index) links to the second entry.
//    This will be the case when only one port is active. However, when 
//    a second port is added, the second index is chained to the first.
//    subsequently, the second row entry of the FIRST port becomes 
//    the NEXT mib entry of the first port. The table is contructed this way 
//    building and chaining columns (from the registry, initially) until all
//    port specific columns are intialized.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitChannelTableMibEntries(		
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{
    UINT        initStatus = SNMP_ERRORSTATUS_NOERROR;
	AsnInteger	portNdx;
	PX25_SXB_IOCTL_INFO	pCurX25SxbIoctlInfo = pX25SxbIoctlInfo;
	PSXB_PORT_INFO	pCurSxbPortInfo = pSxbPortInfo;
	int			ioctlNdx;

	// Pointers used to manipulate Mib table as it is built

    MIB_ENTRY FAR * pCurX25ChannelIndexMibEntry 
		= &Mib[X25_CHANNEL_FIRST_Index];
    
	MIB_ENTRY FAR * pCurX25ChannelLICMibEntry 
		= &Mib[X25_CHANNEL_FIRST_LIC];
    
	MIB_ENTRY FAR * pCurX25ChannelHICMibEntry 
		= &Mib[X25_CHANNEL_FIRST_HIC];
    	
	MIB_ENTRY FAR * pCurX25ChannelLTCMibEntry
		= &Mib[X25_CHANNEL_FIRST_LTC];
    	
	MIB_ENTRY FAR * pCurX25ChannelHTCMibEntry
		= &Mib[X25_CHANNEL_FIRST_HTC];
    	
	MIB_ENTRY FAR * pCurX25ChannelLOCMibEntry
		= &Mib[X25_CHANNEL_FIRST_LOC];
    
	MIB_ENTRY FAR * pCurX25ChannelHOCMibEntry
		= &Mib[X25_CHANNEL_FIRST_HOC];
    	
	for (portNdx=1; portNdx <= portCount; portNdx++)
    {

	    {
	    	char buf[256];
			wsprintf( buf, "ChannelTable: Port %d\n", portNdx );
			OutputDebugString( buf );
	    }
		// Each Port object knows it's first ioctl's address
		if ((pCurX25SxbIoctlInfo = pCurSxbPortInfo->firstPortIoctl) == NULL)
		{
			//DebugBreak();
			return 12;
		}

		// Locate the first channel ioctl
		for ( ioctlNdx = PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx < PORT_IOCTL_NDX_CHANNEL; ioctlNdx++)
		{
			if ((pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo) == NULL)
			{
				//DebugBreak();
				return 11;
			}
		}
		
		//// Initialize the Mib variables with the registry values
		*( (long *) pCurX25ChannelIndexMibEntry->Storage ) = pCurX25SxbIoctlInfo->PortId;

		pCurX25ChannelLICMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25ChannelData->X25ChannelLIC;	

		pCurX25ChannelHICMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25ChannelData->X25ChannelHIC;	

		pCurX25ChannelLTCMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25ChannelData->X25ChannelLTC;	

		pCurX25ChannelHTCMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25ChannelData->X25ChannelHTC;	

		pCurX25ChannelLOCMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25ChannelData->X25ChannelLOC;	

		pCurX25ChannelHOCMibEntry->pSxbRawData = 
			&pCurX25SxbIoctlInfo->upData.pX25ChannelData->X25ChannelHOC;	

		// Create a new column for the next port if not the last one.
		// The new column element will chain itself in after the existing
		// one, and will increment the last digit in the oid to reflect the
		// next indexed element in a particular row.
		if (portNdx  < portCount)
		{

			pCurX25ChannelIndexMibEntry = CreateNextMibColFrom(pCurX25ChannelIndexMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25ChannelIndexMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}

			 pCurX25ChannelLICMibEntry = CreateNextMibColFrom( 
													pCurX25ChannelLICMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25ChannelLICMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			 pCurX25ChannelHICMibEntry = CreateNextMibColFrom(
														pCurX25ChannelHICMibEntry, 
														1, 
														TRUE,
														NULL);
			// Check for successful completion
			if ( pCurX25ChannelHICMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25ChannelLTCMibEntry = CreateNextMibColFrom(
													pCurX25ChannelLTCMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if ( pCurX25ChannelLTCMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25ChannelHTCMibEntry = CreateNextMibColFrom(
												pCurX25ChannelHTCMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25ChannelHTCMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25ChannelLOCMibEntry = CreateNextMibColFrom(
												pCurX25ChannelLOCMibEntry, 
												1, 
												TRUE,
												NULL);
			// Check for successful completion
			if (pCurX25ChannelLOCMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			pCurX25ChannelHOCMibEntry = CreateNextMibColFrom(
													pCurX25ChannelHOCMibEntry, 
													1, 
													TRUE,
													NULL);
			// Check for successful completion
			if (pCurX25ChannelHOCMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
		}//end_if
		
    	// Locate Next Port
		if ((pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo) == NULL)
		{
#ifdef SNMP_DLL_DEBUG
			OutputDebugString("***E*** X25: Config Circuit MIB table ran out of port structs!\n");
#endif
		}
	} //end_for

    return initStatus;
} // end init_channel_table   

// InitCircuitTableMibEntries
//    Initializes the Circuit Table Entries in the Mib from the registry 
//    values, or SXB interface.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitCircuitTableMibEntries(
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{
UINT					initStatus = SNMP_ERRORSTATUS_NOERROR;
PX25_SXB_IOCTL_INFO		pCurX25SxbIoctlInfo = pX25SxbIoctlInfo;
PSXB_PORT_INFO			pCurSxbPortInfo = pSxbPortInfo;
AsnInteger				callParamIndex = 1;
AsnObjectIdentifier *	pCallParamOid;
int						ioctlNdx;
int						circuitIndex;
int						totalChannelCount=0;
AsnInteger				portNdx;
int						curChanIndex = 1;
PMIB_CircuitCallBindTable_t	pCurCircuitCallBindTable = pCircuitCallBindTable;

    // Pointers used to manipulate Mib table as it is built
    MIB_ENTRY FAR * pCurX25CircuitIndexMibEntry 
		= &Mib[X25_CIRCUIT_FIRST_Index];
    
    MIB_ENTRY FAR * pCurX25CircuitChannelMibEntry
		= &Mib[X25_CIRCUIT_FIRST_Channel];
    
    MIB_ENTRY FAR * pCurX25CircuitStatusMibEntry
		= &Mib[X25_CIRCUIT_FIRST_Status];
    
    MIB_ENTRY FAR * pCurX25CircuitEstablishTimeMibEntry
		= &Mib[X25_CIRCUIT_FIRST_EstablishTime];
    
    MIB_ENTRY FAR * pCurX25CircuitDirectionMibEntry
		= &Mib[X25_CIRCUIT_FIRST_Direction];
    
    MIB_ENTRY FAR * pCurX25CircuitInOctetsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_InOctets];
    
    MIB_ENTRY FAR * pCurX25CircuitInPdusMibEntry
		= &Mib[X25_CIRCUIT_FIRST_InPdus];
    
    MIB_ENTRY FAR * pCurX25CircuitRemotelyInitiatedResetsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_RemotelyInitiatedResets];
    
    MIB_ENTRY FAR * pCurX25CircuitProviderInitiatedResetsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_ProviderInitiatedResets];
    
    MIB_ENTRY FAR * pCurX25CircuitInInterruptsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_InInterrupts];
  
    MIB_ENTRY FAR * pCurX25CircuitOutOctetsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_OutOctets];
    
    MIB_ENTRY FAR * pCurX25CircuitOutPdusMibEntry
		= &Mib[X25_CIRCUIT_FIRST_OutPdus];
    
    MIB_ENTRY FAR * pCurX25CircuitOutInterruptsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_OutInterrupts];
    
    MIB_ENTRY FAR * pCurX25CircuitDataRetransmissionTimeoutsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_DataRetransmissionTimeouts];
    
    MIB_ENTRY FAR * pCurX25CircuitResetTimeoutsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_ResetTimeouts];
    
    MIB_ENTRY FAR * pCurX25CircuitInterruptTimeoutsMibEntry
		= &Mib[X25_CIRCUIT_FIRST_InterruptTimeouts];
    
    MIB_ENTRY FAR * pCurX25CircuitCallParamIdMibEntry
		= &Mib[X25_CIRCUIT_FIRST_CallParamId];
    
    MIB_ENTRY FAR * pCurX25CircuitCalledDteAddressMibEntry
		= &Mib[X25_CIRCUIT_FIRST_CalledDteAddress];
    
    MIB_ENTRY FAR * pCurX25CircuitCallingDteAddressMibEntry
		= &Mib[X25_CIRCUIT_FIRST_CallingDteAddress];
    
    MIB_ENTRY FAR * pCurX25CircuitOriginallyCalledAddressMibEntry
		= &Mib[X25_CIRCUIT_FIRST_OriginallyCalledAddress];

    MIB_ENTRY FAR * pCurX25CircuitDescrMibEntry
		= &Mib[X25_CIRCUIT_FIRST_CircuitDescr];
    
	// Compute the total number of circuits
	for (portNdx=1; portNdx <= portCount; portNdx++)
	{
		totalChannelCount += pCurSxbPortInfo->ChannelCount;
		pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo;
	}

	if ((pCurSxbPortInfo = pSxbPortInfo) == NULL)
	{
		//DebugBreak();
		return 10;
	}

	for (portNdx=1; portNdx <= portCount; portNdx++)
    {
	    {
	    	char buf[256];
			wsprintf( buf, "CircuitTable: Port %d\n", portNdx );
			OutputDebugString( buf );
	    }
		//Each Port object knows it's first ioctl's address
		if ((pCurX25SxbIoctlInfo = pCurSxbPortInfo->firstPortIoctl) == NULL)
		{
			//DebugBreak();
			return 12;
		}

		// Locate the first circuit ioctl
		for ( ioctlNdx = PORT_IOCTL_NDX_ADMN_OPER; ioctlNdx < PORT_IOCTL_NDX_CIRCUIT; ioctlNdx++)
		{
			if ((pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo) == NULL)
			{
				//DebugBreak();
				return 11;
			}
		}
		
		for (circuitIndex = 0; circuitIndex < pCurSxbPortInfo->ChannelCount; circuitIndex++)
		{
			// Initialize the circuit-call table with circuit values
			pCurCircuitCallBindTable->pCircuitMib	= pCurX25CircuitIndexMibEntry;
			pCurCircuitCallBindTable->Circuit		= pCurX25SxbIoctlInfo->Channel;

			//// Initialize the Mib variables with the registry values
			*( (long *) pCurX25CircuitIndexMibEntry->Storage ) = pX25SxbIoctlInfo->PortId;

			pCurX25CircuitChannelMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitChannel;	

			pCurX25CircuitStatusMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitStatus;	

			pCurX25CircuitEstablishTimeMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitEstablishTime;

			pCurX25CircuitDirectionMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitDirection;

			pCurX25CircuitInOctetsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitInOctets ;

			pCurX25CircuitInPdusMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitInPDUs ;

			pCurX25CircuitRemotelyInitiatedResetsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitRemotelyInitiatedResets ;

			pCurX25CircuitProviderInitiatedResetsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitProviderInitiatedResets ;	

			pCurX25CircuitInInterruptsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitInInterrupts;

			pCurX25CircuitOutOctetsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitOutOctets;

			pCurX25CircuitOutPdusMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitOutPDUs;

			pCurX25CircuitOutInterruptsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitOutInterrupts;

			pCurX25CircuitDataRetransmissionTimeoutsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitDataRxmtTimeouts ;	

			pCurX25CircuitResetTimeoutsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitResetTimeouts;

			pCurX25CircuitInterruptTimeoutsMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitInterruptTimeouts;
			
			// We must increment the Call Param Oid for each circuit after the first one
			pCallParamOid = ((AsnObjectIdentifier *) pCurX25CircuitCallParamIdMibEntry->Storage );
			pCallParamOid->ids[callParamOidLen - 1] = callParamIndex++;
	
			pCurX25CircuitCalledDteAddressMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitCalledDteAddress ;

			pCurX25CircuitCallingDteAddressMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitCallingDteAddress ;

			pCurX25CircuitOriginallyCalledAddressMibEntry->pSxbRawData = 
				&pCurX25SxbIoctlInfo->upData.pX25CircuitData->X25CircuitOriginallyCalledAddress;

			pCurX25CircuitDescrMibEntry->pSxbRawData = 
				NULL ;
    
			// Create a new column for the next port if not the last one.
			// The new column element will chain itself in after the existing
			// one, and will increment the last digit in the oid to reflect the
			// next indexed element in a particular row.
			if (curChanIndex++ <totalChannelCount)
			{
				// The circuit table was built in Call parm init. Advance to next and check
				if ((pCurCircuitCallBindTable = pCurCircuitCallBindTable->pNextCircuitCallBindTable) == NULL)
				{
					//DebugBreak();
					return 24;
				}

				pCurX25CircuitIndexMibEntry = CreateNextMibColFrom(pCurX25CircuitIndexMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitIndexMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitChannelMibEntry = CreateNextMibColFrom(pCurX25CircuitChannelMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitChannelMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitStatusMibEntry = CreateNextMibColFrom(pCurX25CircuitStatusMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitStatusMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitEstablishTimeMibEntry = CreateNextMibColFrom(pCurX25CircuitEstablishTimeMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitEstablishTimeMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitDirectionMibEntry = CreateNextMibColFrom(
																pCurX25CircuitDirectionMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitDirectionMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitInOctetsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitInOctetsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitInOctetsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitInPdusMibEntry = CreateNextMibColFrom(
																pCurX25CircuitInPdusMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitInPdusMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitRemotelyInitiatedResetsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitRemotelyInitiatedResetsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitRemotelyInitiatedResetsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitProviderInitiatedResetsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitProviderInitiatedResetsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitProviderInitiatedResetsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitInInterruptsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitInInterruptsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitInInterruptsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitOutOctetsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitOutOctetsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitOutOctetsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitOutPdusMibEntry = CreateNextMibColFrom(
																pCurX25CircuitOutPdusMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitOutPdusMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitOutInterruptsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitOutInterruptsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitOutInterruptsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitDataRetransmissionTimeoutsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitDataRetransmissionTimeoutsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitDataRetransmissionTimeoutsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitResetTimeoutsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitResetTimeoutsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitResetTimeoutsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitInterruptTimeoutsMibEntry = CreateNextMibColFrom(
																pCurX25CircuitInterruptTimeoutsMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitInterruptTimeoutsMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitCallParamIdMibEntry = CreateNextMibColFrom(
																pCurX25CircuitCallParamIdMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitCallParamIdMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitCalledDteAddressMibEntry = CreateNextMibColFrom(
																pCurX25CircuitCalledDteAddressMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitCalledDteAddressMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitCallingDteAddressMibEntry = CreateNextMibColFrom(
																pCurX25CircuitCallingDteAddressMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitCallingDteAddressMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitOriginallyCalledAddressMibEntry = CreateNextMibColFrom(
																pCurX25CircuitOriginallyCalledAddressMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitOriginallyCalledAddressMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}

				pCurX25CircuitDescrMibEntry = CreateNextMibColFrom(
																pCurX25CircuitDescrMibEntry, 
																1, 
																TRUE,
																NULL);
				// Check for successful completion
				if (pCurX25CircuitDescrMibEntry == NULL)
				{
					initStatus = SNMP_ERRORSTATUS_GENERR;
					break;
				}
			} //end_if
			
			//Locate the next IOCTL structure for this port
			pCurX25SxbIoctlInfo	= pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo;

		} //end_for each circuit

		// Locate Next Port
		if ((pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo) == NULL)
		{
#ifdef SNMP_DLL_DEBUG
			OutputDebugString("***E*** X25: Config Circuit MIB table ran out of port structs!\n");
#endif
		}
    } //end_for each port
    return initStatus;
}

//
// InitClearedCircuitTableMibEntries
//    Initializes the Circuit Table Entries in the Mib from the registry 
//    values, or SXB interface.
//    The table is initialized in the same manner as the dlcmi table.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitClearedCircuitTableMibEntries(
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{

    UINT        initStatus = SNMP_ERRORSTATUS_NOERROR;

	// Pointers to the IOCTL structures used to collect data from the SXB interface
	// First IOCTL gets stats, second in chain gets config data
	//PX25_SXB_IOCTL_INFO	pSxbConfig	= pX25SxbIoctlInfo->pNextX25SxbIoctlInfo;
    
    // Pointers used to manipulate Mib table as it is built
    MIB_ENTRY FAR * pCurX25ClearedChannelIndexMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_Index];

    MIB_ENTRY FAR * pCurX25ClearedChannelPleIndexMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_PleIndex];

    MIB_ENTRY FAR * pCurX25ClearedChannelTimeEstablishedMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_TimeEstablished];

    MIB_ENTRY FAR * pCurX25ClearedChannelTimeClearedMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_TimeCleared];

    MIB_ENTRY FAR * pCurX25ClearedChannelChannelMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_Channel];

    MIB_ENTRY FAR * pCurX25ClearedChannelClearingCauseMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_ClearingCause];

    MIB_ENTRY FAR * pCurX25ClearedChannelDiagnosticCodeMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_DiagnosticCode];

    MIB_ENTRY FAR * pCurX25ClearedChannelInPdusMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_InPdus];

    MIB_ENTRY FAR * pCurX25ClearedChannelOutPdusMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_OutPdus];

    MIB_ENTRY FAR * pCurX25ClearedChannelCalledAddressMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_CalledAddress];

    MIB_ENTRY FAR * pCurX25ClearedChannelCallingAddressMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_CallingAddress];

    MIB_ENTRY FAR * pCurX25ClearedChannelFacilitiesMibEntry
		= &Mib[X25_CLEARED_CIRCUIT_FIRST_Facilities];

    return initStatus;
} // end InitClearedCircuitTableMibEntries

//
// InitCallParmTableMibEntries
//    Initializes the Call Parameter Table Entries in the Mib from the registry 
//    values, or SXB interface.
//    The table is initialized in the same manner as the dlcmi table.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT InitCallParmTableMibEntries(
		IN PMIB_ENTRY pMibBase, 
		IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
		IN PSXB_PORT_INFO pSxbPortInfo )
{
    UINT        initStatus = SNMP_ERRORSTATUS_NOERROR;

AsnInteger					portNdx;
PSXB_PORT_INFO				pCurSxbPortInfo = pSxbPortInfo;
int							totalCircuitCount=0;
int							cktNdx;
PMIB_CircuitCallBindTable_t	pCurCircuitCallBindTable = pCircuitCallBindTable;

	// Pointers to the IOCTL structures used to collect data from the SXB interface
	// First IOCTL gets stats, second in chain gets config data
	//PX25_SXB_IOCTL_INFO	pSxbConfig	= pX25SxbIoctlInfo->pNextX25SxbIoctlInfo;
    
    // Pointers used to manipulate Mib table as it is built
    MIB_ENTRY FAR * pCurX25CallParmIndexMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Index];

    MIB_ENTRY FAR * pCurX25CallParmStatusMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Status];

    MIB_ENTRY FAR * pCurX25CallParmRefCountMibEntry
		= &Mib[X25_CALL_PARM_FIRST_RefCount];

    MIB_ENTRY FAR * pCurX25CallParmInPacketSizeMibEntry
		= &Mib[X25_CALL_PARM_FIRST_InPacketSize];

    MIB_ENTRY FAR * pCurX25CallParmOutPacketSizeMibEntry
		= &Mib[X25_CALL_PARM_FIRST_OutPacketSize];

    MIB_ENTRY FAR * pCurX25CallParmInWindowSizeMibEntry
		= &Mib[X25_CALL_PARM_FIRST_InWindowSize];

    MIB_ENTRY FAR * pCurX25CallParmOutWindowSizeMibEntry
		= &Mib[X25_CALL_PARM_FIRST_OutWindowSize];

    MIB_ENTRY FAR * pCurX25CallParmAcceptReverseChargingMibEntry
		= &Mib[X25_CALL_PARM_FIRST_AcceptReverseCharging];

    MIB_ENTRY FAR * pCurX25CallParmProposeReverseChargingMibEntry
		= &Mib[X25_CALL_PARM_FIRST_ProposeReverseCharging];

    MIB_ENTRY FAR * pCurX25CallParmFastSelectMibEntry
		= &Mib[X25_CALL_PARM_FIRST_FastSelect];
    
	MIB_ENTRY FAR * pCurX25CallParmInThruputClasSizeMibEntry
		= &Mib[X25_CALL_PARM_FIRST_InThruputClasSize];

	MIB_ENTRY FAR * pCurX25CallParmOutThruputClasSizeMibEntry
		= &Mib[X25_CALL_PARM_FIRST_OutThruputClasSize];

    MIB_ENTRY FAR * pCurX25CallParmCugMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Cug];

    MIB_ENTRY FAR * pCurX25CallParmCugoaMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Cugoa];

    MIB_ENTRY FAR * pCurX25CallParmBcugMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Bcug];

    MIB_ENTRY FAR * pCurX25CallParmNuiMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Nui];

    MIB_ENTRY FAR * pCurX25CallParmChargingInfoMibEntry
		= &Mib[X25_CALL_PARM_FIRST_ChargingInfo];

    MIB_ENTRY FAR * pCurX25CallParmRpoaMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Rpoa];

    MIB_ENTRY FAR * pCurX25CallParmTrnstDlyMibEntry
		= &Mib[X25_CALL_PARM_FIRST_TrnstDly];

    MIB_ENTRY FAR * pCurX25CallParmCallingExtMibEntry
		= &Mib[X25_CALL_PARM_FIRST_CallingExt];
    	
	MIB_ENTRY FAR * pCurX25CallParmCalledExtMibEntry
		= &Mib[X25_CALL_PARM_FIRST_CalledExt];

    MIB_ENTRY FAR * pCurX25CallParmInMinThuPutClsMibEntry
		= &Mib[X25_CALL_PARM_FIRST_InMinThuPutCls];

    MIB_ENTRY FAR * pCurX25CallParmOutMinThuPutClsMibEntry
		= &Mib[X25_CALL_PARM_FIRST_OutMinThuPutCls];

    MIB_ENTRY FAR * pCurX25CallParmEndTrnsDlyMibEntry
		= &Mib[X25_CALL_PARM_FIRST_EndTrnsDly];

    MIB_ENTRY FAR * pCurX25CallParmPriorityMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Priority];

    MIB_ENTRY FAR * pCurX25CallParmProtectionMibEntry
		= &Mib[X25_CALL_PARM_FIRST_Protection];

    MIB_ENTRY FAR * pCurX25CallParmExcptDataMibEntry
		= &Mib[X25_CALL_PARM_FIRST_ExcptData];

    MIB_ENTRY FAR * pCurX25CallParmUserDataMibEntry
		= &Mib[X25_CALL_PARM_FIRST_UserData];

    MIB_ENTRY FAR * pCurX25CallParmCallingNetworkFacilitiesMibEntry
		= &Mib[X25_CALL_PARM_FIRST_CallingNetworkFacilities];

    MIB_ENTRY FAR * pCurX25CallParmCalledNetworkFacilitiesMibEntry
		= &Mib[X25_CALL_PARM_FIRST_CalledNetworkFacilities];

	// Make sure that the port info structure is valid
	if ((pCurSxbPortInfo = pSxbPortInfo) == NULL)
	{
		//DebugBreak();
		return 10;
	}

	// Compute the total number of circuits 
	for (portNdx=1; portNdx <= portCount; portNdx++)
	{
		totalCircuitCount += pCurSxbPortInfo->ChannelCount;
		pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo;
	}

	for (cktNdx=1; cktNdx <= totalCircuitCount; cktNdx++)
    {

		//// Fill in the circuit-call binding table's call parm pointer
		pCurCircuitCallBindTable->pCallParmMib				= pCurX25CallParmIndexMibEntry;
		pCurCircuitCallBindTable->pNextCircuitCallBindTable = NULL;
		
		// Create a new column for the next port if not the last one.
		// The new column element will chain itself in after the existing
		// one, and will increment the last digit in the oid to reflect the
		// next indexed element in a particular row.
		if (cktNdx  < totalCircuitCount)
		{

			// Add another circuit-call bind table list entry
			if ((pCurCircuitCallBindTable->pNextCircuitCallBindTable = 
					SNMP_malloc(sizeof(MIB_CircuitCallBindTable_t))) == NULL)
			{
				//DebugBreak();
				return 23;
			}
			pCurCircuitCallBindTable = pCurCircuitCallBindTable->pNextCircuitCallBindTable;
			


			// Chain another column into the Mib
			pCurX25CallParmIndexMibEntry = CreateNextMibColFrom(
															pCurX25CallParmIndexMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmIndexMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}

			pCurX25CallParmStatusMibEntry = CreateNextMibColFrom(
															pCurX25CallParmStatusMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmStatusMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmIndexMibEntry->NextMibColumn = pCurX25CallParmStatusMibEntry;
			}

			pCurX25CallParmRefCountMibEntry= CreateNextMibColFrom(
															pCurX25CallParmRefCountMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmRefCountMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmStatusMibEntry->NextMibColumn = pCurX25CallParmRefCountMibEntry;
			}

			pCurX25CallParmInPacketSizeMibEntry = CreateNextMibColFrom(
															pCurX25CallParmInPacketSizeMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmInPacketSizeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmRefCountMibEntry->NextMibColumn = pCurX25CallParmInPacketSizeMibEntry;
			}

			pCurX25CallParmOutPacketSizeMibEntry= CreateNextMibColFrom(
															pCurX25CallParmOutPacketSizeMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmOutPacketSizeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmInPacketSizeMibEntry->NextMibColumn = pCurX25CallParmOutPacketSizeMibEntry;
			}

			pCurX25CallParmInWindowSizeMibEntry = CreateNextMibColFrom(
															pCurX25CallParmInWindowSizeMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmInWindowSizeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmOutPacketSizeMibEntry->NextMibColumn = pCurX25CallParmInWindowSizeMibEntry;
			}

			pCurX25CallParmOutWindowSizeMibEntry = CreateNextMibColFrom(
															pCurX25CallParmOutWindowSizeMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmOutWindowSizeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmInWindowSizeMibEntry->NextMibColumn = pCurX25CallParmOutWindowSizeMibEntry;
			}

			pCurX25CallParmAcceptReverseChargingMibEntry = CreateNextMibColFrom(
															pCurX25CallParmAcceptReverseChargingMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmAcceptReverseChargingMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmOutWindowSizeMibEntry->NextMibColumn = pCurX25CallParmAcceptReverseChargingMibEntry;
			}

			pCurX25CallParmProposeReverseChargingMibEntry = CreateNextMibColFrom(
															pCurX25CallParmProposeReverseChargingMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmProposeReverseChargingMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmAcceptReverseChargingMibEntry->NextMibColumn = pCurX25CallParmProposeReverseChargingMibEntry;
			}

			 pCurX25CallParmFastSelectMibEntry = CreateNextMibColFrom(
															pCurX25CallParmFastSelectMibEntry, 
															1, 
															TRUE,
															NULL);

			 
			 // Check for successful completion
			if (pCurX25CallParmFastSelectMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmProposeReverseChargingMibEntry->NextMibColumn = pCurX25CallParmFastSelectMibEntry;
			}


			pCurX25CallParmInThruputClasSizeMibEntry = CreateNextMibColFrom(
															pCurX25CallParmInThruputClasSizeMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmInThruputClasSizeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmFastSelectMibEntry->NextMibColumn = pCurX25CallParmInThruputClasSizeMibEntry;
			}

			pCurX25CallParmOutThruputClasSizeMibEntry = CreateNextMibColFrom(
															pCurX25CallParmOutThruputClasSizeMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmOutThruputClasSizeMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmInThruputClasSizeMibEntry->NextMibColumn = pCurX25CallParmOutThruputClasSizeMibEntry;
			}

			pCurX25CallParmCugMibEntry  = CreateNextMibColFrom(
															pCurX25CallParmCugMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmCugMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmOutThruputClasSizeMibEntry->NextMibColumn = pCurX25CallParmCugMibEntry;
			}

			pCurX25CallParmCugoaMibEntry = CreateNextMibColFrom(
															pCurX25CallParmCugoaMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmCugoaMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmCugMibEntry->NextMibColumn = pCurX25CallParmCugoaMibEntry;
			}

			 pCurX25CallParmBcugMibEntry = CreateNextMibColFrom(
															pCurX25CallParmBcugMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmBcugMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmCugoaMibEntry->NextMibColumn = pCurX25CallParmBcugMibEntry;
			}

			pCurX25CallParmNuiMibEntry = CreateNextMibColFrom(
															pCurX25CallParmNuiMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmNuiMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmBcugMibEntry->NextMibColumn = pCurX25CallParmNuiMibEntry;
			}

			pCurX25CallParmChargingInfoMibEntry = CreateNextMibColFrom(
															pCurX25CallParmChargingInfoMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmChargingInfoMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmNuiMibEntry->NextMibColumn = pCurX25CallParmChargingInfoMibEntry;
			}

			pCurX25CallParmRpoaMibEntry = CreateNextMibColFrom(
															pCurX25CallParmRpoaMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmRpoaMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmChargingInfoMibEntry->NextMibColumn = pCurX25CallParmRpoaMibEntry;
			}

			pCurX25CallParmTrnstDlyMibEntry = CreateNextMibColFrom(
															pCurX25CallParmTrnstDlyMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmTrnstDlyMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmRpoaMibEntry->NextMibColumn = pCurX25CallParmTrnstDlyMibEntry;
			}

			pCurX25CallParmCallingExtMibEntry = CreateNextMibColFrom(
															pCurX25CallParmCallingExtMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmCallingExtMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmTrnstDlyMibEntry->NextMibColumn = pCurX25CallParmCallingExtMibEntry;
			}

			pCurX25CallParmCalledExtMibEntry = CreateNextMibColFrom(
															pCurX25CallParmCalledExtMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmCalledExtMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmCallingExtMibEntry->NextMibColumn = pCurX25CallParmCalledExtMibEntry;
			}


			pCurX25CallParmInMinThuPutClsMibEntry = CreateNextMibColFrom(
															pCurX25CallParmInMinThuPutClsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmInMinThuPutClsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmCalledExtMibEntry->NextMibColumn = pCurX25CallParmInMinThuPutClsMibEntry;
			}

			pCurX25CallParmOutMinThuPutClsMibEntry = CreateNextMibColFrom(
															pCurX25CallParmOutMinThuPutClsMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmOutMinThuPutClsMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmInMinThuPutClsMibEntry->NextMibColumn = pCurX25CallParmOutMinThuPutClsMibEntry;
			}

			pCurX25CallParmEndTrnsDlyMibEntry = CreateNextMibColFrom(
															pCurX25CallParmEndTrnsDlyMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmEndTrnsDlyMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmOutMinThuPutClsMibEntry->NextMibColumn = pCurX25CallParmEndTrnsDlyMibEntry;
			}

			pCurX25CallParmPriorityMibEntry = CreateNextMibColFrom(
															pCurX25CallParmPriorityMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmPriorityMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmEndTrnsDlyMibEntry->NextMibColumn = pCurX25CallParmPriorityMibEntry;
			}

			pCurX25CallParmProtectionMibEntry = CreateNextMibColFrom(
															pCurX25CallParmProtectionMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmProtectionMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmPriorityMibEntry->NextMibColumn = pCurX25CallParmProtectionMibEntry;
			}

			pCurX25CallParmExcptDataMibEntry = CreateNextMibColFrom(
															pCurX25CallParmExcptDataMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmExcptDataMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmProtectionMibEntry->NextMibColumn = pCurX25CallParmExcptDataMibEntry;
			}

			pCurX25CallParmUserDataMibEntry = CreateNextMibColFrom(
															pCurX25CallParmUserDataMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmUserDataMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmExcptDataMibEntry->NextMibColumn = pCurX25CallParmUserDataMibEntry;
			}

			pCurX25CallParmCallingNetworkFacilitiesMibEntry = CreateNextMibColFrom(
															pCurX25CallParmCallingNetworkFacilitiesMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmCallingNetworkFacilitiesMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmUserDataMibEntry->NextMibColumn = pCurX25CallParmCallingNetworkFacilitiesMibEntry;
			}

			pCurX25CallParmCalledNetworkFacilitiesMibEntry = CreateNextMibColFrom(
															pCurX25CallParmCalledNetworkFacilitiesMibEntry, 
															1, 
															TRUE,
															NULL);
			// Check for successful completion
			if (pCurX25CallParmCalledNetworkFacilitiesMibEntry == NULL)
			{
				initStatus = SNMP_ERRORSTATUS_GENERR;
				break;
			}
			else
			{
				// Do the column chaining to the last element
				pCurX25CallParmCallingNetworkFacilitiesMibEntry->NextMibColumn = pCurX25CallParmCalledNetworkFacilitiesMibEntry;
			}


		} //end_if
		
    } //end_for
	return initStatus;

} // end InitCallParmTableMibEntries

//
// CreateNextMibColFrom
//    Creates the nest mib column element in a row fraom an existing row
//    MIB element. It will bump the last oid digit to indicate a new column.
//    It will also create the necessary storage as well. If a NULL mib pointer
//    is returned the operation has failed.
//
// Notes:
//    The Adjust Index parameter is included to tell the utility which parameter
//    in a multi-dimensional array must be adjusted. A value of 1 means the last
//    digit. A value of 2 means the nex to last digit, and so on. The insertInChain
//    parameter will insert the new element into the mib structure. This is used when
//    adding a one dimensional column. If a 2 dimensional array is being expanded, the
//    calling routine must manage linkage on a vector by vector basis.
//
// Return Codes:
//    Pointer to a new Mib Element. NULL if failure.
//
// Error Codes:
//    None.
//
PMIB_ENTRY CreateNextMibColFrom(
                MIB_ENTRY FAR * pOldMibEntry, 
                UINT			AdjustIndex,
                BOOL			insertInChain,
				PVOID			pRawData
           )
{
    UINT            createStatus = 0;
    MIB_ENTRY FAR * pNewMibEntry;
    AsnOctetString * pSrcOctetString;
    AsnOctetString * pDstOctetString;
	AsnObjectIdentifier *	pSrcObjectIdentifier;
	AsnObjectIdentifier *	pDstObjectIdentifier;

    // Allocate memory for the new MIB_ENTRY
    pNewMibEntry = SNMP_malloc(sizeof(MIB_ENTRY));
  
    if (pNewMibEntry == NULL)
    {
		//DebugBreak();
	    return NULL;
    }
    
    // Allocate storage for the Oid
    pNewMibEntry->Oid.ids = SNMP_malloc(pOldMibEntry->Oid.idLength);
    if (pNewMibEntry->Oid.ids == NULL)
    {
		//DebugBreak();
	    SNMP_free (pNewMibEntry);
	    return NULL;
    }

    // Copy the oid from old to new, and bump the last digit
    createStatus = SNMP_oidcpy(&(pNewMibEntry->Oid), &(pOldMibEntry->Oid));

    if (createStatus != TRUE)
	{
#ifdef SNMP_DLL_DEBUG
		OutputDebugString("***E*** LAPB: CreateNewColumn Failed on OID Copy!\n");
#endif
		SNMP_free(pNewMibEntry);
		return NULL;
	}

    // Bump the last digit of the Oid up by one
    pNewMibEntry->Oid.ids[pNewMibEntry->Oid.idLength-AdjustIndex] += 1;

    // Copy over the Mib Entry's type field
    pNewMibEntry->Type = pOldMibEntry->Type;

    // Copy over the Mib Entry's access field
    pNewMibEntry->Access = pOldMibEntry->Access;

    // Copy over the Mib Entry's function pointer field
    pNewMibEntry->MibFunc = pOldMibEntry->MibFunc;

    // If required, chain the new column element into the Mib by:
    //   1. Setting New.NextMib = Old.NextMib
    //   2. Setting Old.NextMib = &New
    //
    if (insertInChain == TRUE)
    {
        pNewMibEntry->MibNext = pOldMibEntry->MibNext;
        pOldMibEntry->MibNext = pNewMibEntry;
    }

    // Copy the Oid Storage area from old to new
    switch (pOldMibEntry->Type) {
    
/*
typedef struct {
    UINT   idLength;            // number of integers in oid
    UINT * ids;                 // pointer to integer stream
} AsnObjectIdentifier;

*/
    case ASN_OBJECTIDENTIFIER:
        pSrcObjectIdentifier = (AsnObjectIdentifier *) pOldMibEntry->Storage;
	    pNewMibEntry->Storage = SNMP_malloc(sizeof(AsnObjectIdentifier));
		pDstObjectIdentifier = (AsnObjectIdentifier *) pNewMibEntry->Storage;
        // First figure out how much storage to add;

        pDstObjectIdentifier->idLength = pSrcObjectIdentifier->idLength;

        if (pSrcObjectIdentifier->ids != NULL )
        {
            if ( pSrcObjectIdentifier->idLength != 0 )
            {
                pDstObjectIdentifier->ids = 
                    SNMP_malloc(pSrcObjectIdentifier->idLength * sizeof(UINT));

                memcpy( pDstObjectIdentifier->ids,
	                    pSrcObjectIdentifier->ids,
	                    (pSrcObjectIdentifier->idLength * sizeof(UINT)) );
            }
            else
            {
                pDstObjectIdentifier->ids = NULL;
                pDstObjectIdentifier->idLength = 0;
            }
        }
        else
        {
            pDstObjectIdentifier->ids = NULL;
            pDstObjectIdentifier->idLength = 0;
        }

		break;

    case ASN_OCTETSTRING:
        pSrcOctetString = (AsnOctetString *) pOldMibEntry->Storage;
	    pNewMibEntry->Storage = SNMP_malloc(sizeof(AsnOctetString));
        pDstOctetString = (AsnOctetString *) pNewMibEntry->Storage;

        // First figure out how much storage to add;
        pDstOctetString->length = pSrcOctetString->length;
        if (pSrcOctetString->stream != NULL )
        {
            if ( pSrcOctetString->length != 0 )
            {
                pDstOctetString->length = pSrcOctetString->length;
                pDstOctetString->stream = 
                    SNMP_malloc(pSrcOctetString->length * sizeof(UINT));

                memcpy( pDstOctetString->stream,
	                    pSrcOctetString->stream,
	                    pSrcOctetString->length *sizeof (UINT));
            }
            else
            {
                pDstOctetString->stream = NULL;
                pDstOctetString->length = 0;
            }
        }
        else
        {
            pDstOctetString->stream = NULL;
            pDstOctetString->length = 0;
        }
        pDstOctetString->dynamic = pSrcOctetString->length;
        break;

    case ASN_RFC1155_TIMETICKS:
	case ASN_RFC1155_COUNTER:
    case ASN_RFC1155_GAUGE:
    case ASN_INTEGER:
	    pNewMibEntry->Storage = SNMP_malloc(sizeof(AsnInteger));
	    *( (long *) pNewMibEntry->Storage ) = *( (long *) pOldMibEntry->Storage );
	    break;
    
    default:
		//DebugBreak();
	    createStatus = 0;
    	break;
    }

    if (!createStatus)
    {
	    SNMP_free (pNewMibEntry->Storage);
	    SNMP_oidfree (&(pNewMibEntry->Oid));
	    SNMP_free (pNewMibEntry);
	    pNewMibEntry = NULL;
    }

    return pNewMibEntry;
}    

//
// ResolveVarBind
//    Resolves a single variable binding.  Modifies the variable on a GET
//    or a GET-NEXT.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT ResolveVarBind(
		IN OUT RFC1157VarBind *VarBind, // Variable Binding to resolve
	    IN UINT PduAction               // Action specified in PDU
	 )

{
MIB_ENTRY            *MibPtr;
AsnObjectIdentifier  TempOid;
int                  CompResult;
UINT                 I;
UINT                 nResult;

    // Search for var bind name in the MIB
    I      = 0;
    MibPtr = Mib;
    while ( MibPtr != NULL )
    {
      // Construct OID with complete prefix for comparison purposes
      SNMP_oidcpy( &TempOid, &MIB_OidPrefix );
      SNMP_oidappend( &TempOid, &(MibPtr->Oid) );

      // Check for OID in MIB - On a GET-NEXT the OID does not have to exactly
      // match a variable in the MIB, it must only fall under the MIB root.
      CompResult = SNMP_oidcmp( &VarBind->name, &TempOid );
      if ( CompResult < 0 )
	  {
	     // Since there is not an exact match, the only valid action is GET-NEXT
	     if ( PduAction  != MIB_ACTION_GETNEXT )
	     {
    		nResult = SNMP_ERRORSTATUS_NOSUCHNAME;
	    	goto Exit;
	     }

	     // Since the match was not exact, but var bind name is within MIB,
	     // we are at the NEXT MIB variable down from the one specified.
	     PduAction = MIB_ACTION_GET;
	     
	     // Replace var bind name with new name
	     SNMP_oidfree( &VarBind->name );
	     SNMP_oidcpy( &VarBind->name, &MIB_OidPrefix );
	     SNMP_oidappend( &VarBind->name, &MibPtr->Oid );
	     break;
      }
      else
      {
	    if (CompResult == 0)
	        break;
      }

      // Free OID memory before checking another variable
      SNMP_oidfree( &TempOid );

      MibPtr = MibPtr->MibNext;
   } // while
   // If OID not within scope of MIB, then no such name
   if ( MibPtr == NULL )
   {
      nResult = SNMP_ERRORSTATUS_NOSUCHNAME;
      goto Exit;
   }

   // Call function to process request.  Each MIB entry has a function pointer
   // that knows how to process its MIB variable.
   nResult = (*MibPtr->MibFunc)( PduAction, MibPtr, VarBind );

   // Free temp memory
   SNMP_oidfree( &TempOid );

Exit:
   return nResult;
} // ResolveVarBind

//
// MIB_leaf_func
//    Performs generic actions on LEAF variables in the MIB.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT MIB_leaf_func( IN UINT Action,
					IN MIB_ENTRY *MibPtr,
					IN RFC1157VarBind *VarBind )
{
	UINT   ErrStat;
	
	switch ( Action )
	{
	case MIB_ACTION_GETNEXT:
		// If there is no GET-NEXT pointer, this is the end of this MIB
		if ( MibPtr->MibNext == NULL )
		{
			ErrStat = SNMP_ERRORSTATUS_NOSUCHNAME;
			goto Exit;
		}

		// Setup var bind name of NEXT MIB variable
		SNMP_oidfree( &VarBind->name );
		SNMP_oidcpy( &VarBind->name, &MIB_OidPrefix );
		SNMP_oidappend( &VarBind->name, &MibPtr->MibNext->Oid );

		// Call function to process request.  Each MIB entry has a function
		// pointer that knows how to process its MIB variable.
		ErrStat = (*MibPtr->MibNext->MibFunc)( MIB_ACTION_GET,
						MibPtr->MibNext, VarBind );
		break;

	case MIB_ACTION_GET:
		// Make sure that this variable's ACCESS is GET'able
		if ( MibPtr->Access != MIB_ACCESS_READ &&
			  MibPtr->Access != MIB_ACCESS_READWRITE )
		{
			ErrStat = SNMP_ERRORSTATUS_NOSUCHNAME;
			goto Exit;
		}

		// Setup varbind's return value
		VarBind->value.asnType = MibPtr->Type;
		switch ( VarBind->value.asnType )
		{
		case ASN_RFC1155_TIMETICKS:
		case ASN_RFC1155_COUNTER:
		case ASN_RFC1155_GAUGE:
		case ASN_INTEGER:
			if (MibPtr->pSxbRawData != NULL)
			 {
				 VarBind->value.asnValue.number = *((AsnInteger*)MibPtr->pSxbRawData);
			 }
			 else
			 {
				 VarBind->value.asnValue.number = *(AsnInteger *)(MibPtr->Storage);
			 }
		     break;

		case ASN_OCTETSTRING: // This entails ASN_RFC1213_DISPSTRING also
			VarBind->value.asnValue.string.length =
			strlen( (LPSTR)MibPtr->Storage );

			if ( NULL == 
				(VarBind->value.asnValue.string.stream =
					SNMP_malloc(VarBind->value.asnValue.string.length *
						sizeof(char))) )
			{
				ErrStat = SNMP_ERRORSTATUS_GENERR;
				goto Exit;
			}

			memcpy( VarBind->value.asnValue.string.stream,
					(LPSTR)MibPtr->Storage,
					VarBind->value.asnValue.string.length );
					VarBind->value.asnValue.string.dynamic = TRUE;

			break;

		case ASN_OBJECTIDENTIFIER:
			VarBind->value.asnValue.object.idLength =
				((AsnObjectIdentifier *)MibPtr->Storage)->idLength;

			if ( NULL == 
			    (VarBind->value.asnValue.object.ids =
			    SNMP_malloc(VarBind->value.asnValue.object.idLength *
				   sizeof(UINT))) )
			{
				ErrStat = SNMP_ERRORSTATUS_GENERR;
				goto Exit;
			}

			memcpy( VarBind->value.asnValue.object.ids,
			       (UINT *)(((AsnObjectIdentifier*)MibPtr->Storage)->ids),
			       VarBind->value.asnValue.object.idLength * sizeof(UINT));
			break;

			default:
				ErrStat = SNMP_ERRORSTATUS_GENERR;
				goto Exit;
	       }
	       break;

	case MIB_ACTION_SET:
	// Make sure that this variable's ACCESS is SET'able
#ifdef WRITE_IMPLEMENTED
		if ( MibPtr->Access != MIB_ACCESS_READWRITE &&
    		  MibPtr->Access != MIB_ACCESS_WRITE )
		{
#endif
			ErrStat = SNMP_ERRORSTATUS_NOSUCHNAME;
	        goto Exit;
#ifdef WRITE_IMPLEMENTED
		}

		// Check for proper type before setting
		if ( MibPtr->Type != VarBind->value.asnType )
		{
			ErrStat = SNMP_ERRORSTATUS_BADVALUE;
			goto Exit;
		}
		
		// Save value in MIB
		switch ( VarBind->value.asnType )
		{
		case ASN_RFC1155_COUNTER:
		case ASN_RFC1155_TIMETICKS:
		case ASN_INTEGER:
			*(AsnInteger *)(MibPtr->Storage) = VarBind->value.asnValue.number;
			break;

		default:
			ErrStat = SNMP_ERRORSTATUS_GENERR;
			goto Exit;
		}
		break;

		default:
			ErrStat = SNMP_ERRORSTATUS_GENERR;
			goto Exit;
#endif
	} // switch

	// Signal no error occurred
	ErrStat = SNMP_ERRORSTATUS_NOERROR;

Exit:
	return ErrStat;
} // MIB_leaf_func

//
// MIB_time_leaf_func
//    Performs actions on time driven LEAF variables in the MIB.
//
// Notes:
//
// Return Codes:
//    Standard PDU error codes.
//
// Error Codes:
//    None.
//
UINT MIB_time_leaf_func(
		IN UINT Action,
	    IN MIB_ENTRY *MibPtr,
	    IN RFC1157VarBind *VarBind
	 )
{
	UINT   ErrStat;
	
	switch ( Action )
	{
	case MIB_ACTION_GETNEXT:
		// If there is no GET-NEXT pointer, this is the end of this MIB
		if ( MibPtr->MibNext == NULL )
		{
			ErrStat = SNMP_ERRORSTATUS_NOSUCHNAME;
			goto Exit;
		}

		// Setup var bind name of NEXT MIB variable
		SNMP_oidfree( &VarBind->name );
		SNMP_oidcpy( &VarBind->name, &MIB_OidPrefix );
		SNMP_oidappend( &VarBind->name, &MibPtr->MibNext->Oid );

		// Call function to process request.  Each MIB entry has a function
		// pointer that knows how to process its MIB variable.
		ErrStat = (*MibPtr->MibNext->MibFunc)( MIB_ACTION_GET,
						MibPtr->MibNext, VarBind );
		break;

	case MIB_ACTION_GET:
		// Make sure that this variable's ACCESS is GET'able
		if ( MibPtr->Access != MIB_ACCESS_READ &&
			  MibPtr->Access != MIB_ACCESS_READWRITE )
		{
			ErrStat = SNMP_ERRORSTATUS_NOSUCHNAME;
			goto Exit;
		}

		// Setup varbind's return value
		VarBind->value.asnType = MibPtr->Type;
		switch ( VarBind->value.asnType )
		{
		case ASN_RFC1155_TIMETICKS:
			if (MibPtr->pSxbRawData != NULL)
			 {
				 VarBind->value.asnValue.number = *((AsnInteger*)MibPtr->pSxbRawData);
			 }
			 else
			 {
				 VarBind->value.asnValue.number = *(AsnInteger *)(MibPtr->Storage);
			 }

			 // Add in the time base from SNMP
			 VarBind->value.asnValue.number += dwTimeZero;
		     break;

		default:
			ErrStat = SNMP_ERRORSTATUS_GENERR;
			goto Exit;
		}
		break;

	case MIB_ACTION_SET:
	// Make sure that this variable's ACCESS is SET'able
#ifdef WRITE_IMPLEMENTED
		if ( MibPtr->Access != MIB_ACCESS_READWRITE &&
    		  MibPtr->Access != MIB_ACCESS_WRITE )
		{
#endif
			ErrStat = SNMP_ERRORSTATUS_NOSUCHNAME;
	        goto Exit;
#ifdef WRITE_IMPLEMENTED
		}

		// Check for proper type before setting
		if ( MibPtr->Type != VarBind->value.asnType )
		{
			ErrStat = SNMP_ERRORSTATUS_BADVALUE;
			goto Exit;
		}
		
		// Save value in MIB
		switch ( VarBind->value.asnType )
		{
		case ASN_RFC1155_TIMETICKS:
			*(AsnInteger *)(MibPtr->Storage) = VarBind->value.asnValue.number - dwTimeZero;
			break;

		default:
			ErrStat = SNMP_ERRORSTATUS_GENERR;
			goto Exit;
		}
		break;

		default:
			ErrStat = SNMP_ERRORSTATUS_GENERR;
			goto Exit;
#endif
	} // switch

	// Signal no error occurred
	ErrStat = SNMP_ERRORSTATUS_NOERROR;

Exit:
	return ErrStat;
} // MIB_time_leaf_func


//
// x25_Update_MIB_Data
//    Collects all the data needed to update the MIB structure
//
// Notes:
//      This routine is spawned as a thread from the init routine. It runs
//  off a timer tick in .1 second increments.
//
// Return Codes:
//
// Error Codes:
//
long WINAPI x25_Update_MIB_Data(long pX25SxbIoctlInfo)
{
BOOL					bSuccess;
PX25_SXB_IOCTL_INFO		pBaseX25SxbIoctlInfo = (PX25_SXB_IOCTL_INFO)pX25SxbIoctlInfo;
PX25_SXB_IOCTL_INFO		pCurX25SxbIoctlInfo;
PX_IOCTL				pCurSxbIoctl;
int						ndx=0;
DWORD					returnStatus = 0;
rfc_1382_admn_t *		pX25AdmnOperInfo;	// Pointer to the error statistics area
rfc_1382_stat_t *		pX25StatInfo;		// Pointer to the dlcmi config area
rfc_1382_channel_t *	pX25ChannelInfo;	// Pointer to the circuit config area
rfc_1382_circuit_t *	pX25CircuitInfo;	// Pointer to the circuit config table
CHAR					curDevName[SXB_DEVICE_NAME_SIZE];
BOOL					handleOpen = FALSE;
UINT					retryCount;

	// Open a file handle to each port required
	if (( pCurX25SxbIoctlInfo = pBaseX25SxbIoctlInfo ) == NULL ) {
#ifdef SNMP_DLL_DEBUG
		OutputDebugString("***E*** X25: No input parameter to SXB Data Collector\n");
#endif
		returnStatus = -1;
		goto Exit;
	}

    while (pCurX25SxbIoctlInfo != NULL)
    {
		// APP FILE HANDLE OPEN:
		// Open an application file handle to the SXB driver
		strcpy(curDevName,pCurX25SxbIoctlInfo->DeviceName);

		if( (pCurX25SxbIoctlInfo->hSxbPort = 
                    CreateFile(  pCurX25SxbIoctlInfo->DeviceName,
			                     GENERIC_READ | GENERIC_WRITE,
			                     FILE_SHARE_READ | FILE_SHARE_WRITE,
			                     NULL, OPEN_EXISTING,
			                     FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
			                     NULL )) == INVALID_HANDLE_VALUE )
        {
			returnStatus = GetLastError();
#ifdef SNMP_DLL_DEBUG
			wsprintf(DbgBuf,
					"***E*** X25: Couldn't open file handle to SXB adapter, Error = 0x%x\n",
					returnStatus);
			OutputDebugString(DbgBuf);
#endif
			goto Exit;
        }

		// SXB INTERNAL HANDLE OPEN:
		// First, Open a USER PORT inside SXB for IOCTL use
		bSuccess = FALSE;
		retryCount = 0;
		while (!bSuccess && (retryCount < 5))
		{
			DS_OPEN Open;
			ZeroMemory( &Open, sizeof( Open ) );
			strcpy( (PVOID)&Open.DeviceName, ID_STR_SXB_X25_STATS );
			strcpy(curDevName, pCurX25SxbIoctlInfo->DeviceName);
			bSuccess = DeviceIoControl( pCurX25SxbIoctlInfo->hSxbPort,
										(ULONG)IOCTL_DS_OPEN,
										&Open, sizeof( Open ),
										&Open, sizeof( Open ),
										&(pCurX25SxbIoctlInfo->dwBytesWritten), NULL );

			pCurX25SxbIoctlInfo->VCX25Device = Open.hStream;
			if( !bSuccess || Open.ErrorCode )
			{
				returnStatus = GetLastError();
#ifdef SNMP_DLL_DEBUG
				wsprintf(DbgBuf,
				         "***E*** X.25: IOCTL_S_OPEN failed 0x%x, ErrorCode 0x%x\n",
								returnStatus, Open.ErrorCode);
				OutputDebugString(DbgBuf);
#endif
				retryCount++;
				StrToWStr(  pCurX25SxbIoctlInfo->X25Name,
							ID_STR_SXB_X25_STATS,
							strlen(ID_STR_SXB_X25_STATS) + 1 );
				SleepEx(20,FALSE);
			}
		}

		if (!bSuccess)
			goto Exit;

		// ACCOUNTING FOR several IOCTLs PER X25 PORT
        // You need to init each subsequent IOCTL in each group. It is the same
		// X25 Port handle as the first
		do
		{
			if ((pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo) != NULL)
			{
#ifdef SNMP_DLL_DEBUG
				wsprintf(DbgBuf,
						"Current Port Device Name='%s', Compare Device Name = '%s'\n", 
						curDevName,
						pCurX25SxbIoctlInfo->DeviceName);
				OutputDebugString(DbgBuf);
#endif

				if (strcmp(curDevName,pCurX25SxbIoctlInfo->DeviceName) == 0)
				{
					pCurX25SxbIoctlInfo->hSxbPort = 
						pCurX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo->hSxbPort;
					pCurX25SxbIoctlInfo->VCX25Device =
						pCurX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo->VCX25Device;
				}
			}
			else
			{
				break;
			}
		} while ((pCurX25SxbIoctlInfo != NULL) && 
				(strcmp(curDevName,pCurX25SxbIoctlInfo->DeviceName) == 0));
    } //end_while

    // If the X25 User ports opened okay, start collecting stats
	ndx = 0;
	do
    {
 		pCurX25SxbIoctlInfo = pBaseX25SxbIoctlInfo; 

		while (pCurX25SxbIoctlInfo != 0)
		{
			//
			// Okay, lets send down the requests for stats and config!
			//
			pCurSxbIoctl = &(pCurX25SxbIoctlInfo->XIoctl);
				// Do IOCTL specific init
				switch (pCurX25SxbIoctlInfo->IoctlType) {
				case PORT_IOCTL_NDX_ADMN_OPER:
					pCurSxbIoctl->DsIoctl.Command = RFC_1382_ADMN;
					pCurX25SxbIoctlInfo->upData.pX25AdmnOperData = (PVOID)&(pCurSxbIoctl->Data);
					pCurSxbIoctl->DsIoctl.cbDataIn = pCurSxbIoctl->DsIoctl.cbMaxDataOut = sizeof(rfc_1382_admn_t);
					pX25AdmnOperInfo = (rfc_1382_admn_t *)&pCurSxbIoctl->Data;
					pX25AdmnOperInfo->X25AdmnIndex = pCurX25SxbIoctlInfo->Snid;
					//OutputDebugString("X25: PORT_IOCTL_NDX_ADMN_OPER sent to SXB\n");
					break;

				case PORT_IOCTL_NDX_STATS:
					pCurSxbIoctl->DsIoctl.Command = RFC_1382_STAT;
					pCurX25SxbIoctlInfo->upData.pX25StatData = (PVOID)&(pCurSxbIoctl->Data);
					pCurSxbIoctl->DsIoctl.cbDataIn = pCurSxbIoctl->DsIoctl.cbMaxDataOut = sizeof(rfc_1382_stat_t);
					pX25StatInfo = (rfc_1382_stat_t	*)&pCurSxbIoctl->Data;
					pX25StatInfo->X25StatIndex = pCurX25SxbIoctlInfo->Snid;
					//OutputDebugString("X25: PORT_IOCTL_NDX_STATS sent to SXB\n");
					break;

				case PORT_IOCTL_NDX_CHANNEL:
					pCurSxbIoctl->DsIoctl.Command = RFC_1382_CHANNEL;
					pCurX25SxbIoctlInfo->upData.pX25ChannelData = (PVOID)&(pCurSxbIoctl->Data);
					pCurSxbIoctl->DsIoctl.cbDataIn = pCurSxbIoctl->DsIoctl.cbMaxDataOut = sizeof(rfc_1382_channel_t);
					pX25ChannelInfo = (rfc_1382_channel_t *)&pCurSxbIoctl->Data;
					pX25ChannelInfo->X25ChannelIndex = pCurX25SxbIoctlInfo->Snid;
					//OutputDebugString("X25: PORT_IOCTL_NDX_CHANNEL sent to SXB\n");
					break;

				case PORT_IOCTL_NDX_CIRCUIT:
					pCurSxbIoctl->DsIoctl.Command = RFC_1382_CIRCUIT;
					pCurX25SxbIoctlInfo->upData.pX25CircuitData = (PVOID)&(pCurSxbIoctl->Data);
					pCurSxbIoctl->DsIoctl.cbDataIn = pCurSxbIoctl->DsIoctl.cbMaxDataOut = sizeof(rfc_1382_circuit_t);
					pX25CircuitInfo = (rfc_1382_circuit_t *)&pCurSxbIoctl->Data;
					pX25CircuitInfo->X25CircuitIndex = pCurX25SxbIoctlInfo->Snid;
					pX25CircuitInfo->X25CircuitChannel = pCurX25SxbIoctlInfo->Channel;
					//OutputDebugString("X25: PORT_IOCTL_NDX_CIRCUIT sent to SXB\n");
					break;

				default:
				// The IOCTL list is corrupt, we can't continue to collect data
#ifdef SNMP_DLL_DEBUG
					OutputDebugString("***E*** X25: Built BAD IOCTL type\n");
#endif
					returnStatus = -1;
					break;
				}

				// Do IOCTL independent init
				pCurSxbIoctl->DsIoctl.hStream = pCurX25SxbIoctlInfo->VCX25Device;
				pCurSxbIoctl->DsIoctl.pDataIn = pCurSxbIoctl->DsIoctl.pDataOut = (PVOID)&pCurSxbIoctl->Data;

				// Now that we've built an IOCTL, send it down to SXB
				bSuccess = DeviceIoControl( pCurX25SxbIoctlInfo->hSxbPort,
											(ULONG)IOCTL_DS_IOCTL,
											&pCurSxbIoctl->DsIoctl, sizeof( DS_IOCTL ),
											&pCurSxbIoctl->DsIoctl, sizeof( DS_IOCTL ),
											&(pCurX25SxbIoctlInfo->dwBytesWritten), 
											NULL );
				if( !bSuccess  )
				{
#ifdef SNMP_DLL_DEBUG
					OutputDebugString("***W*** X.25: Failure on USER IOCTL\n");
#endif
					returnStatus = GetLastError();
				}
				else
				{	
					if ( pCurSxbIoctl->DsIoctl.ReturnValue || 
					     pCurSxbIoctl->DsIoctl.ErrorCode )
					{
#ifdef SNMP_DLL_DEBUG
						wsprintf(DbgBuf,"***E*** X.25: IOCTL Failure on RETURN CODE of USER_IOCTL = %x\n",
											pCurSxbIoctl->DsIoctl.ErrorCode );
						OutputDebugString(DbgBuf);
#endif
						returnStatus = pCurSxbIoctl->DsIoctl.ErrorCode * -1;
					}
					else
					{
					}
				}
			// Go to the next IOCTL
			pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo;
		} //end_while
    
		SleepEx(500,FALSE);
	} while ( WaitForSingleObject( terminateEvent, 0) != WAIT_OBJECT_0);

Exit:
	return returnStatus;
}  // end x25_Update_MIB_Data

//
// x25_Terminate_MIB_Data_Collection
//    Collects all the data needed to update the MIB structure
//
// Notes:
//      This routine is spawned as a thread from the init routine. It runs
//  off a timer tick in .1 second increments.
//
// Return Codes:
//
// Error Codes:
//
void x25_Terminate_MIB_Data_Collection(
			IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
			IN PSXB_PORT_INFO pBaseSxbPortInfo)
{
BOOL				bSuccess;
BOOL				firstPassFlag;
PX25_SXB_IOCTL_INFO	pDelX25SxbIoctlInfo;
PX25_SXB_IOCTL_INFO	pBaseX25SxbIoctlInfo = pX25SxbIoctlInfo;
PX25_SXB_IOCTL_INFO	pCurX25SxbIoctlInfo;
HANDLE				hSxbDevice = NULL;       
PSXB_CIRCUIT_INFO	pCircuitInfo;
PSXB_CIRCUIT_INFO	pNextCircuitInfo;
PSXB_PORT_INFO		pCurSxbPortInfo;
PSXB_PORT_INFO		pDelSxbPortInfo;
DWORD				returnStatus = 0;

	// Signal to stop
	SetEvent(terminateEvent); //This will notify the collection threads

	// Wait on the data collector thread to terminate
	returnStatus = WaitForSingleObject(hSxbCollectionThread,1000);
	switch (returnStatus) {
	case WAIT_OBJECT_0:
#ifdef SNMP_DLL_DEBUG
		wsprintf(DbgBuf,"***I*** X25: Wait for data collection terminate completed\n");
		OutputDebugString(DbgBuf);
#endif
		break;
	
	case WAIT_TIMEOUT:
#ifdef SNMP_DLL_DEBUG
		wsprintf(DbgBuf,"***E*** X25: Wait for trace collection terminate timed out\n");
		OutputDebugString(DbgBuf);
#endif
		break;
	
	case WAIT_ABANDONED:
	default:
#ifdef SNMP_DLL_DEBUG
		wsprintf(DbgBuf,
				"***E*** X25: Wait for collection terminate failed, error=%x\n",
				GetLastError()
				);
		OutputDebugString(DbgBuf);
#endif
		break;
	}

	// Shut Down the trace collection thread
	returnStatus = WaitForSingleObject(hSxbTraceCollectionThread,1000);
	switch (returnStatus) {
	case WAIT_OBJECT_0:
#ifdef SNMP_DLL_DEBUG
		wsprintf(DbgBuf,"***I*** X25: Wait for collection terminate completed\n");
		OutputDebugString(DbgBuf);
#endif
		break;
	
	case WAIT_TIMEOUT:
#ifdef SNMP_DLL_DEBUG
		wsprintf(DbgBuf,"***E*** X25: Wait for collection terminate timed out\n");
		OutputDebugString(DbgBuf);
#endif
		break;
	
	case WAIT_ABANDONED:
	default:
#ifdef SNMP_DLL_DEBUG
		wsprintf(DbgBuf,
				"***E*** X25: Wait for collection terminate failed, error=%x\n",
				GetLastError()
				);
		OutputDebugString(DbgBuf);
#endif
		break;
	}
	x25_Terminate_Sxb_Trace_Data_Collection();

	// Open a file handle to each port required
 	if ((pCurX25SxbIoctlInfo = pBaseX25SxbIoctlInfo) == NULL) {
#ifdef SNMP_DLL_DEBUG
	    OutputDebugString("***E*** x25_Terminate_MIB_Data_Collection Failure\n");
#endif
		return;
	}
    
	firstPassFlag = TRUE;
	while (pCurX25SxbIoctlInfo != NULL)
    {
		if (hSxbDevice != pCurX25SxbIoctlInfo->hSxbPort)
		{
			DS_CLOSE Close;
			Close.hStream = pCurX25SxbIoctlInfo->VCX25Device;
			hSxbDevice = pCurX25SxbIoctlInfo->hSxbPort;

			// Close the handle depending on the snid
			bSuccess = DeviceIoControl( hSxbDevice,
										(ULONG)IOCTL_DS_CLOSE,
										&Close, sizeof( Close ),
										&Close, sizeof( Close ),
										&(pCurX25SxbIoctlInfo->dwBytesWritten), NULL );
			if( !bSuccess  )
			{
				returnStatus = GetLastError();
#ifdef SNMP_DLL_DEBUG
				wsprintf(DbgBuf,"***W*** X.25: Failure on IOCTL_S_CLOSE\n= %x\n",
								returnStatus);
				OutputDebugString(DbgBuf);
#endif
				hSxbDevice = NULL;
			}
			else
			{
				CloseHandle( pCurX25SxbIoctlInfo->hSxbPort);
			}
		} // end if
		pCurX25SxbIoctlInfo->hSxbPort = NULL;
		pDelX25SxbIoctlInfo = pCurX25SxbIoctlInfo;
		pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo;

		if (firstPassFlag)
		{
			// Don't free the first SXB Info structure. It was a global var
			firstPassFlag = FALSE;
		}
		else
		{
			// Free the other SXB Info structures. They were allocated
			SNMP_free(pDelX25SxbIoctlInfo);
		}
	} // end while

	// Delete the SxbPortInfo structures
	pCurSxbPortInfo = pBaseSxbPortInfo;
	while (pCurSxbPortInfo != NULL)
	{
		// Delete the circuit tables for each port
		pCircuitInfo = pCurSxbPortInfo->pCircuitList;
		while (pCircuitInfo !=NULL)
		{
			pNextCircuitInfo = pCircuitInfo->pNextSxbCircuitInfo;
			SNMP_free(pCircuitInfo);
			pCircuitInfo = pNextCircuitInfo;
		}

		// Release the port Info structures
		pDelSxbPortInfo = pCurSxbPortInfo;
		pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo;
		SNMP_free (pDelSxbPortInfo);
	}
}  // end x25_Terminate_MIB_Data_Collection


//
// x25_Init_MIB_Data_Structures:
//  Initializes the structures needed to update the MIB structure
//	and collect data from the SXB driver
//
// Notes:
//	The routine will build IOCTls in a linked list structure that will
//	update the Mib variables as required by RFC 1315. At his time, the 
//	SXB firmware structures for config and stats will be required for the 
//	DLCMI and error tables, and the link stats and config structures will
//	be required for the circuit tables
//
// Return Codes:
//
// Error Codes:
//
long x25_Init_MIB_Data_Structures(
			IN PX25_SXB_IOCTL_INFO pX25SxbIoctlInfo,
			IN PSXB_PORT_INFO pSxbPortInfo
		)
{
	PX25_SXB_IOCTL_INFO		pCurX25SxbIoctlInfo;
	PSXB_PORT_INFO		pCurSxbPortInfo;
	BOOL				firstTimeThrough = TRUE;
	PSXB_CIRCUIT_INFO	pCurCircuitList = NULL;
	int					vcNdx;

	if ((pCurX25SxbIoctlInfo = pX25SxbIoctlInfo) == NULL)
	{
		//DebugBreak();
		return -1;
	}

	if ((pCurSxbPortInfo = pSxbPortInfo) == NULL)
	{
		//DebugBreak();
		return -1;
	}

    // Initialize the X25SxbIoctlInfo structures to access the Data Structures
	// The first list item has no previous list item
	pCurX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo = NULL;

	// This is done on a port by port basis. Each SxbPortInfo structure
	// Contains the information for a port. Each port will have Ioctls for
	// Admn/Oper, Stats and Channels. The Call related parms are handled
	// by a trace facility and are not part of the current IOCTL machanism
	while (pCurSxbPortInfo != NULL)
	{
		// Point to the first Ioctl for the port 
		pCurSxbPortInfo->firstPortIoctl = pCurX25SxbIoctlInfo;

		// Build the first one for Admn and Oper
		strcpy(pCurX25SxbIoctlInfo->DeviceName, "\\\\.\\");
		strcat(pCurX25SxbIoctlInfo->DeviceName, pCurSxbPortInfo->DeviceName);
		pCurX25SxbIoctlInfo->IoctlType = PORT_IOCTL_NDX_ADMN_OPER;
		pCurX25SxbIoctlInfo->AdapterId = 0;
		pCurX25SxbIoctlInfo->PortId = 0;
		pCurX25SxbIoctlInfo->Snid = pCurSxbPortInfo->Snid;
		pCurX25SxbIoctlInfo->PortId = pCurSxbPortInfo->WANLinksPortId;
		pCurX25SxbIoctlInfo->upData.pX25AdmnOperData = (PVOID)&(pCurX25SxbIoctlInfo->XIoctl.Data);
		
		//The x25 statistics for the port are identified by REL_PORT_NAME
		StrToWStr(  pCurX25SxbIoctlInfo->X25Name,
					ID_STR_SXB_X25_STATS,
					strlen(ID_STR_SXB_X25_STATS) + 1 );

		// Allocate the second IOCTL for Stats
		pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo = SNMP_malloc(sizeof(struct X25_SXB_IOCTL_INFO));
		if (pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo == NULL )
		{
			//DebugBreak();
			return 4;
		}

		// Go ahead and init the previous pointer for the Stats IOCTL
		pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo = pCurX25SxbIoctlInfo;

		// Build the Stats Ioctl
		pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo;

		pCurX25SxbIoctlInfo->IoctlType = PORT_IOCTL_NDX_STATS;
		strcpy(pCurX25SxbIoctlInfo->DeviceName, "\\\\.\\");
		strcat(pCurX25SxbIoctlInfo->DeviceName, pCurSxbPortInfo->DeviceName);
		pCurX25SxbIoctlInfo->AdapterId = 0;
		pCurX25SxbIoctlInfo->PortId = 0;
		pCurX25SxbIoctlInfo->Snid = pCurSxbPortInfo->Snid;
		pCurX25SxbIoctlInfo->PortId = pCurSxbPortInfo->WANLinksPortId;
		pCurX25SxbIoctlInfo->upData.pX25StatData = (PVOID)&(pCurX25SxbIoctlInfo->XIoctl.Data);
		//The x25 statistics for the port are identified by X25_PORT_NAME
		StrToWStr(  pCurX25SxbIoctlInfo->X25Name,
					ID_STR_SXB_X25_STATS,
					strlen(ID_STR_SXB_X25_STATS) + 1 );

		// Allocate the channel IOCTL
		pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo = SNMP_malloc(sizeof(struct X25_SXB_IOCTL_INFO));
		if (pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo == NULL )
		{
			//DebugBreak();
			return 4;
		}

		// Go ahead and init the previous pointer for the Circuit Stats IOCTL
		pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo = pCurX25SxbIoctlInfo;

		// Build the one for channel info
		pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo;

		pCurX25SxbIoctlInfo->IoctlType = PORT_IOCTL_NDX_CHANNEL;
		strcpy(pCurX25SxbIoctlInfo->DeviceName, "\\\\.\\");
		strcat(pCurX25SxbIoctlInfo->DeviceName, pCurSxbPortInfo->DeviceName);
		pCurX25SxbIoctlInfo->AdapterId = 0;
		pCurX25SxbIoctlInfo->PortId = 0;
		pCurX25SxbIoctlInfo->PortId = pCurSxbPortInfo->WANLinksPortId;
		pCurX25SxbIoctlInfo->Snid = pCurSxbPortInfo->Snid;
		pCurX25SxbIoctlInfo->upData.pX25ChannelData = (PVOID)&(pCurX25SxbIoctlInfo->XIoctl.Data);
		//The x25 statistics for the port are identified by X25_PORT_NAME
		StrToWStr(  pCurX25SxbIoctlInfo->X25Name,
					ID_STR_SXB_X25_STATS,
					strlen(ID_STR_SXB_X25_STATS) + 1 );


		// Work off the Circuit structures required.
		pCurCircuitList = pCurSxbPortInfo->pCircuitList;
		for (vcNdx = 0; vcNdx < pCurSxbPortInfo->ChannelCount; vcNdx++)
		{
			// Allocate the VC circuit IOCTL
			pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo = SNMP_malloc(sizeof(struct X25_SXB_IOCTL_INFO));
			if (pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo == NULL )
			{
				//DebugBreak();
				return 4;
			}

			// Go ahead and init the previous pointer for the Channel IOCTL
			pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo = pCurX25SxbIoctlInfo;

			// Build the one for circuit stats
			pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo;

			pCurX25SxbIoctlInfo->IoctlType = PORT_IOCTL_NDX_CIRCUIT;
			strcpy(pCurX25SxbIoctlInfo->DeviceName, "\\\\.\\");
			strcat(pCurX25SxbIoctlInfo->DeviceName, pCurSxbPortInfo->DeviceName);
			pCurX25SxbIoctlInfo->AdapterId = 0;
			pCurX25SxbIoctlInfo->Channel = pCurCircuitList->Channel;							;
			pCurX25SxbIoctlInfo->PortId = 0;
			pCurX25SxbIoctlInfo->PortId = pCurSxbPortInfo->WANLinksPortId;
			pCurX25SxbIoctlInfo->Snid = pCurSxbPortInfo->Snid;
			pCurX25SxbIoctlInfo->upData.pX25CircuitData = (PVOID)&(pCurX25SxbIoctlInfo->XIoctl.Data);
			//The x25 statistics for the port are identified by X25_PORT_NAME
			StrToWStr(  pCurX25SxbIoctlInfo->X25Name,
						ID_STR_SXB_X25_STATS,
						strlen(ID_STR_SXB_X25_STATS) + 1 );
			// Get the next circuit list identifier 
			pCurCircuitList = pCurCircuitList->pNextSxbCircuitInfo;

		} //end for (circuit list)

		// Advance to the next Port Info Object after the config IOCTL
		pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo;

		if (pCurSxbPortInfo != NULL)
		{
			pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo = SNMP_malloc(sizeof(struct X25_SXB_IOCTL_INFO));
			if (pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo == NULL )
			{
				//DebugBreak();
				return 4;
			}

			// Go ahead and init the previous pointer for the port 2 stats IOCTL
			pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo->pPreviousX25SxbIoctlInfo = pCurX25SxbIoctlInfo;
		}
		else
		{
				pCurX25SxbIoctlInfo->pNextX25SxbIoctlInfo = NULL;
		}

		// Work on the next Stats Ioctl
		pCurX25SxbIoctlInfo = pCurX25SxbIoctlInfo ->pNextX25SxbIoctlInfo; 
	} // end while
	return 0;
} //end x25_Init_MIB_Data_Structures()

//
// x25_Init_Sxb_port_info
//    Initialize the SXB port information from the registry
//
// Notes:
//      The \\HKEY_LOCAL_MACHINE\Sotware\Microsoft\SNMP\Parameters\WanLinksHDLCMIB\
//  key will be used to enumerate adaters and their ports to collect information
//	needed to build the port info structure list. This list is used to build the 
//	MIB and IOCTL list as well.
//
// Return Codes:
//
// Error Codes:
//
long x25_Init_Sxb_Port_Info(
		IN PSXB_PORT_INFO pSxbPortInfo
		)
{
	HKEY				hKeyMib;
	HKEY				hKeyAdapter;
	HKEY				hKeyPort;
    DWORD				retCodeAdapter;
	DWORD				retCodePort;
	DWORD				retCodePortValue;
	CHAR				AdapterKeyName[MAX_PATH];
	CHAR				AdapterKeyPathName[MAX_PATH];
	CHAR				PortKeyName[MAX_PATH];
	CHAR				PortKeyPathName[MAX_PATH];
	UINT				ndx;
	int					i;
	int					j;
	int					k;
	UINT				l;
	BYTE *				pbData;
	DWORD				cbData;
	CHAR				ValueName[MAX_VALUE_NAME];
	DWORD				cbValueName = MAX_VALUE_NAME;
	DWORD				dwType;
	BOOL				firstTimeThrough = TRUE;
	PSXB_PORT_INFO		pCurSxbPortInfo = pSxbPortInfo;
	PSXB_CIRCUIT_INFO   pSxbCircuitInfo = NULL;
	PSXB_CIRCUIT_INFO   pCurSxbCircuitInfo = NULL;
	PSXB_CIRCUIT_INFO   pNextCircuitInfo = NULL;
	CHAR *				pVcStr;
	short				vcVal;
	BOOL				firstCircuit = TRUE;
	CHAR				buildVc[10];
	DWORD				buildNdx;
	DWORD				vcCount;
	BOOL				newStr;
	BOOL				portIsX25 = FALSE;
	int					x25PortCount = 0;
	int					totalPortCount = 0;
	CHAR				WANLinksParamtersPath[MAX_PATH];
	ULONG 				Snid = 0;

	//Build the pathname to the WANLinks SNMP Info
	strcpy(WANLinksParamtersPath, c_pszNTServiceBase);
	strcat(WANLinksParamtersPath,"\\SNMP\\Parameters\\");
	strcat(WANLinksParamtersPath, c_pszSNMP_RS232);

	// Open the key to the LAPB Links SNMP area
	retCodeAdapter = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
							WANLinksParamtersPath,
							0,
							KEY_ENUMERATE_SUB_KEYS |
							KEY_EXECUTE |
							KEY_QUERY_VALUE,
							&hKeyMib);

	if (retCodeAdapter != ERROR_SUCCESS)
	{
		//DebugBreak();
		return -1;
	}

	// Walk the Adapter sub-keys
	for (i=0, retCodeAdapter = ERROR_SUCCESS; retCodeAdapter == ERROR_SUCCESS; i++)
	{
		retCodeAdapter = RegEnumKey (hKeyMib, i, AdapterKeyName, MAX_PATH);
		if (retCodeAdapter == (DWORD)ERROR_SUCCESS)
		{
			// Build the name of the Adapter Key
			strcpy(AdapterKeyPathName, WANLinksParamtersPath);
			strcat(AdapterKeyPathName,"\\");
			strcat(AdapterKeyPathName, AdapterKeyName);

			// Open the key to the Adapter
			retCodeAdapter = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
									AdapterKeyPathName,
									0,
									KEY_ENUMERATE_SUB_KEYS |
									KEY_EXECUTE |
									KEY_QUERY_VALUE,
									&hKeyAdapter);
			
			if (retCodeAdapter != ERROR_SUCCESS)
			{
				//DebugBreak();
				return -1;
			}

			pbData  = SNMP_malloc(MAX_DATA_LEN);
			
			// Walk the Port sub-keys
			for (j=0, retCodePort = ERROR_SUCCESS; retCodePort == ERROR_SUCCESS; j++)
			{
				retCodePort = RegEnumKey (hKeyAdapter, j, PortKeyName, MAX_PATH);
				if (retCodePort == (DWORD)ERROR_SUCCESS)
				{
					// Update the port's found counter
						totalPortCount++;
					
					// Build the name of the Adapter Key
					strcpy(PortKeyPathName, AdapterKeyPathName);
					strcat(PortKeyPathName,"\\");
					strcat(PortKeyPathName, PortKeyName);

					// Open the key to the Adapter
					retCodePort = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
											PortKeyPathName,
											0,
											KEY_ENUMERATE_SUB_KEYS |
											KEY_EXECUTE |
											KEY_QUERY_VALUE,
											&hKeyPort);
					
					if ( retCodePort != ERROR_SUCCESS )
					{
						//DebugBreak();
						return -1;
					}
					
					// The key for the port has opened, determine it's contents
					for (k=0, retCodePortValue=ERROR_SUCCESS; retCodePortValue==ERROR_SUCCESS; k++)
					{
						cbData = MAX_DATA_LEN;
						cbValueName = MAX_DATA_LEN;
		
						retCodePortValue = RegEnumValue ( hKeyPort,		// Key handle returned from RegOpenKeyEx.
														  k,			// Value index, taken from listbox.
														  ValueName,	// Name of value.
														  &cbValueName,	// Size of value name.
														  NULL,			// Reserved, dword = NULL.
														  &dwType,		// Type of data.
														  pbData,		// Data buffer.
														  &cbData);		// Size of data buffer.

						if ( retCodePortValue != ERROR_SUCCESS )
						{
							if (retCodePortValue != ERROR_NO_MORE_ITEMS) 
							{
								//DebugBreak();
								return -1;
							}
						}
						else
						{
							// Determine the type of key and add it into the port structure
							if (strcmp(ValueName, c_pszSNMP_Circuits) == 0)
							{

								// Parse the circuits list and add them in
								//Calculate the number of VC's in the key
								newStr = TRUE; //Keeps from counting NULL strings
			
								
								for (l=0, vcCount=0; l < cbData; l++)
								{
									if (!pbData[l] && !newStr)
									{
										vcCount++;
										newStr = TRUE;
									}
									else
									{
										newStr = FALSE;
									}
								}

								// Gather all the VCs from the registry data
								// Convert them into numbers
								// Add into the VC list
								// Update the circuit count for the port in it's sxb info structure
								firstCircuit = TRUE;
								pVcStr = pbData;
								for (ndx = 0; ndx < vcCount; ndx++)
								{	
									//Look for the next NULL character that delimits UNICODE strings
									buildNdx = 0;
									while ((buildVc[buildNdx++] = *pVcStr++) != '\0')
									{
									}
									vcVal = (short)my_atoi(buildVc);

									// The first circuit in the chain needs to attach 
									// to the  Port Info Structure
									if (firstCircuit)
									{
										if ((pSxbCircuitInfo
											= SNMP_malloc(sizeof(struct SXB_CIRCUIT_INFO))) 
												== NULL)
										{
											//DebugBreak();
											return -1;
										}
										pCurSxbCircuitInfo = pSxbCircuitInfo;
										pCurSxbCircuitInfo->pPreviousSxbCircuitInfo = NULL;
										pCurSxbCircuitInfo->pNextSxbCircuitInfo = NULL;
										firstCircuit = FALSE;
									}
									else
									{
										if ((pCurSxbCircuitInfo->pNextSxbCircuitInfo
											= SNMP_malloc(sizeof(struct SXB_CIRCUIT_INFO))) 
												== NULL)
										{
											//DebugBreak();
											return -1;
										}
										pCurSxbCircuitInfo->pNextSxbCircuitInfo->pPreviousSxbCircuitInfo 
											= pCurSxbCircuitInfo;
										pCurSxbCircuitInfo->pNextSxbCircuitInfo->pNextSxbCircuitInfo
											= NULL;
										pCurSxbCircuitInfo
											= pCurSxbCircuitInfo->pNextSxbCircuitInfo;
									} // end if
									pCurSxbCircuitInfo->Channel = vcVal;
								} //end for
							}

							// Check for protocol identifier registry key
							else if (strcmp(ValueName, c_pszSNMP_ProtocolIdentifier) == 0)
							{
								// Test for X.25
								if (strcmp(pbData, c_pszValueX25Protocol) == 0)
								{
									x25PortCount++;
									portIsX25 = TRUE;
								}
								else //if (strcmp(pbData, c_pszValueFRProtocol) == 0)
								{
									portIsX25 = FALSE;
								}
							}
							else if (strcmp(ValueName, DXB_REGVAL_LINE_SNID) == 0)
							{
								PULONG pSnid = (PVOID)pbData;
								if ( dwType == REG_DWORD && cbData >= sizeof *pSnid )
									Snid = *pSnid;
							}
						} // end if
					} // end for

					//// If this is the first pass, we have a port info structure,
					if (portIsX25)
					{
						//// If not we need to tack a new one on the end of thelist
						if (firstTimeThrough)
						{
							firstTimeThrough = FALSE;
							pCurSxbPortInfo->pPreviousSxbPortInfo = NULL;
							pCurSxbPortInfo->firstPortOnAdapter = TRUE;
						}
						else
						{	
							pCurSxbPortInfo->pNextSxbPortInfo = SNMP_malloc(sizeof(SXB_PORT_INFO));
							pCurSxbPortInfo->pNextSxbPortInfo->pPreviousSxbPortInfo = pCurSxbPortInfo;
							pCurSxbPortInfo = pCurSxbPortInfo->pNextSxbPortInfo;
							pCurSxbPortInfo->pNextSxbPortInfo = NULL;
							pCurSxbPortInfo->firstPortOnAdapter = FALSE;
						}

						// Initialize the Variables in the port info structure
						portIsX25 = FALSE;
						
						// Build the name of the adapter port object for SXB driver IOCTLs
						// It looks like "DigiSxb2A"
						strcpy(pCurSxbPortInfo->DeviceName, AdapterKeyName);
						//strcat(pCurSxbPortInfo->DeviceName, PortKeyName);
						
						pCurSxbPortInfo->Snid = Snid;
						
						//Update the remainder of the SXB Info
						pCurSxbPortInfo->ProtocolId = SXB_PROTOCOL_ID_X25;
						pCurSxbPortInfo->WANLinksPortId = totalPortCount;

						// Add the Sxb Circuit List to the Port Info structure
						pCurSxbPortInfo->ChannelCount = vcCount;
						pCurSxbPortInfo->pCircuitList = pSxbCircuitInfo;
						pCurSxbCircuitInfo = NULL; //The list has been reallocated
						{
							char buf[256];
							wsprintf( buf, "Snid %d, channelCount %d\n", Snid, vcCount );
							OutputDebugString( buf );
						}
					}
					else //Port isn't x.25, so release the circuit list elements
					{
						if (!firstCircuit)
						{
							pCurSxbCircuitInfo = pSxbCircuitInfo;
							while ( pCurSxbCircuitInfo != NULL )
							{
								pNextCircuitInfo = pCurSxbCircuitInfo->pNextSxbCircuitInfo;
								SNMP_free(pCurSxbCircuitInfo);
								pCurSxbCircuitInfo = pNextCircuitInfo;
							}
						}
					}
					
					// Close the Port Key
					RegCloseKey (hKeyPort);   // Close the key handle.
				}
			}

			// Free the memory for the key
			SNMP_free(pbData);
		
			// Close the Adapter Key
			RegCloseKey (hKeyAdapter);   // Close the key handle.
		}
	}

	// We now know the Port Count
	if ((portCount = x25PortCount) == 0)
	{
		return -1;
	}

	{
		char buf[128];
		wsprintf( buf, "X25 PortCount: %d\n", portCount );
		OutputDebugString( buf );
	}
	RegCloseKey (hKeyMib);   // Close the key handle.
	return 0;
}

// Utilities to play games with unicode strings
int StrToWStr( LPWSTR wszDest, LPSTR szSrc, LONG count )
{
   LONG i;

   for( i = 0; i < count; i++ )
   {
      wszDest[i] = szSrc[i];
   }

   return( i-1 );
}

USHORT WstrLength( IN LPWSTR Wstr )   
/*++

Routine Description:

   Determines the number of bytes used by the passed in Wstr

Arguments:

   Wstr - Pointer to wide character string.

Return Value:

   Length, in bytes.
   
--*/
{
   USHORT Length=0;

   while( *Wstr++ )
   {
      Length += sizeof(WCHAR);
   }
   return( Length );
}  // end DigiWstrLength


int my_atoi( const char * SrcString )
/*++

Routine Description:

   Homespun version of atoi, since it's apparently not available in the
   statically linked lib, libcmt.lib.  It is available in the dll version
   libcdll.lib, but that requires us to install msvcrt.dll, yuk.

Arguments:

   SrcString

Return Value:

   Integer conversion of SrcString, base 10.
   
--*/
{
	int Value = 0;
	const char * SrcChar = SrcString;

	while ( *SrcChar )
	{
		if ( *SrcChar < '0' || *SrcChar > '9' )
			return( 0 );

		Value *= 10;
		Value += *SrcChar - '0';
		SrcChar++;
	}
	return( Value );
}
