/*
*
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements.
*
*
* This distribution may include materials developed by third parties. Sun,
* Sun Microsystems, the Sun logo and Solaris are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
*
*/
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.iterate.conf,v 5.5 2002/12/16 22:50:18 hardaker Exp $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include "stdhdr.h"
#include "entPhysicalTable.h"
#include "entPhysicalContainsTable.h"
#include "entLastChangeTime.h"
#include "entAliasMappingTable.h"
#include "entLPMappingTable.h"
int gPhysicalTableSize;
/* Fix for 4915824 */
/* End of Fix for 4915824 */
static int AddToPhysicalTable(entPhysicalEntry_t *);
static int FreePhysicalEntry(entPhysicalEntry_t *);
/** Initialize the entPhysicalTable table by defining its contents and how it's structured */
void
{
/* create the table structure itself */
/* if your table is read only, it's easiest to change the
HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY */
/* Fix for 4921485: Temporarily disabling write access, until we */
/* actually need to re-enable it */
/* End of Fix for 4921485 */
/* Future Fix for 4922782: When we re-enable write access, we will also */
/* look into 4914919 - persistency. Of course */
/* we need to remove 4921485 and enable the */
/* CAN_RWRITE. Treat the write handling code */
/* in entPhysicalTable_handlerNeeds as hostile: */
/* everything should be tested and properly */
/* reviewed. Pay special attention to when */
/* to return error codes */
/*
my_handler = netsnmp_create_handler_registration("entPhysicalTable",
entPhysicalTable_handler,
entPhysicalTable_oid,
OID_LENGTH(entPhysicalTable_oid),
HANDLER_CAN_RWRITE);
*/
/* End of Future Fix for 4922782 */
return; /* mallocs failed */
/***************************************************
* Setting up the table's definition
*/
ASN_INTEGER, /* index: entPhysicalIndex */
0);
/* iterator access routines */
/***************************************************
* registering the table with the master agent
*/
DEBUGMSGTL(("initialize_table_entPhysicalTable",
"Registering table entPhysicalTable as a table iterator\n"));
}
/** Initializes the entPhysicalTable module */
void
init_entPhysicalTable(void)
{
/* here we initialize all the tables we're planning on supporting */
gPhysicalTableSize = 0;
}
/** returns the first data point within the entPhysicalTable table data.
Set the my_loop_context variable to the first data point structure
of your choice (from which you can find the next one). This could
be anything from the first node in a linked list, to an integer
pointer containing the beginning of an array variable.
Set the my_data_context variable to something to be returned to
you later that will provide you with the data to return in a given
row. This could be the same pointer as what my_loop_context is
set to, or something different.
The put_index_data variable contains a list of snmp variable
bindings, one for each index in your table. Set the values of
each appropriately according to the data matching the first row
and return the put_index_data variable at the end of the function.
*/
{
while (zRunner) {
if (zRunner->entPhysicalIndex > 0)
break;
}
*my_loop_context = (void *)zRunner;
*my_data_context = (void *)zRunner;
return put_index_data;
}
/** functionally the same as entPhysicalTable_get_first_data_point, but
my_loop_context has already been set to a previous value and should
be updated to the next in the list. For example, if it was a
linked list, you might want to cast it and the return
my_loop_context->next. The my_data_context pointer should be set
to something you need later and the indexes in put_index_data
updated again. */
{
while (zRunner) {
break;
}
*my_loop_context = (void *)zRunner;
*my_data_context = (void *)zRunner;
return put_index_data;
}
/** handles requests for the entPhysicalTable table, if anything else needs to be done */
int
continue;
/* perform anything here that you need to do before each
request is processed. */
/* the following extracts the my_data_context pointer set in
the loop functions above. You can then use the results to
help return data for the columns of the entPhysicalTable table in question */
continue;
}
/* XXX: no row existed, if you support creation and this is a
set, start dealing with it here, else continue */
}
/* extracts the information about the table from the request */
/* table_info->colnum contains the column number requested */
/* table_info->indexes contains a linked list of snmp variable
bindings for the indexes of the table. Values in the list
have been set corresponding to the indexes of the
request */
if (table_info==NULL) {
continue;
}
/* the table_iterator helper should change all GETNEXTs
into GETs for you automatically, so you don't have to
worry about the GETNEXT case. Only GETs and SETs need
to be dealt with here */
case MODE_GET:
switch(table_info->colnum) {
case COLUMN_ENTPHYSICALDESCR:
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalDescr, strlen(zPhysicalEntry->entPhysicalDescr));
break;
snmp_set_var_typed_value(var, ASN_OBJECT_ID, (u_char *) zPhysicalEntry->entPhysicalVendorType, zPhysicalEntry->entPhysicalVendorTypeSize);
break;
snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *)&zPhysicalEntry->entPhysicalContainedIn, sizeof(zPhysicalEntry->entPhysicalContainedIn));
break;
case COLUMN_ENTPHYSICALCLASS:
snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *)&zPhysicalEntry->entPhysicalClass, sizeof(zPhysicalEntry->entPhysicalClass));
break;
snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *)&zPhysicalEntry->entPhysicalParentRelPos, sizeof(zPhysicalEntry->entPhysicalParentRelPos));
break;
case COLUMN_ENTPHYSICALNAME:
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalName, strlen(zPhysicalEntry->entPhysicalName));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalHardwareRev, strlen(zPhysicalEntry->entPhysicalHardwareRev));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalFirmwareRev, strlen(zPhysicalEntry->entPhysicalFirmwareRev));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalSoftwareRev, strlen(zPhysicalEntry->entPhysicalSoftwareRev));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalSerialNum, strlen(zPhysicalEntry->entPhysicalSerialNum));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalMfgName, strlen(zPhysicalEntry->entPhysicalMfgName));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalModelName, strlen(zPhysicalEntry->entPhysicalModelName));
break;
case COLUMN_ENTPHYSICALALIAS:
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalAlias, strlen(zPhysicalEntry->entPhysicalAlias));
break;
snmp_set_var_typed_value(var, ASN_OCTET_STR, (u_char *) zPhysicalEntry->entPhysicalAssetID, strlen(zPhysicalEntry->entPhysicalAssetID));
break;
case COLUMN_ENTPHYSICALISFRU:
snmp_set_var_typed_value(var, ASN_INTEGER, (u_char *) &zPhysicalEntry->entPhysicalIsFRU, sizeof(zPhysicalEntry->entPhysicalIsFRU));
break;
default:
/* We shouldn't get here */
}
break;
/* Fix for 4915824: We have rewritten much of the section here, and */
/* we have also improved the way the boundary */
/* checking and return code is handled */
case MODE_SET_RESERVE1:
switch(table_info->colnum) {
return SNMP_ERR_WRONGTYPE;
}
/* Fix for 4911817: Check for size and boundary limits */
return SNMP_ERR_WRONGLENGTH;
}
}
/* End of Fix for 4911817 */
break;
case COLUMN_ENTPHYSICALALIAS:
return SNMP_ERR_WRONGTYPE;
}
/* Fix for 4911817: Check for size and boundary limits */
return SNMP_ERR_WRONGLENGTH;
}
}
/* End of Fix for 4911817 */
break;
return SNMP_ERR_WRONGTYPE;
}
/* Fix for 4911817: Check for size and boundary limits */
return SNMP_ERR_WRONGLENGTH;
}
}
/* End of Fix for 4911817 */
break;
default:
}
break;
case MODE_SET_RESERVE2:
switch(table_info->colnum) {
if (zOldentPhySerialNum == NULL)
free));
break;
case COLUMN_ENTPHYSICALALIAS:
if (zOldentPhyAlias == NULL)
free));
break;
if (zOldentPhyAssetId == NULL)
free));
break;
default:
}
break;
case MODE_SET_FREE:
switch(table_info->colnum) {
/* We do not need to free anything, because the zOld* will be */
/* freed as part of the request */
break;
case COLUMN_ENTPHYSICALALIAS:
break;
break;
default:
}
break;
case MODE_SET_ACTION:
switch(table_info->colnum) {
/* As part of the 4915824 fix, we have improved */
/* the way we are doing the string copying. Using */
/* var->val_len will guarantee that we are not copying junk, */
/* since var->val.string is not NULL terminated*/
else {
}
break;
case COLUMN_ENTPHYSICALALIAS:
else {
}
break;
else {
}
break;
default:
}
break;
case MODE_SET_COMMIT:
switch(table_info->colnum) {
/* Fix for 4910657: There is no need to free the data set, */
/* as it is handled by the agent */
/* infrastructure. However, Purify should */
/* be run to make sure that there is no */
/* memory leak */
/* End of Fix 4910657 */
break;
case COLUMN_ENTPHYSICALALIAS:
break;
break;
default:
}
break;
case MODE_SET_UNDO:
switch(table_info->colnum) {
zentPhySerialNum = strdup((char *)netsnmp_request_get_list_data(request, ENTPHYSICALSERIALNUM_CACHE));
break;
case COLUMN_ENTPHYSICALALIAS:
break;
break;
default:
}
break;
/* End of Fix for 4915824 */
default:
}
}
return SNMP_ERR_NOERROR;
}
/*
* Allocates a physical entry. if physidx >0 attempts to reuse an
* existing entry
*/
int
{
int index;
/* Fix for 4927388 */
/* End of Fix for 4927388 */
/* Fix for 4927412 */
/* End of Fix for 4927412 */
/* Fix for 4927412: according to RFC 2737, entPhysicalDescr has to be */
/* unique - NULL should be rejected. */
/* entPhysicalVendorType will default to { 0, 0 } for */
/* NULL. For the rest, we will force NULL = "" */
/* (zero-length string) */
return -1;
/* Fix for 4927388 */
}
/* End of Fix for 4927388 */
/* End of Fix for 4927412 */
/* Fix for 4921309 */
return NULL;
/* End of Fix for 4921309 */
/* Fix for 4884681: Check entPhysicalClass and make sure that it
is between 1 and 11 - read the Entity MIB RFC
for details */
if (newPhysEntry->entPhysicalClass < ENTPHYSICAL_CLASS_OTHER || newPhysEntry->entPhysicalClass > ENTPHYSICAL_CLASS_STACK) {
return (-1);
}
/* End of Fix for 4884681 */
/* Fix for 4884702: */
/* Make sure when entPhysicalContainedIn is 0 that */
/* entPhysicalParentRelPos is -1. Also check for boundary */
if (newPhysEntry->entPhysicalParentRelPos < -1 || newPhysEntry->entPhysicalParentRelPos > MAX_ENTITY_INDEX)
return -1;
return -1;
/* End of Fix for 4884702 */
/* Fix for 4929711 */
/* Make sure when entPhysicalRelPos is -1 that */
/* entPhysicalParentContainedIn is 0. */
&& newPhysEntry->entPhysicalContainedIn != 0)
return -1;
/* End of Fix for 4929711 */
/* Fix for 4893121: */
/* check for invalid entries: negative number or greater than allowed */
/* range, stale, or non-existing entry. */
if ((newPhysEntry->entPhysicalContainedIn < 0 || newPhysEntry->entPhysicalContainedIn > MAX_ENTITY_INDEX)) {
/* reject because it is beyond the valid physical index range */
return (-1);
} else if (newPhysEntry->entPhysicalContainedIn != 0 && getPhysicalTableEntry(newPhysEntry->entPhysicalContainedIn) == NULL) {
/* If the intended parent (newPhysEntry->entPhysicalContainedIn) is */
/* a possible index (0 - 2^31-1), but it is stale or does not exist, */
/* then we will reject the entry */
return (-1);
}
/* End of Fix for 4893121 */
/* Fix for 4911817: Check for size and boundary limits */
/* entPhysicalDescr 0..255 */
return -1;
/* entPhysicalName 0..255 */
return -1;
/* entPhysicalHardwareRev 0..255 */
return -1;
/* entPhysicalFirmwareRev 0..255 */
return -1;
/* entPhysicalSoftwareRev 0..255 */
return -1;
/* entPhysicalSerialNum 0..32 */
return -1;
/* entPhysicalMfgName 0..255 */
return -1;
/* entPhysicalModelName 0..255 */
return -1;
/* entPhysicalAlias 0..32 */
return -1;
/* entPhysicalAssetID 0..32 */
return -1;
/* entPhysicalIsFRU only MIB_TRUE and MIB_FALSE */
return (-1);
/* End of Fix for 4911817 */
/* sent a message to log file */
return (-1);
}
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
return (-1);
}
/* End of Fix for 4884526 */
/* Fix for 4884526 */
{
return (-1);
}
/* End of Fix for 4884526 */
return (index);
}
static int
{
int zIndex;
/* Fix for 4921309 */
/* If index > 0, attempt to insert in appropriate place. */
if (xnewPhysicalEntry->entPhysicalIndex > 0) {
placeFound = 0;
} else {
break;
}
}
/* If the indexes don't match, we can use the specified index */
placeFound = 1;
/* Index > last value, make this the last entry */
placeFound = 1;
} else if (xnewPhysicalEntry->entPhysicalIndex !=
/* Index < zRunner, insert entry before it */
if (zRunner == gPhysicalTableHead) {
/* Index fits before list head, insert entry */
} else {
/* Index fits between two entries, insert entry */
}
placeFound = 1;
}
if (placeFound) {
return (xnewPhysicalEntry->entPhysicalIndex);
} else {
/* Re-initialize for code that follows */
}
}
/* Either index was zero or specified index is already taken */
/* End of Fix for 4921309 */
if (gPhysicalTableSize > LARGE_TABLE) {
return (zIndex);
}
if (gPhysicalTableHead) { /* A slightly slower way to add into the list */
return (zIndex);
}
}
} else {
}
return (zIndex);
}
{
int zPhysicalIndex;
/* Fix for 4888088 */
return NULL;
/* End of Fix for 4888088 */
while (zRunner) {
if (zPhysicalIndex > 0) {
if (zPhysicalIndex == xPhysicalIndex)
return zRunner;
}
if (zPhysicalIndex == -(xPhysicalIndex)) {
return NULL; /* The stale entry exist, we can stop the search*/
}
}
return NULL;
}
{
int zPhysicalIndex;
/* Fix for 4888088 */
return NULL;
/* End of Fix for 4888088 */
while (zRunner) {
if (zPhysicalIndex < 0) {
if (zPhysicalIndex == -(xPhysicalIndex))
return zRunner;
}
if (zPhysicalIndex == xPhysicalIndex) {
return NULL; /* The live entry exist, we can stop the search*/
}
}
return NULL;
}
char *entPhysicalDescr,
int entPhysicalClass,
char *entPhysicalName,
char *entPhysicalHardwareRev,
char *entPhysicalFirmwareRev,
char *entPhysicalSoftwareRev,
char *entPhysicalSerialNum,
char *entPhysicalMfgName,
char *entPhysicalModelName,
char *entPhysicalAlias,
char *entPhysicalAssetID,
int entPhysicalIsFRU)
{
}
int
{
int zPhysicalIndex;
/* Fix for 4888088 */
return (-1);
/* End of Fix for 4888088 */
while (zRunner) {
if (zPhysicalIndex > 0) {
if (zPhysicalIndex == xPhysicalIndex) {
/* Fix for 4918876: We need to delete the related entries */
/* first */
/*
Delete all instances of this physical index in all other
tables to maintain table integrity. Should we roll-back if a
deletion fails, perhaps not ?
*/
/* Fix for 4891869 */
/* End of Fix for 4891869 */
/* End of Fix for 4918876 */
if (prevEntry)
else
return (0);
}
}
if (zPhysicalIndex == -(xPhysicalIndex)) {
return (-2); /* The stale entry exist, we can stop the search*/
}
}
return (-1);
}
static int
{
return (1);
}
int
{
int zPhysicalIndex;
/* Fix for 4888088 */
return (-1);
/* End of Fix for 4888088 */
while (zRunner) {
if (zPhysicalIndex < 0) {
if (zPhysicalIndex == -(xPhysicalIndex))
return (-2); /* Entry is already stale */
}
if (zPhysicalIndex == xPhysicalIndex) {
/* Fix for 4918876: We need to delete the related entries first */
/*
Delete all instances of this physical index in all other
tables to maintain table integrity. Should we roll-back if a
deletion fails, perhaps not ?
*/
/* Fix for 4891869 */
/* End of Fix for 4891869 */
/* End of Fix for 4918876 */
return (0);
}
}
return (-1);
}
int
{
int zPhysicalIndex;
/* Fix for 4888088 */
return (-1);
/* End of Fix for 4888088 */
while (zRunner) {
if (zPhysicalIndex > 0) {
if (zPhysicalIndex == xPhysicalIndex)
return (-2); /* Entry is already live */
}
if (zPhysicalIndex == -(xPhysicalIndex)) {
return (0);
}
}
return (-1);
}
/* Fix for 4915080 */
/* Given a parent, find all its children based on the relationship defined */
/* in entPhysicalContainedIn. Needs to free the memory after */
{
child_list = NULL;
i = 0;
/* Fix for 4888088 */
return NULL;
/* End of Fix for 4888088 */
while (zRunner) {
if (child_list == NULL) {
if (child_list == NULL)
return NULL;
child_list[1] = 0;
i++;
} else {
temp = child_list;
if (child_list == NULL) {
return NULL;
}
child_list[i+1] = 0;
}
}
}
return child_list;
}
/* End of Fix for 4915080 */