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 Sep 13, 2015
1 parent d89aa61 commit b809424
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 75 deletions.
92 changes: 17 additions & 75 deletions mpls/mplsTeStdMIB.c
Original file line number Diff line number Diff line change
Expand Up @@ -6071,23 +6071,6 @@ gmplsTunnelErrorTable_init (void)
/* Initialise the contents of the table here */
}

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

return
(pEntry1->u32Index < pEntry2->u32Index) ||
(pEntry1->u32Index == pEntry2->u32Index && pEntry1->u32Instance < pEntry2->u32Instance) ||
(pEntry1->u32Index == pEntry2->u32Index && pEntry1->u32Instance == pEntry2->u32Instance && pEntry1->u32IngressLSRId < pEntry2->u32IngressLSRId) ||
(pEntry1->u32Index == pEntry2->u32Index && pEntry1->u32Instance == pEntry2->u32Instance && pEntry1->u32IngressLSRId == pEntry2->u32IngressLSRId && pEntry1->u32EgressLSRId < pEntry2->u32EgressLSRId) ? -1:
(pEntry1->u32Index == pEntry2->u32Index && pEntry1->u32Instance == pEntry2->u32Instance && pEntry1->u32IngressLSRId == pEntry2->u32IngressLSRId && pEntry1->u32EgressLSRId == pEntry2->u32EgressLSRId) ? 0: 1;
}

xBTree_t oGmplsTunnelErrorTable_BTree = xBTree_initInline (&gmplsTunnelErrorTable_BTreeNodeCmp);

/* create a new row in the table */
gmplsTunnelErrorEntry_t *
gmplsTunnelErrorTable_createEntry (
Expand All @@ -6097,23 +6080,14 @@ gmplsTunnelErrorTable_createEntry (
uint32_t u32EgressLSRId)
{
register gmplsTunnelErrorEntry_t *poEntry = NULL;
register mplsTunnelEntry_t *poTunnel = NULL;

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

poEntry->u32Index = u32Index;
poEntry->u32Instance = u32Instance;
poEntry->u32IngressLSRId = u32IngressLSRId;
poEntry->u32EgressLSRId = u32EgressLSRId;
if (xBTree_nodeFind (&poEntry->oBTreeNode, &oGmplsTunnelErrorTable_BTree) != NULL)
if ((poTunnel = mplsTunnelTable_getByIndex (u32Index, u32Instance, u32IngressLSRId, u32EgressLSRId)) == NULL)
{
xBuffer_free (poEntry);
return NULL;
}
poEntry = &poTunnel->oError;

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

Expand All @@ -6124,26 +6098,14 @@ gmplsTunnelErrorTable_getByIndex (
uint32_t u32IngressLSRId,
uint32_t u32EgressLSRId)
{
register gmplsTunnelErrorEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;

if ((poTmpEntry = xBuffer_cAlloc (sizeof (*poTmpEntry))) == NULL)
{
return NULL;
}
register mplsTunnelEntry_t *poTunnel = NULL;

poTmpEntry->u32Index = u32Index;
poTmpEntry->u32Instance = u32Instance;
poTmpEntry->u32IngressLSRId = u32IngressLSRId;
poTmpEntry->u32EgressLSRId = u32EgressLSRId;
if ((poNode = xBTree_nodeFind (&poTmpEntry->oBTreeNode, &oGmplsTunnelErrorTable_BTree)) == NULL)
if ((poTunnel = mplsTunnelTable_getByIndex (u32Index, u32Instance, u32IngressLSRId, u32EgressLSRId)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, gmplsTunnelErrorEntry_t, oBTreeNode);
return &poTunnel->oError;
}

gmplsTunnelErrorEntry_t *
Expand All @@ -6153,40 +6115,20 @@ gmplsTunnelErrorTable_getNextIndex (
uint32_t u32IngressLSRId,
uint32_t u32EgressLSRId)
{
register gmplsTunnelErrorEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;
register mplsTunnelEntry_t *poTunnel = NULL;

if ((poTmpEntry = xBuffer_cAlloc (sizeof (*poTmpEntry))) == NULL)
if ((poTunnel = mplsTunnelTable_getNextIndex (u32Index, u32Instance, u32IngressLSRId, u32EgressLSRId)) == NULL)
{
return NULL;
}

poTmpEntry->u32Index = u32Index;
poTmpEntry->u32Instance = u32Instance;
poTmpEntry->u32IngressLSRId = u32IngressLSRId;
poTmpEntry->u32EgressLSRId = u32EgressLSRId;
if ((poNode = xBTree_nodeFindNext (&poTmpEntry->oBTreeNode, &oGmplsTunnelErrorTable_BTree)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, gmplsTunnelErrorEntry_t, oBTreeNode);
return &poTunnel->oError;
}

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

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

Expand All @@ -6196,7 +6138,7 @@ gmplsTunnelErrorTable_getFirst (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
*my_loop_context = xBTree_nodeGetFirst (&oGmplsTunnelErrorTable_BTree);
*my_loop_context = xBTree_nodeGetFirst (&oMplsTunnelTable_BTree);
return gmplsTunnelErrorTable_getNext (my_loop_context, my_data_context, put_index_data, mydata);
}

Expand All @@ -6205,14 +6147,14 @@ gmplsTunnelErrorTable_getNext (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
gmplsTunnelErrorEntry_t *poEntry = NULL;
mplsTunnelEntry_t *poEntry = NULL;
netsnmp_variable_list *idx = put_index_data;

if (*my_loop_context == NULL)
{
return NULL;
}
poEntry = xBTree_entry (*my_loop_context, gmplsTunnelErrorEntry_t, oBTreeNode);
poEntry = xBTree_entry (*my_loop_context, mplsTunnelEntry_t, oBTreeNode);

snmp_set_var_typed_integer (idx, ASN_UNSIGNED, poEntry->u32Index);
idx = idx->next_variable;
Expand All @@ -6221,8 +6163,8 @@ gmplsTunnelErrorTable_getNext (
snmp_set_var_typed_integer (idx, ASN_UNSIGNED, poEntry->u32IngressLSRId);
idx = idx->next_variable;
snmp_set_var_typed_integer (idx, ASN_UNSIGNED, poEntry->u32EgressLSRId);
*my_data_context = (void*) poEntry;
*my_loop_context = (void*) xBTree_nodeGetNext (&poEntry->oBTreeNode, &oGmplsTunnelErrorTable_BTree);
*my_data_context = (void*) &poEntry->oError;
*my_loop_context = (void*) xBTree_nodeGetNext (&poEntry->oBTreeNode, &oMplsTunnelTable_BTree);
return put_index_data;
}

Expand All @@ -6231,13 +6173,13 @@ gmplsTunnelErrorTable_get (
void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
gmplsTunnelErrorEntry_t *poEntry = NULL;
mplsTunnelEntry_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;
register netsnmp_variable_list *idx4 = idx3->next_variable;

poEntry = gmplsTunnelErrorTable_getByIndex (
poEntry = mplsTunnelTable_getByIndex (
*idx1->val.integer,
*idx2->val.integer,
*idx3->val.integer,
Expand All @@ -6247,7 +6189,7 @@ gmplsTunnelErrorTable_get (
return false;
}

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

Expand Down
1 change: 1 addition & 0 deletions mpls/mplsTeStdMIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ typedef struct mplsTunnelEntry_t
mplsTunnelExtEntry_t oX;
gmplsTunnelEntry_t oG;
gmplsTunnelReversePerfEntry_t oReversePerf;
gmplsTunnelErrorEntry_t oError;
neMplsTunnelEntry_t oNe;

xBTree_Node_t oBTreeNode;
Expand Down

0 comments on commit b809424

Please sign in to comment.