📄 dot1xmib.c
字号:
/* dot1xMib.c - IDB+ Module source for dot1xMib.mi2. */
/* Copyright 2003 Wind River, Inc. */
#include "copyright_wrs.h"
/*
modification history
--------------------
xxx,25Jun03,idb Created by IDBGEN. Ver 2.28
%%BeginUserCode dot1xMib_Modifications
%%EndUserCode dot1xMib_Modifications
*/
/*
DESCRIPTION
This module defines the IDB+ structures and IDB+ Object handler routines to
access the IDB+ objects defined in dot1xMib.mi2.
INCLUDE FILES: dot1xMib.h
*/
/* Includes */
#include "tmsTypes.h"
#include "idbLib.h"
#include "dot1xMib.h"
#include "nvm/nvmLib.h"
/* %%BeginUserCode dot1xMib_IncludeFiles */
#include "dot1xAuth.h"
/* %%EndUserCode dot1xMib_IncludeFiles */
/* Defines */
/* %%BeginUserCode dot1xMib_Defines */
/* %%EndUserCode dot1xMib_Defines */
/* Globals */
/* %%BeginUserCode dot1xMib_Globals */
extern u_long dot1xAuthPro;
extern u_long dot1xReAuthEn;
extern u_long dot1xReAuthInterVal;
extern u_long dot1xMAXReAuthTimes;
extern u_long dot1xWaitTimerInterVal;
extern u_long dot1xMAXReTryTimes;
extern u_long FailedHoldTime;
extern u_long dot1xReAuthStyle;
extern u_long dot1xReAuthTimeout;
/* %%EndUserCode dot1xMib_Globals */
/* Locals */
LOCAL char * moduleName = "dot1xMib";
/* %%BeginUserCode dot1xMib_Locals */
/* %%EndUserCode dot1xMib_Locals */
/* Prototypes */
LOCAL STATUS dot1xMibScalarHandler ( idbRequest_t request, idb_t * idb );
/* %%BeginUserCode dot1xMib_Prototypes */
/* %%EndUserCode dot1xMib_Prototypes */
/****************************************************************************
* IDB+ Module Object Descriptors
*/
LOCAL idbObjDesc_t dot1xAuthProtocol_objDesc[] = {
{ dot1xAuthProtocol, 1, 4, /* localId=0 1.3.6.1.4.1.10293.1.1.2.14.1.1 */
{ 1, 4 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xAuthProtocol" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xReAuthEnable_objDesc[] = {
{ dot1xReAuthEnable, 2, 4, /* localId=1 1.3.6.1.4.1.10293.1.1.2.14.1.2 */
{ 1, 2 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xReAuthEnable" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xReAuthPeriod_objDesc[] = {
{ dot1xReAuthPeriod, 3, 4, /* localId=2 1.3.6.1.4.1.10293.1.1.2.14.1.3 */
{ 1, 65535 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xReAuthPeriod" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xReAuthRetryTimes_objDesc[] = {
{ dot1xReAuthRetryTimes, 4, 4, /* localId=3 1.3.6.1.4.1.10293.1.1.2.14.1.4 */
{ 1, 10 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xReAuthRetryTimes" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xReAuthSuppTimeOut_objDesc[] = {
{ dot1xReAuthSuppTimeOut, 5, 4, /* localId=4 1.3.6.1.4.1.10293.1.1.2.14.1.5 */
{ 1, 65535 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xReAuthSuppTimeOut" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xSuppTimeOut_objDesc[] = {
{ dot1xSuppTimeOut, 6, 4, /* localId=5 1.3.6.1.4.1.10293.1.1.2.14.1.6 */
{ 1, 65535 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xSuppTimeOut" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xTxRetryTimes_objDesc[] = {
{ dot1xTxRetryTimes, 7, 4, /* localId=6 1.3.6.1.4.1.10293.1.1.2.14.1.7 */
{ 1, 10 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xTxRetryTimes" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xTxHoldTimes_objDesc[] = {
{ dot1xTxHoldTimes, 8, 4, /* localId=7 1.3.6.1.4.1.10293.1.1.2.14.1.8 */
{ 0, 30 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xTxHoldTimes" },
{ 0 }
};
LOCAL idbObjDesc_t dot1xReAuthType_objDesc[] = {
{ dot1xReAuthType, 9, 4, /* localId=8 1.3.6.1.4.1.10293.1.1.2.14.1.9 */
{ 1, 2 }, IDB_INTEGER, (IDB_READ|IDB_WRITE),
(IDB_VALID), dot1xMibScalarHandler,
(char *)0, "dot1xMib:dot1xReAuthType" },
{ 0 }
};
/*****************************************************************************
* IDB+ Module OID Table
*
* The OID list below (e.g.,{1,3,6,1, ...}) is the OID prefix minus the
* last sub-identifier. The last sub-identifier is found in the
* object descriptor idbObjDesc_t structure.
*/
LOCAL idbOidTable_t oidTable[] = {
/* 0: Scalar Object -- dot1xAuthProtocol */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xAuthProtocol_objDesc },
/* 1: Scalar Object -- dot1xReAuthEnable */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xReAuthEnable_objDesc },
/* 2: Scalar Object -- dot1xReAuthPeriod */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xReAuthPeriod_objDesc },
/* 3: Scalar Object -- dot1xReAuthRetryTimes */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xReAuthRetryTimes_objDesc },
/* 4: Scalar Object -- dot1xReAuthSuppTimeOut */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xReAuthSuppTimeOut_objDesc },
/* 5: Scalar Object -- dot1xSuppTimeOut */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xSuppTimeOut_objDesc },
/* 6: Scalar Object -- dot1xTxRetryTimes */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xTxRetryTimes_objDesc },
/* 7: Scalar Object -- dot1xTxHoldTimes */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xTxHoldTimes_objDesc },
/* 8: Scalar Object -- dot1xReAuthType */
{ IDB_SNMP_STRUCT, {1,3,6,1,4,1,10293,1,1,2,14,1}, 13, /*lint !e785 */
0, 1, { 0 },
dot1xReAuthType_objDesc },
{ IDB_TERMINATOR }
};
/*****************************************************************************
* IDB+ Module Translate Table
*/
LOCAL idbXlateTable_t xlateTable[] = {
{ &oidTable[ 0], &dot1xAuthProtocol_objDesc[0] },
{ &oidTable[ 1], &dot1xReAuthEnable_objDesc[0] },
{ &oidTable[ 2], &dot1xReAuthPeriod_objDesc[0] },
{ &oidTable[ 3], &dot1xReAuthRetryTimes_objDesc[0] },
{ &oidTable[ 4], &dot1xReAuthSuppTimeOut_objDesc[0] },
{ &oidTable[ 5], &dot1xSuppTimeOut_objDesc[0] },
{ &oidTable[ 6], &dot1xTxRetryTimes_objDesc[0] },
{ &oidTable[ 7], &dot1xTxHoldTimes_objDesc[0] },
{ &oidTable[ 8], &dot1xReAuthType_objDesc[0] },
{ 0 }
};
/*
* If you are defining an octet string value and need to convert
* say an IP address and port number to a 6 byte octet string then use
* one of the following formats.
* Decmial: "# 192 1 192 172 0 6"
* Hex: "# 0xC0 0x01 0xC0 0xAC 0x0 0x06"
* Octal: "# 0300 01 0300 0254 00 06"
* Mix: "# 0xC0 1 0300 0254 0x0 06"
* A '#' as the first character in the string causes the translation.
* The numbers can be seperated by whitespaces or a comma.
*
* Examples:
* {"Example0", "0", IDB_INTEGER, "1000"},
* {"Example1", "1.10.100", IDB_OCTET_STRING, "someString1"},
* { DITTO, "1.10.101", IDB_OCTET_STRING, "someString2"},
* {"Example2", "1.10.200", IDB_OCTET_STRING, "defaultString"},
* { DITTO, "1.10.201", IDB_OCTET_STRING, DITTO},
* {"Example3", "1.10.300", IDB_IpAddress, "# 192 1 192 101"},
*
* Use "# 0" for a NULL string instead of "". The "# 0" sets the length
* of the defVal to one the other form is set to zero, which may not be
* what you wanted.
*
* NOTE:
* To have IDBGEN add or remove objects from this section you must delete
* this section or add/remove them by hand editing this section.
*/
LOCAL nvmDefVal_t idbModule_NvmDv[] = {
/* %%BeginUserCode dot1xMibNvmDefVal_Prolog */
/* **************** Durable objects **************** */
{ FALSE, 0, "dot1xAuthProtocol", "0", IDB_INTEGER, "1" },
{ FALSE, 0, "dot1xReAuthEnable", "0", IDB_INTEGER, "1" },
{ FALSE, 0, "dot1xReAuthPeriod", "0", IDB_INTEGER, "30" },
{ FALSE, 0, "dot1xReAuthRetryTimes", "0", IDB_INTEGER, "4" },
{ FALSE, 0, "dot1xReAuthSuppTimeOut", "0", IDB_INTEGER, "30" },
{ FALSE, 0, "dot1xSuppTimeOut", "0", IDB_INTEGER, "30" },
{ FALSE, 0, "dot1xTxRetryTimes", "0", IDB_INTEGER, "4" },
{ FALSE, 0, "dot1xTxHoldTimes", "0", IDB_INTEGER, "10" },
{ FALSE, 0, "dot1xReAuthType", "0", IDB_INTEGER, "1" },
/* %%EndUserCode dot1xMibNvmDefVal_Prolog */
{ 0 }
};
/******************************************************************************
* User Local Functions.
*/
/* %%BeginUserCode dot1xMib_UserFunctions */
STATUS Dot1xNvmObjUpdate
(
char * obj,
ulong_t * idx,
ulong_t idxLen,
char * val,
ulong_t valLen,
BOOL update
)
{
STATUS rc = OK;
LOCAL nvmMod_t * mod = NULL;
if ( mod == NULL )
{
if (nvmModuleIdGet( moduleName, NVM_DURABLE, &mod ) == ERROR)
return ERROR;
}
if (nvmObjectCreate (mod, obj, idx, idxLen, val, valLen) == ERROR)
{
if ( errnoGet() == S_nvmLib_ObjExists)
{
/* object already created */
if (update == TRUE)
rc = nvmObjectUpdate (mod, obj, idx, idxLen, val, valLen);
}
else
rc = ERROR;
}
/* else object did not exist; nvm object creation successful */
return rc;
}
STATUS Dot1xNvmObjDelete
(
char * obj,
ulong_t * idx,
ulong_t idxLen
)
{
LOCAL nvmMod_t * mod = NULL;
if ( mod == NULL )
{
if (nvmModuleIdGet( moduleName, NVM_DURABLE, &mod ) == ERROR)
return ERROR;
}
return nvmObjectDelete (mod, obj, idx, idxLen);
}
/* %%EndUserCode dot1xMib_UserFunctions */
/****************************************************************************
*
* dot1xMibInit - initialize/register dot1xMib and objects.
*
* This routine initializes the modules IDB routines.
*
* RETURNS: OK or ERROR
*
* ERRNO: N/A
*/
STATUS dot1xMibInit
(
void * parm1,
void * parm2
)
{
STATUS rc;
/* %%BeginUserCode dot1xMibInit_Prolog */
/* %%EndUserCode dot1xMibInit_Prolog */
rc = OK;
/* %%BeginUserCode dot1xMibInit_Body */
dot1xMibNvmInit();
/* %%EndUserCode dot1xMibInit_Body */
/* Register the module's information with IDB+ engine */
idbModuleRegister( moduleName, &xlateTable[0] );
/* Setup the durable and persistant objects */
nvmDefValInit( moduleName, idbModule_NvmDv );
/* %%BeginUserCode dot1xMibInit_Epilog */
nvmModuleRetrieve( moduleName ); /*wanghn 20030623 add*/
/* %%EndUserCode dot1xMibInit_Epilog */
return( rc );
}
/******************************************************************************
*
* dot1xMibTerminate - Terminate dot1xMib and objects.
*
* This routine de-initializes the IDB module functions.
*
* RETURNS: OK or ERROR
*
* ERRNO: N/A
*/
STATUS dot1xMibTerminate
(
void * parm
)
{
STATUS rc;
/* %%BeginUserCode dot1xMibTerminate_Prolog */
/* %%EndUserCode dot1xMibTerminate_Prolog */
rc = OK;
/* De-register the module's information with IDB+ engine */
idbModuleDeRegister( moduleName );
/* %%BeginUserCode dot1xMibTerminate_Epilog */
/* %%EndUserCode dot1xMibTerminate_Epilog */
return( rc );
}
/******************************************************************************
*
* dot1xMibScalarHandler - handles all scalar objects.
*
* This routine handles all scalar objects for this IDB+ Module.
*
* RETURNS: OK or ERROR
*
* ERRNO: N/A
*/
LOCAL STATUS dot1xMibScalarHandler
(
idbRequest_t request,
idb_t * idb
)
{
STATUS rc;
/* %%BeginUserCode dot1xMibScalarHandler_Prolog */
/* %%EndUserCode dot1xMibScalarhandler_Prolog */
rc = OK;
/* Validate the Scalar indexSubIdCount and instance value */
if ( idbScalarValidate( request, idb ) == ERROR )
return idbErrorRequestMap( request );
switch( idb->localId )
{
default:
rc = idbErrorNoSuchInstance();
break;
/* ================================================================= */
/*
* Edot1xAuthProtocol_pap 1
* Edot1xAuthProtocol_chap 2
* Edot1xAuthProtocol_eap_md5 3
* Edot1xAuthProtocol_lcbap 4
*/
case dot1xAuthProtocol: /* INTEGER, read-write */
{
/* %%BeginUserCode dot1xAuthProtocol_Body */
switch ( request )
{
case IDB_GET_NEXT:
/* Check to make sure the next object is valid. */
rc = idbNextScalarIndex(idb);
/* FALLTHRU */
case IDB_GET:
if ( rc == OK )
{
ulongSet(idb, dot1xAuthPro);
}
break;
case IDB_VALIDATE:
if ( (ulongGet(idb) < 1) || (ulongGet(idb) > 4) )
rc = idbErrorInvalidRange();
else if ( idb->valueLen > 4 )
rc = idbErrorInvalidLength();
break;
case IDB_SET_NVM:
dot1xAuthPro = ulongGet(idb);
break;
case IDB_COMMIT:
dot1xAuthPro = ulongGet(idb);
if (ulongGet(idb) == Edot1xAuthProtocol_pap)
Dot1xNvmObjDelete("dot1xAuthProtocol", idb->pIndex, idb->indexSubIdCount);
else
Dot1xNvmObjUpdate("dot1xAuthProtocol", idb->pIndex, idb->indexSubIdCount, idb->pValueBuf, idb->valueLen, TRUE);
break;
}
/* %%EndUserCode dot1xAuthProtocol_Body */
}
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -