252N/A/*
252N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
252N/A *
252N/A * U.S. Government Rights - Commercial software. Government users are subject
252N/A * to the Sun Microsystems, Inc. standard license agreement and applicable
252N/A * provisions of the FAR and its supplements.
252N/A *
252N/A *
252N/A * This distribution may include materials developed by third parties. Sun,
252N/A * Sun Microsystems, the Sun logo and Solaris are trademarks or registered
252N/A * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
252N/A *
252N/A */
252N/A/*
252N/A * Note: this file originally auto-generated by mib2c using
252N/A * : mib2c.iterate.conf,v 5.5 2002/12/16 22:50:18 hardaker Exp $
252N/A */
252N/A
252N/A#include <net-snmp/net-snmp-config.h>
252N/A#include <net-snmp/net-snmp-includes.h>
252N/A#include <net-snmp/agent/net-snmp-agent-includes.h>
252N/A#include "stdhdr.h"
252N/A#include "entAliasMappingTable.h"
252N/A#include "entLogicalTable.h"
252N/A#include "entPhysicalTable.h"
252N/A#include "entLastChangeTime.h"
252N/A
252N/AentAliasMappingTableEntry_t *gAliasMappingTableHead;
252N/Aint gAliasMappingTableSize;
252N/Astatic logicalAlias *gCurAliasEntry;
252N/A
252N/A
252N/A
252N/A/** Initialize the entAliasMappingTable table by defining its contents and how it's structured */
252N/Avoid
252N/Ainitialize_table_entAliasMappingTable(void)
252N/A{
252N/A static oid entAliasMappingTable_oid[] = {1,3,6,1,2,1,47,1,3,2};
252N/A netsnmp_table_registration_info *table_info;
252N/A netsnmp_handler_registration *my_handler;
252N/A netsnmp_iterator_info *iinfo;
252N/A
252N/A /* create the table structure itself */
252N/A table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
252N/A iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);
252N/A
252N/A /* if your table is read only, it's easiest to change the
252N/A HANDLER_CAN_RWRITE definition below to HANDLER_CAN_RONLY */
252N/A /* Fix for 4910624 - changing HANDLER_CAN_RWRITE to HANDLER_CAN_RONLY */
252N/A my_handler = netsnmp_create_handler_registration("entAliasMappingTable",
252N/A entAliasMappingTable_handler,
252N/A entAliasMappingTable_oid,
252N/A OID_LENGTH(entAliasMappingTable_oid),
252N/A HANDLER_CAN_RONLY);
252N/A /* End of Fix for 4910624 */
252N/A
252N/A if (!my_handler || !table_info || !iinfo)
252N/A return; /* mallocs failed */
252N/A
252N/A /***************************************************
252N/A * Setting up the table's definition
252N/A */
252N/A netsnmp_table_helper_add_indexes(table_info,
252N/A ASN_INTEGER, /* index: entPhysicalIndex */
252N/A ASN_INTEGER, /* index: entAliasLogicalIndexOrZero */
252N/A 0);
252N/A
252N/A table_info->min_column = 2;
252N/A table_info->max_column = 2;
252N/A
252N/A /* iterator access routines */
252N/A iinfo->get_first_data_point = entAliasMappingTable_get_first_data_point;
252N/A iinfo->get_next_data_point = entAliasMappingTable_get_next_data_point;
252N/A
252N/A iinfo->table_reginfo = table_info;
252N/A
252N/A /***************************************************
252N/A * registering the table with the master agent
252N/A */
252N/A DEBUGMSGTL(("initialize_table_entAliasMappingTable",
252N/A "Registering table entAliasMappingTable as a table iterator\n"));
252N/A netsnmp_register_table_iterator(my_handler, iinfo);
252N/A}
252N/A
252N/A/** Initializes the entAliasMappingTable module */
252N/Avoid
252N/Ainit_entAliasMappingTable(void)
252N/A{
252N/A
252N/A /* here we initialize all the tables we're planning on supporting */
252N/A initialize_table_entAliasMappingTable();
252N/A gAliasMappingTableSize = 0;
252N/A gAliasMappingTableHead = NULL;
252N/A gCurAliasEntry = NULL;
252N/A}
252N/A
252N/A/** returns the first data point within the entAliasMappingTable table data.
252N/A
252N/A Set the my_loop_context variable to the first data point structure
252N/A of your choice (from which you can find the next one). This could
252N/A be anything from the first node in a linked list, to an integer
252N/A pointer containing the beginning of an array variable.
252N/A
252N/A Set the my_data_context variable to something to be returned to
252N/A you later that will provide you with the data to return in a given
252N/A row. This could be the same pointer as what my_loop_context is
252N/A set to, or something different.
252N/A
252N/A The put_index_data variable contains a list of snmp variable
252N/A bindings, one for each index in your table. Set the values of
252N/A each appropriately according to the data matching the first row
252N/A and return the put_index_data variable at the end of the function.
252N/A*/
252N/Anetsnmp_variable_list *
252N/AentAliasMappingTable_get_first_data_point(void **my_loop_context, void **my_data_context,
252N/A netsnmp_variable_list *put_index_data,
252N/A netsnmp_iterator_info *mydata)
252N/A{
252N/A
252N/A netsnmp_variable_list *vptr;
252N/A entAliasMappingTableEntry_t *zRunner, *zpValidEntry;
252N/A logicalAlias *zlogicalAliases, *zValidAlias;
252N/A int bFound=0;
252N/A
252N/A zRunner = gAliasMappingTableHead;
252N/A zpValidEntry = NULL;
252N/A gCurAliasEntry = NULL;
252N/A while (zRunner) {
252N/A if (zRunner->entPhysicalIndex > 0) {
252N/A zlogicalAliases = zRunner->entlogicalAliases;
252N/A while ((zlogicalAliases != NULL) &&
252N/A (zlogicalAliases->entAliasMapIdSize >= 0)){
252N/A if (zlogicalAliases->entAliasLogicalIndexorZero >= 0) {
252N/A bFound = 1;
252N/A break;
252N/A }
252N/A zlogicalAliases++;
252N/A }
252N/A if (bFound) {
252N/A zpValidEntry = zRunner;
252N/A zValidAlias = zlogicalAliases;
252N/A break;
252N/A }
252N/A }
252N/A zRunner = zRunner->pNextEntry;
252N/A }
252N/A if (zRunner == NULL) return NULL;
252N/A
252N/A *my_loop_context = (void *) zpValidEntry;
252N/A *my_data_context = (void *) zValidAlias;
252N/A gCurAliasEntry = zValidAlias;
252N/A
252N/A vptr = put_index_data;
252N/A
252N/A snmp_set_var_value(vptr, (u_char *) &zpValidEntry->entPhysicalIndex, sizeof(zpValidEntry->entPhysicalIndex));
252N/A vptr = vptr->next_variable;
252N/A snmp_set_var_value(vptr, (u_char *) &zValidAlias->entAliasLogicalIndexorZero, sizeof(zValidAlias->entAliasLogicalIndexorZero));
252N/A vptr = vptr->next_variable;
252N/A
252N/A return put_index_data;
252N/A}
252N/A
252N/A/** functionally the same as entAliasMappingTable_get_first_data_point, but
252N/A my_loop_context has already been set to a previous value and should
252N/A be updated to the next in the list. For example, if it was a
252N/A linked list, you might want to cast it and the return
252N/A my_loop_context->next. The my_data_context pointer should be set
252N/A to something you need later and the indexes in put_index_data
252N/A updated again. */
252N/A
252N/Anetsnmp_variable_list *
252N/AentAliasMappingTable_get_next_data_point(void **my_loop_context, void **my_data_context,
252N/A netsnmp_variable_list *put_index_data,
252N/A netsnmp_iterator_info *mydata)
252N/A{
252N/A
252N/A netsnmp_variable_list *vptr;
252N/A entAliasMappingTableEntry_t *zRunner, *zpValidEntry;
252N/A logicalAlias *zlogicalAliases, *zValidAlias;
252N/A int bFound=0;
252N/A
252N/A zRunner = (entAliasMappingTableEntry_t *)*my_loop_context;
252N/A zlogicalAliases = (logicalAlias *) *my_data_context;
252N/A zlogicalAliases = gCurAliasEntry;
252N/A
252N/A if (zlogicalAliases != NULL)
252N/A zlogicalAliases++;
252N/A
252N/A while (zRunner) {
252N/A if (zRunner->entPhysicalIndex > 0) {
252N/A while ((zlogicalAliases != NULL) &&
252N/A (zlogicalAliases->entAliasMapIdSize >= 0)){
252N/A if (zlogicalAliases->entAliasLogicalIndexorZero >= 0) {
252N/A bFound = 1;
252N/A break;
252N/A }
252N/A zlogicalAliases++;
252N/A }
252N/A if (bFound) {
252N/A zpValidEntry = zRunner;
252N/A zValidAlias = zlogicalAliases;
252N/A break;
252N/A }
252N/A }
252N/A zRunner = zRunner->pNextEntry;
252N/A if (zRunner)
252N/A zlogicalAliases = zRunner->entlogicalAliases;
252N/A }
252N/A if (zRunner == NULL) return NULL;
252N/A
252N/A *my_loop_context = (void *) zpValidEntry;
252N/A *my_data_context = (void *) zValidAlias;
252N/A gCurAliasEntry = zValidAlias;
252N/A
252N/A vptr = put_index_data;
252N/A
252N/A snmp_set_var_value(vptr, (u_char *) &zpValidEntry->entPhysicalIndex, sizeof(zpValidEntry->entPhysicalIndex));
252N/A vptr = vptr->next_variable;
252N/A snmp_set_var_value(vptr, (u_char *) &zValidAlias->entAliasLogicalIndexorZero, sizeof(zValidAlias->entAliasLogicalIndexorZero));
252N/A vptr = vptr->next_variable;
252N/A
252N/A return put_index_data;
252N/A}
252N/A
252N/A/** handles requests for the entAliasMappingTable table, if anything else needs to be done */
252N/Aint
252N/AentAliasMappingTable_handler(
252N/A netsnmp_mib_handler *handler,
252N/A netsnmp_handler_registration *reginfo,
252N/A netsnmp_agent_request_info *reqinfo,
252N/A netsnmp_request_info *requests) {
252N/A
252N/A netsnmp_request_info *request;
252N/A netsnmp_table_request_info *table_info;
252N/A netsnmp_variable_list *var;
252N/A logicalAlias *zAliasEntry;
252N/A
252N/A for(request = requests; request; request = request->next) {
252N/A var = request->requestvb;
252N/A if (request->processed != 0)
252N/A continue;
252N/A
252N/A /* perform anything here that you need to do before each
252N/A request is processed. */
252N/A
252N/A /* the following extracts the my_data_context pointer set in
252N/A the loop functions above. You can then use the results to
252N/A help return data for the columns of the entAliasMappingTable table in question */
252N/A zAliasEntry = (logicalAlias *) netsnmp_extract_iterator_context(request);
252N/A if (zAliasEntry == NULL) {
252N/A if (reqinfo->mode == MODE_GET) {
252N/A netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE);
252N/A continue;
252N/A }
252N/A /* XXX: no row existed, if you support creation and this is a
252N/A set, start dealing with it here, else continue */
252N/A }
252N/A
252N/A /* extracts the information about the table from the request */
252N/A table_info = netsnmp_extract_table_info(request);
252N/A /* table_info->colnum contains the column number requested */
252N/A /* table_info->indexes contains a linked list of snmp variable
252N/A bindings for the indexes of the table. Values in the list
252N/A have been set corresponding to the indexes of the
252N/A request */
252N/A if (table_info==NULL) {
252N/A continue;
252N/A }
252N/A
252N/A switch(reqinfo->mode) {
252N/A /* the table_iterator helper should change all GETNEXTs
252N/A into GETs for you automatically, so you don't have to
252N/A worry about the GETNEXT case. Only GETs and SETs need
252N/A to be dealt with here */
252N/A case MODE_GET:
252N/A switch(table_info->colnum) {
252N/A case COLUMN_ENTALIASMAPPINGIDENTIFIER:
252N/A snmp_set_var_typed_value(var, ASN_OBJECT_ID, (u_char *) zAliasEntry->entAliasMapId, zAliasEntry->entAliasMapIdSize);
252N/A break;
252N/A
252N/A default:
252N/A /* We shouldn't get here */
252N/A snmp_log(LOG_ERR, "problem encountered in entAliasMappingTable_handler: unknown column\n");
252N/A }
252N/A break;
252N/A
252N/A case MODE_SET_RESERVE1:
252N/A /* set handling... */
252N/A
252N/A default:
252N/A snmp_log(LOG_ERR, "problem encountered in entAliasMappingTable_handler: unsupported mode\n");
252N/A }
252N/A }
252N/A return SNMP_ERR_NOERROR;
252N/A}
252N/A
252N/A/* Add an entry into the Alias Mapping Table
252N/A returns 0 for success
252N/A 1 for entry already exist
252N/A -1 for failure
252N/A -2 for stale index
252N/A*/
252N/A
252N/Aint
252N/AaddAliasMappingTableEntry(int xentPhysicalIndex, int xentLogicalIndex,
252N/A oid *xAliasMapId, int xAliasMapIdSize)
252N/A{
252N/A entAliasMappingTableEntry_t *zAliasTableEntry, *zRunner, *zlastEntry;
252N/A entPhysicalEntry_t *physentry;
252N/A entLogicalEntry_t *zLogicalEntry;
252N/A logicalAlias *zLogicalAliases;
252N/A
252N/A /* Fix for 4927412: Rejects NULL xAliasMapId */
252N/A if (xAliasMapId == NULL)
252N/A return -1;
252N/A /* End of Fix for 4927412 */
252N/A
252N/A /* Fix for 4888088: logical index cannot be smaller than zero, */
252N/A /* and physical index cannot be smaller than */
252N/A /* or equal to zero. -2 for stale entries */
252N/A if (xentPhysicalIndex <= 0 || xentPhysicalIndex > MAX_ENTITY_INDEX || xentLogicalIndex < 0 || xentLogicalIndex > MAX_ENTITY_INDEX)
252N/A return -1;
252N/A physentry = getPhysicalTableStaleEntry(xentPhysicalIndex);
252N/A if (physentry != NULL)
252N/A return -2;
252N/A
252N/A zLogicalEntry = getLogicalTableStaleEntry(xentLogicalIndex);
252N/A if (zLogicalEntry != NULL)
252N/A return -2;
252N/A /* End of Fix for 4888088 */
252N/A
252N/A physentry = getPhysicalTableEntry(xentPhysicalIndex);
252N/A
252N/A if (physentry != NULL) {
252N/A if (physentry->entPhysicalClass != 10) return (-1);
252N/A } else return (-1);
252N/A
252N/A if (xentLogicalIndex != 0) {
252N/A zLogicalEntry = getLogicalTableEntry(xentLogicalIndex);
252N/A if (zLogicalEntry == NULL) return (-1);
252N/A }
252N/A if (xAliasMapId == NULL) return (-1);
252N/A
252N/A zlastEntry = NULL;
252N/A zRunner = gAliasMappingTableHead;
252N/A while (zRunner != NULL) {
252N/A if (zRunner->entPhysicalIndex == xentPhysicalIndex) {
252N/A break;
252N/A }
252N/A zlastEntry = zRunner;
252N/A zRunner = zRunner->pNextEntry;
252N/A }
252N/A if (zRunner != NULL ) {/* Found a entry with physical index */
252N/A logicalAlias *p;
252N/A p = zRunner->entlogicalAliases;
252N/A if (p == NULL) {
252N/A zLogicalAliases = (logicalAlias *) malloc(2 * sizeof (logicalAlias));
252N/A if (!zLogicalAliases) return -1;
252N/A zLogicalAliases[0].entAliasLogicalIndexorZero = xentLogicalIndex;
252N/A zLogicalAliases[0].entAliasMapId = malloc(xAliasMapIdSize);
252N/A if (!zLogicalAliases[0].entAliasMapId) return -1;
252N/A memcpy(zLogicalAliases[0].entAliasMapId, xAliasMapId,
252N/A xAliasMapIdSize);
252N/A zLogicalAliases[0].entAliasMapIdSize = xAliasMapIdSize;
252N/A zLogicalAliases[1].entAliasLogicalIndexorZero = 0;
252N/A zLogicalAliases[1].entAliasMapId = NULL;
252N/A zLogicalAliases[1].entAliasMapIdSize = -1;
252N/A zRunner->entlogicalAliases = zLogicalAliases;
252N/A } else {/* Add phy index to last entry in the array */
252N/A int i=0;
252N/A while (p != NULL && p->entAliasMapIdSize >= 0) {
252N/A if (p->entAliasLogicalIndexorZero == xentLogicalIndex) return (1);
252N/A if (p->entAliasMapIdSize < 0 ) {
252N/A p->entAliasLogicalIndexorZero = xentLogicalIndex;
252N/A p->entAliasMapId = malloc(xAliasMapIdSize);
252N/A if (!p->entAliasMapId) return -1;
252N/A memcpy(p->entAliasMapId, xAliasMapId, xAliasMapIdSize);
252N/A p->entAliasMapIdSize = xAliasMapIdSize;
252N/A }
252N/A p++;
252N/A i++;
252N/A }
252N/A zRunner->entlogicalAliases =
252N/A (logicalAlias *)realloc(zRunner->entlogicalAliases, (i + 2)*sizeof(logicalAlias));
252N/A zRunner->entlogicalAliases[i].entAliasLogicalIndexorZero =
252N/A xentLogicalIndex;
252N/A zRunner->entlogicalAliases[i].entAliasMapId =
252N/A malloc(xAliasMapIdSize);
252N/A if (!zRunner->entlogicalAliases[i].entAliasMapId) return -1;
252N/A memcpy(zRunner->entlogicalAliases[i].entAliasMapId, xAliasMapId,
252N/A xAliasMapIdSize);
252N/A zRunner->entlogicalAliases[i].entAliasMapIdSize = xAliasMapIdSize;
252N/A zRunner->entlogicalAliases[i+1].entAliasLogicalIndexorZero = 0;
252N/A zRunner->entlogicalAliases[i+1].entAliasMapId = NULL;
252N/A zRunner->entlogicalAliases[i+1].entAliasMapIdSize = -1;
252N/A }
252N/A configChanged();
252N/A return (0);
252N/A }
252N/A
252N/A /* New entry*/
252N/A zAliasTableEntry = (entAliasMappingTableEntry_t *)malloc(sizeof(entAliasMappingTableEntry_t));
252N/A if (!zAliasTableEntry) return -1;
252N/A zAliasTableEntry->entPhysicalIndex = xentPhysicalIndex;
252N/A zLogicalAliases = (logicalAlias *) malloc(2 * sizeof (logicalAlias));
252N/A if (!zLogicalAliases) return -1;
252N/A zLogicalAliases[0].entAliasLogicalIndexorZero = xentLogicalIndex;
252N/A zLogicalAliases[0].entAliasMapId = malloc(xAliasMapIdSize);
252N/A if (!zLogicalAliases[0].entAliasMapId) return -1;
252N/A memcpy(zLogicalAliases[0].entAliasMapId, xAliasMapId,
252N/A xAliasMapIdSize);
252N/A zLogicalAliases[0].entAliasMapIdSize = xAliasMapIdSize;
252N/A zLogicalAliases[1].entAliasLogicalIndexorZero = 0;
252N/A zLogicalAliases[1].entAliasMapId = NULL;
252N/A zLogicalAliases[1].entAliasMapIdSize = -1;
252N/A zAliasTableEntry->entlogicalAliases = zLogicalAliases;
252N/A zAliasTableEntry->pNextEntry = NULL;
252N/A if (gAliasMappingTableHead){
252N/A zlastEntry->pNextEntry = zAliasTableEntry;
252N/A } else {
252N/A gAliasMappingTableHead = zAliasTableEntry;
252N/A }
252N/A gAliasMappingTableSize++;
252N/A configChanged();
252N/A return (0);
252N/A}
252N/A
252N/A/* Returns 0 for successful deletion
252N/A -1 for entry not found
252N/A -2 for stale entry
252N/A*/
252N/Aint
252N/AdeleteAliasMappingTableEntry(int xentPhysicalIndex, int xentLogicalIndex)
252N/A{
252N/A entAliasMappingTableEntry_t *zRunner;
252N/A logicalAlias *zLogicalAliases;
252N/A int zPhyIndx;
252N/A entPhysicalEntry_t *zPhysicalEntry;
252N/A entLogicalEntry_t *zLogicalEntry;
252N/A
252N/A /* Fix for 4888088: logical index cannot be smaller than zero, */
252N/A /* and physical index cannot be smaller than */
252N/A /* or equal to zero. -2 for stale entries */
252N/A if (xentPhysicalIndex <= 0 || xentPhysicalIndex > MAX_ENTITY_INDEX || xentLogicalIndex < 0 || xentLogicalIndex > MAX_ENTITY_INDEX)
252N/A return -1;
252N/A zPhysicalEntry = getPhysicalTableStaleEntry(xentPhysicalIndex);
252N/A if (zPhysicalEntry != NULL)
252N/A return -2;
252N/A
252N/A zLogicalEntry = getLogicalTableStaleEntry(xentLogicalIndex);
252N/A if (zLogicalEntry != NULL)
252N/A return -2;
252N/A /* End of Fix for 4888088 */
252N/A
252N/A zRunner = gAliasMappingTableHead;
252N/A
252N/A while (zRunner != NULL) {
252N/A zPhyIndx = zRunner->entPhysicalIndex;
252N/A
252N/A if (zPhyIndx > 0) {
252N/A if (zPhyIndx == xentPhysicalIndex) {
252N/A zLogicalAliases = zRunner->entlogicalAliases;
252N/A while (zLogicalAliases != NULL
252N/A && zLogicalAliases->entAliasMapIdSize >= 0) {
252N/A int zLogIndx = zLogicalAliases->entAliasLogicalIndexorZero;
252N/A if (zLogIndx >=0 ) {
252N/A if (zLogIndx == xentLogicalIndex) {
252N/A zLogicalAliases->entAliasLogicalIndexorZero = -1;
252N/A free(zLogicalAliases->entAliasMapId);
252N/A zLogicalAliases->entAliasMapId = NULL;
252N/A zLogicalAliases->entAliasMapIdSize = 0;
252N/A configChanged();
252N/A return (0);
252N/A }
252N/A }
252N/A zLogicalAliases++;
252N/A }
252N/A return (-1); /* Entry not found */
252N/A }
252N/A }
252N/A zRunner = zRunner->pNextEntry;
252N/A }
252N/A return (-1);
252N/A}
252N/A
252N/Astatic int
252N/AFreeAliasMappingTableEntry(entAliasMappingTableEntry_t *xEntry)
252N/A{
252N/A logicalAlias *zAliases;
252N/A int nEntries=0;
252N/A if (xEntry == NULL) return (-1);
252N/A zAliases = xEntry->entlogicalAliases;
252N/A while (zAliases != NULL && zAliases->entAliasMapIdSize >= 0) {
252N/A /* Fix for 4906853: we only need to free it (and count) if */
252N/A /* entAliasMapId != NULL. A better fix is to use a link list */
252N/A /* instead of an array for this structure */
252N/A if (zAliases->entAliasMapId != NULL) {
252N/A free(zAliases->entAliasMapId);
252N/A nEntries++;
252N/A }
252N/A /* End of Fix for 4906853 */
252N/A zAliases++;
252N/A }
252N/A free(xEntry->entlogicalAliases);
252N/A free(xEntry);
252N/A xEntry = NULL;
252N/A return nEntries;
252N/A}
252N/A
252N/A/* Deletes all the entries in the table with primary index as
252N/A given physical index
252N/A Return number of entries deleted on success,
252N/A -1 on failure
252N/A -2 for a existing stale entry
252N/A*/
252N/A
252N/Aint
252N/AdeleteAliasMappingPhysicalIndex(int xentPhysicalIndex)
252N/A{
252N/A entAliasMappingTableEntry_t *zRunner, *temp, *prevEntry;
252N/A int zPhyIndx, nEntries=0;
252N/A entPhysicalEntry_t *zPhysicalEntry;
252N/A
252N/A /* Fix for 4888088: We do not need the check for 4883511 anymore, */
252N/A /* because entAliasLogicalIndexorZero will never be set */
252N/A /* to negative values. Instead we will check if the */
252N/A /* entries are stale (except when xentLogicalIndex = 0) */
252N/A if (xentPhysicalIndex <= 0 || xentPhysicalIndex > MAX_ENTITY_INDEX)
252N/A return -1;
252N/A zPhysicalEntry = getPhysicalTableStaleEntry(xentPhysicalIndex);
252N/A if (zPhysicalEntry != NULL)
252N/A return -2;
252N/A /* End of Fix for 4888088 */
252N/A
252N/A zRunner = gAliasMappingTableHead;
252N/A prevEntry = NULL;
252N/A
252N/A while (zRunner != NULL) {
252N/A zPhyIndx = zRunner->entPhysicalIndex;
252N/A
252N/A if (zPhyIndx > 0) {
252N/A if (zPhyIndx == xentPhysicalIndex) {
252N/A temp = zRunner->pNextEntry;
252N/A zRunner->pNextEntry = NULL;
252N/A if (prevEntry)
252N/A prevEntry->pNextEntry = temp;
252N/A else
252N/A gAliasMappingTableHead = temp;
252N/A nEntries = FreeAliasMappingTableEntry(zRunner);
252N/A gAliasMappingTableSize--;
252N/A configChanged();
252N/A return nEntries;
252N/A }
252N/A }
252N/A prevEntry = zRunner;
252N/A zRunner = zRunner->pNextEntry;
252N/A }
252N/A return (-1);
252N/A}
252N/A
252N/A/* Deletes all entries of the table for a given logical index.
252N/A Returns the number if entries deleted
252N/A -1 if the entry is not found
252N/A -2 if the logical index is stale
252N/A The memory allocated is freed when the primary index, physical index
252N/A is deleted.
252N/A*/
252N/Aint
252N/AdeleteAliasMappingLogicalIndex(int xentLogicalIndex)
252N/A{
252N/A entAliasMappingTableEntry_t *zRunner;
252N/A logicalAlias *zLogicalAliases;
252N/A int zPhyIndx, nFound=0;
252N/A entLogicalEntry_t *zLogicalEntry;
252N/A
252N/A /* Fix for 4888088: Here we are not allowing logical index = 0. We are */
252N/A /* forcing the user to use deleteAliasMappingTableEntry */
252N/A if (xentLogicalIndex <= 0 || xentLogicalIndex > MAX_ENTITY_INDEX)
252N/A return -1;
252N/A zLogicalEntry = getLogicalTableStaleEntry(xentLogicalIndex);
252N/A if (zLogicalEntry != NULL)
252N/A return -2;
252N/A /* End of Fix for 4888088 */
252N/A
252N/A zRunner = gAliasMappingTableHead;
252N/A
252N/A while (zRunner != NULL) {
252N/A zPhyIndx = zRunner->entPhysicalIndex;
252N/A if (zPhyIndx > 0) {
252N/A zLogicalAliases = zRunner->entlogicalAliases;
252N/A while (zLogicalAliases != NULL
252N/A && zLogicalAliases->entAliasMapIdSize >= 0) {
252N/A int zLogIndx = zLogicalAliases->entAliasLogicalIndexorZero;
252N/A if (zLogIndx >= 0 ) {
252N/A if (zLogIndx == xentLogicalIndex) {
252N/A zLogicalAliases->entAliasLogicalIndexorZero = -1;
252N/A free(zLogicalAliases->entAliasMapId);
252N/A zLogicalAliases->entAliasMapId = NULL;
252N/A zLogicalAliases->entAliasMapIdSize = 0;
252N/A nFound++;
252N/A break;
252N/A }
252N/A }
252N/A zLogicalAliases++;
252N/A }
252N/A }
252N/A zRunner = zRunner->pNextEntry;
252N/A }
252N/A /* Fix for 4888088 */
252N/A if (nFound) {
252N/A configChanged();
252N/A return (nFound);
252N/A } else {
252N/A return -1;
252N/A }
252N/A /* End of Fix for 4888088 */
252N/A}