summaryrefslogtreecommitdiff
path: root/cleopatre/application/spidnetsnmp/agent/mibgroup
diff options
context:
space:
mode:
authorTom Yang2012-06-08 07:46:37 +0530
committerTom Yang2012-06-11 15:31:10 +0530
commitc85004bf2e9c262b78fc1caa9078622d01a82edc (patch)
tree6efc990e548065949855c63c7ec6568e61839533 /cleopatre/application/spidnetsnmp/agent/mibgroup
parentccee323a07fd42df98e0b8c99d6f217139c8c448 (diff)
cleo/app/snmp[eoc]: add the support of eocCNUConfigurationSaving, closes #3118
- fixed eocCNUAuthorizationState not correct
Diffstat (limited to 'cleopatre/application/spidnetsnmp/agent/mibgroup')
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable.h1
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_access.c11
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_set.c51
3 files changed, 58 insertions, 5 deletions
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable.h
index e38b2b0404..403d593a82 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable.h
@@ -265,6 +265,7 @@ typedef struct eocCNUTable_ref_rowreq_ctx_s {
extern oid eocCNUTable_oid[];
extern int eocCNUTable_oid_size;
+extern int saving_result[LIBSPID_WHITE_LIST_MAX_STA_NUM];
#include "eocCNUTable_interface.h"
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_access.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_access.c
index 9680d83b0f..ad0d9e3c39 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_access.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_access.c
@@ -14,7 +14,9 @@
#include "eocCNUTable_data_access.h"
-#define DEMO_PATH "/onlinedemo.info"
+
+int saving_result[LIBSPID_WHITE_LIST_MAX_STA_NUM];
+
/** @ingroup interface
* @addtogroup data_access data_access: Routines to access data
@@ -125,6 +127,8 @@ eocCNUTable_container_init(netsnmp_container **container_ptr_ptr,
cache->timeout = EOCCNUTABLE_CACHE_TIMEOUT; /* seconds */
/* adjust cache flags */
cache->flags |= ( NETSNMP_CACHE_PRELOAD );
+
+ memset (saving_result, 0, sizeof (saving_result));
} /* eocCNUTable_container_init */
/**
@@ -563,7 +567,7 @@ eocCNUTable_row_prep (eocCNUTable_rowreq_ctx *rowreq_ctx)
if (rc == LIBSPID_ERROR_NOT_FOUND)
{
- eocCNUAuthorizationState = EOCCNUAUTHORIZATIONSTATE_AUTHORIZED;
+ eocCNUAuthorizationState = EOCCNUAUTHORIZATIONSTATE_NOT_AUTHORIZED;
}
else
{
@@ -795,7 +799,8 @@ eocCNUTable_row_prep (eocCNUTable_rowreq_ctx *rowreq_ctx)
* enums usually need mapping.
*/
- rowreq_ctx->data.eocCNUConfigurationResult = eocCNUConfigurationResult;
+ rowreq_ctx->data.eocCNUConfigurationResult =
+ saving_result[rowreq_ctx->tbl_idx.eocCNUIndex];
return MFD_SUCCESS;
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_set.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_set.c
index 4c6d9aa40f..e335394f64 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_set.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocCNUGroup/eocCNU/eocCNUTable/eocCNUTable_data_set.c
@@ -585,7 +585,8 @@ eocCNUReset_set( eocCNUTable_rowreq_ctx *rowreq_ctx, u_long eocCNUReset_val )
}
/* check if slave is authorized before attempting reset */
- if (LIBSPID_SUCCESS != libspid_eoc_wl_authorization (mac_str))
+ if (rowreq_ctx->data.eocCNUAuthorizationState ==
+ EOCCNUAUTHORIZATIONSTATE_NOT_AUTHORIZED)
return SNMP_ERR_AUTHORIZATIONERROR;
if (LIBSPID_SUCCESS == libspid_eoc_reboot (mac_str))
@@ -759,17 +760,63 @@ eocCNUConfigurationSaving_undo_setup( eocCNUTable_rowreq_ctx *rowreq_ctx)
int
eocCNUConfigurationSaving_set( eocCNUTable_rowreq_ctx *rowreq_ctx, u_long eocCNUConfigurationSaving_val )
{
+ char mac_str[LIBSPID_MAC_STR_LEN];
DEBUGMSGTL(("verbose:eocCNUTable:eocCNUConfigurationSaving_set","called\n"));
/** should never get a NULL pointer */
netsnmp_assert (NULL != rowreq_ctx);
+ switch (eocCNUConfigurationSaving_val)
+ {
+ case EOCCNUCONFIGURATIONSAVING_SAVE:
+ /* if saving value is given, call libspid function for rebooting
+ * slave with MAC address corresponding to current row */
+
+ /* convert MAC address from char array to string */
+ if (LIBSPID_SUCCESS !=
+ libspid_mac_bin_to_str (rowreq_ctx->data.eocCNUMACAddress,
+ mac_str))
+ {
+ snmp_log (LOG_ERR, "libspid_mac_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+
+ /* check if slave is authorized before attempting reset */
+ if (rowreq_ctx->data.eocCNUAuthorizationState ==
+ EOCCNUAUTHORIZATIONSTATE_NOT_AUTHORIZED)
+ return SNMP_ERR_AUTHORIZATIONERROR;
+
+ if (LIBSPID_SUCCESS == libspid_eoc_reboot (mac_str))
+ {
+ rowreq_ctx->data.eocCNUConfigurationSaving =
+ EOCCNUCONFIGURATIONSAVING_SAVE;
+ saving_result[rowreq_ctx->tbl_idx.eocCNUIndex] =
+ EOCCNUCONFIGURATIONRESULT_SUCCESS;
+ }
+ else
+ {
+ snmp_log (LOG_ERR,
+ "Couldn't reboot slave for MAC address: %s \n",
+ mac_str);
+ rowreq_ctx->data.eocCNUConfigurationSaving =
+ EOCCNUCONFIGURATIONSAVING_SAVE;
+ saving_result[rowreq_ctx->tbl_idx.eocCNUIndex] =
+ EOCCNUCONFIGURATIONRESULT_FAILED;
+ }
+ break;
+
+ default:
+ snmp_log (LOG_ERR,
+ "couldn't reverse map value %ld"
+ " for eocCNUConfigurationSaving\n",
+ eocCNUConfigurationSaving_val);
+ return SNMP_ERR_GENERR;
+ }
/*
* TODO:461:M: |-> Set eocCNUConfigurationSaving value.
* set eocCNUConfigurationSaving value in rowreq_ctx->data
*/
- rowreq_ctx->data.eocCNUConfigurationSaving = eocCNUConfigurationSaving_val;
return MFD_SUCCESS;
}