original files of m241
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
/* wmbSNMPLib.c - SNMP interface handler of WMB */
|
||||
|
||||
/* Copyright 2002-2007 Wind River Systems, Inc. */
|
||||
|
||||
#include "copyright_wrs.h"
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This file includes support for registering SNMP objects with the backplane and managing
|
||||
all aspects of the SNMP related functions, including portfolios
|
||||
*/
|
||||
|
||||
/* includes */
|
||||
#include "wm.h"
|
||||
#include "wmb.h"
|
||||
#include "wmbSNMPLib.h"
|
||||
#ifdef ENVOY_STACK_K
|
||||
#include "wmmMethodRoutine.h"
|
||||
#endif
|
||||
|
||||
#if defined __ENABLE_SNMP_RESOURCE_REGISTER__
|
||||
/* defines */
|
||||
|
||||
/* typedefs */
|
||||
|
||||
/* locals */
|
||||
static WMB_SNMP_ENTRY_T wmbEntry[WMB_MAX_SNMP_ENTRIES];
|
||||
static int numTables = 0;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* wmbSNMPEntryLookup - Return the index of WMB_SNMP_ENTRY_T for a component
|
||||
*
|
||||
* RETURNS: index
|
||||
*
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
LOCAL sbyte2 wmbSNMPEntryLookup
|
||||
(
|
||||
WMB_CID_T component /* [in] Component ID */
|
||||
)
|
||||
{
|
||||
sbyte4 i;
|
||||
|
||||
for (i = 0; i < WMB_MAX_SNMP_ENTRIES; i++)
|
||||
{
|
||||
if (wmbEntry[i].component == component)
|
||||
break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* wmbSNMPResourceRegister - Register SNMP object
|
||||
*
|
||||
* RETURNS: ERROR, OK
|
||||
*
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
STATUS wmbSNMPResourceRegister
|
||||
(
|
||||
WMB_CID_T component, /* [in] Component ID */
|
||||
sbyte *objName, /* [in] Object name */
|
||||
ubyte4 *Id, /* [in] OID */
|
||||
ubyte2 oidLen, /* [in] OID Len */
|
||||
ubyte2 dataType, /* [in] Data Type */
|
||||
ubyte2 accessRead, /* [in] Read access value */
|
||||
ubyte2 accessWrite, /* [in] Write access value */
|
||||
ubyte2 flags, /* [in] Flags */
|
||||
WMB_HANDLER_T wmbHandler /* [in] Pointer to the WMB Handler function */
|
||||
)
|
||||
{
|
||||
STATUS rc = OK;
|
||||
WMB_ENTRY_T *pEntry;
|
||||
sbyte4 i;
|
||||
|
||||
if (accessWrite == -1)
|
||||
flags |= DB_FLAG_READONLY_K;
|
||||
|
||||
i = wmbSNMPEntryLookup(component);
|
||||
|
||||
if (i == WMB_MAX_SNMP_ENTRIES)
|
||||
return ERROR;
|
||||
|
||||
if (wmbEntry[i].numEntry == wmbEntry[i].maxEntry)
|
||||
return ERROR;
|
||||
|
||||
pEntry = &(wmbEntry[i].pEntryArray[wmbEntry[i].numEntry]);
|
||||
|
||||
pEntry->accessRead = 0;
|
||||
pEntry->accessWrite = 0;
|
||||
pEntry->flags = flags | DB_FLAG_INSTANCE;
|
||||
pEntry->handler = wmbHandler;
|
||||
pEntry->localId = 0;
|
||||
pEntry->pData = Id;
|
||||
pEntry->pName = objName;
|
||||
pEntry->pValid = NULL;
|
||||
pEntry->sibling = 0;
|
||||
pEntry->size = oidLen;
|
||||
pEntry->table = 0;
|
||||
pEntry->type = dataType;
|
||||
|
||||
#ifdef ENVOY_STACK_K
|
||||
rc = wmmRegisterSNMPObject(objName, Id, oidLen / sizeof (ubyte4),
|
||||
dataType, accessRead, accessWrite, Id);
|
||||
#endif
|
||||
if ( rc == OK )
|
||||
wmbEntry[i].numEntry++;
|
||||
else
|
||||
bzero( (char *)pEntry, sizeof(WMB_ENTRY_T) );
|
||||
|
||||
return rc;
|
||||
}
|
||||
/**************************************************************************
|
||||
*
|
||||
* wmbSNMPObjectEntryCreate - Allocate space for MIB Object entries
|
||||
*
|
||||
* RETURNS: ERROR, OK
|
||||
*
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
STATUS wmbSNMPObjectEntryCreate
|
||||
(
|
||||
WMB_CID_T component, /* [in] Component ID */
|
||||
sbyte2 maxMIBObjects /* [in] Number of Entries to allocate for */
|
||||
)
|
||||
{
|
||||
sbyte4 i;
|
||||
|
||||
if (numTables == WMB_MAX_SNMP_ENTRIES)
|
||||
return wmError(ERROR_MEMMGR_NO_MEMORY, "wmbSNMPObjectEntryCreate: Access beyond wmbEntry array");
|
||||
|
||||
for (i = 0; i < WMB_MAX_SNMP_ENTRIES; i++)
|
||||
{
|
||||
if (wmbEntry[i].maxEntry == 0)
|
||||
break;
|
||||
}
|
||||
wmbEntry[i].component = component;
|
||||
wmbEntry[i].numEntry = 0;
|
||||
wmbEntry[i].maxEntry = maxMIBObjects;
|
||||
|
||||
/* Use Calloc to get zero'd memory */
|
||||
wmbEntry[i].pEntryArray = wmCalloc(maxMIBObjects, sizeof(WMB_ENTRY_T));
|
||||
|
||||
if (wmbEntry[i].pEntryArray == NULL)
|
||||
return wmError(ERROR_MEMMGR_NO_MEMORY, "wmbSNMPObjectEntryCreate");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* wmbSNMPObjectEntryDelete - Delete MIB Object entries for the component
|
||||
*
|
||||
* RETURNS: N/A
|
||||
*
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
void wmbSNMPObjectEntryDelete
|
||||
(
|
||||
WMB_CID_T component /* [in] Component ID */
|
||||
)
|
||||
{
|
||||
sbyte4 i;
|
||||
|
||||
i = wmbSNMPEntryLookup(component);
|
||||
if (i == WMB_MAX_SNMP_ENTRIES)
|
||||
return;
|
||||
|
||||
wmbEntry[i].maxEntry = 0;
|
||||
wmbEntry[i].component = NULL;
|
||||
wmbEntry[i].numEntry = 0;
|
||||
wmFree(wmbEntry[i].pEntryArray);
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* wmbSNMPResourceArrayRegister - Registration of objects completed. WMB will be
|
||||
* updated.
|
||||
*
|
||||
* RETURNS: ERROR, OK
|
||||
*
|
||||
*
|
||||
* NOMANUAL
|
||||
*/
|
||||
STATUS wmbSNMPResourceArrayRegister
|
||||
(
|
||||
WMB_CID_T component, /* [in] Component ID */
|
||||
sbyte *path, /* [in] Path of the component */
|
||||
WMB_HANDLER_T wmbHandler /* [in] Pointer to the WMB Handler function */
|
||||
)
|
||||
{
|
||||
sbyte4 i;
|
||||
|
||||
i = wmbSNMPEntryLookup(component);
|
||||
if (i == WMB_MAX_SNMP_ENTRIES)
|
||||
return ERROR;
|
||||
|
||||
return wmbResourceRegister(wmbComponentNameGet(component), path, wmbEntry[i].pEntryArray,
|
||||
wmbEntry[i].numEntry, NULL, 0, wmbHandler);
|
||||
}
|
||||
#endif /* __ENABLE_SNMP_RESOURCE_REGISTER__ */
|
||||
Reference in New Issue
Block a user