/*
*
* 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.
*
*/
#pragma ident "@(#)entLPMappingTable.c 1.1 03/02/24 SMI"
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.iterate.conf,v 5.4 2002/09/11 22:42:04 hardaker Exp $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include "stdhdr.h"
#include "entLPMappingTable.h"
#include "entLogicalTable.h"
#include "entPhysicalTable.h"
#include "entLastChangeTime.h"
typedef struct LPIndex_s {
} LPIndex_t;
int gLPMappingTableSize;
/*
* Initialize the entLPMappingTable 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
*/
netsnmp_create_handler_registration("entLPMappingTable",
return; /* mallocs failed */
/*
* Setting up the table's definition
*/
ASN_INTEGER, /* index: entLogicalIndex */
ASN_INTEGER, /* index: entLPPhysicalIndex */
0);
/*
* iterator access routines
*/
/*
* registering the table with the master agent
*/
DEBUGMSGTL(("initialize_table_entLPMappingTable",
"Registering table entLPMappingTable as a table iterator\n"));
}
/* Initializes the entLPMappingTable module */
void
init_entLPMappingTable(void)
{
/*
* here we initialize all the tables we're planning on supporting
*/
gLPMappingTableSize = 0;
}
/*
* returns the first data point within the entLPMappingTable 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->entLogicalIndex > 0) {
if (*zPhyIndexes > 0) {
break;
}
zPhyIndexes++;
}
if (zValidPhyIdx) {
break;
}
}
}
*my_loop_context = (void *) zpValidEntry;
*my_data_context = (void *) zpValidPhyIdx;
sizeof(zpValidEntry->entLogicalIndex));
return (put_index_data);
}
/*
* functionally the same as entLPMappingTable_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.
*/
{
if (zPhyIndexes != NULL)
zPhyIndexes++;
while (zRunner) {
if (zRunner->entLogicalIndex > 0) {
if (*zPhyIndexes > 0) {
break;
}
zPhyIndexes++;
}
if (zValidPhyIdx) {
break;
}
}
if (zRunner)
}
*my_loop_context = (void *) zpValidEntry;
*my_data_context = (void *) zpValidPhyIdx;
sizeof(int_l));
return (put_index_data);
}
/*
* handles requests for the entLPMappingTable table, if anything else
* needs to be done
*/
int
{
continue;
/*
* perform anything here that you need to do. The request have
* already been processed by the master table_dataset handler,
* but this gives you chance to act on the request in some
* other way if need be.
*/
/*
* 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 entLPMappingTable
* table in question
*/
/*
* XXX
*/
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) {
sizeof (idx));
break;
default:
/*
* We shouldn't get here
*/
}
break;
case MODE_SET_RESERVE1:
/*
* set handling...
*/
default:
}
}
return (SNMP_ERR_NOERROR);
}
/* Return 0 for success
1 for entry already exists
-1 for failure
-2 for stale index */
int
{
/* Fix for 4888088: return -1 for out of bound index, return -2 for */
/* stale entry */
if (xentLogicalIndex <= 0 || xentLogicalIndex > MAX_ENTITY_INDEX || xentPhysicalIndex <= 0 || xentPhysicalIndex > MAX_ENTITY_INDEX)
return -1;
return -2;
}
/* End of Fix for 4888088 */
/*
Handle error here. Send it to log files
*/
return (-1);
}
zlastEntry = NULL;
break;
}
}
int_l *p;
p = zRunner->physicalIndexes;
if (p == NULL) {
if (!zPhyIndexes) return -1;
zPhyIndexes[0] = xentPhysicalIndex;
zPhyIndexes[1] = 0;
} else {/* Add phy index to last entry in the array */
int i=0;
while (p != NULL && *p != 0) {
/* Fix for 4888088: entry already exists, return 1 */
if (*p == xentPhysicalIndex)
return (1);
/* End of Fix for 4888088 */
if (*p == -xentPhysicalIndex) { /* Reuse a 'deleted' entry */
*p = xentPhysicalIndex;
/* Fix for 4928821 - does not generate notification event */
/* End of Fix for 4928821 */
return (0);
}
p++;
i++;
}
}
return (0);
}
/* New entry*/
if (!zPhyIndexes) return -1;
zPhyIndexes[0] = xentPhysicalIndex;
zPhyIndexes[1] = 0;
if (gLPMappingTableHead){
} else {
}
return (0);
}
/*
This function deletes the table entries for a given logical index
and physical index.
Returns 0 for success,
-1 for failure,
-2 for stale entry
*/
int
{
int_l *p;
/* Fix for 4888088: return -1 for invalid index, -2 for stale entry */
if (xentLogicalIndex <= 0 || xentLogicalIndex > MAX_ENTITY_INDEX || xentPhysicalIndex <= 0 || xentPhysicalIndex > MAX_ENTITY_INDEX)
return -1;
if (zLogicalEntry != NULL)
return -2;
if (zPhysicalEntry != NULL)
return -2;
if (zLogicalEntry == NULL)
return -1;
if (zPhysicalEntry == NULL)
return -1;
/* End of Fix for 4888088 */
p = zRunner->physicalIndexes;
while (p != NULL && *p != 0) {
if (*p == xentPhysicalIndex) {
*p = -xentPhysicalIndex;
return (0);
}
p++;
}
return (-1);
}
}
return (-1);
}
static int
{
int nFound = 0;
/* Fix for 4888088 */
/* End of Fix for 4888088 */
/* Fix for 4888088: We need to count the number of entries deleted, and */
/* return that accordingly. Hence the loop */
if (*zPhyIndexes > 0) {
/* Only count valid entries (i.e. non-negative ones) */
nFound++;
}
zPhyIndexes++;
}
/* End of Fix for 4888088 */
/* Fix for 4888088 */
return (nFound);
/* End of Fix for 4888088 */
}
/* Returns num of successful deletion
-1 for entry not found
-2 for stale physical entry
*/
int
int_l *p;
int num=0;
/* Fix for 4888088: -2 for stale entry, -1 for invalid index */
return -1;
if (zPhysicalEntry != NULL)
return -2;
if (zPhysicalEntry == NULL)
return -1;
/* End of Fix for 4888088 */
p = zRunner->physicalIndexes;
while (p != NULL && *p != 0) {
if (*p == xentPhysicalIndex) {
*p = -xentPhysicalIndex;
num++;
break;
}
p++;
}
}
if (num) {
return (num);
} else {
return -1;
}
}
/* Returns num of successful deletion
-1 for entry not found
-2 for stale logical entry
*/
int
/* Fix for 4888088: -1 for invalid index, -2 for stale entry */
return -1;
if (zLogicalEntry != NULL)
return -2;
if (zLogicalEntry == NULL)
return -1;
/* End of Fix for 4888088 */
if (zLogicalIndex > 0) {
if (zLogicalIndex == xentLogicalIndex) {
if (prevEntry)
else
/* Fix for 4888088: we are going to return the number of */
/* entries removed */
/* End of Fix for 4888088 */
/* Fix for 4888088 */
return (nEntries); /* Successful deletion */
/* End of Fix for 4888088 */
}
}
}
return (-1); /* Entry not found */
}