Skip to content

Commit

Permalink
[nes]: ENTITY changes ...
Browse files Browse the repository at this point in the history
  • Loading branch information
nes-repo committed Jan 7, 2015
1 parent 49b207c commit c8026ec
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 25 deletions.
80 changes: 57 additions & 23 deletions system/entityMIB.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,67 +1989,104 @@ neEntPhysicalTable_init (void)
/* Initialise the contents of the table here */
}

static int8_t
neEntPhysicalTable_BTreeNodeCmp (
xBTree_Node_t *pNode1, xBTree_Node_t *pNode2, xBTree_t *pBTree)
{
register neEntPhysicalEntry_t *pEntry1 = xBTree_entry (pNode1, neEntPhysicalEntry_t, oBTreeNode);
register neEntPhysicalEntry_t *pEntry2 = xBTree_entry (pNode2, neEntPhysicalEntry_t, oBTreeNode);

return
(pEntry1->u32Index < pEntry2->u32Index) ? -1:
(pEntry1->u32Index == pEntry2->u32Index) ? 0: 1;
}

xBTree_t oNeEntPhysicalTable_BTree = xBTree_initInline (&neEntPhysicalTable_BTreeNodeCmp);

/* create a new row in the (unsorted) table */
neEntPhysicalEntry_t *
neEntPhysicalTable_createEntry (
uint32_t u32Index)
{
register neEntPhysicalEntry_t *poEntry = NULL;
register entPhysicalData_t *poEntPhysicalData = NULL;

if ((poEntPhysicalData = entPhysicalData_createEntry (u32Index)) == NULL)
if ((poEntry = xBuffer_cAlloc (sizeof (*poEntry))) == NULL)
{
return NULL;
}

poEntry->u32Index = u32Index;
if (xBTree_nodeFind (&poEntry->oBTreeNode, &oNeEntPhysicalTable_BTree) != NULL)
{
xBuffer_free (poEntry);
return NULL;
}
poEntry = &poEntPhysicalData->oNe;

poEntry->u8RowStatus = xRowStatus_notInService_c;
poEntry->u8StorageType = neEntPhysicalStorageType_nonVolatile_c;

xBitmap_setBit (poEntPhysicalData->au8Flags, entPhysicalFlags_neCreated_c, 1);
xBTree_nodeAdd (&poEntry->oBTreeNode, &oNeEntPhysicalTable_BTree);
return poEntry;
}

neEntPhysicalEntry_t *
neEntPhysicalTable_getByIndex (
uint32_t u32Index)
{
register entPhysicalData_t *poEntPhysicalData = NULL;
register neEntPhysicalEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;

if ((poEntPhysicalData = entPhysicalData_getByIndex (u32Index)) == NULL ||
!xBitmap_getBit (poEntPhysicalData->au8Flags, entPhysicalFlags_neCreated_c))
if ((poTmpEntry = xBuffer_cAlloc (sizeof (*poTmpEntry))) == NULL)
{
return NULL;
}

poTmpEntry->u32Index = u32Index;
if ((poNode = xBTree_nodeFind (&poTmpEntry->oBTreeNode, &oNeEntPhysicalTable_BTree)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

return &poEntPhysicalData->oNe;
xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, neEntPhysicalEntry_t, oBTreeNode);
}

neEntPhysicalEntry_t *
neEntPhysicalTable_getNextIndex (
uint32_t u32Index)
{
register entPhysicalData_t *poEntPhysicalData = NULL;
register neEntPhysicalEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;

if ((poEntPhysicalData = entPhysicalData_getNextIndex (u32Index)) == NULL ||
!xBitmap_getBit (poEntPhysicalData->au8Flags, entPhysicalFlags_neCreated_c))
if ((poTmpEntry = xBuffer_cAlloc (sizeof (*poTmpEntry))) == NULL)
{
return NULL;
}

return &poEntPhysicalData->oNe;
poTmpEntry->u32Index = u32Index;
if ((poNode = xBTree_nodeFindNext (&poTmpEntry->oBTreeNode, &oNeEntPhysicalTable_BTree)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, neEntPhysicalEntry_t, oBTreeNode);
}

/* remove a row from the table */
void
neEntPhysicalTable_removeEntry (neEntPhysicalEntry_t *poEntry)
{
if (poEntry == NULL)
if (poEntry == NULL ||
xBTree_nodeFind (&poEntry->oBTreeNode, &oNeEntPhysicalTable_BTree) == NULL)
{
return; /* Nothing to remove */
}

entPhysicalData_removeEntry (entPhysicalData_getByNeEntry (poEntry));
xBTree_nodeRemove (&poEntry->oBTreeNode, &oNeEntPhysicalTable_BTree);
xBuffer_free (poEntry); /* XXX - release any other internal resources */
return;
}

Expand All @@ -2075,8 +2112,8 @@ neEntPhysicalTable_createExt (

oEntityGeneral.u32LastChangeTime++; /* TODO */


neEntPhysicalTable_createExt_cleanup:

return poEntry;
}

Expand All @@ -2090,23 +2127,21 @@ neEntPhysicalTable_removeExt (neEntPhysicalEntry_t *poEntry)
goto neEntPhysicalTable_removeExt_cleanup;
}
neEntPhysicalTable_removeEntry (poEntry);
bRetCode = true;

oEntityGeneral.u32LastChangeTime--; /* TODO */

bRetCode = true;

neEntPhysicalTable_removeExt_cleanup:

return bRetCode;
}

bool
neEntPhysicalTable_createHier (
neEntPhysicalEntry_t *poEntry)
{
register entPhysicalData_t *poEntPhysicalData = entPhysicalData_getByNeEntry (poEntry);

if (entPhysicalTable_getByIndex (poEntPhysicalData->u32Index) == NULL &&
entPhysicalTable_createEntry (poEntPhysicalData->u32Index) == NULL)
if (entPhysicalTable_getByIndex (poEntry->u32Index) == NULL &&
entPhysicalTable_createEntry (poEntry->u32Index) == NULL)
{
goto neEntPhysicalTable_createHier_cleanup;
}
Expand All @@ -2125,9 +2160,8 @@ neEntPhysicalTable_removeHier (
neEntPhysicalEntry_t *poEntry)
{
register entPhysicalEntry_t *poEntPhysicalEntry = NULL;
register entPhysicalData_t *poEntPhysicalData = entPhysicalData_getByNeEntry (poEntry);

if ((poEntPhysicalEntry = entPhysicalTable_getByIndex (poEntPhysicalData->u32Index)) != NULL)
if ((poEntPhysicalEntry = entPhysicalTable_getByIndex (poEntry->u32Index)) != NULL)
{
entPhysicalTable_removeEntry (poEntPhysicalEntry);
}
Expand Down
11 changes: 9 additions & 2 deletions system/entityMIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,12 @@ enum
typedef struct neEntPhysicalEntry_t
{
/* Index values */
// uint32_t u32Index;
uint32_t u32Index;

uint8_t au8MfgName[32];
size_t u16MfgName_len;
uint8_t au8SerialNum[32];
size_t u16SerialNum_len;

/* Column values */
uint32_t u32ContainedIn;
Expand All @@ -413,10 +418,12 @@ typedef struct neEntPhysicalEntry_t
uint8_t u8RowStatus;
uint8_t u8StorageType;

entPhysicalEntry_t oPhy;

uint32_t u32ChassisIndex;
struct neEntPhysicalEntry_t *pOldEntry;

// xBTree_Node_t oBTreeNode;
xBTree_Node_t oBTreeNode;
} neEntPhysicalEntry_t;

extern xBTree_t oNeEntPhysicalTable_BTree;
Expand Down

0 comments on commit c8026ec

Please sign in to comment.