Skip to content

Commit

Permalink
[nes]: GMPLS changes ...
Browse files Browse the repository at this point in the history
  • Loading branch information
nes-repo committed Nov 5, 2015
1 parent feed37b commit 7ddb605
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 71 deletions.
1 change: 1 addition & 0 deletions mpls/mplsTeStdMIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ typedef struct mplsTunnelHopEntry_t
uint8_t u8StorageType;

gmplsTunnelHopEntry_t oG;
neMplsTunnelHopEntry_t oNe;

xBTree_Node_t oBTreeNode;
} mplsTunnelHopEntry_t;
Expand Down
88 changes: 17 additions & 71 deletions mpls/neMplsTeMIB.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,22 +1054,6 @@ neMplsTunnelHopTable_init (void)
/* Initialise the contents of the table here */
}

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

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

xBTree_t oNeMplsTunnelHopTable_BTree = xBTree_initInline (&neMplsTunnelHopTable_BTreeNodeCmp);

/* create a new row in the table */
neMplsTunnelHopEntry_t *
neMplsTunnelHopTable_createEntry (
Expand All @@ -1078,22 +1062,14 @@ neMplsTunnelHopTable_createEntry (
uint32_t u32Index)
{
register neMplsTunnelHopEntry_t *poEntry = NULL;
register mplsTunnelHopEntry_t *poTunnelHop = NULL;

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

poEntry->u32ListIndex = u32ListIndex;
poEntry->u32PathOptionIndex = u32PathOptionIndex;
poEntry->u32Index = u32Index;
if (xBTree_nodeFind (&poEntry->oBTreeNode, &oNeMplsTunnelHopTable_BTree) != NULL)
if ((poTunnelHop = mplsTunnelHopTable_getByIndex (u32ListIndex, u32PathOptionIndex, u32Index)) == NULL)
{
xBuffer_free (poEntry);
return NULL;
}
poEntry = &poTunnelHop->oNe;

xBTree_nodeAdd (&poEntry->oBTreeNode, &oNeMplsTunnelHopTable_BTree);
return poEntry;
}

Expand All @@ -1103,25 +1079,14 @@ neMplsTunnelHopTable_getByIndex (
uint32_t u32PathOptionIndex,
uint32_t u32Index)
{
register neMplsTunnelHopEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;
register mplsTunnelHopEntry_t *poTunnelHop = NULL;

if ((poTmpEntry = xBuffer_cAlloc (sizeof (*poTmpEntry))) == NULL)
if ((poTunnelHop = mplsTunnelHopTable_getByIndex (u32ListIndex, u32PathOptionIndex, u32Index)) == NULL)
{
return NULL;
}

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

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, neMplsTunnelHopEntry_t, oBTreeNode);
return &poTunnelHop->oNe;
}

neMplsTunnelHopEntry_t *
Expand All @@ -1130,39 +1095,20 @@ neMplsTunnelHopTable_getNextIndex (
uint32_t u32PathOptionIndex,
uint32_t u32Index)
{
register neMplsTunnelHopEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;

if ((poTmpEntry = xBuffer_cAlloc (sizeof (*poTmpEntry))) == NULL)
{
return NULL;
}
register mplsTunnelHopEntry_t *poTunnelHop = NULL;

poTmpEntry->u32ListIndex = u32ListIndex;
poTmpEntry->u32PathOptionIndex = u32PathOptionIndex;
poTmpEntry->u32Index = u32Index;
if ((poNode = xBTree_nodeFindNext (&poTmpEntry->oBTreeNode, &oNeMplsTunnelHopTable_BTree)) == NULL)
if ((poTunnelHop = mplsTunnelHopTable_getNextIndex (u32ListIndex, u32PathOptionIndex, u32Index)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, neMplsTunnelHopEntry_t, oBTreeNode);
return &poTunnelHop->oNe;
}

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

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

Expand All @@ -1172,7 +1118,7 @@ neMplsTunnelHopTable_getFirst (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
*my_loop_context = xBTree_nodeGetFirst (&oNeMplsTunnelHopTable_BTree);
*my_loop_context = xBTree_nodeGetFirst (&oMplsTunnelHopTable_BTree);
return neMplsTunnelHopTable_getNext (my_loop_context, my_data_context, put_index_data, mydata);
}

Expand All @@ -1181,22 +1127,22 @@ neMplsTunnelHopTable_getNext (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
neMplsTunnelHopEntry_t *poEntry = NULL;
mplsTunnelHopEntry_t *poEntry = NULL;
netsnmp_variable_list *idx = put_index_data;

if (*my_loop_context == NULL)
{
return NULL;
}
poEntry = xBTree_entry (*my_loop_context, neMplsTunnelHopEntry_t, oBTreeNode);
poEntry = xBTree_entry (*my_loop_context, mplsTunnelHopEntry_t, oBTreeNode);

snmp_set_var_typed_integer (idx, ASN_UNSIGNED, poEntry->u32ListIndex);
idx = idx->next_variable;
snmp_set_var_typed_integer (idx, ASN_UNSIGNED, poEntry->u32PathOptionIndex);
idx = idx->next_variable;
snmp_set_var_typed_integer (idx, ASN_UNSIGNED, poEntry->u32Index);
*my_data_context = (void*) poEntry;
*my_loop_context = (void*) xBTree_nodeGetNext (&poEntry->oBTreeNode, &oNeMplsTunnelHopTable_BTree);
*my_data_context = (void*) &poEntry->oNe;
*my_loop_context = (void*) xBTree_nodeGetNext (&poEntry->oBTreeNode, &oMplsTunnelHopTable_BTree);
return put_index_data;
}

Expand All @@ -1205,12 +1151,12 @@ neMplsTunnelHopTable_get (
void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
neMplsTunnelHopEntry_t *poEntry = NULL;
mplsTunnelHopEntry_t *poEntry = NULL;
register netsnmp_variable_list *idx1 = put_index_data;
register netsnmp_variable_list *idx2 = idx1->next_variable;
register netsnmp_variable_list *idx3 = idx2->next_variable;

poEntry = neMplsTunnelHopTable_getByIndex (
poEntry = mplsTunnelHopTable_getByIndex (
*idx1->val.integer,
*idx2->val.integer,
*idx3->val.integer);
Expand All @@ -1219,7 +1165,7 @@ neMplsTunnelHopTable_get (
return false;
}

*my_data_context = (void*) poEntry;
*my_data_context = (void*) &poEntry->oNe;
return true;
}

Expand Down

0 comments on commit 7ddb605

Please sign in to comment.