summaryrefslogtreecommitdiff
path: root/cleopatre/application/spidnetsnmp/agent/mibgroup
diff options
context:
space:
mode:
authorTom Yang2012-05-11 19:43:50 +0530
committerLysin Miao2012-05-21 20:41:11 +0800
commit335c3717d4e2366590dd442207534a626e2712d4 (patch)
treeb5c4dc24f8bfd6f339ad6aefeac72ab3ae54c8e3 /cleopatre/application/spidnetsnmp/agent/mibgroup
parent4ebc575bc39900f0c70b205c3ff9cc7abe5402c2 (diff)
cleo/app/spidnetsnmp[eoc]: implement eocCNUPort of the NSCRTV-EPONEOC-MOD-EOC-MIB, closes #3021
Diffstat (limited to 'cleopatre/application/spidnetsnmp/agent/mibgroup')
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup.h2
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort.h4
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.c123
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.h3
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable.h10
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable.h12
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.c231
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.h8
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set.c311
9 files changed, 493 insertions, 211 deletions
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup.h
index e992cdccb8..78ca8518a1 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup.h
@@ -1,5 +1,5 @@
//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUService)
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort)
//config_require(mstar-eoc-mib/eocCNUGroup/eocCNU)
config_require(mstar-eoc-mib/eocCNUGroup/eocCNUUnauthList)
config_require(mstar-eoc-mib/eocCNUGroup/eocCNUWhiteList)
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort.h
index 039e097213..48ff31d7a3 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort.h
@@ -1,2 +1,2 @@
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable)
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort)
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.c
index b52e0b6fd7..8caf677c5a 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.c
@@ -7,7 +7,6 @@
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "eocCNUPort.h"
-
/** Initializes the eocCNUPort module */
void
init_eocCNUPort(void)
@@ -40,20 +39,21 @@ handle_eocCNUPortPerCNULimitation(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
-
- switch(reqinfo->mode) {
-
- case MODE_GET:
- snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
- (u_char *) /* XXX: a pointer to the scalar's data */,
- /* XXX: the length of the data in bytes */);
- break;
-
-
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_eocCNUPortPerCNULimitation\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
+ int port_per_cnu_limit = LIBSPID_PORT_PER_SLAVE_MAX;
+
+ switch (reqinfo->mode)
+ {
+ case MODE_GET:
+ snmp_set_var_typed_value (requests->requestvb, ASN_INTEGER,
+ (u_char *) & port_per_cnu_limit,
+ sizeof (port_per_cnu_limit));
+ break;
+ default:
+ /* we should never get here, so this is a really bad error */
+ snmp_log (LOG_ERR,
+ "unknown mode (%d) in handle_eocCNUPortPerCNULimitation\n",
+ reqinfo->mode);
+ return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
@@ -70,69 +70,36 @@ handle_eocCNUPortAmountLimitation(netsnmp_mib_handler *handler,
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
-
- switch(reqinfo->mode) {
-
- case MODE_GET:
- snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
- (u_char *) /* XXX: a pointer to the scalar's data */,
- /* XXX: the length of the data in bytes */);
- break;
-
- /*
- * SET REQUEST
- *
- * multiple states in the transaction. See:
- * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
- */
- case MODE_SET_RESERVE1:
- /* or you could use netsnmp_check_vb_type_and_size instead */
- ret = netsnmp_check_vb_type(requests->requestvb, ASN_INTEGER);
- if ( ret != SNMP_ERR_NOERROR ) {
- netsnmp_set_request_error(reqinfo, requests, ret );
- }
- break;
-
- case MODE_SET_RESERVE2:
- /* XXX malloc "undo" storage buffer */
- if (/* XXX if malloc, or whatever, failed: */) {
- netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE);
- }
- break;
-
- case MODE_SET_FREE:
- /* XXX: free resources allocated in RESERVE1 and/or
- RESERVE2. Something failed somewhere, and the states
- below won't be called. */
- break;
-
- case MODE_SET_ACTION:
- /* XXX: perform the value change here */
- if (/* XXX: error? */) {
- netsnmp_set_request_error(reqinfo, requests, /* some error */);
- }
- break;
-
- case MODE_SET_COMMIT:
- /* XXX: delete temporary storage */
- if (/* XXX: error? */) {
- /* try _really_really_ hard to never get to this point */
- netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED);
- }
- break;
-
- case MODE_SET_UNDO:
- /* XXX: UNDO and return to previous value for the object */
- if (/* XXX: error? */) {
- /* try _really_really_ hard to never get to this point */
- netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED);
- }
- break;
-
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_eocCNUPortAmountLimitation\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
+ int amount_limit = LIBSPID_PORT_TOTAL_MAX;
+
+ switch (reqinfo->mode)
+ {
+ case MODE_GET:
+ snmp_set_var_typed_value (requests->requestvb, ASN_INTEGER,
+ (u_char *) & amount_limit,
+ sizeof (amount_limit));
+ break;
+ case MODE_SET_RESERVE1:
+ break;
+
+ case MODE_SET_RESERVE2:
+ break;
+
+ case MODE_SET_FREE:
+ break;
+
+ case MODE_SET_ACTION:
+ netsnmp_set_request_error (reqinfo, requests, SNMP_ERR_NOTWRITABLE);
+ break;
+ case MODE_SET_COMMIT:
+ break;
+ case MODE_SET_UNDO:
+ break;
+ default:
+ snmp_log (LOG_ERR,
+ "unknown mode (%d) in handle_eocCNUPortAmountLimitation\n",
+ reqinfo->mode);
+ return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.h
index c57919ae02..52c516811d 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPort.h
@@ -5,6 +5,9 @@
#ifndef EOCCNUPORT_H
#define EOCCNUPORT_H
+/* include common header */
+#include "EoCCommon.h"
+
/* function declarations */
void init_eocCNUPort(void);
Netsnmp_Node_Handler handle_eocCNUPortPerCNULimitation;
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable.h
index 55fdaa400d..2c0ee2f568 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable.h
@@ -1,5 +1,5 @@
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable)
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set)
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access)
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_get)
-//config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_interface)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_get)
+config_require(mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_interface)
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable.h
index a66298f151..894eea57b7 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable.h
@@ -19,13 +19,7 @@ extern "C" {
#include <net-snmp/library/asn1.h>
/* other required module components */
- /* *INDENT-OFF* */
-config_add_mib(NSCRTV-EPONEOC-MOD-EOC-MIB)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocCNUPortTable/eocCNUPortTable_interface)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocCNUPortTable/eocCNUPortTable_data_access)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocCNUPortTable/eocCNUPortTable_data_get)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocCNUPortTable/eocCNUPortTable_data_set)
- /* *INDENT-ON* */
+
/* OID and column number definitions for eocCNUPortTable */
#include "eocCNUPortTable_oids.h"
@@ -33,6 +27,9 @@ config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocCNUPortTable/eocCNUPortTable_data_s
/* enum definions */
#include "eocCNUPortTable_enums.h"
+/* include common header */
+#include "EoCCommon.h"
+
/* *********************************************************************
* function declarations
*/
@@ -77,6 +74,7 @@ typedef netsnmp_data_list eocCNUPortTable_registration;
*/
typedef struct eocCNUPortTable_data_s {
+ char eocCNUPortMACAddress[LIBSPID_MAC_STR_LEN];
/*
* eocCNUPortEN(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
*/
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.c
index a3fe23ce1f..308266fc3c 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.c
@@ -1,6 +1,6 @@
/*
* Note: this file originally auto-generated by mib2c using
- * version : 14170 $ of $
+ * version : 14170 $ of $
*
* $Id:$
*/
@@ -14,13 +14,12 @@
#include "eocCNUPortTable_data_access.h"
-
/** @ingroup interface
* @addtogroup data_access data_access: Routines to access data
*
* These routines are used to locate the data used to satisfy
* requests.
- *
+ *
* @{
*/
/**********************************************************************
@@ -96,7 +95,7 @@ eocCNUPortTable_container_init(netsnmp_container **container_ptr_ptr,
netsnmp_cache *cache)
{
DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortTable_container_init","called\n"));
-
+
if (NULL == container_ptr_ptr) {
snmp_log(LOG_ERR,"bad container param to eocCNUPortTable_container_init\n");
return;
@@ -144,7 +143,7 @@ void
eocCNUPortTable_container_shutdown(netsnmp_container *container_ptr)
{
DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortTable_container_shutdown","called\n"));
-
+
if (NULL == container_ptr) {
snmp_log(LOG_ERR,"bad params to eocCNUPortTable_container_shutdown\n");
return;
@@ -189,26 +188,41 @@ int
eocCNUPortTable_container_load(netsnmp_container *container)
{
eocCNUPortTable_rowreq_ctx *rowreq_ctx;
- size_t count = 0;
+ size_t count = 0;
+ int rc = MFD_SUCCESS;
/*
* temporary storage for index values
*/
- /*
- * eocCNUPortCBATCardIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
- */
- long eocCNUPortCBATCardIndex;
- /*
- * eocCNUPortCNUIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
- */
- long eocCNUPortCNUIndex;
- /*
- * eocCNUPortIndex(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
- */
- long eocCNUPortIndex;
+ /*
+ * eocCNUPortCBATCardIndex(1)/
+ * INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
+ */
+ long eocCNUPortCBATCardIndex = 0;
+ /*
+ * eocCNUPortCNUIndex(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
+ */
+ long eocCNUPortCNUIndex;
+ /*
+ * eocCNUPortIndex(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h
+ */
+ long eocCNUPortIndex;
+
+ u_long eocCNUPortEN = 0;
+ long eocCNUPortService = 0;
+ int i, j;
+ int port_count;
- DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortTable_container_load","called\n"));
+ /* declarations for calls to libspid */
+ char mac_str[LIBSPID_MAC_STR_LEN];
+ char *index_str;
+ libspid_eoc_wl_entry_t eoc_wl_entry;
+ int tei;
+ int ret;
+
+ /* port entries read from config file */
+ libspid_eoc_port_entry_t port_entries[LIBSPID_PORT_TOTAL_MAX];
/*
* TODO:351:M: |-> Load/update data in the eocCNUPortTable container.
@@ -216,69 +230,166 @@ eocCNUPortTable_container_load(netsnmp_container *container)
* set the index(es) [and data, optionally] and insert into
* the container.
*/
- while( 1 ) {
- /*
- * check for end of data; bail out if there is no more data
- */
- if( 1 )
- break;
+ memset (port_entries, 0x0, sizeof (port_entries));
+ /* check errors in contents of port list prior to
+ * reading and log message if errors are found */
+ if (LIBSPID_SUCCESS != libspid_eoc_port_check ())
+ {
+ snmp_log (LOG_ERR,
+ "errors detected in port config file, refer to syslog\n");
+ }
+ /* get current contents of port config file */
+ if (LIBSPID_SUCCESS !=
+ libspid_eoc_port_get_list (port_entries, &port_count))
+ {
+ snmp_log (LOG_ERR, "port config file not read correctly\n");
+ return MFD_ERROR;
+ }
+
+ if (0 == port_count)
+ {
+ rc = MFD_END_OF_DATA;
+ }
+
+ DEBUGMSGTL (("verbose:eocCNUPortTable:eocCNUPortTable_container_load",
+ "port_count = %d\n", port_count));
+
+ for (i = 0; i < port_count; i++)
+ {
+
+ /* parse port index from port entry */
+ if (1 != sscanf (port_entries[i].port_index, "%ld", &eocCNUPortIndex))
+ {
+ snmp_log (LOG_ERR,
+ "parsing failed, setting port index to invalid\n");
+ eocCNUPortIndex = INVALID_EOCCNUPORTINDEX;
+ }
+
+ /* copy MAC address from port entry to avoid
+ * being corrupted by call to read_line in wl_get */
+ strncpy (mac_str, port_entries[i].mac_addr, LIBSPID_MAC_STR_LEN);
+
+
+ memset (&eoc_wl_entry, 0, sizeof (eoc_wl_entry));
+
+ /* get white list entry for current MAC address */
+ ret = libspid_eoc_wl_get (mac_str, &eoc_wl_entry);
+
+ if (LIBSPID_SUCCESS == ret)
+ {
+ /* parse current TEI from white list entry */
+ if (1 != sscanf (eoc_wl_entry.tei, "%d", &tei))
+ {
+ snmp_log (LOG_ERR,
+ "error parsing TEI from white list entry, "
+ "setting CNUIndex value to invalid\n");
+ eocCNUPortCNUIndex = INVALID_EOCCNUPORTCNUINDEX;
+ }
+ else
+ {
+ /* convert current TEI to slave index */
+ eocCNUPortCNUIndex = tei - 2;
+ }
+ }
+ else
+ {
+ snmp_log (LOG_ERR,
+ "PortTable_container_load: "
+ "cannot find White list entry with current MAC, "
+ "setting CNUIndex value to invalid\n");
+ eocCNUPortCNUIndex = INVALID_EOCCNUPORTCNUINDEX;
+ }
/*
- * TODO:352:M: | |-> set indexes in new eocCNUPortTable rowreq context.
+ * TODO:352:M: | |-> set indexes in new eocCNUPortTable rowreq
+ * context.
* data context will be set from the param (unless NULL,
* in which case a new data context will be allocated)
*/
- rowreq_ctx = eocCNUPortTable_allocate_rowreq_ctx(NULL);
- if (NULL == rowreq_ctx) {
- snmp_log(LOG_ERR, "memory allocation failed\n");
+ rowreq_ctx = eocCNUPortTable_allocate_rowreq_ctx (NULL);
+ if (NULL == rowreq_ctx)
+ {
+ snmp_log (LOG_ERR, "memory allocation failed\n");
return MFD_RESOURCE_UNAVAILABLE;
}
- if(MFD_SUCCESS != eocCNUPortTable_indexes_set(rowreq_ctx
- , eocCNUPortCBATCardIndex
- , eocCNUPortCNUIndex
- , eocCNUPortIndex
- )) {
- snmp_log(LOG_ERR,"error setting index while loading "
- "eocCNUPortTable data.\n");
- eocCNUPortTable_release_rowreq_ctx(rowreq_ctx);
+ if (MFD_SUCCESS !=
+ eocCNUPortTable_indexes_set (rowreq_ctx,
+ eocCNUPortCBATCardIndex,
+ eocCNUPortCNUIndex,
+ eocCNUPortIndex))
+ {
+ snmp_log (LOG_ERR,
+ "error setting index while loading "
+ "eocCNUPortTable data.\n");
+ eocCNUPortTable_release_rowreq_ctx (rowreq_ctx);
continue;
}
+ /* copy slave MAC address to row request context */
+ strcpy (rowreq_ctx->data.eocCNUPortMACAddress,
+ port_entries[i].mac_addr);
+
/*
* TODO:352:r: | |-> populate eocCNUPortTable data context.
* Populate data context here. (optionally, delay until row prep)
*/
- /*
- * TRANSIENT or semi-TRANSIENT data:
- * copy data or save any info needed to do it in row_prep.
- */
- /*
- * setup/save data for eocCNUPortEN
- * eocCNUPortEN(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
- */
- /** no mapping */
- rowreq_ctx->data.eocCNUPortEN = eocCNUPortEN;
-
- /*
- * setup/save data for eocCNUPortService
- * eocCNUPortService(5)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/r/d/h
- */
- /** no mapping */
- rowreq_ctx->data.eocCNUPortService = eocCNUPortService;
-
-
+ /*
+ * TRANSIENT or semi-TRANSIENT data:
+ * copy data or save any info needed to do it in row_prep.
+ */
+ /*
+ * setup/save data for eocCNUPortEN
+ * eocCNUPortEN(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ */
+ if (1 != sscanf (port_entries[i].port_en, "%lu", &eocCNUPortEN))
+ {
+ snmp_log (LOG_ERR,
+ "parsing failed, setting port enable to invalid\n");
+ eocCNUPortEN = INVALID_EOCCNUPORTEN;
+ }
+
+ /*
+ * TODO:246:r: |-> Define eocCNUPortEN mapping.
+ * Map values between raw/native values and MIB values
+ *
+ * enums usually need mapping.
+ */
+ /* mapping unnecessary here */
+ rowreq_ctx->data.eocCNUPortEN = eocCNUPortEN;
+
+ /*
+ * setup/save data for eocCNUPortService
+ * eocCNUPortService(5)/INTEGER/ASN_INTEGER/long(long)//l/A/W/e/r/d/h
+ */
+ if (1 != sscanf (port_entries[i].service_index, "%ld",
+ &eocCNUPortService))
+ {
+ snmp_log (LOG_ERR,
+ "parsing failed, setting port service to invalid\n");
+ eocCNUPortService = INVALID_EOCCNUPORTSERVICE;
+ }
+
+ /*
+ * TODO:246:r: |-> Define eocCNUPortService mapping.
+ * Map values between raw/native values and MIB values
+ *
+ * Integer based value can usually just do a direct copy.
+ */
+ rowreq_ctx->data.eocCNUPortService = eocCNUPortService;
+
/*
* insert into table container
*/
- CONTAINER_INSERT(container, rowreq_ctx);
+ CONTAINER_INSERT (container, rowreq_ctx);
++count;
}
- DEBUGMSGT(("verbose:eocCNUPortTable:eocCNUPortTable_container_load",
- "inserted %d records\n", count));
+
+ DEBUGMSGT (("verbose:eocCNUPortTable:eocCNUPortTable_container_load",
+ "inserted %d records\n", count));
return MFD_SUCCESS;
-} /* eocCNUPortTable_container_load */
+}
/**
* container clean up
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.h
index 03de7522b1..c7c268725c 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_access.h
@@ -32,6 +32,14 @@ extern "C" {
* OID: .1.3.6.1.4.1.17409.2.4.5.4.3, length: 12
*/
+#define INVALID_EOCCNUPORTCNUINDEX (-2)
+#define INVALID_EOCCNUPORTINDEX (-2)
+#define INVALID_EOCCNUPORTEN 2
+#define INVALID_EOCCNUPORTSERVICE (-1)
+#define INVALID_EOCCNUPORTVLANTAGEN 2
+#define INVALID_EOCCNUPORTVLANMARKID (-1)
+
+
int eocCNUPortTable_init_data(eocCNUPortTable_registration * eocCNUPortTable_reg);
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set.c
index 2dd8359a74..748c44c362 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNUPort/eocCNUPortTable/eocCNUPortTable_data_set.c
@@ -12,13 +12,14 @@
/* include our parent header */
#include "eocCNUPortTable.h"
+#include "libspid.h"
/** @defgroup data_set data_set: Routines to set data
*
* These routines are used to set the value for individual objects. The
* row context is passed, along with the new value.
- *
+ *
* @{
*/
/**********************************************************************
@@ -240,13 +241,21 @@ int
eocCNUPortTable_commit( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
{
int rc = MFD_SUCCESS;
- int save_flags;
-
- DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortTable_commit","called\n"));
+ int save_flags;
+ int ret;
+ libspid_eoc_port_entry_t port_entry;
+ char port_key[LIBSPID_LINE_MAX_LEN];
+ DEBUGMSGTL (("verbose:eocCNUPortTable:eocCNUPortTable_commit",
+ "called\n"));
/** we should have a non-NULL pointer */
- netsnmp_assert( NULL != rowreq_ctx );
+ netsnmp_assert ( NULL != rowreq_ctx );
+
+ /* check if current MAC address is valid */
+ netsnmp_assert (NULL != rowreq_ctx->data.eocCNUPortMACAddress);
+ /* initialize port entry */
+ memset (&port_entry, 0, sizeof (port_entry));
/*
* save flags, then clear until we actually do something
*/
@@ -260,49 +269,109 @@ eocCNUPortTable_commit( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
* 3) set the column's flag in column_set_flags if it needs undo
* processing in case of a failure.
*/
- if (save_flags & COLUMN_EOCCNUPORTEN_FLAG) {
- save_flags &= ~COLUMN_EOCCNUPORTEN_FLAG; /* clear eocCNUPortEN */
- /*
- * TODO:482:o: |-> commit column eocCNUPortEN.
- */
- rc = -1;
- if(-1 == rc) {
- snmp_log(LOG_ERR,"eocCNUPortTable column eocCNUPortEN commit failed\n");
- }
- else {
- /*
- * set flag, in case we need to undo eocCNUPortEN
- */
- rowreq_ctx->column_set_flags |= COLUMN_EOCCNUPORTEN_FLAG;
- }
+ if (0 == save_flags)
+ {
+ DEBUGMSGTL (("modEoCCNUPortTable:modEoCCNUPortTable_commit",
+ "no change\n"));
+ return MFD_SUCCESS;
}
- if (save_flags & COLUMN_EOCCNUPORTSERVICE_FLAG) {
- save_flags &= ~COLUMN_EOCCNUPORTSERVICE_FLAG; /* clear eocCNUPortService */
- /*
- * TODO:482:o: |-> commit column eocCNUPortService.
- */
- rc = -1;
- if(-1 == rc) {
- snmp_log(LOG_ERR,"eocCNUPortTable column eocCNUPortService commit failed\n");
- }
- else {
- /*
- * set flag, in case we need to undo eocCNUPortService
- */
- rowreq_ctx->column_set_flags |= COLUMN_EOCCNUPORTSERVICE_FLAG;
- }
+ if (save_flags & COLUMN_EOCCNUPORTEN_FLAG)
+ {
+ save_flags &= ~COLUMN_EOCCNUPORTEN_FLAG; /* clear eocCNUPortEN */
+ /*
+ * set flag, in case we need to undo eocCNUPortEN
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_EOCCNUPORTEN_FLAG;
+ }
+
+ if (save_flags & COLUMN_EOCCNUPORTSERVICE_FLAG)
+ {
+ /* clear eocCNUPortService */
+ save_flags &= ~COLUMN_EOCCNUPORTSERVICE_FLAG;
+ /*
+ * set flag, in case we need to undo modEoCCNUPortService
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_EOCCNUPORTSERVICE_FLAG;
+ }
+
+ /* convert port index to string */
+ sprintf (port_key, "%ld", rowreq_ctx->tbl_idx.eocCNUPortIndex);
+
+ /* read existing line from configuration file */
+ ret = libspid_eoc_port_get (
+ rowreq_ctx->data.eocCNUPortMACAddress,
+ port_key, &port_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_get error\n");
+ return MFD_ERROR;
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCCNUPORTEN_FLAG)
+ {
+ /* copy port enable to port entry */
+ sprintf (port_entry.port_en, "%lu", rowreq_ctx->data.eocCNUPortEN);
+ }
+
+ /* VLANTagEN and VLANMarkID for port entry are set to 0 along with service */
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCCNUPORTSERVICE_FLAG)
+ {
+ /* copy service to port entry */
+ sprintf (port_entry.service_index, "%ld",
+ rowreq_ctx->data.eocCNUPortService);
+ sprintf (port_entry.vlan_tag_en, "%lu", 0);
+ sprintf (port_entry.vlan_mark_id, "%ld", 0);
+ }
+
+ /* check configuration file before attempting
+ * synchronization of port list */
+ if (LIBSPID_SUCCESS != libspid_eoc_port_check ())
+ {
+ snmp_log (LOG_ERR,
+ "errors detected in port configuration file, cannot sync\n");
+ return MFD_ERROR;
+ }
+ /* write modified line to configuration file */
+ DEBUGMSGTL (("mac Addr %s\r\n", rowreq_ctx->data.eocCNUPortMACAddress));
+ ret = libspid_eoc_port_set (
+ rowreq_ctx->data.eocCNUPortMACAddress,
+ port_key, &port_entry);
+
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_set error\n");
+ return MFD_ERROR;
+ }
+ else
+ {
+ DEBUGMSGTL (("modEoCCNUPortTable_commit",
+ "line succesfully written to conf file!\n"));
+ }
+
+ /* propagate port list changes */
+ ret = libspid_eoc_port_sync ();
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_sync error\n");
+ return MFD_ERROR;
+ }
+ else
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_sync succeeded\n");
}
/*
* if we successfully commited this row, set the dirty flag.
*/
- if (MFD_SUCCESS == rc) {
+ if (MFD_SUCCESS == rc)
+ {
rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY;
}
- if (save_flags) {
- snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags);
+ if (save_flags)
+ {
+ snmp_log (LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags);
return MFD_ERROR;
}
@@ -328,12 +397,17 @@ int
eocCNUPortTable_undo_commit( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
{
int rc = MFD_SUCCESS;
+ int ret;
+ libspid_eoc_port_entry_t port_entry;
+ char port_key[LIBSPID_LINE_MAX_LEN];
- DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortTable_undo_commit","called\n"));
+ DEBUGMSGTL (("verbose:eocCNUPortTable:eocCNUPortTable_undo_commit",
+ "called\n"));
/** we should have a non-NULL pointer */
- netsnmp_assert( NULL != rowreq_ctx );
+ netsnmp_assert (NULL != rowreq_ctx );
+ memset (&port_entry, 0, sizeof (port_entry));
/*
* TODO:485:M: |-> Undo eocCNUPortTable commit.
* check the column's flag in rowreq_ctx->column_set_flags to see
@@ -342,11 +416,82 @@ eocCNUPortTable_undo_commit( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
* eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {}
*/
-
+ /* convert port index to string */
+ sprintf (port_key, "%ld", rowreq_ctx->tbl_idx.eocCNUPortIndex);
+
+ /* read existing line from configuration file */
+ ret = libspid_eoc_port_get (
+ rowreq_ctx->data.eocCNUPortMACAddress,
+ port_key, &port_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_get error\n");
+ return MFD_ERROR;
+ }
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCCNUPORTEN_FLAG)
+ {
+ /* copy port enable to port entry */
+ sprintf (port_entry.port_en, "%lu", rowreq_ctx->undo->eocCNUPortEN);
+ /* copy VLAN Mark ID to port entry (in case it needs undoing) */
+ }
+ /* VLANTagEN and VLANMarkID for port are restored to 0 along with service */
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCCNUPORTSERVICE_FLAG)
+ {
+ /* copy service to port entry */
+ sprintf (port_entry.service_index, "%ld",
+ rowreq_ctx->undo->eocCNUPortService);
+ sprintf (port_entry.vlan_tag_en, "%ld", 0);
+ sprintf (port_entry.vlan_mark_id, "%ld", 0);
+ }
+
+ /* check configuration file before attempting
+ * synchronization of port list */
+ if (LIBSPID_SUCCESS != libspid_eoc_port_check ())
+ {
+ snmp_log (LOG_ERR,
+ "errors detected in port configuration file, cannot sync\n");
+ return MFD_ERROR;
+ }
+
+ /* write modified line to configuration file */
+
+ DEBUGMSGTL (("mac Addr %s\r\n",
+ rowreq_ctx->data.eocCNUPortMACAddress));
+ ret = libspid_eoc_port_set (
+ rowreq_ctx->data.eocCNUPortMACAddress,
+ port_key, &port_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_config_write_line_error\n");
+ DEBUGMSGTL (("modEoCCNUPortTable_undo_commit",
+ "libspid_config_write_line () returned error: %d\n",
+ ret));
+ return MFD_ERROR;
+ }
+ else
+ {
+ DEBUGMSGTL (("modEoCCNUPortTable_undo_commit",
+ "line succesfully written to conf file!\n"));
+ }
+
+ /* propagate port list changes */
+ ret = libspid_eoc_port_sync ();
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_sync error\n");
+ return MFD_ERROR;
+ }
+ else
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_port_sync succeeded\n");
+ }
+
+
/*
* if we successfully un-commited this row, clear the dirty flag.
*/
- if (MFD_SUCCESS == rc) {
+ if (MFD_SUCCESS == rc)
+ {
rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY;
}
@@ -396,12 +541,12 @@ CNU端口启动或关闭,0表示禁止,1表示使能。
* You should check that the requested change between the undo value and the
* new value is legal (ie, the transistion from one value to another
* is legal).
- *
+ *
*@note
* This check is only to determine if the new value
* is \b potentially valid. This is the first check of many, and
* is one of the simplest ones.
- *
+ *
*@note
* this is not the place to do any checks for values
* which depend on some other value in the mib. Those
@@ -482,15 +627,23 @@ eocCNUPortEN_undo_setup( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
int
eocCNUPortEN_set( eocCNUPortTable_rowreq_ctx *rowreq_ctx, u_long eocCNUPortEN_val )
{
+ char key_buffer[LIBSPID_KEY_MAX_LEN] = {0};
+ const char delimiters[2] = LIBSPID_SERVICE_CONF_DELIMITER "\0";
+ char buffer[LIBSPID_KEY_MAX_LEN] = {0};
+ unsigned int elt_number = LIBSPID_ELT_MAX_NB;
+ char *elt_buffer[LIBSPID_ELT_MAX_NB] = {0};
+
+ u_long value;
- DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortEN_set","called\n"));
+ DEBUGMSGTL (("verbose:eocCNUPortTable:eocCNUPortEN_set","called\n"));
/** should never get a NULL pointer */
- netsnmp_assert(NULL != rowreq_ctx);
+ netsnmp_assert (NULL != rowreq_ctx);
/*
- * TODO:461:M: |-> Set eocCNUPortEN value.
- * set eocCNUPortEN value in rowreq_ctx->data
+ * TODO:245:o: |-> Implement eocCNUPortEN reverse mapping.
+ * If the values for your data type don't exactly match the
+ * possible values defined by the mib, you should map them here.
*/
rowreq_ctx->data.eocCNUPortEN = eocCNUPortEN_val;
@@ -520,7 +673,7 @@ eocCNUPortEN_undo( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
*/
rowreq_ctx->data.eocCNUPortEN = rowreq_ctx->undo->eocCNUPortEN;
-
+
return MFD_SUCCESS;
} /* eocCNUPortEN_undo */
@@ -560,12 +713,12 @@ CNU端口业务索引。
* You should check that the requested change between the undo value and the
* new value is legal (ie, the transistion from one value to another
* is legal).
- *
+ *
*@note
* This check is only to determine if the new value
* is \b potentially valid. This is the first check of many, and
* is one of the simplest ones.
- *
+ *
*@note
* this is not the place to do any checks for values
* which depend on some other value in the mib. Those
@@ -581,18 +734,53 @@ CNU端口业务索引。
int
eocCNUPortService_check_value( eocCNUPortTable_rowreq_ctx *rowreq_ctx, long eocCNUPortService_val)
{
- DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortService_check_value","called\n"));
+ /* declarations for calls to libspid */
+ char key_buffer[LIBSPID_KEY_MAX_LEN] = {0};
+ const char delimiters[2] = LIBSPID_SERVICE_CONF_DELIMITER "\0";
+ char buffer[LIBSPID_LINE_MAX_LEN] = {0};
+ unsigned int elt_number = LIBSPID_ELT_MAX_NB;
+ char *elt_buffer[LIBSPID_ELT_MAX_NB] = {0};
+
+ DEBUGMSGTL (("verbose:eocCNUPortTable:eocCNUPortService_check_value",
+ "called\n"));
/** should never get a NULL pointer */
- netsnmp_assert(NULL != rowreq_ctx);
+ netsnmp_assert (NULL != rowreq_ctx);
/*
* TODO:441:o: |-> Check for valid eocCNUPortService value.
*/
+ /* check that proposed service value is between 0 and max allowed */
+ if ((eocCNUPortService_val < 0) ||
+ (eocCNUPortService_val > LIBSPID_SERVICE_AMOUNT_LIMIT))
+ {
+ DEBUGMSGTL(("The Value Is Error:%d",eocCNUPortService_val));
+ return SNMP_ERR_WRONGVALUE;
+ }
- return MFD_SUCCESS; /* eocCNUPortService value not illegal */
-} /* eocCNUPortService_check_value */
+ if (0 == eocCNUPortService_val)
+ {
+ return MFD_SUCCESS;
+ }
+
+ /* convert proposed service value to string to
+ * serve as key for service configuration file */
+ sprintf (key_buffer, "%ld", eocCNUPortService_val);
+
+ /* check that proposed service string exists in
+ * service configuration file */
+ if (LIBSPID_SUCCESS !=
+ libspid_config_read_line (LIBSPID_SERVICE_CONF_PATH,
+ delimiters, key_buffer,
+ &elt_number, elt_buffer,
+ buffer, LIBSPID_LINE_MAX_LEN))
+ {
+ snmp_log (LOG_ERR, "libspid_config_read_line error\n");
+ return SNMP_ERR_WRONGVALUE;
+ }
+ return MFD_SUCCESS;
+}
/**
* Save old value information
*
@@ -645,11 +833,18 @@ eocCNUPortService_undo_setup( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
int
eocCNUPortService_set( eocCNUPortTable_rowreq_ctx *rowreq_ctx, long eocCNUPortService_val )
{
+ /* declarations for calls to libspid */
+ char key_buffer[LIBSPID_KEY_MAX_LEN] = {0};
+ const char delimiters[2] = LIBSPID_SERVICE_CONF_DELIMITER "\0";
+ char buffer[LIBSPID_LINE_MAX_LEN] = {0};
+ unsigned int elt_number = LIBSPID_ELT_MAX_NB;
+ char *elt_buffer[LIBSPID_ELT_MAX_NB] = {0};
+ u_long value;
- DEBUGMSGTL(("verbose:eocCNUPortTable:eocCNUPortService_set","called\n"));
+ DEBUGMSGTL (("verbose:eocCNUPortTable:eocCNUPortService_set","called\n"));
/** should never get a NULL pointer */
- netsnmp_assert(NULL != rowreq_ctx);
+ netsnmp_assert (NULL != rowreq_ctx);
/*
* TODO:461:M: |-> Set eocCNUPortService value.
@@ -683,7 +878,7 @@ eocCNUPortService_undo( eocCNUPortTable_rowreq_ctx *rowreq_ctx)
*/
rowreq_ctx->data.eocCNUPortService = rowreq_ctx->undo->eocCNUPortService;
-
+
return MFD_SUCCESS;
} /* eocCNUPortService_undo */