/*	RawRAS.c - Oid Elements for RawRas
*
*******************************************************************************
* Copyright (c) 1996-97 Digi International Inc., All Rights Reserved          *
*                                                                             *
* This  software  contains  proprietary  and  confidential   information   of *
* Digi International  Inc.   By  accepting  transfer  of this copy, Recipient *
* agrees to retain this software in  confidence,  to  prevent  disclosure  to *
* others,  and  to make no  use of this software other than that for which it *
* was delivered.  This is an unpublished copyright work  Digi   International *
* Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is *
* strictly prohibited.                                                        *
*                                                                             *
* Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc. *
* Confidential  when   combined   with   the   aggregated  modules  for  this *
* product) OBJECT CODE ONLY SOURCE MATERIALS                                  *
*                                                                             *
* (C) COPYRIGHT Digi International Inc. 1996-97                               *
*                                                                             *
* All Rights Reserved                                                         *
*                                                                             *
* US   Government   Users   Restricted   Rights   -   Use,   duplication   or *
* disclosure  restricted by GSA ADP Schedule Contract with Digi International *
* Inc.                                                                        *
*                                                                             *
*******************************************************************************
*
*/

#include "DS_RAS.h"
#include "RawRAS.h"
#include "VarBind.h"
#include "Traps.h"
#include "Topology.h"
#include "dxbtypes.h"
#include "mgmtshim.h"
#include "mgmthlc.h"

/* Helper Functions: */

/* ADAPTER TABLE */

static BOOL SetCacheObject_Adapter(size_t const iOffset, RFC1157VarBind const * const pvb, CacheObject_t * const pco)
{
	pco->iBoard = pvb->name.ids[iOffset + 1];
	return TRUE;
}

static BOOL MaxIndex_Adapter(size_t const iOffset, AsnObjectIdentifier * const poia, size_t const i, UINT * const pcLength)
{
	BOOL fSuccess = FALSE;

	switch (i)
	{
		case 0:		*pcLength = AdapterCount();	break;
		default:	goto Error;					break;
	}

	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL Index_Adapter(IndexFunction_t const eType, size_t const cIndicies, size_t const iOffset, AsnObjectIdentifier * const poia, AsnInteger * const piaErrorStatus)
{
	return Index_Linear(eType, cIndicies, iOffset, poia, piaErrorStatus, MaxIndex_Adapter);
}

static BOOL VarBind_AdapterIndex(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;

	if (eType == ASN_RFC1157_GETREQUEST)
	{
		if (!OidRangeToValue(&pvb->name, iOffset, 1, ASN_INTEGER, &pvb->value))
			goto Error;
	}

	*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
	fSuccess = TRUE;

Error:

	return fSuccess;
}

/* DRIVER TABLE */

static BOOL SetCacheObject_Driver(size_t const iOffset, RFC1157VarBind const * const pvb, CacheObject_t * const pco)
{
	pco->iBoard = pvb->name.ids[iOffset];
	return TRUE;
}

static BOOL MaxIndex_Driver(size_t const iOffset, AsnObjectIdentifier * const poia, size_t const i, UINT * const pcLength)
{
	BOOL fSuccess = FALSE;

	switch (i)
	{
		case 0:		*pcLength = DriverCount(poia->ids[iOffset]);	break;
		case 1:		*pcLength = AdapterCount();						break;
		default:	goto Error;										break;
	}

	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL Index_Driver(IndexFunction_t const eType, size_t const cIndicies, size_t const iOffset, AsnObjectIdentifier * const poia, AsnInteger * const piaErrorStatus)
{
	return Index_Linear(eType, cIndicies, iOffset, poia, piaErrorStatus, MaxIndex_Driver);
}

static BOOL VarBind_DriverAdapter(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;

	if (eType == ASN_RFC1157_GETREQUEST)
	{
		if (!OidRangeToValue(&pvb->name, iOffset, 1, ASN_INTEGER, &pvb->value))
			goto Error;
	}

	*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_DriverIndex(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;

	if (eType == ASN_RFC1157_GETREQUEST)
	{
		if (!OidRangeToValue(&pvb->name, iOffset + 1, 1, ASN_INTEGER, &pvb->value))
			goto Error;
	}

	*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_DriverData(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;
	OID_DATA const * const pod = pvMulti;
	uint32 iBoard = pvb->name.ids[iOffset];
	uint32 iDriver = pvb->name.ids[iOffset + 1];
	CacheObject_t co = { pod->eType, iBoard };
	CacheValue_t cv = pod->cv;

	cv.iOffset += (iDriver * sizeof elementof(mgmt_drv_vers_t, drivers));

	return VarBind_CachedObject(eType, &co, &pod->cv, &pvb->value, piaErrorStatus);
}

/* DS1 TABLE */

static BOOL SetCacheObject_Ds1(size_t const iOffset, RFC1157VarBind const * const pvb, CacheObject_t * const pco)
{
	pco->iBoard = pvb->name.ids[iOffset];
	pco->iGeneric1 = pvb->name.ids[iOffset + 1];

	return TRUE;
}

static BOOL MaxIndex_Ds1(size_t const iOffset, AsnObjectIdentifier * const poia, size_t const i, UINT * const pcLength)
{
	BOOL fSuccess = FALSE;

	switch (i)
	{
		case 0:		*pcLength = AdapterCount();						break;
		case 1:		*pcLength = Ds1Count(poia->ids[iOffset]);		break;
		default:	goto Error;										break;
	}

	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL ValidIndex_Ds1(size_t const iOffset, AsnObjectIdentifier * const poia, BOOL * const pfValid)
{
	size_t cDs1s = Ds1Count(poia->ids[iOffset]);

	*pfValid = (poia->ids[iOffset + 1] <= cDs1s);

	return TRUE;
}

static BOOL Index_Ds1(IndexFunction_t const eType, size_t const cIndicies, size_t const iOffset, AsnObjectIdentifier * const poia, AsnInteger * const piaErrorStatus)
{
	return Index_SparseLinear(eType, cIndicies, iOffset, poia, piaErrorStatus, MaxIndex_Ds1, ValidIndex_Ds1);
}

static BOOL VarBind_Ds1Adapter(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;

	if (eType == ASN_RFC1157_GETREQUEST)
	{
		if (!OidRangeToValue(&pvb->name, iOffset, 1, ASN_INTEGER, &pvb->value))
			goto Error;
	}

	*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_Ds1Port(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;

	if (eType == ASN_RFC1157_GETREQUEST)
	{
		if (!OidRangeToValue(&pvb->name, iOffset + 1, 1, ASN_INTEGER, &pvb->value))
			goto Error;
	}

	*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_Ds1LongHaulLineBuildOut(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;
	size_t const iAdapter = pvb->name.ids[iOffset];
	size_t const iPort = pvb->name.ids[iOffset + 1];
	dxb_uint32 eInterfaceType = GetDs1InterfaceType(iAdapter, iPort);

	switch (eInterfaceType)
	{
		case LONG_HAUL:
		{
			if (!VarBind_GenericData(eType, pvMulti, iOffset, pvb, piaErrorStatus))
				goto Error;

			break;
		}

		default:
		{
			if (eType == ASN_RFC1157_SETREQUEST)
			{
				pvb->value.asnType = ASN_INTEGER;
				pvb->value.asnValue.number = 0;
			}

			*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
			break;
		}
	}

	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_Ds1ShortHaulLength(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;
	size_t const iAdapter = pvb->name.ids[iOffset];
	size_t const iPort = pvb->name.ids[iOffset + 1];
	dxb_uint32 eInterfaceType = GetDs1InterfaceType(iAdapter, iPort);

	switch (eInterfaceType)
	{
		case SHORT_HAUL:
		{
			if (!VarBind_GenericData(eType, pvMulti, iOffset, pvb, piaErrorStatus))
				goto Error;

			break;
		}

		default:
		{
			if (eType == ASN_RFC1157_SETREQUEST)
			{
				pvb->value.asnType = ASN_INTEGER;
				pvb->value.asnValue.number = 0;
			}

			*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
			break;
		}
	}

	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_Ds1WinkDigits(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;

	/* normalize value to ones-based. */
	if (eType == ASN_RFC1157_SETREQUEST)
		pvb->value.asnValue.number++;

	if (!VarBind_GenericData(eType, pvMulti, iOffset, pvb, piaErrorStatus))
		goto Error;

	if (*piaErrorStatus != SNMP_ERRORSTATUS_NOERROR)
		goto Error;

	/* normalize value to zero-based. */
	if (eType == ASN_RFC1157_GETREQUEST)
		pvb->value.asnValue.number--;

	fSuccess = TRUE;

Error:

	return fSuccess;
}

static BOOL VarBind_Ds1Ct1EqualizerGainLimit(BYTE const eType, void const * const pvMulti, size_t const iOffset, RFC1157VarBind * const pvb, AsnInteger * const piaErrorStatus)
{
	BOOL fSuccess = FALSE;
	size_t const iAdapter = pvb->name.ids[iOffset];
	size_t const iPort = pvb->name.ids[iOffset + 1];
	dxb_uint32 eSignalling = GetDs1Signalling(iAdapter, iPort);

	switch (eSignalling)
	{
		/* The CT1 types: */
		case CT1_LOOP_START:
		case CT1_WINK_START:
		case CT1_GROUND_START:
		case CT1_IMMED_START:
		{
			if (!VarBind_GenericData(eType, pvMulti, iOffset, pvb, piaErrorStatus))
				goto Error;

			break;
		}

		default:
		{
			if (eType == ASN_RFC1157_SETREQUEST)
			{
				pvb->value.asnType = ASN_INTEGER;
				pvb->value.asnValue.number = 0;
			}

			*piaErrorStatus = SNMP_ERRORSTATUS_NOERROR;
		}
	}

	fSuccess = TRUE;

Error:

	return fSuccess;
}

/*** MIB TOP ***/

static ASN_OBJECT_ARRAY(RawRAS) { 1, 3, 6, 1, 4, 1, 332, 56 };
static ASN_OBJECT_ID(RawRAS);

static ASN_OBJECT_ARRAY(ShimProtocolVersion) { 1 };
static ASN_OBJECT_ID(ShimProtocolVersion);
static OID_DATA const odShimProtocolVersion =
{
	ACCESS_READONLY,
	SHIM(MGMT_SHIM_VER),
	SetCacheObject_Generic,
	{
		offsetof(get_mgmt_shim_ver_response_t, ver),
		sizeof elementof(get_mgmt_shim_ver_response_t, ver),
		ASN_INTEGER
	}
};

/*** ADAPTER TABLE ***/

static ASN_OBJECT_ARRAY(AdapterIndex) { 1 };
static ASN_OBJECT_ID(AdapterIndex);
static OID_DATA const odAdapterIndex = { ACCESS_READONLY };

static ASN_OBJECT_ARRAY(AdapterId) { 2 };
static ASN_OBJECT_ID(AdapterId);
static OID_DATA const odAdapterId =
{
	ACCESS_READONLY,
	SHIM(MGMT_BOARD_INFO),
	SetCacheObject_Adapter,
	{
		offsetof(mgmt_board_info_t, BrdId),
		sizeof elementof(mgmt_board_info_t, BrdId),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterClass) { 3 };
static ASN_OBJECT_ID(AdapterClass);
static OID_DATA const odAdapterClass =
{
	ACCESS_READONLY,
	SHIM(MGMT_BOARD_INFO),
	SetCacheObject_Adapter,
	{
		offsetof(mgmt_board_info_t, BoardType),
		sizeof elementof(mgmt_board_info_t, BoardType),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterType) { 4 };
static ASN_OBJECT_ID(AdapterType);
static OID_DATA const odAdapterType =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, board_type),
		sizeof elementof(adapter_info_t, board_type),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterConfiguredPortCount) { 5 };
static ASN_OBJECT_ID(AdapterConfiguredPortCount);
static OID_DATA const odAdapterConfiguredPortCount =
{
	ACCESS_READONLY,
	SHIM(MGMT_BOARD_INFO),
	SetCacheObject_Adapter,
	{
		offsetof(mgmt_board_info_t, TotalPorts),
		sizeof elementof(mgmt_board_info_t, TotalPorts),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterConfiguredChannelCount) { 6 };
static ASN_OBJECT_ID(AdapterConfiguredChannelCount);
static OID_DATA const odAdapterConfiguredChannelCount =
{
	ACCESS_READONLY,
	SHIM(MGMT_BOARD_INFO),
	SetCacheObject_Adapter,
	{
		offsetof(mgmt_board_info_t, TotalChannels),
		sizeof elementof(mgmt_board_info_t, TotalChannels),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterProtocolVersion) { 7 };
static ASN_OBJECT_ID(AdapterProtocolVersion);
static OID_DATA const odAdapterProtocolVersion =
{
	ACCESS_READONLY,
	MGMT_PROTOCOL_VERSION,
	SetCacheObject_Generic,
	{
		offsetof(mgmt_protocol_version_t, version),
		sizeof elementof(mgmt_protocol_version_t, version),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterPhysicalPortCount) { 8 };
static ASN_OBJECT_ID(AdapterPhysicalPortCount);
static OID_DATA const odAdapterPhysicalPortCount =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, port_count),
		sizeof elementof(adapter_info_t, port_count),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterPhysicalChannelsPerPort) { 9 };
static ASN_OBJECT_ID(AdapterPhysicalChannelsPerPort);
static OID_DATA const odAdapterPhysicalChannelsPerPort =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, channels_per_port),
		sizeof elementof(adapter_info_t, channels_per_port),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterMemorySize) { 10 };
static ASN_OBJECT_ID(AdapterMemorySize);
static OID_DATA const odAdapterMemorySize =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, memory_size),
		sizeof elementof(adapter_info_t, memory_size),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterFEPVersion) { 11 };
static ASN_OBJECT_ID(AdapterFEPVersion);
static OID_DATA const odAdapterFEPVersion =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, fep_version),
		sizeof elementof(adapter_info_t, fep_version),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterCSCVersion) { 12 };
static ASN_OBJECT_ID(AdapterCSCVersion);
static OID_DATA const odAdapterCSCVersion =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, csc_version),
		sizeof elementof(adapter_info_t, csc_version),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterPumpVersion) { 13 };
static ASN_OBJECT_ID(AdapterPumpVersion);
static OID_DATA const odAdapterPumpVersion =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, pump_version),
		sizeof elementof(adapter_info_t, pump_version),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterMainBoardRevision) { 14 };
static ASN_OBJECT_ID(AdapterMainBoardRevision);
static OID_DATA const odAdapterMainBoardRevision =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, main_board_revision),
		sizeof elementof(adapter_info_t, main_board_revision),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterMainBoardSerialNumber) { 15 };
static ASN_OBJECT_ID(AdapterMainBoardSerialNumber);
static OID_DATA const odAdapterMainBoardSerialNumber =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, main_board_serial),
		sizeof elementof(adapter_info_t, main_board_serial),
		ASN_INTERNAL_DISPSTRING
	}
};

static ASN_OBJECT_ARRAY(AdapterDaughterCardRevision) { 16 };
static ASN_OBJECT_ID(AdapterDaughterCardRevision);
static OID_DATA const odAdapterDaughterCardRevision =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, daughter_card_revision),
		sizeof elementof(adapter_info_t, daughter_card_revision),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterDaughterCardSerialNumber) { 17 };
static ASN_OBJECT_ID(AdapterDaughterCardSerialNumber);
static OID_DATA const odAdapterDaughterCardSerialNumber =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, daughter_card_serial),
		sizeof elementof(adapter_info_t, daughter_card_serial),
		ASN_INTERNAL_DISPSTRING
	}
};

static ASN_OBJECT_ARRAY(AdapterPartNumber) { 18 };
static ASN_OBJECT_ID(AdapterPartNumber);
static OID_DATA const odAdapterPartNumber =
{
	ACCESS_READONLY,
	ADAPTER_INFO,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_info_t, part_number),
		sizeof elementof(adapter_info_t, part_number),
		ASN_INTERNAL_DISPSTRING
	}
};

static ASN_OBJECT_ARRAY(AdapterMemoryUsage) { 19 };
static ASN_OBJECT_ID(AdapterMemoryUsage);
static OID_DATA const odAdapterMemoryUsage =
{
	ACCESS_READONLY,
	ADAPTER_STATE,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_state_t, memory_usage),
		sizeof elementof(adapter_state_t, memory_usage),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterCpuUsage) { 20 };
static ASN_OBJECT_ID(AdapterCpuUsage);
static OID_DATA const odAdapterCpuUsage =
{
	ACCESS_READONLY,
	ADAPTER_STATE,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_state_t, cpu_usage),
		sizeof elementof(adapter_state_t, cpu_usage),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(AdapterHostToAdapterCount) { 21 };
static ASN_OBJECT_ID(AdapterHostToAdapterCount);
static OID_DATA const odAdapterHostToAdapterCount =
{
	ACCESS_READONLY,
	ADAPTER_STATE,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_state_t, dxb_h2a_count),
		sizeof elementof(adapter_state_t, dxb_h2a_count),
		ASN_RFC1155_COUNTER
	}
};

static ASN_OBJECT_ARRAY(AdapterAdapterToHostCount) { 22 };
static ASN_OBJECT_ID(AdapterAdapterToHostCount);
static OID_DATA const odAdapterAdapterToHostCount =
{
	ACCESS_READONLY,
	ADAPTER_STATE,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_state_t, dxb_a2h_count),
		sizeof elementof(adapter_state_t, dxb_a2h_count),
		ASN_RFC1155_COUNTER
	}
};

static ASN_OBJECT_ARRAY(AdapterUptimeSeconds) { 23 };
static ASN_OBJECT_ID(AdapterUptimeSeconds);
static OID_DATA const odAdapterUptimeSeconds =
{
	ACCESS_READONLY,
	ADAPTER_STATE,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_state_t, uptime.seconds),
		sizeof elementof(adapter_state_t, uptime.seconds),
		ASN_RFC1155_COUNTER
	}
};

static ASN_OBJECT_ARRAY(AdapterUptimeMilliseconds) { 24 };
static ASN_OBJECT_ID(AdapterUptimeMilliseconds);
static OID_DATA const odAdapterUptimeMilliseconds =
{
	ACCESS_READONLY,
	ADAPTER_STATE,
	SetCacheObject_Adapter,
	{
		offsetof(adapter_state_t, uptime.mseconds),
		sizeof elementof(adapter_state_t, uptime.mseconds),
		ASN_RFC1155_COUNTER
	}
};

static ASN_OBJECT_ARRAY(AdapterModemNationality) { 25 };
static ASN_OBJECT_ID(AdapterModemNationality);
static OID_DATA const odAdapterModemNationality =
{
	ACCESS_READWRITE,
	MODEM_NATIONALITY,
	SetCacheObject_Adapter,
	{
		offsetof(modem_nationality_t, country_code),
		sizeof elementof(modem_nationality_t, country_code),
		ASN_INTEGER
	}
};

static OID_MAP_ENTRY const aomeAdapterTable[] =
{
	{ &ASN_OBJECT_ID_VAR(AdapterIndex),						{	Object_Data,	&odAdapterIndex						},	VarBind_AdapterIndex	},
	{ &ASN_OBJECT_ID_VAR(AdapterId),						{	Object_Data,	&odAdapterId						},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterClass),						{	Object_Data,	&odAdapterClass						},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterType),						{	Object_Data,	&odAdapterType						},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterConfiguredPortCount),		{	Object_Data,	&odAdapterConfiguredPortCount		},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterConfiguredChannelCount),	{	Object_Data,	&odAdapterConfiguredChannelCount	},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterProtocolVersion),			{	Object_Data,	&odAdapterProtocolVersion			},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterPhysicalPortCount),			{	Object_Data,	&odAdapterPhysicalPortCount			},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterPhysicalChannelsPerPort),	{	Object_Data,	&odAdapterPhysicalChannelsPerPort	},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterMemorySize),				{	Object_Data,	&odAdapterMemorySize				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterFEPVersion),				{	Object_Data,	&odAdapterFEPVersion				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterCSCVersion),				{	Object_Data,	&odAdapterCSCVersion				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterPumpVersion),				{	Object_Data,	&odAdapterPumpVersion				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterMainBoardRevision),			{	Object_Data,	&odAdapterMainBoardRevision			},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterMainBoardSerialNumber),		{	Object_Data,	&odAdapterMainBoardSerialNumber		},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterDaughterCardRevision),		{	Object_Data,	&odAdapterDaughterCardRevision		},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterDaughterCardSerialNumber),	{	Object_Data,	&odAdapterDaughterCardSerialNumber	},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterPartNumber),				{	Object_Data,	&odAdapterPartNumber				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterMemoryUsage),				{	Object_Data,	&odAdapterMemoryUsage				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterCpuUsage),					{	Object_Data,	&odAdapterCpuUsage					},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterHostToAdapterCount),		{	Object_Data,	&odAdapterHostToAdapterCount		},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterAdapterToHostCount),		{	Object_Data,	&odAdapterAdapterToHostCount		},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterUptimeSeconds),				{	Object_Data,	&odAdapterUptimeSeconds				},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterUptimeMilliseconds),		{	Object_Data,	&odAdapterUptimeMilliseconds		},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterModemNationality),			{	Object_Data,	&odAdapterModemNationality			},	VarBind_GenericData		}
};

static ASN_OBJECT_ARRAY(AdapterTable) { 2, 1 };
static ASN_OBJECT_ID(AdapterTable);
static OID_TABLE const otAdapterTable =
{
	1,
	Index_Adapter,
	{ ElementCount(aomeAdapterTable), aomeAdapterTable }
};

/*** DRIVER TABLE ***/

static ASN_OBJECT_ARRAY(DriverAdapter) { 1 };
static ASN_OBJECT_ID(DriverAdapter);
static OID_DATA const odDriverAdapter = { ACCESS_READONLY };

static ASN_OBJECT_ARRAY(DriverIndex) { 2 };
static ASN_OBJECT_ID(DriverIndex);
static OID_DATA const odDriverIndex = { ACCESS_READONLY };

static ASN_OBJECT_ARRAY(DriverType) { 3 };
static ASN_OBJECT_ID(DriverType);
static OID_DATA const odDriverType =
{
	ACCESS_READONLY,
	SHIM(MGMT_DRV_VERS),
	SetCacheObject_Driver,
	{
		offsetof(mgmt_drv_vers_t, drivers[0].type),
		sizeof elementof(mgmt_drv_vers_t, drivers[0].type),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(DriverName) { 4 };
static ASN_OBJECT_ID(DriverName);
static OID_DATA const odDriverName =
{
	ACCESS_READONLY,
	SHIM(MGMT_DRV_VERS),
	SetCacheObject_Driver,
	{
		offsetof(mgmt_drv_vers_t, drivers[0].name),
		sizeof elementof(mgmt_drv_vers_t, drivers[0].name),
		ASN_INTERNAL_DISPSTRING
	}
};

static ASN_OBJECT_ARRAY(DriverVersion) { 5 };
static ASN_OBJECT_ID(DriverVersion);
static OID_DATA const odDriverVersion =
{
	ACCESS_READONLY,
	SHIM(MGMT_DRV_VERS),
	SetCacheObject_Driver,
	{
		offsetof(mgmt_drv_vers_t, drivers[0].version),
		sizeof elementof(mgmt_drv_vers_t, drivers[0].version),
		ASN_INTERNAL_DISPSTRING
	}
};

static OID_MAP_ENTRY const aomeDriverTable[] =
{
	{ &ASN_OBJECT_ID_VAR(DriverAdapter),	{	Object_Data,	&odDriverAdapter	},	VarBind_DriverAdapter	},
	{ &ASN_OBJECT_ID_VAR(DriverIndex),		{	Object_Data,	&odDriverIndex		},	VarBind_DriverIndex		},
	{ &ASN_OBJECT_ID_VAR(DriverType),		{	Object_Data,	&odDriverType		},	VarBind_DriverData		},
	{ &ASN_OBJECT_ID_VAR(DriverName),		{	Object_Data,	&odDriverName		},	VarBind_DriverData		},
	{ &ASN_OBJECT_ID_VAR(DriverVersion),	{	Object_Data,	&odDriverVersion	},	VarBind_DriverData		}
};

static ASN_OBJECT_ARRAY(DriverTable) { 3, 1 };
static ASN_OBJECT_ID(DriverTable);
static OID_TABLE const otDriverTable = 
{
	2,
	Index_Driver,
	{ ElementCount(aomeDriverTable), aomeDriverTable }
};

/*** DS1 TABLE ***/

static ASN_OBJECT_ARRAY(Ds1Adapter) { 1 };
static ASN_OBJECT_ID(Ds1Adapter);
static OID_DATA const odDs1Adapter = { ACCESS_READONLY };

static ASN_OBJECT_ARRAY(Ds1Port) { 2 };
static ASN_OBJECT_ID(Ds1Port);
static OID_DATA const odDs1Port = { ACCESS_READONLY };

static ASN_OBJECT_ARRAY(Ds1Coding) { 3 };
static ASN_OBJECT_ID(Ds1Coding);
static OID_DATA const odDs1Coding =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, coding),
		sizeof elementof(ds1_config_t, coding),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1Framing) { 4 };
static ASN_OBJECT_ID(Ds1Framing);
static OID_DATA const odDs1Framing =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, framing),
		sizeof elementof(ds1_config_t, framing),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1Interface) { 5 };
static ASN_OBJECT_ID(Ds1Interface);
static OID_DATA const odDs1Interface =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, if_type),
		sizeof elementof(ds1_config_t, if_type),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1LongHaulLineBuildOut) { 6 };
static ASN_OBJECT_ID(Ds1LongHaulLineBuildOut);
static OID_DATA const odDs1LongHaulLineBuildOut =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, long_haul_lbo),
		sizeof elementof(ds1_config_t, long_haul_lbo),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1ShortHaulLength) { 7 };
static ASN_OBJECT_ID(Ds1ShortHaulLength);
static OID_DATA const odDs1ShortHaulLength =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, short_haul_len),
		sizeof elementof(ds1_config_t, short_haul_len),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1Signalling) { 8 };
static ASN_OBJECT_ID(Ds1Signalling);
static OID_DATA const odDs1Signalling =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, signalling),
		sizeof elementof(ds1_config_t, signalling),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1WinkDigits) { 9 };
static ASN_OBJECT_ID(Ds1WinkDigits);
static OID_DATA const odDs1WinkDigits =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, wink_digits),
		sizeof elementof(ds1_config_t, wink_digits),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1Clocking) { 10 };
static ASN_OBJECT_ID(Ds1Clocking);
static OID_DATA const odDs1Clocking =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, clocking),
		sizeof elementof(ds1_config_t, clocking),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1JitterAttenuation) { 11 };
static ASN_OBJECT_ID(Ds1JitterAttenuation);
static OID_DATA const odDs1JitterAttenuation =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, jitter_atten),
		sizeof elementof(ds1_config_t, jitter_atten),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1Ct1EqualizerGainLimit) { 12 };
static ASN_OBJECT_ID(Ds1Ct1EqualizerGainLimit);
static OID_DATA const odDs1Ct1EqualizerGainLimit =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, eq_gain_limit),
		sizeof elementof(ds1_config_t, eq_gain_limit),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1LeasedMask) { 13 };
static ASN_OBJECT_ID(Ds1LeasedMask);
static OID_DATA const odDs1LeasedMask =
{
	ACCESS_READWRITE,
	DS1_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_config_t, leased_mask),
		sizeof elementof(ds1_config_t, leased_mask),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1TransmitSpecial) { 14 };
static ASN_OBJECT_ID(Ds1TransmitSpecial);
static OID_DATA const odDs1TransmitSpecial =
{
	ACCESS_READWRITE,
	DS1_EXT_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_ext_config_t, tx_special),
		sizeof elementof(ds1_ext_config_t, tx_special),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1AutoConfiguration) { 15 };
static ASN_OBJECT_ID(Ds1AutoConfiguration);
static OID_DATA const odDs1AutoConfiguration =
{
	ACCESS_READWRITE,
	DS1_EXT_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_ext_config_t, auto_config),
		sizeof elementof(ds1_ext_config_t, auto_config),
		ASN_INTEGER
	}
};

static ASN_OBJECT_ARRAY(Ds1Loopback) { 16 };
static ASN_OBJECT_ID(Ds1Loopback);
static OID_DATA const odDs1Loopback =
{
	ACCESS_READWRITE,
	DS1_EXT_CONFIG,
	SetCacheObject_Ds1,
	{
		offsetof(ds1_ext_config_t, loopback),
		sizeof elementof(ds1_ext_config_t, loopback),
		ASN_INTEGER
	}
};

static OID_MAP_ENTRY const aomeDs1Table[] =
{
	{ &ASN_OBJECT_ID_VAR(Ds1Adapter),				{	Object_Data,	&odDs1Adapter				},	VarBind_Ds1Adapter					},
	{ &ASN_OBJECT_ID_VAR(Ds1Port),					{	Object_Data,	&odDs1Port					},	VarBind_Ds1Port						},
	{ &ASN_OBJECT_ID_VAR(Ds1Coding),				{	Object_Data,	&odDs1Coding				},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1Framing),				{	Object_Data,	&odDs1Framing				},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1Interface),				{	Object_Data,	&odDs1Interface				},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1LongHaulLineBuildOut),	{	Object_Data,	&odDs1LongHaulLineBuildOut	},	VarBind_Ds1LongHaulLineBuildOut		},
	{ &ASN_OBJECT_ID_VAR(Ds1ShortHaulLength),		{	Object_Data,	&odDs1ShortHaulLength		},	VarBind_Ds1ShortHaulLength			},
	{ &ASN_OBJECT_ID_VAR(Ds1Signalling),			{	Object_Data,	&odDs1Signalling			},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1WinkDigits),			{	Object_Data,	&odDs1WinkDigits			},	VarBind_Ds1WinkDigits				},
	{ &ASN_OBJECT_ID_VAR(Ds1Clocking),				{	Object_Data,	&odDs1Clocking				},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1JitterAttenuation),		{	Object_Data,	&odDs1JitterAttenuation		},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1Ct1EqualizerGainLimit),	{	Object_Data,	&odDs1Ct1EqualizerGainLimit	},	VarBind_Ds1Ct1EqualizerGainLimit	},
	{ &ASN_OBJECT_ID_VAR(Ds1LeasedMask),			{	Object_Data,	&odDs1LeasedMask			},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1TransmitSpecial),		{	Object_Data,	&odDs1TransmitSpecial		},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1AutoConfiguration),		{	Object_Data,	&odDs1AutoConfiguration		},	VarBind_GenericData					},
	{ &ASN_OBJECT_ID_VAR(Ds1Loopback),				{	Object_Data,	&odDs1Loopback				},	VarBind_GenericData					}
};

static ASN_OBJECT_ARRAY(Ds1Table) { 4, 1 };
static ASN_OBJECT_ID(Ds1Table);
static OID_TABLE const otDs1Table = 
{
	2,
	Index_Ds1,
	{ ElementCount(aomeDs1Table), aomeDs1Table }
};

/*** THE MIB ***/

static OID_MAP_ENTRY const aomeRawRAS[] =
{
	{ &ASN_OBJECT_ID_VAR(ShimProtocolVersion),	{	Object_Data,	&odShimProtocolVersion	},	VarBind_GenericData		},
	{ &ASN_OBJECT_ID_VAR(AdapterTable),			{	Object_Table,	&otAdapterTable			},	VarBind_GenericTable	},
	{ &ASN_OBJECT_ID_VAR(DriverTable),			{	Object_Table,	&otDriverTable			},	VarBind_GenericTable	},
	{ &ASN_OBJECT_ID_VAR(Ds1Table),				{	Object_Table,	&otDs1Table				},	VarBind_GenericTable	}
};

/*** TRAPS ***/

static BOOL AlarmStatus(size_t const iBoard, void const * const pvData, TrapData_t const * const ptd)
{
	return FALSE;
}

static TRAP_ENTRY const ateRawRAS[] =
{
	{ DS1_STATUS, 6, 1, offsetof(ds1_status_t, alarm), sizeof elementof(ds1_status_t, alarm), AlarmStatus, Ds1Count }
};

/*** Root Map ***/

ROOT_MAP const rmRawRAS =
{
	&ASN_OBJECT_ID_VAR(RawRAS),
	{ ElementCount(aomeRawRAS), aomeRawRAS },
	{ ElementCount(ateRawRAS), ateRawRAS }
};


