Skip to content

Commit

Permalink
[nes]: STP changes ...
Browse files Browse the repository at this point in the history
  • Loading branch information
nes-repo committed Jun 2, 2015
1 parent 58aa3dd commit 0d76f08
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include ${MK_COMMON}
CFLAGS +=

SNMP_SRC := ieee8021SpanningTreeMib.c ieee8021MstpMib.c neIeee8021StpMIB.c
MODULE_SRC := stp_main.c ${SNMP_SRC}
MODULE_SRC := stp_main.c stpUtils.c ${SNMP_SRC}

$(call MODULE_DEP,${MODULE_SRC},${CFLAGS},${INCLUDES})

Expand Down
65 changes: 65 additions & 0 deletions stp/ieee8021SpanningTreeMib.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ extern "C" {



#include "ieee8021MstpMib.h"
#include "neIeee8021StpMIB.h"

#include "lib/binaryTree.h"
#include "lib/snmp.h"

#include <stdbool.h>
#include <stdint.h>

#define TOBE_REPLACED 1


Expand Down Expand Up @@ -129,6 +135,62 @@ Netsnmp_Node_Handler ieee8021SpanningTreeTable_mapper;
#endif /* SNMP_SRC */


/**
* table ieee8021SpanningTreePortExtensionTable definitions
*/
#define IEEE8021SPANNINGTREEPORTRSTPAUTOEDGEPORT 1
#define IEEE8021SPANNINGTREEPORTRSTPAUTOISOLATEPORT 2
#define IEEE8021SPANNINGTREEPORTRSTPISOLATEPORT 3

enum
{
/* enums for column ieee8021SpanningTreePortRstpAutoEdgePort */
ieee8021SpanningTreePortRstpAutoEdgePort_true_c = 1,
ieee8021SpanningTreePortRstpAutoEdgePort_false_c = 2,

/* enums for column ieee8021SpanningTreePortRstpAutoIsolatePort */
ieee8021SpanningTreePortRstpAutoIsolatePort_true_c = 1,
ieee8021SpanningTreePortRstpAutoIsolatePort_false_c = 2,

/* enums for column ieee8021SpanningTreePortRstpIsolatePort */
ieee8021SpanningTreePortRstpIsolatePort_true_c = 1,
ieee8021SpanningTreePortRstpIsolatePort_false_c = 2,
};

/* table ieee8021SpanningTreePortExtensionTable row entry data structure */
typedef struct ieee8021SpanningTreePortExtensionEntry_t
{
/* Index values */
// uint32_t u32ComponentId;
// uint32_t u32Port;

/* Column values */
uint8_t u8AutoEdgePort;
uint8_t u8AutoIsolatePort;
uint8_t u8IsolatePort;

// xBTree_Node_t oBTreeNode;
} ieee8021SpanningTreePortExtensionEntry_t;

// extern xBTree_t oIeee8021SpanningTreePortExtensionTable_BTree;

/* ieee8021SpanningTreePortExtensionTable table mapper */
void ieee8021SpanningTreePortExtensionTable_init (void);
ieee8021SpanningTreePortExtensionEntry_t * ieee8021SpanningTreePortExtensionTable_createEntry (
uint32_t u32ComponentId,
uint32_t u32Port);
ieee8021SpanningTreePortExtensionEntry_t * ieee8021SpanningTreePortExtensionTable_getByIndex (
uint32_t u32ComponentId,
uint32_t u32Port);
ieee8021SpanningTreePortExtensionEntry_t * ieee8021SpanningTreePortExtensionTable_getNextIndex (
uint32_t u32ComponentId,
uint32_t u32Port);
void ieee8021SpanningTreePortExtensionTable_removeEntry (ieee8021SpanningTreePortExtensionEntry_t *poEntry);
#ifdef SNMP_SRC
Netsnmp_Node_Handler ieee8021SpanningTreePortExtensionTable_mapper;
#endif /* SNMP_SRC */


/**
* table ieee8021SpanningTreePortTable definitions
*/
Expand Down Expand Up @@ -200,6 +262,9 @@ typedef struct ieee8021SpanningTreePortEntry_t
int32_t i32RstpPortOperEdgePort;
int32_t i32RstpPortAdminPathCost;

ieee8021MstpCistPortEntry_t oCist;

uint8_t u8AdminStatus;
uint8_t u8RowStatus;

xBTree_Node_t oBTreeNode;
Expand Down
60 changes: 60 additions & 0 deletions stp/stpUtils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2008-2015
#* NES Dev <nes.open.switch@gmail.com>
*
* All rights reserved. This source file is the sole property of NES, and
* contain proprietary and confidential information related to NES.
*
* Licensed under the NES RED License, Version 1.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain a
* copy of the License bundled along with this file. Any kind of reproduction
* or duplication of any part of this file which conflicts with the License
* without prior written consent from NES is strictly prohibited.
*
* Unless required by applicable law and agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
//set ts=4 sw=4

#ifndef __STP_UTILS_C__
# define __STP_UTILS_C__



#include "ieee8021SpanningTreeMib.h"
#include "if/ifMIB.h"

#include "lib/time.h"

#include <stdbool.h>
#include <stdint.h>


bool
ieee8021StpPort_init (
ieee8021SpanningTreeEntry_t *poStp,
ieee8021SpanningTreePortEntry_t *poEntry)
{
poEntry->i32State = poEntry->u8AdminStatus != ifAdminStatus_up_c ? ieee8021SpanningTreePortState_disabled_c: ieee8021SpanningTreePortState_blocking_c;
memcpy (poEntry->au8DesignatedRoot, poStp->au8DesignatedRoot, sizeof (poEntry->au8DesignatedRoot));
poEntry->i32DesignatedCost = 0;
memcpy (poEntry->au8DesignatedBridge, poStp->au8DesignatedRoot, sizeof (poEntry->au8DesignatedBridge));
memset (poEntry->au8DesignatedPort, 0, sizeof (poEntry->au8DesignatedPort));
poEntry->u64ForwardTransitions = 0;
//poEntry->u8RstpOperEdgePort = poEntry->u8RstpAdminEdgePort;
poEntry->oCist.u32Uptime = xTime_centiTime (xTime_typeMono_c);
memcpy (poEntry->oCist.au8DesignatedRoot, poStp->au8DesignatedRoot, sizeof (poEntry->oCist.au8DesignatedRoot));
//poEntry->oCist.u8OperEdgePort = poEntry->oCist.u8AdminEdgePort;
//poEntry->oCist.u8Disputed = ieee8021MstpCistPortDisputed_false_c;
memcpy (poEntry->oCist.au8CistRegionalRootId, poStp->au8DesignatedRoot, sizeof (poEntry->oCist.au8CistRegionalRootId));
poEntry->oCist.u32CistPathCost = 0;

return true;
}



#endif // __STP_UTILS_C__
38 changes: 38 additions & 0 deletions stp/stpUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2008-2015
* NES Dev <nes.open.switch@gmail.com>
*
* All rights reserved. This source file is the sole property of NES, and
* contain proprietary and confidential information related to NES.
*
* Licensed under the NES RED License, Version 1.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain a
* copy of the License bundled along with this file. Any kind of reproduction
* or duplication of any part of this file which conflicts with the License
* without prior written consent from NES is strictly prohibited.
*
* Unless required by applicable law and agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
//set ts=4 sw=4

#ifndef __STP_UTILS_H__
# define __STP_UTILS_H__

# ifdef __cplusplus
extern "C" {
# endif






# ifdef __cplusplus
}
# endif

#endif // __STP_UTILS_H__

0 comments on commit 0d76f08

Please sign in to comment.