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 8, 2015
1 parent d80c4a0 commit 126fc08
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 75 deletions.
93 changes: 18 additions & 75 deletions mpls/mplsTeExtStdMIB.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "mplsTeStdMIB.h"
#include "mplsTeExtStdMIB.h"

#include "system_ext.h"
Expand Down Expand Up @@ -103,23 +104,6 @@ mplsTunnelExtTable_init (void)
/* Initialise the contents of the table here */
}

static int8_t
mplsTunnelExtTable_BTreeNodeCmp (
xBTree_Node_t *pNode1, xBTree_Node_t *pNode2, xBTree_t *pBTree)
{
register mplsTunnelExtEntry_t *pEntry1 = xBTree_entry (pNode1, mplsTunnelExtEntry_t, oBTreeNode);
register mplsTunnelExtEntry_t *pEntry2 = xBTree_entry (pNode2, mplsTunnelExtEntry_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 oMplsTunnelExtTable_BTree = xBTree_initInline (&mplsTunnelExtTable_BTreeNodeCmp);

/* create a new row in the table */
mplsTunnelExtEntry_t *
mplsTunnelExtTable_createEntry (
Expand All @@ -129,28 +113,19 @@ mplsTunnelExtTable_createEntry (
uint32_t u32EgressLSRId)
{
register mplsTunnelExtEntry_t *poEntry = NULL;
register mplsTunnelEntry_t *poTunnel = NULL;

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

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

poEntry->u8OppositeDirTnlValid = mplsTunnelExtOppositeDirTnlValid_false_c;
poEntry->u8DestTnlValid = mplsTunnelExtDestTnlValid_false_c;
poEntry->u8IngressLSRLocalIdValid = mplsTunnelExtIngressLSRLocalIdValid_false_c;
poEntry->u8EgressLSRLocalIdValid = mplsTunnelExtEgressLSRLocalIdValid_false_c;

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

Expand All @@ -161,26 +136,14 @@ mplsTunnelExtTable_getByIndex (
uint32_t u32IngressLSRId,
uint32_t u32EgressLSRId)
{
register mplsTunnelExtEntry_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, &oMplsTunnelExtTable_BTree)) == NULL)
if ((poTunnel = mplsTunnelTable_getByIndex (u32Index, u32Instance, u32IngressLSRId, u32EgressLSRId)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, mplsTunnelExtEntry_t, oBTreeNode);
return &poTunnel->oX;
}

mplsTunnelExtEntry_t *
Expand All @@ -190,40 +153,20 @@ mplsTunnelExtTable_getNextIndex (
uint32_t u32IngressLSRId,
uint32_t u32EgressLSRId)
{
register mplsTunnelExtEntry_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_nodeFindNext (&poTmpEntry->oBTreeNode, &oMplsTunnelExtTable_BTree)) == NULL)
if ((poTunnel = mplsTunnelTable_getNextIndex (u32Index, u32Instance, u32IngressLSRId, u32EgressLSRId)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, mplsTunnelExtEntry_t, oBTreeNode);
return &poTunnel->oX;
}

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

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

Expand All @@ -233,7 +176,7 @@ mplsTunnelExtTable_getFirst (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
*my_loop_context = xBTree_nodeGetFirst (&oMplsTunnelExtTable_BTree);
*my_loop_context = xBTree_nodeGetFirst (&oMplsTunnelTable_BTree);
return mplsTunnelExtTable_getNext (my_loop_context, my_data_context, put_index_data, mydata);
}

Expand All @@ -242,14 +185,14 @@ mplsTunnelExtTable_getNext (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
mplsTunnelExtEntry_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, mplsTunnelExtEntry_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 @@ -258,8 +201,8 @@ mplsTunnelExtTable_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, &oMplsTunnelExtTable_BTree);
*my_data_context = (void*) &poEntry->oX;
*my_loop_context = (void*) xBTree_nodeGetNext (&poEntry->oBTreeNode, &oMplsTunnelTable_BTree);
return put_index_data;
}

Expand All @@ -268,13 +211,13 @@ mplsTunnelExtTable_get (
void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
mplsTunnelExtEntry_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 = mplsTunnelExtTable_getByIndex (
poEntry = mplsTunnelTable_getByIndex (
*idx1->val.integer,
*idx2->val.integer,
*idx3->val.integer,
Expand All @@ -284,7 +227,7 @@ mplsTunnelExtTable_get (
return false;
}

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

Expand Down
2 changes: 2 additions & 0 deletions mpls/mplsTeStdMIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {



#include "mplsTeExtStdMIB.h"
#include "neMplsTeMIB.h"

#include "lib/binaryTree.h"
Expand Down Expand Up @@ -1035,6 +1036,7 @@ typedef struct mplsTunnelEntry_t
uint8_t u8StorageType;

mplsTunnelPerfEntry_t oPerf;
mplsTunnelExtEntry_t oX;
gmplsTunnelEntry_t oG;
gmplsTunnelReversePerfEntry_t oReversePerf;
neMplsTunnelEntry_t oNe;
Expand Down

0 comments on commit 126fc08

Please sign in to comment.