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 Jul 22, 2015
1 parent 1354749 commit 971a61d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 81 deletions.
92 changes: 17 additions & 75 deletions mpls/mplsTeStdMIB.c
Original file line number Diff line number Diff line change
Expand Up @@ -4392,23 +4392,6 @@ gmplsTunnelTable_init (void)
/* Initialise the contents of the table here */
}

static int8_t
gmplsTunnelTable_BTreeNodeCmp (
xBTree_Node_t *pNode1, xBTree_Node_t *pNode2, xBTree_t *pBTree)
{
register gmplsTunnelEntry_t *pEntry1 = xBTree_entry (pNode1, gmplsTunnelEntry_t, oBTreeNode);
register gmplsTunnelEntry_t *pEntry2 = xBTree_entry (pNode2, gmplsTunnelEntry_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 oGmplsTunnelTable_BTree = xBTree_initInline (&gmplsTunnelTable_BTreeNodeCmp);

/* create a new row in the table */
gmplsTunnelEntry_t *
gmplsTunnelTable_createEntry (
Expand All @@ -4418,21 +4401,13 @@ gmplsTunnelTable_createEntry (
uint32_t u32EgressLSRId)
{
register gmplsTunnelEntry_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, &oGmplsTunnelTable_BTree) != NULL)
{
xBuffer_free (poEntry);
return NULL;
}
poEntry = &poTunnel->oG;

poEntry->u8UnnumIf = gmplsTunnelUnnumIf_false_c;
poEntry->i32LSPEncoding = gmplsTunnelLSPEncoding_tunnelLspNotGmpls_c;
Expand All @@ -4451,7 +4426,6 @@ gmplsTunnelTable_createEntry (
/*poEntry->au8SendPathNotifyRecipient = 0*/;
/*poEntry->aoExtraParamsPtr = zeroDotZero*/;

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

Expand All @@ -4462,26 +4436,14 @@ gmplsTunnelTable_getByIndex (
uint32_t u32IngressLSRId,
uint32_t u32EgressLSRId)
{
register gmplsTunnelEntry_t *poTmpEntry = NULL;
register xBTree_Node_t *poNode = NULL;
register mplsTunnelEntry_t *poTunnel = NULL;

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

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

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, gmplsTunnelEntry_t, oBTreeNode);
return &poTunnel->oG;
}

gmplsTunnelEntry_t *
Expand All @@ -4491,40 +4453,20 @@ gmplsTunnelTable_getNextIndex (
uint32_t u32IngressLSRId,
uint32_t u32EgressLSRId)
{
register gmplsTunnelEntry_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, &oGmplsTunnelTable_BTree)) == NULL)
{
xBuffer_free (poTmpEntry);
return NULL;
}

xBuffer_free (poTmpEntry);
return xBTree_entry (poNode, gmplsTunnelEntry_t, oBTreeNode);
return &poTunnel->oG;
}

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

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

Expand All @@ -4534,7 +4476,7 @@ gmplsTunnelTable_getFirst (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
*my_loop_context = xBTree_nodeGetFirst (&oGmplsTunnelTable_BTree);
*my_loop_context = xBTree_nodeGetFirst (&oMplsTunnelTable_BTree);
return gmplsTunnelTable_getNext (my_loop_context, my_data_context, put_index_data, mydata);
}

Expand All @@ -4543,14 +4485,14 @@ gmplsTunnelTable_getNext (
void **my_loop_context, void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
gmplsTunnelEntry_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, gmplsTunnelEntry_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 @@ -4559,8 +4501,8 @@ gmplsTunnelTable_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, &oGmplsTunnelTable_BTree);
*my_data_context = (void*) &poEntry->oG;
*my_loop_context = (void*) xBTree_nodeGetNext (&poEntry->oBTreeNode, &oMplsTunnelTable_BTree);
return put_index_data;
}

Expand All @@ -4569,13 +4511,13 @@ gmplsTunnelTable_get (
void **my_data_context,
netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata)
{
gmplsTunnelEntry_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 = gmplsTunnelTable_getByIndex (
poEntry = mplsTunnelTable_getByIndex (
*idx1->val.integer,
*idx2->val.integer,
*idx3->val.integer,
Expand All @@ -4585,7 +4527,7 @@ gmplsTunnelTable_get (
return false;
}

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

Expand Down
14 changes: 8 additions & 6 deletions mpls/mplsTeStdMIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ enum
typedef struct gmplsTunnelEntry_t
{
/* Index values */
uint32_t u32Index;
uint32_t u32Instance;
uint32_t u32IngressLSRId;
uint32_t u32EgressLSRId;
// uint32_t u32Index;
// uint32_t u32Instance;
// uint32_t u32IngressLSRId;
// uint32_t u32EgressLSRId;

/* Column values */
uint8_t u8UnnumIf;
Expand Down Expand Up @@ -581,10 +581,10 @@ typedef struct gmplsTunnelEntry_t
xOid_t aoExtraParamsPtr[128];
size_t u16ExtraParamsPtr_len; /* # of xOid_t elements */

xBTree_Node_t oBTreeNode;
// xBTree_Node_t oBTreeNode;
} gmplsTunnelEntry_t;

extern xBTree_t oGmplsTunnelTable_BTree;
// extern xBTree_t oGmplsTunnelTable_BTree;

/* gmplsTunnelTable table mapper */
void gmplsTunnelTable_init (void);
Expand Down Expand Up @@ -1098,6 +1098,8 @@ typedef struct mplsTunnelEntry_t
uint8_t u8RowStatus;
uint8_t u8StorageType;

gmplsTunnelEntry_t oG;

xBTree_Node_t oBTreeNode;
} mplsTunnelEntry_t;

Expand Down

0 comments on commit 971a61d

Please sign in to comment.