summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Yang2012-05-15 11:40:47 +0530
committerLysin Miao2012-05-22 23:55:07 +0800
commitc6221bb0427099c4f3e5676c828fa47621d563fd (patch)
treed6e6d8b4de544d430bab8270c4b71e065a00fb16
parent2bb707f6e27929fbd10b1341b6d209f3b775679c (diff)
cleo/app/snmp[eoc]: implement eocTrapGroup of the NSCRTV-EPONEOC-MOD-EOC-MIB, closes #3025
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib.h2
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup.h4
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c693
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.h3
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable.h10
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable.h46
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.c467
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.h2
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get.c36
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set.c945
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.c375
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.h4
12 files changed, 2058 insertions, 529 deletions
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib.h
index 2314dbf1e7..2e22da6584 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib.h
@@ -6,7 +6,7 @@ config_require(mstar-eoc-mib/eocCBATCardMACGroup)
config_require(mstar-eoc-mib/eocCNUGroup)
config_require(mstar-eoc-mib/eocStatisticGroup)
//config_require(mstar-eoc-mib/eocCBATCardMACGroup)
-//config_require(mstar-eoc-mib/eocTrapGroup)
+config_require(mstar-eoc-mib/eocTrapGroup)
//config_require(mstar-eoc-mib/eocVLANGroup)
config_require(mstar-eoc-mib/eocBroadcastStormProtectionGroup)
config_require(mstar-eoc-mib/eocExtObjects)
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup.h
index 56ac711965..b1a624e12a 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup.h
@@ -1,2 +1,2 @@
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapGroup)
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapGroup)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable)
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c
index c52d7d2460..8bffd7140e 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c
@@ -48,74 +48,172 @@ handle_eocTrapMaxTimes(netsnmp_mib_handler *handler,
netsnmp_request_info *requests)
{
int ret;
+
+ int max_times;
+ int *max_times_save = NULL;
+ long value;
+
+ char buffer[LIBSPID_LINE_MAX_LEN];
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* 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;
+ switch (reqinfo->mode)
+ {
+
+ case MODE_GET:
+ ret = libspid_config_read_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_TIMES,
+ buffer, LIBSPID_LINE_MAX_LEN);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MaxTimes: \
+ libspid_config_read_item error for GET\n");
+ /* max times set to default value to permit walk requests */
+ max_times = TRAP_MAX_TIMES_DEFAULT_VALUE;
+ }
+ else
+ {
+ /* parse max times from buffer */
+ if (1 != sscanf (buffer, "%ld", &value))
+ max_times = TRAP_MAX_TIMES_DEFAULT_VALUE;
+ else if ((TRAP_MAX_TIMES_MIN <= value) &&
+ (TRAP_MAX_TIMES_MAX >= value))
+ max_times = value;
+ else
+ max_times = TRAP_MAX_TIMES_DEFAULT_VALUE;
+ }
+ snmp_set_var_typed_value (requests->requestvb, ASN_INTEGER,
+ (u_char *) & max_times,
+ sizeof (max_times));
+ 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);
+ }
+ /* check range of set value */
+ ret = netsnmp_check_vb_range (requests->requestvb, TRAP_MAX_TIMES_MIN,
+ TRAP_MAX_TIMES_MAX);
+ if (ret != SNMP_ERR_NOERROR)
+ {
+ netsnmp_set_request_error (reqinfo, requests, ret);
+ }
+ break;
+
+ case MODE_SET_RESERVE2:
+ /* malloc "undo" storage buffer */
+ /* read buffer for max times from config file */
+ ret = libspid_config_read_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_TIMES,
+ buffer, LIBSPID_LINE_MAX_LEN);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MaxTimes: \
+ libspid_config_read_item error for RESERVE2\n");
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ else
+ {
+ /* parse max times from buffer */
+ if (1 != sscanf (buffer, "%ld", &value))
+ max_times = TRAP_MAX_TIMES_DEFAULT_VALUE;
+ else
+ max_times = value;
+ }
+
+ memdup ((u_char **) & max_times_save,
+ (u_char *) & max_times, sizeof (max_times));
+ if (NULL == max_times_save)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ else
+ {
+ netsnmp_request_add_list_data (requests,
+ netsnmp_create_data_list (
+ "maxtimes",
+ max_times_save,
+ free));
+
+ }
+ break;
+
+ case MODE_SET_FREE:
/*
- * SET REQUEST
- *
- * multiple states in the transaction. See:
- * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
+ * free resources allocated in RESERVE1 and/or
+ * RESERVE2. Something failed somewhere, and the states
+ * below won't be called.
*/
- 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;
+ free (max_times_save);
+ 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;
+ case MODE_SET_ACTION:
+ /*
+ * perform the value change here
+ */
+ value = *(requests->requestvb->val.integer);
+ sprintf (buffer, "%ld", value);
+
+ ret = libspid_config_write_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_TIMES,
+ buffer);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_COMMITFAILED);
+ }
+ break;
+ case MODE_SET_COMMIT:
+ /*
+ * delete temporary storage
+ */
+ free (max_times_save);
+ break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_eocTrapMaxTimes\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
+ case MODE_SET_UNDO:
+ /*
+ * UNDO and return to previous value for the object
+ */
+ value =
+ *((u_long *) netsnmp_request_get_list_data (requests,
+ "maxtimes"));
+ sprintf (buffer, "%ld", value);
+
+ ret = libspid_config_write_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_TIMES, buffer);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_UNDOFAILED);
+ }
+ free (max_times_save);
+ break;
+
+ default:
+ /* we should never get here, so this is a really bad error */
+ snmp_log (LOG_ERR,
+ "unknown mode (%d) in handle_eocTrapMaxTimes\n",
+ reqinfo->mode);
+ return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
@@ -127,74 +225,184 @@ handle_eocTrapMinInterval(netsnmp_mib_handler *handler,
netsnmp_request_info *requests)
{
int ret;
+
+ int min_interval;
+ int *min_interval_save = NULL;
+ long value;
+
+ char buffer[LIBSPID_LINE_MAX_LEN];
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* 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 );
+ switch (reqinfo->mode)
+ {
+
+ case MODE_GET:
+ /* read buffer for min interval from config file */
+ ret = libspid_config_read_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MIN_INTERVAL,
+ buffer, LIBSPID_LINE_MAX_LEN);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MinInterval: \
+ libspid_config_read_item error for GET\n");
+ /* min interval set to default value to permit walk requests */
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
+ }
+ else
+ {
+ /* parse min interval from buffer */
+ if (1 != sscanf (buffer, "%ld", &value))
+ {
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
}
- 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);
+ else if (value >= 0)
+ {
+ min_interval = value;
}
- 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 */);
+ else
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MinInterval: \
+ config file value negative: %d\n", value);
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
}
- 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;
+ }
+ snmp_set_var_typed_value (requests->requestvb, ASN_INTEGER,
+ (u_char *) &min_interval,
+ sizeof (min_interval));
+ 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:
+ /* check type of set value */
+ ret = netsnmp_check_vb_type (requests->requestvb, ASN_INTEGER);
+ if (ret != SNMP_ERR_NOERROR)
+ {
+ netsnmp_set_request_error (reqinfo, requests, ret);
+ }
+ /* check range of set value */
+ ret = netsnmp_check_vb_range (requests->requestvb, 0, INT_MAX);
+ if (ret != SNMP_ERR_NOERROR)
+ {
+ netsnmp_set_request_error (reqinfo, requests, ret);
+ }
+ break;
+ case MODE_SET_RESERVE2:
+ /*
+ * malloc "undo" storage buffer
+ */
+ /* read buffer for min interval from config file */
+ ret = libspid_config_read_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MIN_INTERVAL,
+ buffer, LIBSPID_LINE_MAX_LEN);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MinInterval: \
+ libspid_config_read_item error for RESERVE2\n");
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ else
+ {
+ /* parse min interval from buffer */
+ if (1 != sscanf (buffer, "%ld", &value))
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
+ else if (value >= 0)
+ min_interval = value;
+ else
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
+ }
+
+ memdup ((u_char **) & min_interval_save,
+ (u_char *) & min_interval, sizeof (min_interval));
+
+ if ( NULL == min_interval_save)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ else
+ {
+ netsnmp_request_add_list_data (requests,
+ netsnmp_create_data_list (
+ "mininterval",
+ min_interval_save,
+ free));
+ }
+ break;
+
+ case MODE_SET_FREE:
+ /*
+ * free resources allocated in RESERVE1 and/or
+ * RESERVE2. Something failed somewhere, and the states
+ * below won't be called.
+ */
+ free (min_interval_save);
+ break;
+ case MODE_SET_ACTION:
+ /*
+ * perform the value change here
+ */
+ value = *(requests->requestvb->val.integer);
+ sprintf (buffer, "%ld", value);
+
+ ret = libspid_config_write_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MIN_INTERVAL,
+ buffer);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_COMMITFAILED);
+ }
+ break;
+
+ case MODE_SET_COMMIT:
+ /*
+ * delete temporary storage
+ */
+ free (min_interval_save);
+ break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_eocTrapMinInterval\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
+ case MODE_SET_UNDO:
+ /*
+ * UNDO and return to previous value for the object
+ */
+ value =
+ *((u_long *) netsnmp_request_get_list_data (requests,
+ "mininterval"));
+
+ sprintf (buffer, "%ld", value);
+ ret = libspid_config_write_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MIN_INTERVAL, buffer);
+ if ( LIBSPID_SUCCESS != ret)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_UNDOFAILED);
+ }
+ free (min_interval_save);
+ break;
+
+ default:
+ /* we should never get here, so this is a really bad error */
+ snmp_log (LOG_ERR,
+ "unknown mode (%d) in handle_eocTrapMinInterval\n",
+ reqinfo->mode);
+ return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
@@ -206,74 +414,178 @@ handle_eocTrapMaxInterval(netsnmp_mib_handler *handler,
netsnmp_request_info *requests)
{
int ret;
- /* We are never called for a GETNEXT if it's registered as a
- "instance", as it's "magically" handled for us. */
+ int max_interval;
+ int *max_interval_save = NULL;
+ long value;
+ char buffer[LIBSPID_KEY_MAX_LEN];
+
+ /*
+ * We are never called for a GETNEXT if it's registered as a
+ * "instance", as it's "magically" handled for us.
+ */
/* 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;
+ switch (reqinfo->mode)
+ {
+ case MODE_GET:
+ /* read buffer for max interval from config file */
+ ret = libspid_config_read_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_INTERVAL, buffer,
+ LIBSPID_KEY_MAX_LEN);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MaxInterval: \
+ libspid_config_read_item error for GET\n");
+ /* max interval set to default value to permit walk requests */
+ max_interval = TRAP_MAX_INTERVAL_DEFAULT_VALUE;
+ }
+ else
+ {
+ /* parse max interval from buffer */
+ if (1 != sscanf (buffer, "%ld", &value))
+ max_interval = TRAP_MAX_INTERVAL_DEFAULT_VALUE;
+ else if (value >= 0)
+ max_interval = value;
+ else
+ max_interval = TRAP_MAX_INTERVAL_DEFAULT_VALUE;
+ }
+
+ snmp_set_var_typed_value (requests->requestvb, ASN_INTEGER,
+ (u_char *) &max_interval,
+ sizeof (max_interval));
+ 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);
+ }
+ /* check range of set value */
+ ret = netsnmp_check_vb_range (requests->requestvb, 0, INT_MAX);
+ if (ret != SNMP_ERR_NOERROR)
+ {
+ netsnmp_set_request_error (reqinfo, requests, ret);
+ }
+ break;
+
+ case MODE_SET_RESERVE2:
/*
- * SET REQUEST
- *
- * multiple states in the transaction. See:
- * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
+ * malloc "undo" storage buffer
*/
- 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;
+ /* read buffer for max interval from config file */
+ ret = libspid_config_read_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_INTERVAL,
+ buffer, LIBSPID_KEY_MAX_LEN);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MaxInterval: \
+ libspid_config_read_item error for RESERVE2\n");
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ else
+ {
+ /* parse max interval from buffer */
+ if (1 != sscanf (buffer, "%ld", &value))
+ max_interval = TRAP_MAX_INTERVAL_DEFAULT_VALUE;
+ else if (value >= 0)
+ max_interval = value;
+ else
+ max_interval = TRAP_MAX_INTERVAL_DEFAULT_VALUE;
+ }
+
+ memdup ((u_char **) & max_interval_save,
+ (u_char *) & max_interval, sizeof (max_interval));
+ if (NULL == max_interval_save)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ else
+ {
+ netsnmp_request_add_list_data (requests,
+ netsnmp_create_data_list
+ ("maxinterval", max_interval_save,
+ free));
+
+ }
+ break;
+
+ case MODE_SET_FREE:
+ /*
+ * free resources allocated in RESERVE1 and/or
+ * RESERVE2. Something failed somewhere, and the states
+ * below won't be called.
+ */
+ free (max_interval_save);
+ 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;
+ case MODE_SET_ACTION:
+ /*
+ * perform the value change here
+ */
+ value = *(requests->requestvb->val.integer);
+ sprintf (buffer, "%ld", value);
+
+ ret = libspid_config_write_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_INTERVAL,
+ buffer);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_COMMITFAILED);
+ }
+ break;
+
+ case MODE_SET_COMMIT:
+ /*
+ * delete temporary storage
+ */
+ free (max_interval_save);
+ break;
- default:
- /* we should never get here, so this is a really bad error */
- snmp_log(LOG_ERR, "unknown mode (%d) in handle_eocTrapMaxInterval\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
+ case MODE_SET_UNDO:
+ /*
+ * UNDO and return to previous value for the object
+ */
+ value =
+ *((u_long *) netsnmp_request_get_list_data (requests,
+ "maxinterval"));
+ sprintf (buffer, "%ld", value);
+ ret = libspid_config_write_item (
+ LIBSPID_SNMP_CONF_PATH,
+ LIBSPID_SNMP_CONF_LABEL_TRAP_MAX_INTERVAL, buffer);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ netsnmp_set_request_error (reqinfo, requests,
+ SNMP_ERR_UNDOFAILED);
+ }
+
+ free (max_interval_save);
+ break;
+
+ default:
+ /*
+ * we should never get here, so this is a really bad error
+ */
+ snmp_log (LOG_ERR,
+ "unknown mode (%d) in handle_eocTrapMaxInterval\n",
+ reqinfo->mode);
+ return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
@@ -284,25 +596,28 @@ handle_eocTrapVersion(netsnmp_mib_handler *handler,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
+ char trapversion[] = "SNMPv2 Trap";
+
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* 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_OCTET_STR,
- (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_eocTrapVersion\n", reqinfo->mode );
- return SNMP_ERR_GENERR;
+ switch (reqinfo->mode)
+ {
+ case MODE_GET:
+ snmp_set_var_typed_value (requests->requestvb, ASN_OCTET_STR,
+ (u_char *) trapversion,
+ sizeof (trapversion));
+ break;
+
+ default:
+ /* we should never get here, so this is a really bad error */
+ snmp_log (LOG_ERR,
+ "unknown mode (%d) in handle_eocTrapVersion\n",
+ reqinfo->mode);
+ return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.h
index ddbab14bb1..3d38a586c3 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.h
@@ -5,6 +5,9 @@
#ifndef EOCTRAPGROUP_H
#define EOCTRAPGROUP_H
+/* include common header */
+#include "EoCCommon.h"
+
/* function declarations */
void init_eocTrapGroup(void);
Netsnmp_Node_Handler handle_eocTrapMaxTimes;
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable.h
index 068ff0ec3a..79715b181f 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable.h
@@ -1,5 +1,5 @@
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get)
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set)
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable)
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access)
-//config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access)
+config_require(mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface)
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable.h
index 5a04212012..7358ce82f9 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable.h
@@ -20,11 +20,6 @@ extern "C" {
/* other required module components */
/* *INDENT-OFF* */
-config_add_mib(NSCRTV-EPONEOC-MOD-EOC-MIB)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocTrapTable/eocTrapTable_interface)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocTrapTable/eocTrapTable_data_access)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocTrapTable/eocTrapTable_data_get)
-config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocTrapTable/eocTrapTable_data_set)
/* *INDENT-ON* */
/* OID and column number definitions for eocTrapTable */
@@ -33,6 +28,9 @@ config_require(NSCRTV-EPONEOC-MOD-EOC-MIB/eocTrapTable/eocTrapTable_data_set)
/* enum definions */
#include "eocTrapTable_enums.h"
+/* include common header */
+#include "EoCCommon.h"
+
/* *********************************************************************
* function declarations
*/
@@ -76,29 +74,32 @@ typedef netsnmp_data_list eocTrapTable_registration;
* eocTrapTable.
*/
typedef struct eocTrapTable_data_s {
-
+ /* fields added to use for container iteration */
+ netsnmp_index oid_index; /* MUST BE FIRST!! for container use */
+ oid st_index; /* arbitrary index */
+
+
/*
* eocTrapIP(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h
*/
- char eocTrapIP[65535];
-size_t eocTrapIP_len; /* # of char elements, not bytes */
-
+ char eocTrapIP[4];
+ size_t eocTrapIP_len; /* # of char elements, not bytes */
+
/*
* eocTrapCommunity(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h
*/
- char eocTrapCommunity[65535];
-size_t eocTrapCommunity_len; /* # of char elements, not bytes */
-
+ char eocTrapCommunity[32];
+ size_t eocTrapCommunity_len; /* # of char elements, not bytes */
+
/*
* eocTrapStatus(4)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
*/
- u_long eocTrapStatus;
-
+ u_long eocTrapStatus;
/*
* eocTrapRowStatus(5)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
*/
- u_long eocTrapRowStatus;
-
+ u_long eocTrapRowStatus;
+
} eocTrapTable_data;
@@ -142,10 +143,10 @@ typedef struct eocTrapTable_rowreq_ctx_s {
/** this must be first for container compare to work */
netsnmp_index oid_idx;
oid oid_tmp[MAX_eocTrapTable_IDX_LEN];
-
+
eocTrapTable_mib_index tbl_idx;
-
- eocTrapTable_data data;
+
+ eocTrapTable_data * data;
unsigned int column_exists_flags; /* flags for existence */
eocTrapTable_undo_data * undo;
unsigned int column_set_flags; /* flags for set columns */
@@ -160,7 +161,11 @@ typedef struct eocTrapTable_rowreq_ctx_s {
/*
* TODO:131:o: | |-> Add useful data to eocTrapTable rowreq context.
*/
-
+ /*
+ * TODO:131:o: | |-> Add useful data to eocVLANTable rowreq context.
+ */
+ u_char undo_ref_count;
+
/*
* storage for future expansion
*/
@@ -191,6 +196,7 @@ typedef struct eocTrapTable_ref_rowreq_ctx_s {
extern oid eocTrapTable_oid[];
extern int eocTrapTable_oid_size;
+extern int trap_adding_row;
#include "eocTrapTable_interface.h"
#include "eocTrapTable_data_access.h"
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.c
index 6c9967fac1..0bbc045da2 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.c
@@ -1,6 +1,6 @@
/*
* Note: this file originally auto-generated by mib2c using
- * version : 14170 $ of $
+ * version : 14170 $ of $
*
* $Id:$
*/
@@ -15,12 +15,14 @@
#include "eocTrapTable_data_access.h"
+int trap_adding_row;
+
/** @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 +98,7 @@ eocTrapTable_container_init(netsnmp_container **container_ptr_ptr,
netsnmp_cache *cache)
{
DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_container_init","called\n"));
-
+
if (NULL == container_ptr_ptr) {
snmp_log(LOG_ERR,"bad container param to eocTrapTable_container_init\n");
return;
@@ -122,8 +124,9 @@ eocTrapTable_container_init(netsnmp_container **container_ptr_ptr,
* cache->enabled to 0.
*/
cache->timeout = EOCTRAPTABLE_CACHE_TIMEOUT; /* seconds */
-} /* eocTrapTable_container_init */
-
+ /* initialize row adding indication */
+ trap_adding_row = 0;
+}
/**
* container shutdown
*
@@ -144,7 +147,7 @@ void
eocTrapTable_container_shutdown(netsnmp_container *container_ptr)
{
DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_container_shutdown","called\n"));
-
+
if (NULL == container_ptr) {
snmp_log(LOG_ERR,"bad params to eocTrapTable_container_shutdown\n");
return;
@@ -152,6 +155,42 @@ eocTrapTable_container_shutdown(netsnmp_container *container_ptr)
} /* eocTrapTable_container_shutdown */
+
+void
+_trap_update_entry (eocTrapTable_data * lhs, eocTrapTable_data * rhs)
+{
+
+ if (lhs->eocTrapCommunity_len != rhs->eocTrapCommunity_len)
+ {
+ lhs->eocTrapCommunity_len = rhs->eocTrapCommunity_len;
+ memcpy (lhs->eocTrapCommunity, rhs->eocTrapCommunity,
+ rhs->eocTrapCommunity_len);
+ }
+ else if (memcmp (lhs->eocTrapCommunity,
+ rhs->eocTrapCommunity, rhs->eocTrapCommunity_len) != 0)
+ {
+ memcpy (lhs->eocTrapCommunity, rhs->eocTrapCommunity,
+ rhs->eocTrapCommunity_len);
+ }
+
+ if (lhs->eocTrapIP_len != rhs->eocTrapIP_len)
+ {
+ lhs->eocTrapIP_len = rhs->eocTrapIP_len;
+ memcpy (lhs->eocTrapIP, rhs->eocTrapIP, rhs->eocTrapIP_len);
+ }
+ else if (memcmp (lhs->eocTrapIP, rhs->eocTrapIP, rhs->eocTrapIP_len) != 0)
+ {
+ memcpy (lhs->eocTrapIP, rhs->eocTrapIP, rhs->eocTrapIP_len);
+ }
+
+ if (lhs->eocTrapRowStatus != rhs->eocTrapRowStatus)
+ {
+ lhs->eocTrapRowStatus = rhs->eocTrapRowStatus;
+ }
+
+}
+
+
/**
* load initial data
*
@@ -186,124 +225,348 @@ eocTrapTable_container_shutdown(netsnmp_container *container_ptr)
*
*/
int
-eocTrapTable_container_load(netsnmp_container *container)
+_eocTrapTable_container_load (netsnmp_container * container)
{
+ eocTrapTable_data *trap_entry;
eocTrapTable_rowreq_ctx *rowreq_ctx;
- size_t count = 0;
+ libspid_eoc_trap_entry_t trap_config_entries[LIBSPID_EOC_TRAP_SERVER_MAX];
+ unsigned int trap_server_cnt = LIBSPID_EOC_TRAP_SERVER_MAX;
+ long trapIndex = 1;
+ int i = 0, tmp = 0;
+ int init_row_status = ROWSTATUS_ACTIVE;
+
+ DEBUGMSGTL (("eocTrapTable:access",
+ "_eocTrapTable_container_load called \n"));
+
+ if (NULL == container)
+ {
+ snmp_log (LOG_ERR,
+ "no container specified/found for "
+ "_eocTrapTable_container_load\n");
+ return MFD_ERROR;
+ }
- /*
- * temporary storage for index values
- */
- /*
- * eocTrapIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h
- */
- long eocTrapIndex;
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap configuration file\n");
+ init_row_status = ROWSTATUS_NOTINSERVICE;
+ }
+ if (LIBSPID_SUCCESS !=
+ libspid_eoc_trap_get_list (trap_config_entries, &trap_server_cnt))
+ {
+ snmp_log (LOG_ERR, "libspid_config_read_line error\n");
+ return MFD_ERROR;
+ }
- DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_container_load","called\n"));
+ for (i = 0; i < trap_server_cnt; i++)
+ {
+
+
+ if (NULL == (trap_entry = eocTrapTable_allocate_data ()))
+ {
+ snmp_log (LOG_ERR, "trap entry allocation error\n");
+ return MFD_ERROR;
+ }
+
+ trap_entry->st_index = trapIndex;
+
+ if (LIBSPID_SUCCESS !=
+ libspid_ip_str_to_bin (trap_config_entries[i].ip_address,
+ trap_entry->eocTrapIP))
+ {
+ snmp_log (LOG_ERR,
+ "1libspid_ip_str_to_bin failed, "
+ "setting ip address field to NULL\n");
+ trap_entry->eocTrapIP[0] = '\0';
+ }
+
+ trap_entry->eocTrapIP_len = sizeof (trap_entry->eocTrapIP);
+
+ if (1 == atoi (trap_config_entries[i].status))
+ {
+ trap_entry->eocTrapStatus = TRUTHVALUE_TRUE;
+ }
+ else if (0 == atoi (trap_config_entries[i].status))
+ {
+ trap_entry->eocTrapStatus = TRUTHVALUE_FALSE;
+ }
+ else
+ {
+ trap_entry->eocTrapStatus = INVALID_EOCTRAPSTATUS;
+ }
+
+ strncpy (trap_entry->eocTrapCommunity,
+ trap_config_entries[i].community,
+ sizeof (trap_entry->eocTrapCommunity) - 1);
+
+ trap_entry->eocTrapCommunity_len =
+ strlen (trap_entry->eocTrapCommunity);
+
+ trap_entry->eocTrapRowStatus = init_row_status;
+
+
+ trapIndex++;
- /*
- * TODO:351:M: |-> Load/update data in the eocTrapTable container.
- * loop over your eocTrapTable data, allocate a rowreq context,
- * 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;
/*
- * TODO:352:M: | |-> set indexes in new eocTrapTable rowreq context.
- * data context will be set from the param (unless NULL,
- * in which case a new data context will be allocated)
+ *for valid row, add comm name string to internal storage list
+ *(if not already present in there)
*/
- rowreq_ctx = eocTrapTable_allocate_rowreq_ctx(NULL);
- if (NULL == rowreq_ctx) {
- snmp_log(LOG_ERR, "memory allocation failed\n");
- return MFD_RESOURCE_UNAVAILABLE;
- }
- if(MFD_SUCCESS != eocTrapTable_indexes_set(rowreq_ctx
- , eocTrapIndex
- )) {
- snmp_log(LOG_ERR,"error setting index while loading "
- "eocTrapTable data.\n");
- eocTrapTable_release_rowreq_ctx(rowreq_ctx);
- continue;
+ if (ROWSTATUS_ACTIVE == trap_entry->eocTrapRowStatus){
+ tmp = se_find_value_in_slist ("eoc_trap_list",
+ trap_config_entries[i].ip_address);
+ if (tmp == SE_DNE)
+ {
+ se_add_pair_to_slist ("eoc_trap_list",
+ strdup (trap_config_entries[i].ip_address),
+ i + 1);
+ }
}
/*
- * TODO:352:r: | |-> populate eocTrapTable data context.
- * Populate data context here. (optionally, delay until row prep)
+ * insert into table container
*/
+ CONTAINER_INSERT (container, trap_entry);
+ }
+
+ DEBUGMSGT (("verbose:eocTrapTable:eocTrapTable_container_load",
+ "inserted %d records\n", CONTAINER_SIZE (container)));
+
+ return MFD_SUCCESS;
+}
+
+
+
+
+
+/**
+ * check entry for update
+ */
+
+static void
+_trap_check_entry_for_updates (eocTrapTable_rowreq_ctx * rowreq_ctx,
+ void **magic)
+{
+ netsnmp_container *trap_container = magic[0];
+ netsnmp_container *to_delete = (netsnmp_container *) magic[1];
+
+ DEBUGMSGTL (("eocTrapTable:access", "checking entry for updates\n"));
+
+ netsnmp_assert (NULL != trap_container);
+ netsnmp_assert (NULL != rowreq_ctx);
+ netsnmp_assert (NULL != rowreq_ctx->data);
/*
- * TRANSIENT or semi-TRANSIENT data:
- * copy data or save any info needed to do it in row_prep.
+ * check for matching entries to be deleted
*/
+ eocTrapTable_data *trap_entry =
+ CONTAINER_FIND (trap_container, rowreq_ctx->data);
+ if (NULL == trap_entry)
+ {
+
+ if (NULL == to_delete)
+ {
+ magic[1] = to_delete = netsnmp_container_find ("lifo");
+ if (NULL == to_delete)
+ snmp_log (LOG_ERR, "couldn't create delete container\n");
+ }
+ if (NULL != to_delete)
+ CONTAINER_INSERT (to_delete, rowreq_ctx);
+ }
+ else
+ {
+
+ /* check for updates for editable columns from service table */
+ _trap_update_entry (rowreq_ctx->data, trap_entry);
+
+ /*
+ * remove entry from temporary service container
+ */
+ CONTAINER_REMOVE (trap_container, trap_entry);
+ free (trap_entry);
+ }
+}
+
+/**
+ * add new entry
+ */
+static void
+_trap_add_new_entry (eocTrapTable_data * trap_entry,
+ netsnmp_container * container)
+{
+ eocTrapTable_rowreq_ctx *rowreq_ctx;
+ size_t count = 0;
+
+ DEBUGMSGTL (("eocTrapTable:access", "creating new entry\n"));
+
+ netsnmp_assert (NULL != trap_entry);
+ netsnmp_assert (NULL != container);
+
/*
- * setup/save data for eocTrapIP
- * eocTrapIP(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h
+ * allocate an row context and set the index(es)
*/
- /** no mapping */
+ rowreq_ctx = eocTrapTable_allocate_rowreq_ctx (trap_entry, NULL);
+
+ if ((NULL != rowreq_ctx)
+ && (MFD_SUCCESS ==
+ eocTrapTable_indexes_set (rowreq_ctx, trap_entry->st_index)))
+ {
+ if (CONTAINER_INSERT (container, rowreq_ctx) < 0)
+ {
+ snmp_log (LOG_ERR,
+ "eocTrapTable container insert failed for new entry\n");
+ eocTrapTable_release_rowreq_ctx (rowreq_ctx);
+ return;
+ }
+ ++count;
+ }
+ else
+ {
+ if (NULL != rowreq_ctx)
+ {
+ snmp_log (LOG_ERR, "error setting index while loading "
+ "eocTrapTable cache.\n");
+ eocTrapTable_release_rowreq_ctx (rowreq_ctx);
+ }
+ else
+ {
+ snmp_log (LOG_ERR, "memory allocation failed while loading "
+ "eocTrapTable cache.\n");
+ free (trap_entry);
+ }
+
+ return;
+ }
+ rowreq_ctx->data->eocTrapRowStatus = trap_entry->eocTrapRowStatus;
+}
+
+
+
+
+
+/**
+ * load initial data
+ *
+ * TODO:350:M: Implement eocTrapTable data load
+ * This function will also be called by the cache helper to load
+ * the container again (after the container free function has been
+ * called to free the previous contents).
+ *
+ * @param container container to which items should be inserted
+ *
+ * @retval MFD_SUCCESS : success.
+ * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
+ * @retval MFD_ERROR : other error.
+ *
+ * This function is called to load the index(es) (and data, optionally)
+ * for the every row in the data set.
+ *
+ * @remark
+ * While loading the data, the only important thing is the indexes.
+ * If access to your data is cheap/fast (e.g. you have a pointer to a
+ * structure in memory), it would make sense to update the data here.
+ * If, however, the accessing the data invovles more work (e.g. parsing
+ * some other existing data, or peforming calculations to derive the data),
+ * then you can limit yourself to setting the indexes and saving any
+ * information you will need later. Then use the saved information in
+ * eocTrapTable_row_prep() for populating data.
+ *
+ * @note
+ * If you need consistency between rows (like you want statistics
+ * for each row to be from the same time frame), you should set all
+ * data here.
+ *
+ */
+
+int
+eocTrapTable_container_load(netsnmp_container *container)
+{
+ int rc = MFD_SUCCESS;
+ netsnmp_container *trap_container;
+ void *tmp_ptr[2];
/*
- * make sure there is enough space for eocTrapIP data
+ * TODO:351:M: |-> Load/update data in the eoctrapTable container.
+ * loop over your eoctrapTable data, allocate a rowreq context,
+ * set the index(es) [and data, optionally] and insert into
+ * the container.
*/
- if ((NULL == rowreq_ctx->data.eocTrapIP) ||
- (rowreq_ctx->data.eocTrapIP_len <
- (eocTrapIP_len* sizeof(eocTrapIP[0])))) {
- snmp_log(LOG_ERR,"not enough space for value\n");
+ /* create temporary container for fresh service data */
+ trap_container = netsnmp_container_find ("trap_temp:table_container");
+
+
+ if (NULL == trap_container)
+ {
+ snmp_log (LOG_ERR, "trap temp container not found\n");
return MFD_ERROR;
}
- rowreq_ctx->data.eocTrapIP_len = eocTrapIP_len* sizeof(eocTrapIP[0]);
- memcpy( rowreq_ctx->data.eocTrapIP, eocTrapIP, eocTrapIP_len* sizeof(eocTrapIP[0]) );
-
- /*
- * setup/save data for eocTrapCommunity
- * eocTrapCommunity(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h
- */
- /** no mapping */
- /*
- * make sure there is enough space for eocTrapCommunity data
- */
- if ((NULL == rowreq_ctx->data.eocTrapCommunity) ||
- (rowreq_ctx->data.eocTrapCommunity_len <
- (eocTrapCommunity_len* sizeof(eocTrapCommunity[0])))) {
- snmp_log(LOG_ERR,"not enough space for value\n");
+
+ /* load fresh service data into temp container */
+ rc = _eocTrapTable_container_load (trap_container);
+ if (MFD_ERROR == rc)
+ {
+ snmp_log (LOG_ERR, "trap container load error\n");
return MFD_ERROR;
}
- rowreq_ctx->data.eocTrapCommunity_len = eocTrapCommunity_len* sizeof(eocTrapCommunity[0]);
- memcpy( rowreq_ctx->data.eocTrapCommunity, eocTrapCommunity, eocTrapCommunity_len* sizeof(eocTrapCommunity[0]) );
-
+
+ tmp_ptr[0] = trap_container;
+ tmp_ptr[1] = NULL;
+
+ /* check if eoctrapTable container needs updates */
+ /* (this is not called if table container is empty) */
+ CONTAINER_FOR_EACH (container, (netsnmp_container_obj_func *)
+ _trap_check_entry_for_updates, tmp_ptr);
+ /*
+ * add new entries to eoctrapTable container
+ */
+ CONTAINER_FOR_EACH (trap_container,
+ (netsnmp_container_obj_func *) _trap_add_new_entry,
+ container);
+
/*
- * setup/save data for eocTrapStatus
- * eocTrapStatus(4)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ * free temporary container. we've either claimed each entry, or released it,
+ * so we don't need to call CONTAINER_CLEAR to clear the container.
*/
- /** no mapping */
- rowreq_ctx->data.eocTrapStatus = eocTrapStatus;
-
+ CONTAINER_FREE (trap_container);
+
/*
- * setup/save data for eocTrapRowStatus
- * eocTrapRowStatus(5)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h
+ * remove deleted items from eoctrapTable container
*/
- /** no mapping */
- rowreq_ctx->data.eocTrapRowStatus = eocTrapRowStatus;
-
-
+ if (NULL != tmp_ptr[1])
+ {
+ netsnmp_container *tmp_container = (netsnmp_container *) tmp_ptr[1];
+ eocTrapTable_rowreq_ctx *tmp_ctx;
+
/*
- * insert into table container
+ * this works because the tmp_container is a linked list,
+ * which can be used like a stack...
*/
- CONTAINER_INSERT(container, rowreq_ctx);
- ++count;
+ while (CONTAINER_SIZE (tmp_container))
+ {
+ /*
+ * get from delete list
+ */
+ tmp_ctx = CONTAINER_FIRST (tmp_container);
+
+ /*
+ * release context, delete from table container
+ */
+ CONTAINER_REMOVE (container, tmp_ctx);
+ eocTrapTable_release_rowreq_ctx (tmp_ctx);
+
+ /*
+ * pop off delete list
+ */
+ CONTAINER_REMOVE (tmp_container, NULL);
+ }
}
- DEBUGMSGT(("verbose:eocTrapTable:eocTrapTable_container_load",
- "inserted %d records\n", count));
-
+ DEBUGMSGT (("verbose:eocTrapTable:eocTrapTable_container_load",
+ "inserted %d records\n", CONTAINER_SIZE (container)));
return MFD_SUCCESS;
} /* eocTrapTable_container_load */
+
+
/**
* container clean up
*
@@ -320,7 +583,8 @@ eocTrapTable_container_load(netsnmp_container *container)
void
eocTrapTable_container_free(netsnmp_container *container)
{
- DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_container_free","called\n"));
+ DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_container_free",
+ "called\n"));
/*
* TODO:380:M: Free eocTrapTable container data.
@@ -428,7 +692,7 @@ eocTrapIndex_check_index( eocTrapTable_rowreq_ctx *rowreq_ctx )
* is the place to make sure they are valid as a whole when combined. If
* you only have one index, then you probably don't need to do anything else
* here.
- *
+ *
* @note Keep in mind that if the indexes refer to a row in this or
* some other table, you can't check for that row here to make
* decisions, since that row might not be created yet, but may
@@ -460,24 +724,7 @@ eocTrapTable_validate_index( eocTrapTable_registration * eocTrapTable_reg,
/*
* TODO:430:M: |-> Validate potential eocTrapTable index.
*/
- if(1) {
- snmp_log(LOG_WARNING,"invalid index for a new row in the "
- "eocTrapTable table.\n");
- /*
- * determine failure type.
- *
- * If the index could not ever be created, return MFD_NOT_EVER
- * If the index can not be created under the present circumstances
- * (even though it could be created under other circumstances),
- * return MFD_NOT_NOW.
- */
- if(0) {
- return MFD_CANNOT_CREATE_EVER;
- }
- else {
- return MFD_CANNOT_CREATE_NOW;
- }
- }
+
return rc;
} /* eocTrapTable_validate_index */
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.h
index 56b42d3225..db991f44f2 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_access.h
@@ -11,6 +11,8 @@
extern "C" {
#endif
+/* definitions for invalid input value markers */
+#define INVALID_EOCTRAPSTATUS (-1)
/* *********************************************************************
* function declarations
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get.c
index e2dc3daeec..3232fcccdb 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_get.c
@@ -1,6 +1,6 @@
/*
* Note: this file originally auto-generated by mib2c using
- * version : 12088 $ of $
+ * version : 12088 $ of $
*
* $Id:$
*/
@@ -63,7 +63,7 @@ eocTrapTable_indexes_set_tbl_idx(eocTrapTable_mib_index *tbl_idx, long eocTrapIn
/* eocTrapIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/R/d/h */
tbl_idx->eocTrapIndex = eocTrapIndex_val;
-
+
return MFD_SUCCESS;
} /* eocTrapTable_indexes_set_tbl_idx */
@@ -171,18 +171,28 @@ eocTrapIP_get( eocTrapTable_rowreq_ctx *rowreq_ctx, char **eocTrapIP_val_ptr_ptr
*/
if ((NULL == (* eocTrapIP_val_ptr_ptr )) ||
((* eocTrapIP_val_ptr_len_ptr ) <
- (rowreq_ctx->data.eocTrapIP_len* sizeof(rowreq_ctx->data.eocTrapIP[0])))) {
+ (rowreq_ctx->data->eocTrapIP_len* sizeof(rowreq_ctx->data->eocTrapIP[0])))) {
/*
* allocate space for eocTrapIP data
*/
- (* eocTrapIP_val_ptr_ptr ) = malloc(rowreq_ctx->data.eocTrapIP_len* sizeof(rowreq_ctx->data.eocTrapIP[0]));
+ (* eocTrapIP_val_ptr_ptr ) = malloc(rowreq_ctx->data->eocTrapIP_len* sizeof(rowreq_ctx->data->eocTrapIP[0]));
if(NULL == (* eocTrapIP_val_ptr_ptr )) {
snmp_log(LOG_ERR,"could not allocate memory\n");
return MFD_ERROR;
}
}
- (* eocTrapIP_val_ptr_len_ptr ) = rowreq_ctx->data.eocTrapIP_len* sizeof(rowreq_ctx->data.eocTrapIP[0]);
- memcpy( (* eocTrapIP_val_ptr_ptr ), rowreq_ctx->data.eocTrapIP, rowreq_ctx->data.eocTrapIP_len* sizeof(rowreq_ctx->data.eocTrapIP[0]) );
+
+ if (LIBSPID_SUCCESS !=
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP,
+ *eocTrapIP_val_ptr_ptr))
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str failed, \
+ setting ip address field to NULL\n");
+
+ strcpy (*eocTrapIP_val_ptr_ptr, "255.255.255.255");
+ }
+
+ *eocTrapIP_val_ptr_len_ptr = strlen (*eocTrapIP_val_ptr_ptr);
return MFD_SUCCESS;
} /* eocTrapIP_get */
@@ -254,18 +264,18 @@ eocTrapCommunity_get( eocTrapTable_rowreq_ctx *rowreq_ctx, char **eocTrapCommuni
*/
if ((NULL == (* eocTrapCommunity_val_ptr_ptr )) ||
((* eocTrapCommunity_val_ptr_len_ptr ) <
- (rowreq_ctx->data.eocTrapCommunity_len* sizeof(rowreq_ctx->data.eocTrapCommunity[0])))) {
+ (rowreq_ctx->data->eocTrapCommunity_len* sizeof(rowreq_ctx->data->eocTrapCommunity[0])))) {
/*
* allocate space for eocTrapCommunity data
*/
- (* eocTrapCommunity_val_ptr_ptr ) = malloc(rowreq_ctx->data.eocTrapCommunity_len* sizeof(rowreq_ctx->data.eocTrapCommunity[0]));
+ (* eocTrapCommunity_val_ptr_ptr ) = malloc(rowreq_ctx->data->eocTrapCommunity_len* sizeof(rowreq_ctx->data->eocTrapCommunity[0]));
if(NULL == (* eocTrapCommunity_val_ptr_ptr )) {
snmp_log(LOG_ERR,"could not allocate memory\n");
return MFD_ERROR;
}
}
- (* eocTrapCommunity_val_ptr_len_ptr ) = rowreq_ctx->data.eocTrapCommunity_len* sizeof(rowreq_ctx->data.eocTrapCommunity[0]);
- memcpy( (* eocTrapCommunity_val_ptr_ptr ), rowreq_ctx->data.eocTrapCommunity, rowreq_ctx->data.eocTrapCommunity_len* sizeof(rowreq_ctx->data.eocTrapCommunity[0]) );
+ (* eocTrapCommunity_val_ptr_len_ptr ) = rowreq_ctx->data->eocTrapCommunity_len* sizeof(rowreq_ctx->data->eocTrapCommunity[0]);
+ memcpy( (* eocTrapCommunity_val_ptr_ptr ), rowreq_ctx->data->eocTrapCommunity, rowreq_ctx->data->eocTrapCommunity_len* sizeof(rowreq_ctx->data->eocTrapCommunity[0]) );
return MFD_SUCCESS;
} /* eocTrapCommunity_get */
@@ -317,7 +327,7 @@ eocTrapStatus_get( eocTrapTable_rowreq_ctx *rowreq_ctx, u_long * eocTrapStatus_v
* TODO:231:o: |-> Extract the current value of the eocTrapStatus data.
* copy (* eocTrapStatus_val_ptr ) from rowreq_ctx->data
*/
- (* eocTrapStatus_val_ptr ) = rowreq_ctx->data.eocTrapStatus;
+ (* eocTrapStatus_val_ptr ) = rowreq_ctx->data->eocTrapStatus;
return MFD_SUCCESS;
} /* eocTrapStatus_get */
@@ -334,7 +344,7 @@ eocTrapStatus_get( eocTrapTable_rowreq_ctx *rowreq_ctx, u_long * eocTrapStatus_v
notInService(2)- 状态未激活;
notReady(3)- 不能被激活状态;
createAndGo(4)- 创建并激活;
- createAndWait(5)- 创建,但不激活;
+ createAndWait(5)- 创建,但不激活;
destory(6)- 销毁该行。
*
* Attributes:
@@ -367,7 +377,7 @@ eocTrapRowStatus_get( eocTrapTable_rowreq_ctx *rowreq_ctx, u_long * eocTrapRowSt
/** we should have a non-NULL pointer */
netsnmp_assert( NULL != eocTrapRowStatus_val_ptr );
- (* eocTrapRowStatus_val_ptr ) = rowreq_ctx->data.eocTrapRowStatus;
+ (* eocTrapRowStatus_val_ptr ) = rowreq_ctx->data->eocTrapRowStatus;
return MFD_SUCCESS;
} /* eocTrapRowStatus_get */
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set.c
index f61019bc58..9afbdec64e 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_data_set.c
@@ -18,7 +18,7 @@
*
* These routines are used to set the value for individual objects. The
* row context is passed, along with the new value.
- *
+ *
* @{
*/
/**********************************************************************
@@ -144,6 +144,7 @@ eocTrapTable_undo_setup( eocTrapTable_rowreq_ctx *rowreq_ctx)
* set up eocTrapTable undo information, in preparation for a set.
* Undo storage is in (* eocTrapRowStatus_val_ptr )*
*/
+ memcpy (rowreq_ctx->undo, rowreq_ctx->data, sizeof (eocTrapTable_data));
return rc;
} /* eocTrapTable_undo_setup */
@@ -244,12 +245,17 @@ int
eocTrapTable_commit( eocTrapTable_rowreq_ctx *rowreq_ctx)
{
int rc = MFD_SUCCESS;
- int save_flags;
+ int save_flags;
+ const char delimiters[2] = LIBSPID_TRAP_INFO_DELIMITER "\0";
+ char ip_save[LIBSPID_IP_STR_MAX_LEN], ip_undo[LIBSPID_IP_STR_MAX_LEN];
+ int tmp = 0;
+ int ret;
+ libspid_eoc_trap_entry_t trap_entry;
- DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_commit","called\n"));
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_commit", "called\n"));
/** we should have a non-NULL pointer */
- netsnmp_assert( NULL != rowreq_ctx );
+ netsnmp_assert (NULL != rowreq_ctx);
/*
* save flags, then clear until we actually do something
@@ -264,83 +270,341 @@ eocTrapTable_commit( eocTrapTable_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_EOCTRAPIP_FLAG) {
- save_flags &= ~COLUMN_EOCTRAPIP_FLAG; /* clear eocTrapIP */
- /*
- * TODO:482:o: |-> commit column eocTrapIP.
- */
- rc = -1;
- if(-1 == rc) {
- snmp_log(LOG_ERR,"eocTrapTable column eocTrapIP commit failed\n");
- }
- else {
- /*
- * set flag, in case we need to undo eocTrapIP
- */
- rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPIP_FLAG;
- }
+ if (save_flags & COLUMN_EOCTRAPIP_FLAG)
+ {
+ save_flags &= ~COLUMN_EOCTRAPIP_FLAG; /* clear eocTrapIP */
+ /*
+ * TODO:482:o: |-> commit column eocTrapIP.
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPIP_FLAG;
+
}
- if (save_flags & COLUMN_EOCTRAPCOMMUNITY_FLAG) {
- save_flags &= ~COLUMN_EOCTRAPCOMMUNITY_FLAG; /* clear eocTrapCommunity */
- /*
- * TODO:482:o: |-> commit column eocTrapCommunity.
- */
- rc = -1;
- if(-1 == rc) {
- snmp_log(LOG_ERR,"eocTrapTable column eocTrapCommunity commit failed\n");
- }
- else {
- /*
- * set flag, in case we need to undo eocTrapCommunity
- */
- rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPCOMMUNITY_FLAG;
- }
+ if (save_flags & COLUMN_EOCTRAPCOMMUNITY_FLAG)
+ {
+ save_flags &= ~COLUMN_EOCTRAPCOMMUNITY_FLAG; /* clear eocTrapCommunity */
+ /*
+ * TODO:482:o: |-> commit column eocTrapCommunity.
+ */
+ /*
+ * set flag, in case we need to undo eocTrapCommunity
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPCOMMUNITY_FLAG;
}
- if (save_flags & COLUMN_EOCTRAPSTATUS_FLAG) {
- save_flags &= ~COLUMN_EOCTRAPSTATUS_FLAG; /* clear eocTrapStatus */
- /*
- * TODO:482:o: |-> commit column eocTrapStatus.
- */
- rc = -1;
- if(-1 == rc) {
- snmp_log(LOG_ERR,"eocTrapTable column eocTrapStatus commit failed\n");
- }
- else {
- /*
- * set flag, in case we need to undo eocTrapStatus
- */
- rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPSTATUS_FLAG;
- }
+ if (save_flags & COLUMN_EOCTRAPSTATUS_FLAG)
+ {
+ save_flags &= ~COLUMN_EOCTRAPSTATUS_FLAG; /* clear eocTrapStatus */
+ /*
+ * TODO:482:o: |-> commit column eocTrapStatus.
+ */
+
+ /*
+ * set flag, in case we need to undo eocTrapStatus
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPSTATUS_FLAG;
+
}
- if (save_flags & COLUMN_EOCTRAPROWSTATUS_FLAG) {
- save_flags &= ~COLUMN_EOCTRAPROWSTATUS_FLAG; /* clear eocTrapRowStatus */
- /*
- * TODO:482:o: |-> commit column eocTrapRowStatus.
- */
- rc = -1;
- if(-1 == rc) {
- snmp_log(LOG_ERR,"eocTrapTable column eocTrapRowStatus commit failed\n");
- }
- else {
- /*
- * set flag, in case we need to undo eocTrapRowStatus
- */
- rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPROWSTATUS_FLAG;
- }
+ if (save_flags & COLUMN_EOCTRAPROWSTATUS_FLAG)
+ {
+ save_flags &= ~COLUMN_EOCTRAPROWSTATUS_FLAG; /* clear eocTrapRowStatus */
+ /*
+ * TODO:482:o: |-> commit column eocTrapRowStatus.
+ */
+
+ /*
+ * set flag, in case we need to undo eocTrapRowStatus
+ */
+ rowreq_ctx->column_set_flags |= COLUMN_EOCTRAPROWSTATUS_FLAG;
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPROWSTATUS_FLAG)
+ {
+ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)
+ {
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_commit",
+ "new row created!\n"));
+ }
+ else if (ROWSTATUS_DESTROY == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ /* check if deleting unvalidated row */
+ /* a row can be unvalidated either before being added to
+ * configuration file, or to mark invalid line in
+ * configuration file */
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap"
+ " configuration file\n");
+ return MFD_ERROR;
+ }
+
+ if ((rowreq_ctx->undo->eocTrapRowStatus & ROWSTATUS_NOTINSERVICE))
+ {
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_commit",
+ "deleting unvalidated row!\n"));
+ /* convert IP address to string to serve as key for possible
+ * removing of invalid line */
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP,
+ ip_save);
+
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+ /* remove line with given IP address from trap configuration
+ * file, if existing */
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_remove (ip_save))
+ {
+ snmp_log (LOG_ERR, "unvalidated row not in "
+ "configuration file\n");
+ }
+ return MFD_SUCCESS;
+ }
+
+ /* convert IP address to string to serve as key for removing line */
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP, ip_save);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+
+
+ /* remove IP address from internal storage list */
+ if (NULL != se_find_slist ("eoc_trap_list"))
+ {
+ DEBUGMSGTL (("eocTrapTable_commit:",
+ "trying to remove IP address from slist: %s\n",
+ ip_save));
+ ret = se_remove_label_from_slist ("eoc_trap_list", ip_save);
+ if (ret == SE_DNE)
+ {
+ snmp_log (LOG_ERR,
+ "Error! IP address not found in the table!\n");
+ return MFD_ERROR;
+ }
+ }
+ else
+ {
+ snmp_log (LOG_ERR,
+ "Trying to delete from empty IP address list!\n");
+ return MFD_ERROR;
+ }
+ /* remove line with given IP address from trap configuration file */
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_remove (ip_save))
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_remove error\n");
+ return MFD_ERROR;
+ }
+
+ }
+ else if (ROWSTATUS_ACTIVE == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ /* this case covers modifying row status to active - ie.
+ * validating the row */
+ /* row can be either newly added from the agent,
+ * or having row status notInService to mark invalid line
+ * in configuration file */
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_commit",
+ "validating row\n"));
+
+
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP, ip_save);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+
+ /* copy IP address to trap entry */
+ strcpy (trap_entry.ip_address, ip_save);
+
+ if (TRUTHVALUE_TRUE == rowreq_ctx->data->eocTrapStatus)
+ {
+ strcpy (trap_entry.status, "1");
+ }
+ else
+ {
+ strcpy (trap_entry.status, "0");
+ }
+
+ /* copy community to trap entry */
+ strncpy (trap_entry.community, rowreq_ctx->data->eocTrapCommunity,
+ rowreq_ctx->data->eocTrapCommunity_len);
+ trap_entry.community[rowreq_ctx->data->eocTrapCommunity_len] =
+ '\0';
+
+
+ /* add IP address of validated row to internal storage list */
+ tmp = se_find_free_value_in_slist ("eoc_trap_list");
+ if (tmp == SE_DNE)
+ tmp = 1; /* Completely new list! */
+ se_add_pair_to_slist ("eoc_trap_list", strdup (ip_save), tmp);
+
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap"
+ " configuration file\n");
+ return MFD_ERROR;
+ }
+ /* write completed line to trap file */
+ ret = libspid_eoc_trap_set (&trap_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_set error\n");
+ return MFD_ERROR;
+ }
+ /* if commit has successfully passed,
+ * clear trap adding indication */
+ trap_adding_row = 0;
+ }
+ }
+ else
+ {
+ /* this case covers modifying columns without modifying row status */
+ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)
+ && (ROWSTATUS_ACTIVE == rowreq_ctx->data->eocTrapRowStatus))
+ {
+ DEBUGMSGTL (("eocTrapTable_commit", "trying to change data for "
+ "trap table index \n"));
+
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->undo->eocTrapIP, ip_undo);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+ snmp_log (LOG_ERR, "ip_save:%s\n", ip_undo);
+ /* read existing line from configuration file */
+ ret = libspid_eoc_trap_get (ip_undo, &trap_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_get error\n");
+ return MFD_ERROR;
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPIP_FLAG)
+ {
+ DEBUGMSGTL (("eocTrapTable_commit", "ip read from "
+ "rowreq context: %s\n", ip_save));
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_remove (ip_undo))
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_service_remove error\n");
+ return MFD_ERROR;
+ }
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP,
+ ip_save);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+
+ strcpy (trap_entry.ip_address, ip_save);
+
+ /* remove old IP address from internal storage list */
+ if (NULL != se_find_slist ("eoc_trap_list"))
+ {
+ DEBUGMSGTL (("eocTrapTable_commit:",
+ "trying to remove IP address from slist: %s\n",
+ ip_undo));
+ ret = se_remove_label_from_slist ("eoc_trap_list",
+ ip_undo);
+ if (ret == SE_DNE)
+ {
+ snmp_log (LOG_ERR, "Error! IP address not found"
+ " in internal storage list!\n");
+ return MFD_ERROR;
+ }
+ }
+ else
+ {
+ snmp_log (LOG_ERR, "Trying to delete from empty IP"
+ " address internal storage list!\n");
+ return MFD_ERROR;
+ }
+
+ /* add new IP address to internal storage list */
+ tmp = se_find_free_value_in_slist ("eoc_trap_list");
+ DEBUGMSGTL (("verbose:eocTrapTable:",
+ "eocTrapTable_commit",
+ "se_find_value_in_slist found free value: %d\n",
+ tmp));
+ if (tmp == SE_DNE)
+ tmp = 1; /* Completely new list! */
+ se_add_pair_to_slist ("eoc_trap_list", strdup (ip_save), tmp);
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPCOMMUNITY_FLAG)
+ {
+ DEBUGMSGTL (("eocTrapTable_commit", "community flag "
+ "read from rowreq context: %s\n",
+ rowreq_ctx->data->eocTrapCommunity));
+ /* copy eocTrapCommunity to trap entry */
+ strncpy (trap_entry.community,
+ rowreq_ctx->data->eocTrapCommunity,
+ rowreq_ctx->data->eocTrapCommunity_len);
+ /* add terminal 0 to service name */
+ trap_entry.community[rowreq_ctx->data->eocTrapCommunity_len] =
+ '\0';
+
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPSTATUS_FLAG)
+ {
+ DEBUGMSGTL (("eocTrapTable_commit", "community flag "
+ "read from rowreq context: %ld\n",
+ rowreq_ctx->data->eocTrapStatus));
+ if (TRUTHVALUE_TRUE == rowreq_ctx->data->eocTrapStatus)
+ {
+ strcpy (trap_entry.status, "1");
+ }
+ else
+ {
+ strcpy (trap_entry.status, "0");
+ }
+ }
+
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap"
+ " configuration file\n");
+ return MFD_ERROR;
+ }
+ /* write modified line to configuration file */
+ ret = libspid_eoc_trap_set (&trap_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_set error\n");
+ return MFD_ERROR;
+ }
+ else
+ {
+ DEBUGMSGTL (("eocTrapTable_commit",
+ "line succesfully written to conf file!\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;
}
@@ -366,11 +630,19 @@ int
eocTrapTable_undo_commit( eocTrapTable_rowreq_ctx *rowreq_ctx)
{
int rc = MFD_SUCCESS;
+ libspid_eoc_trap_entry_t trap_entry;
+ const char delimiters[2] = LIBSPID_TRAP_INFO_DELIMITER "\0";
+ char ip_save[LIBSPID_IP_STR_MAX_LEN], ip_undo[LIBSPID_IP_STR_MAX_LEN];
+ int tmp = 0;
+ int ret;
- DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_undo_commit","called\n"));
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_undo_commit",
+ "called\n"));
/** we should have a non-NULL pointer */
- netsnmp_assert( NULL != rowreq_ctx );
+ netsnmp_assert (NULL != rowreq_ctx);
+
+ memset (&trap_entry, 0, sizeof (trap_entry));
/*
* TODO:485:M: |-> Undo eocTrapTable commit.
@@ -379,12 +651,283 @@ eocTrapTable_undo_commit( eocTrapTable_rowreq_ctx *rowreq_ctx)
*
* eg: if (rowreq_ctx->column_set_flags & COLUMN__FLAG) {}
*/
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPROWSTATUS_FLAG)
+ {
+ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)
+ {
+ /* when row is created and not validated, there is nothing to do */
+ if ((rowreq_ctx->undo->eocTrapRowStatus & ROWSTATUS_NOTINSERVICE))
+ {
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_undo_commit",
+ "removing unvalidated row!\n"));
+ return MFD_SUCCESS;
+ }
+ }
+ else if (ROWSTATUS_DESTROY == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ /* if a row was deleted, restore it */
+ /* if restoring unvalidated row, there is nothing to do */
+ if ((rowreq_ctx->undo->eocTrapRowStatus & ROWSTATUS_NOTINSERVICE))
+ {
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_commit",
+ "restoring unvalidated row!\n"));
+ return MFD_SUCCESS;
+ }
+
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->undo->eocTrapIP, ip_undo);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+
+ /* convert IP address to string to serve as key for restoring line */
+ strcpy (trap_entry.ip_address, ip_undo);
+
+ /* add IP address of new row to internal storage list */
+ tmp = se_find_free_value_in_slist ("eoc_trap_list");
+ DEBUGMSGTL (("verbose:eocTrapTable:",
+ "eocTrapTable_undo_commit",
+ "se_find_value_in_slist found free value: %d\n",
+ tmp));
+ if (tmp == SE_DNE)
+ tmp = 1; /* Completely new list! */
+ se_add_pair_to_slist ("eoc_trap_list", strdup (ip_undo), tmp);
+
+ /* copy status to trap entry */
+ if (TRUTHVALUE_TRUE == rowreq_ctx->undo->eocTrapStatus)
+ {
+ strcpy (trap_entry.status, "1");
+ }
+ else
+ {
+ strcpy (trap_entry.status, "0");
+ }
+
+ /* copy community to trap entry */
+ strncpy (trap_entry.community, rowreq_ctx->undo->eocTrapCommunity,
+ rowreq_ctx->undo->eocTrapCommunity_len);
+ trap_entry.community[rowreq_ctx->undo->eocTrapCommunity_len] =
+ '\0';
+
+ /* clear flag for deletion */
+ rowreq_ctx->rowreq_flags &= ~MFD_ROW_DELETED;
+
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap"
+ " configuration file\n");
+ return MFD_ERROR;
+ }
+
+ ret = libspid_eoc_trap_set (&trap_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_set error\n");
+ return MFD_ERROR;
+ }
+ }
+ else if (ROWSTATUS_ACTIVE == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapTable_undo_commit",
+ "removing newly validated row!\n"));
+ /* if a row was validated (its status set to active) revert
+ * its status to notInService */
+ rowreq_ctx->data->eocTrapRowStatus =
+ rowreq_ctx->undo->eocTrapRowStatus;
+ /* also remove row data from config file */
+ /* convert IP address to string to serve as key for removing line */
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP, ip_save);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+ /* remove IP address from internal storage list */
+ if (NULL != se_find_slist ("eoc_trap_list"))
+ {
+ DEBUGMSGTL (("eocTrapTable_undo_commit:",
+ "trying to remove IP address from slist: %s\n",
+ ip_save));
+ ret = se_remove_label_from_slist ("eoc_trap_list", ip_save);
+ if (ret == SE_DNE)
+ {
+ snmp_log (LOG_ERR,
+ "Error! IP address not found in the table!\n");
+ return MFD_ERROR;
+ }
+ }
+ else
+ {
+ snmp_log (LOG_ERR,
+ "Trying to delete from empty IP address list!\n");
+ return MFD_ERROR;
+ }
+
+ /* if a new row was added, remove line with given index from
+ * service configuration file */
+ if (1 == trap_adding_row)
+ {
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap"
+ " configuration file\n");
+ return MFD_ERROR;
+ }
+
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_remove (ip_save))
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_remove error\n");
+ return MFD_ERROR;
+ }
+
+ /* if undo has successfully passed, clear service adding
+ * indication */
+ trap_adding_row = 0;
+ }
+ }
+ }
+ else
+ {
+ /* this case covers restoring modified columns
+ * (without row status modified) */
+ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)
+ && (ROWSTATUS_ACTIVE == rowreq_ctx->undo->eocTrapRowStatus))
+ {
+ DEBUGMSGTL (("eocTrapTable_undo_commit", "undoing data for "
+ "index:\n"));
+
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP, ip_save);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+ /* read existing line from configuration file */
+ ret = libspid_eoc_trap_get (ip_save, &trap_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_get error\n");
+ return MFD_ERROR;
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPIP_FLAG)
+ {
+ DEBUGMSGTL (("eocTrapTable_undo_commit", "ip read from "
+ "rowreq context: %s\n", ip_save));
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_remove (ip_save))
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_remove error\n");
+ return MFD_ERROR;
+ }
+
+ ret =
+ libspid_ip_bin_to_str (rowreq_ctx->undo->eocTrapIP,
+ ip_undo);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_ip_bin_to_str error\n");
+ return MFD_ERROR;
+ }
+
+ strcpy (trap_entry.ip_address, ip_undo);
+
+ /* remove reverted IP address from internal storage list */
+ if (NULL != se_find_slist ("eoc_trap_list"))
+ {
+ DEBUGMSGTL (("eocTrapTable_undo_commit:",
+ "trying to remove IP address from slist: %s\n",
+ ip_save));
+ ret = se_remove_label_from_slist ("eoc_trap_list",
+ ip_save);
+ if (ret == SE_DNE)
+ {
+ snmp_log (LOG_ERR, "Error! IP address not found"
+ " in internal storage list!\n");
+ return MFD_ERROR;
+ }
+ }
+ else
+ {
+ snmp_log (LOG_ERR, "Trying to delete from empty IP"
+ " address internal storage list!\n");
+ return MFD_ERROR;
+ }
+
+ /* add undone IP address to internal storage list */
+ tmp = se_find_free_value_in_slist ("eoc_trap_list");
+ DEBUGMSGTL (("verbose:eocTrapTable:",
+ "eocTrapTable_undo_commit",
+ "se_find_value_in_slist found free value: %d\n",
+ tmp));
+ if (tmp == SE_DNE)
+ tmp = 1; /* Completely new list! */
+ se_add_pair_to_slist ("eoc_trap_list", strdup (ip_undo), tmp);
+
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPCOMMUNITY_FLAG)
+ {
+ DEBUGMSGTL (("eocVLANTable_undo_commit", "community flag "
+ "read from rowreq context: %s\n",
+ rowreq_ctx->undo->eocTrapCommunity));
+ /* copy eocTrapCommunity to trap entry */
+ strncpy (trap_entry.community,
+ rowreq_ctx->undo->eocTrapCommunity,
+ rowreq_ctx->undo->eocTrapCommunity_len);
+ /* add terminal 0 to service name */
+ trap_entry.community[rowreq_ctx->undo->eocTrapCommunity_len] =
+ '\0';
+
+ }
+
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPSTATUS_FLAG)
+ {
+ DEBUGMSGTL (("eocVLANTable_undo_commit", "community flag "
+ "read from rowreq context: %ld\n",
+ rowreq_ctx->undo->eocTrapStatus));
+ if (TRUTHVALUE_TRUE == rowreq_ctx->undo->eocTrapStatus)
+ {
+ strcpy (trap_entry.status, "1");
+ }
+ else
+ {
+ strcpy (trap_entry.status, "0");
+ }
+
+ }
+
+ if (LIBSPID_SUCCESS != libspid_eoc_trap_check ())
+ {
+ snmp_log (LOG_ERR, "errors detected in trap"
+ " configuration file\n");
+ return MFD_ERROR;
+ }
+
+ /* write modified line to configuration file */
+ ret = libspid_eoc_trap_set (&trap_entry);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "libspid_eoc_trap_set error\n");
+ return MFD_ERROR;
+ }
+ else
+ {
+ DEBUGMSGTL (("eocVLANTable_undo_commit",
+ "line succesfully written to conf file!\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;
}
@@ -436,12 +979,12 @@ eocTrapTable_undo_commit( eocTrapTable_rowreq_ctx *rowreq_ctx)
* 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
@@ -458,15 +1001,36 @@ eocTrapTable_undo_commit( eocTrapTable_rowreq_ctx *rowreq_ctx)
int
eocTrapIP_check_value( eocTrapTable_rowreq_ctx *rowreq_ctx, char *eocTrapIP_val_ptr, size_t eocTrapIP_val_ptr_len)
{
- DEBUGMSGTL(("verbose:eocTrapTable:eocTrapIP_check_value","called\n"));
-
+ DEBUGMSGTL (("verbose:eocTrapTable:eocTrapIP_check_value", "called\n"));
+ char ip_address[LIBSPID_IP_STR_MAX_LEN];
+ int ret;
+ int tmp;
/** should never get a NULL pointer */
- netsnmp_assert(NULL != rowreq_ctx);
- netsnmp_assert(NULL != eocTrapIP_val_ptr);
+ netsnmp_assert (NULL != rowreq_ctx);
+ netsnmp_assert (NULL != eocTrapIP_val_ptr);
/*
* TODO:441:o: |-> Check for valid eocTrapIP value.
*/
+ ret = libspid_ip_bin_to_str (eocTrapIP_val_ptr, ip_address);
+ if (LIBSPID_SUCCESS != ret)
+ {
+ snmp_log (LOG_ERR, "eocTrapTable:",
+ "eocTrapIP_check_value",
+ "error converting IP address proposed value to string\n");
+ return MFD_ERROR;
+ }
+ /* check if proposed IP address already exists in internal storage list */
+ /* Ip address will be added to storage list when the row is
+ * validated (and conf file is updated) */
+ tmp = se_find_value_in_slist ("eoc_trap_list", ip_address);
+ if (tmp != SE_DNE)
+ {
+ DEBUGMSGTL (("verbose:eocTrapTable:",
+ "eocTrapIP_check_value",
+ "IP address already exists!\n"));
+ return MFD_NOT_VALID_EVER;
+ }
return MFD_SUCCESS; /* eocTrapIP value not illegal */
} /* eocTrapIP_check_value */
@@ -505,9 +1069,9 @@ eocTrapIP_undo_setup( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapIP and eocTrapIP_len data
* set rowreq_ctx->undo->eocTrapIP from rowreq_ctx->data.eocTrapIP
*/
- memcpy( rowreq_ctx->undo->eocTrapIP, rowreq_ctx->data.eocTrapIP,
- (rowreq_ctx->data.eocTrapIP_len * sizeof(rowreq_ctx->undo->eocTrapIP[0])));
- rowreq_ctx->undo->eocTrapIP_len = rowreq_ctx->data.eocTrapIP_len;
+ memcpy( rowreq_ctx->undo->eocTrapIP, rowreq_ctx->data->eocTrapIP,
+ (rowreq_ctx->data->eocTrapIP_len * sizeof(rowreq_ctx->undo->eocTrapIP[0])));
+ rowreq_ctx->undo->eocTrapIP_len = rowreq_ctx->data->eocTrapIP_len;
return MFD_SUCCESS;
@@ -538,10 +1102,10 @@ eocTrapIP_set( eocTrapTable_rowreq_ctx *rowreq_ctx, char *eocTrapIP_val_ptr, si
* TODO:461:M: |-> Set eocTrapIP value.
* set eocTrapIP value in rowreq_ctx->data
*/
- memcpy( rowreq_ctx->data.eocTrapIP, eocTrapIP_val_ptr, eocTrapIP_val_ptr_len );
+ memcpy( rowreq_ctx->data->eocTrapIP, eocTrapIP_val_ptr, eocTrapIP_val_ptr_len );
/** convert bytes to number of char */
- rowreq_ctx->data.eocTrapIP_len = eocTrapIP_val_ptr_len / sizeof(eocTrapIP_val_ptr[0]);
-
+ rowreq_ctx->data->eocTrapIP_len = eocTrapIP_val_ptr_len / sizeof(eocTrapIP_val_ptr[0]);
+ rowreq_ctx->column_exists_flags |= COLUMN_EOCTRAPIP_FLAG;
return MFD_SUCCESS;
} /* eocTrapIP_set */
@@ -566,11 +1130,11 @@ eocTrapIP_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapIP and eocTrapIP_len data
* set rowreq_ctx->data.eocTrapIP from rowreq_ctx->undo->eocTrapIP
*/
- memcpy( rowreq_ctx->data.eocTrapIP, rowreq_ctx->undo->eocTrapIP,
- (rowreq_ctx->undo->eocTrapIP_len * sizeof(rowreq_ctx->data.eocTrapIP[0])));
- rowreq_ctx->data.eocTrapIP_len = rowreq_ctx->undo->eocTrapIP_len;
+ memcpy( rowreq_ctx->data->eocTrapIP, rowreq_ctx->undo->eocTrapIP,
+ (rowreq_ctx->undo->eocTrapIP_len * sizeof(rowreq_ctx->data->eocTrapIP[0])));
+ rowreq_ctx->data->eocTrapIP_len = rowreq_ctx->undo->eocTrapIP_len;
+
-
return MFD_SUCCESS;
} /* eocTrapIP_undo */
@@ -613,12 +1177,12 @@ eocTrapIP_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* 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
@@ -682,9 +1246,9 @@ eocTrapCommunity_undo_setup( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapCommunity and eocTrapCommunity_len data
* set rowreq_ctx->undo->eocTrapCommunity from rowreq_ctx->data.eocTrapCommunity
*/
- memcpy( rowreq_ctx->undo->eocTrapCommunity, rowreq_ctx->data.eocTrapCommunity,
- (rowreq_ctx->data.eocTrapCommunity_len * sizeof(rowreq_ctx->undo->eocTrapCommunity[0])));
- rowreq_ctx->undo->eocTrapCommunity_len = rowreq_ctx->data.eocTrapCommunity_len;
+ memcpy( rowreq_ctx->undo->eocTrapCommunity, rowreq_ctx->data->eocTrapCommunity,
+ (rowreq_ctx->data->eocTrapCommunity_len * sizeof(rowreq_ctx->undo->eocTrapCommunity[0])));
+ rowreq_ctx->undo->eocTrapCommunity_len = rowreq_ctx->data->eocTrapCommunity_len;
return MFD_SUCCESS;
@@ -715,10 +1279,10 @@ eocTrapCommunity_set( eocTrapTable_rowreq_ctx *rowreq_ctx, char *eocTrapCommunit
* TODO:461:M: |-> Set eocTrapCommunity value.
* set eocTrapCommunity value in rowreq_ctx->data
*/
- memcpy( rowreq_ctx->data.eocTrapCommunity, eocTrapCommunity_val_ptr, eocTrapCommunity_val_ptr_len );
+ memcpy( rowreq_ctx->data->eocTrapCommunity, eocTrapCommunity_val_ptr, eocTrapCommunity_val_ptr_len );
/** convert bytes to number of char */
- rowreq_ctx->data.eocTrapCommunity_len = eocTrapCommunity_val_ptr_len / sizeof(eocTrapCommunity_val_ptr[0]);
-
+ rowreq_ctx->data->eocTrapCommunity_len = eocTrapCommunity_val_ptr_len / sizeof(eocTrapCommunity_val_ptr[0]);
+ rowreq_ctx->column_exists_flags |= COLUMN_EOCTRAPCOMMUNITY_FLAG;
return MFD_SUCCESS;
} /* eocTrapCommunity_set */
@@ -743,11 +1307,11 @@ eocTrapCommunity_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapCommunity and eocTrapCommunity_len data
* set rowreq_ctx->data.eocTrapCommunity from rowreq_ctx->undo->eocTrapCommunity
*/
- memcpy( rowreq_ctx->data.eocTrapCommunity, rowreq_ctx->undo->eocTrapCommunity,
- (rowreq_ctx->undo->eocTrapCommunity_len * sizeof(rowreq_ctx->data.eocTrapCommunity[0])));
- rowreq_ctx->data.eocTrapCommunity_len = rowreq_ctx->undo->eocTrapCommunity_len;
+ memcpy( rowreq_ctx->data->eocTrapCommunity, rowreq_ctx->undo->eocTrapCommunity,
+ (rowreq_ctx->undo->eocTrapCommunity_len * sizeof(rowreq_ctx->data->eocTrapCommunity[0])));
+ rowreq_ctx->data->eocTrapCommunity_len = rowreq_ctx->undo->eocTrapCommunity_len;
+
-
return MFD_SUCCESS;
} /* eocTrapCommunity_undo */
@@ -788,12 +1352,12 @@ eocTrapCommunity_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* 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
@@ -856,7 +1420,7 @@ eocTrapStatus_undo_setup( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapStatus data
* set rowreq_ctx->undo->eocTrapStatus from rowreq_ctx->data.eocTrapStatus
*/
- rowreq_ctx->undo->eocTrapStatus = rowreq_ctx->data.eocTrapStatus;
+ rowreq_ctx->undo->eocTrapStatus = rowreq_ctx->data->eocTrapStatus;
return MFD_SUCCESS;
@@ -884,7 +1448,8 @@ eocTrapStatus_set( eocTrapTable_rowreq_ctx *rowreq_ctx, u_long eocTrapStatus_val
* TODO:461:M: |-> Set eocTrapStatus value.
* set eocTrapStatus value in rowreq_ctx->data
*/
- rowreq_ctx->data.eocTrapStatus = eocTrapStatus_val;
+ rowreq_ctx->data->eocTrapStatus = eocTrapStatus_val;
+ rowreq_ctx->column_exists_flags |= COLUMN_EOCTRAPSTATUS_FLAG;
return MFD_SUCCESS;
} /* eocTrapStatus_set */
@@ -910,9 +1475,9 @@ eocTrapStatus_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapStatus data
* set rowreq_ctx->data.eocTrapStatus from rowreq_ctx->undo->eocTrapStatus
*/
- rowreq_ctx->data.eocTrapStatus = rowreq_ctx->undo->eocTrapStatus;
+ rowreq_ctx->data->eocTrapStatus = rowreq_ctx->undo->eocTrapStatus;
+
-
return MFD_SUCCESS;
} /* eocTrapStatus_undo */
@@ -928,7 +1493,7 @@ eocTrapStatus_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
notInService(2)- 状态未激活;
notReady(3)- 不能被激活状态;
createAndGo(4)- 创建并激活;
- createAndWait(5)- 创建,但不激活;
+ createAndWait(5)- 创建,但不激活;
destory(6)- 销毁该行。
*
* Attributes:
@@ -960,12 +1525,12 @@ eocTrapStatus_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* 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
@@ -990,6 +1555,11 @@ eocTrapRowStatus_check_value( eocTrapTable_rowreq_ctx *rowreq_ctx, u_long eocTra
/*
* TODO:441:o: |-> Check for valid eocTrapRowStatus value.
*/
+ if (ROWSTATUS_CREATEANDGO == eocTrapRowStatus_val)
+ {
+ DEBUGMSGTL (("eocVLANTable", "createAndGo not supported\n"));
+ return MFD_NOT_VALID_EVER;
+ }
return MFD_SUCCESS; /* eocTrapRowStatus value not illegal */
} /* eocTrapRowStatus_check_value */
@@ -1028,7 +1598,7 @@ eocTrapRowStatus_undo_setup( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapRowStatus data
* set rowreq_ctx->undo->eocTrapRowStatus from rowreq_ctx->data.eocTrapRowStatus
*/
- rowreq_ctx->undo->eocTrapRowStatus = rowreq_ctx->data.eocTrapRowStatus;
+ rowreq_ctx->undo->eocTrapRowStatus = rowreq_ctx->data->eocTrapRowStatus;
return MFD_SUCCESS;
@@ -1056,7 +1626,7 @@ eocTrapRowStatus_set( eocTrapTable_rowreq_ctx *rowreq_ctx, u_long eocTrapRowStat
* TODO:461:M: |-> Set eocTrapRowStatus value.
* set eocTrapRowStatus value in rowreq_ctx->data
*/
- rowreq_ctx->data.eocTrapRowStatus = eocTrapRowStatus_val;
+ rowreq_ctx->data->eocTrapRowStatus = eocTrapRowStatus_val;
return MFD_SUCCESS;
} /* eocTrapRowStatus_set */
@@ -1082,10 +1652,161 @@ eocTrapRowStatus_undo( eocTrapTable_rowreq_ctx *rowreq_ctx)
* copy eocTrapRowStatus data
* set rowreq_ctx->data.eocTrapRowStatus from rowreq_ctx->undo->eocTrapRowStatus
*/
- rowreq_ctx->data.eocTrapRowStatus = rowreq_ctx->undo->eocTrapRowStatus;
+ rowreq_ctx->data->eocTrapRowStatus = rowreq_ctx->undo->eocTrapRowStatus;
+
-
return MFD_SUCCESS;
} /* eocTrapRowStatus_undo */
+
+/* change from template: added check for dependencies */
+/**
+ * check dependencies
+ *
+ * This is useful for for tables which have dependencies between columns
+ * (or rows, or tables). For example, two columns allocating a percentage
+ * of something add up 100%.
+ *
+ * Should you need different behavior depending on which columns were
+ * set, rowreq_ctx->column_set_flags will indicate which writeable columns were
+ * set. The definitions for the COLUMN_*_FLAG bits can be found in
+ * eocVLANTable_oids.h.
+ * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags.
+ *
+ * @retval MFD_SUCCESS all the changes to the row are legal
+ * @retval MFD_ERROR one or more changes are not legal
+ *
+ * (see README-table-eocVLANTable if you don't have dependencies)
+ */
+int
+eocTrapTable_check_dependencies(eocTrapTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ DEBUGMSGTL (("internal:eocVLANTable:eocVLANTable_check_dependencies",
+ "called\n"));
+
+ netsnmp_assert (NULL != rowreq_ctx);
+
+ /*
+ * TODO:470:o: Check eocVLANTable row dependencies.
+ * check that all new value are legal and consistent with each other
+ */
+ /*
+ * check RowStatus dependencies
+ */
+ if (rowreq_ctx->column_set_flags & COLUMN_EOCTRAPROWSTATUS_FLAG)
+ {
+ /*
+ * check for valid RowStatus transition (old, new)
+ * (Note: move transition check to
+ * to catch errors earlier)
+ */
+ rc = check_rowstatus_transition (rowreq_ctx->undo->eocTrapRowStatus,
+ rowreq_ctx->data->eocTrapRowStatus);
+
+ if (MFD_SUCCESS != rc)
+ {
+ DEBUGMSGTL (("eocVLANTable", "row status transition from %d to "
+ "%d\n", rowreq_ctx->undo->eocTrapRowStatus,
+ rowreq_ctx->data->eocTrapRowStatus));
+ return rc;
+ }
+ /*
+ * row creation requirements
+ */
+ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)
+ {
+ /* this case permits creating row with rowstatus 'destroy' -
+ * row is created and immediately deleted */
+ if (ROWSTATUS_DESTROY == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED;
+ }
+ else if (ROWSTATUS_CREATEANDWAIT ==
+ rowreq_ctx->data->eocTrapRowStatus)
+ {
+ /* set row adding indication */
+ trap_adding_row = 1;
+ rowreq_ctx->data->eocTrapRowStatus = ROWSTATUS_NOTINSERVICE;
+ }
+ } /* row creation */
+ else
+ {
+ /*
+ * row change requirements
+ */
+ /*
+ * don't allow a destroy if any other value was changed, since
+ * that might call data access routines with bad info.
+ *
+ * you may or may not require the row be notInService before it
+ * can be destroyed.
+ */
+ if (ROWSTATUS_DESTROY == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ if (rowreq_ctx->column_set_flags &
+ ~COLUMN_EOCTRAPROWSTATUS_FLAG)
+ {
+ DEBUGMSGTL (("eocVLANTable", "destroy must be only "
+ "varbind for row\n"));
+ return MFD_NOT_VALID_NOW;
+ }
+ rowreq_ctx->rowreq_flags |= MFD_ROW_DELETED;
+
+ } /* row destroy */
+ else if (ROWSTATUS_NOTINSERVICE ==
+ rowreq_ctx->data->eocTrapRowStatus)
+ {
+ /* do not permit invalidating once validated row */
+ if (rowreq_ctx->undo->eocTrapRowStatus & ROWSTATUS_ACTIVE)
+ {
+ DEBUGMSGTL (("eocVLANTable",
+ "Row status can't be changed "
+ "from Active to Not In Service!\n"));
+ return MFD_NOT_VALID_EVER;
+ }
+ }
+ else if (ROWSTATUS_ACTIVE == rowreq_ctx->data->eocTrapRowStatus)
+ {
+ /* before setting row to active, check that all columns are filled */
+ if ((rowreq_ctx->column_exists_flags &
+ EOCTRAPTABLE_REQUIRED_COLS) !=
+ EOCTRAPTABLE_REQUIRED_COLS)
+ {
+ DEBUGMSGTL (("eocVLANTable", "required columns from "
+ "modEoCCNU table missing (0x%0x != 0x%0x)\n",
+ rowreq_ctx->column_exists_flags,
+ EOCTRAPTABLE_REQUIRED_COLS));
+ return MFD_NOT_VALID_NOW;
+ }
+ rowreq_ctx->data->eocTrapRowStatus = ROWSTATUS_ACTIVE;
+ }
+ } /* row change */
+ }
+ else
+ {
+ /*
+ * must have row status to create a row
+ */
+ if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)
+ {
+ DEBUGMSGTL (("eocVLANTable",
+ "must use RowStatus to create rows\n"));
+ return MFD_CANNOT_CREATE_NOW;
+ }
+ else if (ROWSTATUS_ACTIVE == rowreq_ctx->data->eocTrapRowStatus)
+ {
+
+ }
+ } /* row status not set */
+
+ if (MFD_SUCCESS != rc)
+ return rc;
+
+ return rc;
+} /* eocVLANTable_check_dependencies */
+ /* modEoCCNUServiceTable_check_dependencies */
+
+
/** @} */
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.c b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.c
index 2b9db002eb..abf3b0d0bb 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.c
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.c
@@ -1,6 +1,6 @@
/*
* Note: this file originally auto-generated by mib2c using
- * version : 15899 $ of $
+ * version : 15899 $ of $
*
* $Id:$
*/
@@ -60,7 +60,7 @@ typedef struct eocTrapTable_interface_ctx_s {
netsnmp_cache *cache;
eocTrapTable_registration * user_ctx;
-
+
netsnmp_table_registration_info tbl_info;
netsnmp_baby_steps_access_methods access_multiplexer;
@@ -133,6 +133,8 @@ static Netsnmp_Node_Handler _mfd_eocTrapTable_undo_values;
static Netsnmp_Node_Handler _mfd_eocTrapTable_commit;
static Netsnmp_Node_Handler _mfd_eocTrapTable_undo_commit;
static Netsnmp_Node_Handler _mfd_eocTrapTable_irreversible_commit;
+static Netsnmp_Node_Handler _mfd_eocTrapTable_check_dependencies;
+
NETSNMP_STATIC_INLINE int _eocTrapTable_undo_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
netsnmp_variable_list *var, int column );
@@ -142,8 +144,30 @@ NETSNMP_STATIC_INLINE int _eocTrapTable_check_indexes(eocTrapTable_rowreq_ctx *
eocTrapTable_data *eocTrapTable_allocate_data(void);
/**
+ * common init of container for eocTrapTable and spc300EoCSlaveServiceTable
+ */
+void
+trap_container_init (void)
+{
+ static int done = 0;
+
+ if (done)
+ return;
+
+ DEBUGMSGTL (("internal:eocTrapTable:trap_container_init", "called\n"));
+
+ done = 1;
+
+ /*
+ * set up the container
+ */
+ _eocTrapTable_container_init (&eocTrapTable_if_ctx);
+}
+
+
+/**
* @internal
- * Initialize the table eocTrapTable
+ * Initialize the table eocTrapTable
* (Define its contents and how it's structured)
*/
void
@@ -158,6 +182,9 @@ _eocTrapTable_initialize_interface(eocTrapTable_registration * reg_ptr, u_long
DEBUGMSGTL(("internal:eocTrapTable:_eocTrapTable_initialize_interface","called\n"));
+ (void) trap_container_init ();
+ if (NULL == eocTrapTable_if_ctx.container)
+ return; /* msg already logged */
/*************************************************
*
@@ -193,7 +220,7 @@ _eocTrapTable_initialize_interface(eocTrapTable_registration * reg_ptr, u_long
snmp_log(LOG_ERR,"could not initialize container for eocTrapTable\n");
return;
}
-
+
/*
* access_multiplexer: REQUIRED wrapper for get request handling
*/
@@ -223,12 +250,21 @@ _eocTrapTable_initialize_interface(eocTrapTable_registration * reg_ptr, u_long
access_multiplexer->undo_commit = _mfd_eocTrapTable_undo_commit;
access_multiplexer->irreversible_commit = _mfd_eocTrapTable_irreversible_commit;
+ /* change from template: added check for dependencies */
+ /*
+ * REQUIRED for tables with dependencies
+ */
+
+ access_multiplexer->consistency_checks =
+ _mfd_eocTrapTable_check_dependencies;
+
+
/*************************************************
*
* Create a registration, save our reg data, register table.
*/
DEBUGMSGTL(("eocTrapTable:init_eocTrapTable",
- "Registering eocTrapTable as a mibs-for-dummies table.\n"));
+ "Registering eocTrapTable as a mibs-for-dummies table.\n"));
handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
reginfo = netsnmp_handler_registration_create("eocTrapTable", handler,
eocTrapTable_oid,
@@ -259,14 +295,14 @@ _eocTrapTable_initialize_interface(eocTrapTable_registration * reg_ptr, u_long
mfd_modes |= BABY_STEP_PRE_REQUEST;
if( access_multiplexer->post_request )
mfd_modes |= BABY_STEP_POST_REQUEST;
-
+
if( access_multiplexer->undo_setup )
mfd_modes |= BABY_STEP_UNDO_SETUP;
if( access_multiplexer->undo_cleanup )
mfd_modes |= BABY_STEP_UNDO_CLEANUP;
if( access_multiplexer->undo_sets )
mfd_modes |= BABY_STEP_UNDO_SETS;
-
+
if( access_multiplexer->row_creation )
mfd_modes |= BABY_STEP_ROW_CREATE;
if( access_multiplexer->consistency_checks )
@@ -275,7 +311,7 @@ _eocTrapTable_initialize_interface(eocTrapTable_registration * reg_ptr, u_long
mfd_modes |= BABY_STEP_COMMIT;
if( access_multiplexer->undo_commit )
mfd_modes |= BABY_STEP_UNDO_COMMIT;
-
+
handler = netsnmp_baby_steps_handler_get(mfd_modes);
netsnmp_inject_handler(reginfo, handler);
@@ -340,7 +376,7 @@ eocTrapTable_index_to_oid(netsnmp_index *oid_idx,
eocTrapTable_mib_index *mib_idx)
{
int err = SNMP_ERR_NOERROR;
-
+
/*
* temp storage for parsing indexes
*/
@@ -392,7 +428,7 @@ eocTrapTable_index_from_oid(netsnmp_index *oid_idx,
eocTrapTable_mib_index *mib_idx)
{
int err = SNMP_ERR_NOERROR;
-
+
/*
* temp storage for parsing indexes
*/
@@ -454,6 +490,13 @@ eocTrapTable_allocate_data(void)
snmp_log(LOG_ERR, "unable to malloc memory for new "
"eocTrapTable_data.\n");
}
+ else
+ {
+ /* initialization of fields added for container comparison */
+ rtn->oid_index.len = 1;
+ rtn->oid_index.oids = &rtn->st_index;
+ }
+
return rtn;
} /* eocTrapTable_allocate_data */
@@ -467,6 +510,8 @@ void
eocTrapTable_release_data(eocTrapTable_data *data)
{
DEBUGMSGTL(("verbose:eocTrapTable:eocTrapTable_release_data","called\n"));
+ if (NULL == data)
+ return;
free(data);
} /* eocTrapTable_release_data */
@@ -476,7 +521,7 @@ eocTrapTable_release_data(eocTrapTable_data *data)
* allocate resources for a eocTrapTable_rowreq_ctx
*/
eocTrapTable_rowreq_ctx *
-eocTrapTable_allocate_rowreq_ctx(void *user_init_ctx)
+eocTrapTable_allocate_rowreq_ctx(eocTrapTable_data *data, void *user_init_ctx)
{
eocTrapTable_rowreq_ctx *rowreq_ctx =
SNMP_MALLOC_TYPEDEF(eocTrapTable_rowreq_ctx);
@@ -488,6 +533,49 @@ eocTrapTable_allocate_rowreq_ctx(void *user_init_ctx)
"eocTrapTable_rowreq_ctx.\n");
return NULL;
}
+ else
+ {
+ if (NULL != data)
+ {
+ /*
+ * track if we got data from user
+ */
+ DEBUGMSGTL (("internal:eocTrapTable:eocTrapTable_allocate_rowreq_ctx", "data got from user\n"));
+ rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
+ rowreq_ctx->data = data;
+
+ /* TEMP: maybe set column_exists_flags somewhere else? */
+ /* TODO: check if index flag can be set here? */
+
+ if (NULL == rowreq_ctx->data->eocTrapCommunity)
+ {
+ DEBUGMSGTL (("internal:eocTrapTable:eocTrapTable_allocate_rowreq_ctx", "community name null\n"));
+ }
+ else
+ {
+ rowreq_ctx->column_exists_flags |=
+ COLUMN_EOCTRAPCOMMUNITY_FLAG;
+ }
+
+ if (NULL == rowreq_ctx->data->eocTrapIP)
+ {
+ DEBUGMSGTL (("internal:eocTrapTable:eocTrapTable_allocate_rowreq_ctx", "trap ip null\n"));
+ }
+ else
+ {
+ rowreq_ctx->column_exists_flags |= COLUMN_EOCTRAPIP_FLAG;
+ }
+
+ rowreq_ctx->column_exists_flags |= COLUMN_EOCTRAPSTATUS_FLAG;
+ /* Row Status flag set to existing for allocation purposes */
+ rowreq_ctx->column_exists_flags |= COLUMN_EOCTRAPROWSTATUS_FLAG;
+ }
+ else if (NULL == (rowreq_ctx->data = eocTrapTable_allocate_data ()))
+ {
+ SNMP_FREE (rowreq_ctx);
+ return NULL;
+ }
+ }
rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
@@ -496,11 +584,13 @@ eocTrapTable_allocate_rowreq_ctx(void *user_init_ctx)
/*
* if we allocated data, call init routine
*/
- if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) {
- if(SNMPERR_SUCCESS !=
- eocTrapTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
- eocTrapTable_release_rowreq_ctx(rowreq_ctx);
- rowreq_ctx = NULL;
+ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
+ {
+ if (SNMPERR_SUCCESS !=
+ eocTrapTable_rowreq_ctx_init (rowreq_ctx, user_init_ctx))
+ {
+ eocTrapTable_release_rowreq_ctx (rowreq_ctx);
+ rowreq_ctx = NULL;
}
}
@@ -517,12 +607,18 @@ eocTrapTable_release_rowreq_ctx(eocTrapTable_rowreq_ctx *rowreq_ctx)
DEBUGMSGTL(("internal:eocTrapTable:eocTrapTable_release_rowreq_ctx","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
-
+
eocTrapTable_rowreq_ctx_cleanup(rowreq_ctx);
+ if ((rowreq_ctx->data)
+ && !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
+ {
+ eocTrapTable_release_data (rowreq_ctx->data);
+ }
+
if(rowreq_ctx->undo)
eocTrapTable_release_data(rowreq_ctx->undo);
-
+
/*
* free index oid pointer
*/
@@ -546,13 +642,13 @@ _mfd_eocTrapTable_pre_request(netsnmp_mib_handler *handler,
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_pre_request",
"called\n"));
-
+
if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) {
DEBUGMSGTL(("internal:eocTrapTable",
"skipping additional pre_request\n"));
return SNMP_ERR_NOERROR;
}
-
+
rc = eocTrapTable_pre_request(eocTrapTable_if_ctx.user_ctx);
if (MFD_SUCCESS != rc) {
/*
@@ -562,7 +658,7 @@ _mfd_eocTrapTable_pre_request(netsnmp_mib_handler *handler,
"eocTrapTable_pre_request\n", rc));
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
}
-
+
return SNMP_ERR_NOERROR;
} /* _mfd_eocTrapTable_pre_request */
@@ -597,7 +693,7 @@ _mfd_eocTrapTable_post_request(netsnmp_mib_handler *handler,
"waiting for last post_request\n"));
return SNMP_ERR_NOERROR;
}
-
+
packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0);
if ((MFD_SUCCESS != packet_rc) && eocTrapTable_dirty_get()) {
/*
@@ -616,7 +712,7 @@ _mfd_eocTrapTable_post_request(netsnmp_mib_handler *handler,
DEBUGMSGTL(("eocTrapTable","error %d from "
"eocTrapTable_post_request\n", rc));
}
-
+
return SNMP_ERR_NOERROR;
} /* _mfd_eocTrapTable_post_request */
@@ -639,7 +735,7 @@ _mfd_eocTrapTable_rowreq_from_index(netsnmp_index *oid_idx, int * rc_ptr)
*rc_ptr = MFD_SUCCESS;
memset(&mib_idx, 0x0, sizeof(mib_idx));
-
+
/*
* try to parse oid
*/
@@ -652,12 +748,12 @@ _mfd_eocTrapTable_rowreq_from_index(netsnmp_index *oid_idx, int * rc_ptr)
/*
* allocate new context
*/
- rowreq_ctx = eocTrapTable_allocate_rowreq_ctx(NULL);
+ rowreq_ctx = eocTrapTable_allocate_rowreq_ctx (NULL, NULL);
if (NULL == rowreq_ctx) {
*rc_ptr = MFD_ERROR;
return NULL; /* msg already logged */
}
-
+
memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx));
/*
@@ -694,7 +790,7 @@ _mfd_eocTrapTable_object_lookup(netsnmp_mib_handler *handler,
int rc = SNMP_ERR_NOERROR;
eocTrapTable_rowreq_ctx *rowreq_ctx =
netsnmp_container_table_row_extract(requests);
-
+
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_object_lookup","called\n"));
/*
@@ -752,7 +848,7 @@ _eocTrapTable_get_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
netsnmp_variable_list *var, int column )
{
int rc = SNMPERR_SUCCESS;
-
+
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_get_column",
"called for %d\n", column));
@@ -787,7 +883,6 @@ rc = eocTrapIP_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
"column %d (eocTrapCommunity) doesn't exist\n", column));
return MFD_SKIP;
}
-
var->type = ASN_OCTET_STR;
rc = eocTrapCommunity_get(rowreq_ctx, (char **)&var->val.string, &var->val_len );
break;
@@ -849,7 +944,7 @@ _mfd_eocTrapTable_get_values(netsnmp_mib_handler *handler,
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_get_values","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
-
+
DEBUGMSGTL(("9:eocTrapTable:_mfd_eocTrapTable_get_values",
"exists %p\n", (void*)rowreq_ctx->column_exists_flags));
@@ -874,7 +969,7 @@ _mfd_eocTrapTable_get_values(netsnmp_mib_handler *handler,
tri = netsnmp_extract_table_info(requests);
if(NULL == tri)
continue;
-
+
rc = _eocTrapTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum);
if(rc) {
if(MFD_SKIP == rc) {
@@ -955,7 +1050,7 @@ _eocTrapTable_check_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
netsnmp_variable_list *var, int column )
{
int rc = SNMPERR_SUCCESS;
-
+
DEBUGMSGTL(("internal:eocTrapTable:_eocTrapTable_check_column",
"called for %d\n", column));
@@ -969,26 +1064,31 @@ _eocTrapTable_check_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
/* eocTrapIP(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h */
case COLUMN_EOCTRAPIP:
- rc = netsnmp_check_vb_type_and_max_size( var, ASN_OCTET_STR,
- sizeof( rowreq_ctx->data.eocTrapIP ) );
- if(SNMPERR_SUCCESS != rc) {
- DEBUGMSGTL(("eocTrapTable:_eocTrapTable_check_column:eocTrapIP",
- "varbind validation failed (eg bad type or size)\n"));
- }
- else {
- rc = eocTrapIP_check_value( rowreq_ctx, (char *)var->val.string, var->val_len );
- if((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) &&
- (MFD_NOT_VALID_NOW != rc)) {
- snmp_log(LOG_ERR, "bad rc %d from eocTrapIP_check_value\n", rc);
- rc = SNMP_ERR_GENERR;
+ rc = netsnmp_check_vb_type (var, ASN_IPADDRESS);
+
+ if (SNMPERR_SUCCESS != rc)
+ {
+ DEBUGMSGTL (("eocTrapTable:_eocTrapTable_check_column:eocTrapIP",
+ "varbind validation failed (eg bad type or size)\n"));
+ }
+ else
+ {
+ rc = eocTrapIP_check_value (rowreq_ctx, (char *) var->val.string,
+ var->val_len);
+ if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc)
+ && (MFD_NOT_VALID_NOW != rc))
+ {
+ snmp_log (LOG_ERR, "bad rc %d from eocTrapIP_check_value\n",
+ rc);
+ rc = SNMP_ERR_GENERR;
+ }
}
- }
break;
/* eocTrapCommunity(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/r/d/h */
case COLUMN_EOCTRAPCOMMUNITY:
rc = netsnmp_check_vb_type_and_max_size( var, ASN_OCTET_STR,
- sizeof( rowreq_ctx->data.eocTrapCommunity ) );
+ sizeof( rowreq_ctx->data->eocTrapCommunity ) );
if(SNMPERR_SUCCESS != rc) {
DEBUGMSGTL(("eocTrapTable:_eocTrapTable_check_column:eocTrapCommunity",
"varbind validation failed (eg bad type or size)\n"));
@@ -1006,7 +1106,7 @@ _eocTrapTable_check_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
/* eocTrapStatus(4)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */
case COLUMN_EOCTRAPSTATUS:
rc = netsnmp_check_vb_type_and_size( var, ASN_INTEGER,
- sizeof( rowreq_ctx->data.eocTrapStatus ) );
+ sizeof( rowreq_ctx->data->eocTrapStatus ) );
/* check that the value is one of defined enums */
if( (SNMPERR_SUCCESS == rc)
&& ( *var->val.integer != TRUTHVALUE_TRUE )
@@ -1067,7 +1167,7 @@ _mfd_eocTrapTable_check_objects(netsnmp_mib_handler *handler,
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_check_objects","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
-
+
for(;requests; requests = requests->next) {
/*
@@ -1088,6 +1188,44 @@ _mfd_eocTrapTable_check_objects(netsnmp_mib_handler *handler,
return SNMP_ERR_NOERROR;
} /* _mfd_eocTrapTable_check_objects */
+/* change from template: added check for dependencies */
+/*----------------------------------------------------------------------
+ *
+ * SET: check dependencies
+ *
+ *---------------------------------------------------------------------*/
+/*
+ * @internal
+ * Check dependencies wrapper
+ */
+static int
+_mfd_eocTrapTable_check_dependencies (netsnmp_mib_handler
+ * handler,
+ netsnmp_handler_registration
+ * reginfo,
+ netsnmp_agent_request_info
+ * agtreq_info,
+ netsnmp_request_info * requests)
+{
+ int rc;
+ eocTrapTable_rowreq_ctx *rowreq_ctx =
+ netsnmp_container_table_row_extract (requests);
+ DEBUGMSGTL (("internal:eocTrapTable:_mfd_eocTrap_check_dependencies",
+ "called\n"));
+
+ netsnmp_assert (NULL != rowreq_ctx);
+
+ rc = eocTrapTable_check_dependencies (rowreq_ctx);
+ if (rc)
+ {
+ DEBUGMSGTL (("eocTrapTable:mfd", "error %d from "
+ "eocTrapTable_check_dependencies\n", rc));
+ netsnmp_request_set_error_all (requests, SNMP_VALIDATE_ERR (rc));
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* _mfd_eocCNUServiceTable_check_objects */
+
/*----------------------------------------------------------------------
*
@@ -1102,7 +1240,7 @@ NETSNMP_STATIC_INLINE int
_eocTrapTable_undo_setup_column( eocTrapTable_rowreq_ctx *rowreq_ctx, int column )
{
int rc = SNMPERR_SUCCESS;
-
+
DEBUGMSGTL(("internal:eocTrapTable:_eocTrapTable_undo_setup_column",
"called for %d\n", column));
@@ -1142,6 +1280,39 @@ _eocTrapTable_undo_setup_column( eocTrapTable_rowreq_ctx *rowreq_ctx, int column
return rc;
} /* _eocTrapTable_undo_setup_column */
+/* TODO: check if this is really necessary? */
+int
+_mfd_eocTrap_undo_setup_allocate (eocTrapTable_rowreq_ctx * rowreq_ctx)
+{
+ int rc = MFD_SUCCESS;
+
+ if (NULL == rowreq_ctx)
+ return MFD_ERROR;
+
+ /*
+ * other tables share our container/context and call
+ * this function. so we need to check and see if
+ * someone else already allocated data
+ */
+ if (NULL == rowreq_ctx->undo)
+ {
+ rowreq_ctx->undo = eocTrapTable_allocate_data ();
+ if (NULL == rowreq_ctx->undo)
+ {
+ /** msg already logged */
+ rc = SNMP_ERR_RESOURCEUNAVAILABLE;
+ }
+ else
+ {
+ /* TODO: check if something should be done here? */
+ }
+ }
+ ++rowreq_ctx->undo_ref_count;
+ DEBUGMSGTL (("internal:eocTrapTable:_mfd_eocTrapTable_undo_setup_allocate", "++undo_refcount = %d\n", rowreq_ctx->undo_ref_count));
+
+ return rc;
+}
+
/**
* @internal
@@ -1193,7 +1364,7 @@ _mfd_eocTrapTable_undo_setup(netsnmp_mib_handler *handler,
tri = netsnmp_extract_table_info(requests);
if(NULL == tri)
continue;
-
+
rc = _eocTrapTable_undo_setup_column(rowreq_ctx, tri->colnum);
if(MFD_SUCCESS != rc) {
DEBUGMSGTL(("eocTrapTable:mfd","error %d from "
@@ -1202,10 +1373,28 @@ _mfd_eocTrapTable_undo_setup(netsnmp_mib_handler *handler,
}
} /* for results */
}
-
+
return SNMP_ERR_NOERROR;
} /* _mfd_eocTrapTable_undo_setup */
+void
+_mfd_eocTrapTable_undo_setup_release (eocTrapTable_rowreq_ctx * rowreq_ctx)
+{
+ DEBUGMSGTL (("internal:eocTrapTable:_mfd_eocTrapTable_undo_setup_release",
+ "called\n"));
+
+ netsnmp_assert (rowreq_ctx->undo_ref_count > 0);
+ --rowreq_ctx->undo_ref_count;
+ snmp_log (LOG_ERR, "undo_refcount at %d\n", rowreq_ctx->undo_ref_count);
+
+ if (0 == rowreq_ctx->undo_ref_count)
+ {
+ eocTrapTable_release_data (rowreq_ctx->undo);
+ rowreq_ctx->undo = NULL;
+ }
+}
+
+
/**
* @internal
* undo setup
@@ -1231,7 +1420,7 @@ _mfd_eocTrapTable_undo_cleanup(netsnmp_mib_handler *handler,
/*
* call user cleanup
*/
- rc = eocTrapTable_undo_cleanup(rowreq_ctx);
+ rc = eocTrapTable_undo_cleanup (rowreq_ctx);
if (MFD_SUCCESS != rc) {
/*
* nothing we can do about it but log it
@@ -1243,10 +1432,7 @@ _mfd_eocTrapTable_undo_cleanup(netsnmp_mib_handler *handler,
/*
* release undo context, if needed
*/
- if(rowreq_ctx->undo) {
- eocTrapTable_release_data(rowreq_ctx->undo);
- rowreq_ctx->undo = NULL;
- }
+ _mfd_eocTrapTable_undo_setup_release(rowreq_ctx);
return SNMP_ERR_NOERROR;
@@ -1266,7 +1452,7 @@ _eocTrapTable_set_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
netsnmp_variable_list *var, int column )
{
int rc = SNMPERR_SUCCESS;
-
+
DEBUGMSGTL(("internal:eocTrapTable:_eocTrapTable_set_column",
"called for %d\n", column));
@@ -1303,7 +1489,7 @@ _eocTrapTable_set_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
rc = SNMP_ERR_GENERR;
break;
}
-
+
return rc;
} /* _eocTrapTable_set_column */
@@ -1321,7 +1507,7 @@ _mfd_eocTrapTable_set_values(netsnmp_mib_handler *handler,
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_set_values","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
-
+
rowreq_ctx->column_set_flags = 0;
for(;requests; requests = requests->next) {
/*
@@ -1330,7 +1516,7 @@ _mfd_eocTrapTable_set_values(netsnmp_mib_handler *handler,
tri = netsnmp_extract_table_info(requests);
if(NULL == tri)
continue;
-
+
rc = _eocTrapTable_set_column(rowreq_ctx,
requests->requestvb, tri->colnum);
if(MFD_SUCCESS != rc) {
@@ -1365,7 +1551,7 @@ _mfd_eocTrapTable_commit(netsnmp_mib_handler *handler,
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_commit","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
-
+
rc = eocTrapTable_commit(rowreq_ctx);
if (MFD_SUCCESS != rc) {
DEBUGMSGTL(("eocTrapTable:mfd","error %d from "
@@ -1438,7 +1624,7 @@ _eocTrapTable_undo_column( eocTrapTable_rowreq_ctx *rowreq_ctx,
netsnmp_variable_list *var, int column )
{
int rc = SNMPERR_SUCCESS;
-
+
DEBUGMSGTL(("internal:eocTrapTable:_eocTrapTable_undo_column",
"called for %d\n", column));
@@ -1488,7 +1674,7 @@ _mfd_eocTrapTable_undo_values(netsnmp_mib_handler *handler,
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_undo_values","called\n"));
netsnmp_assert(NULL != rowreq_ctx);
-
+
rc = eocTrapTable_undo(rowreq_ctx);
if (MFD_SUCCESS != rc) {
/*
@@ -1497,7 +1683,7 @@ _mfd_eocTrapTable_undo_values(netsnmp_mib_handler *handler,
DEBUGMSGTL(("eocTrapTable:mfd","error %d from "
"eocTrapTable_undo\n", rc));
}
-
+
for(;requests; requests = requests->next) {
/*
* set column data
@@ -1505,7 +1691,7 @@ _mfd_eocTrapTable_undo_values(netsnmp_mib_handler *handler,
tri = netsnmp_extract_table_info(requests);
if(NULL == tri)
continue;
-
+
rc = _eocTrapTable_undo_column(rowreq_ctx, requests->requestvb,
tri->colnum);
if (MFD_SUCCESS != rc) {
@@ -1537,11 +1723,11 @@ _mfd_eocTrapTable_irreversible_commit(netsnmp_mib_handler *handler,
{
eocTrapTable_rowreq_ctx *rowreq_ctx =
netsnmp_container_table_row_extract(requests);
-
+
DEBUGMSGTL(("internal:eocTrapTable:_mfd_eocTrapTable_irreversible:commit","called\n"));
-
+
netsnmp_assert(NULL != rowreq_ctx);
-
+
/*
* check for and handle row creation/deletion
* and update column exist flags...
@@ -1593,11 +1779,23 @@ _cache_load(netsnmp_cache *cache, void *vmagic)
/** should only be called for an invalid or expired cache */
netsnmp_assert((0 == cache->valid) || (1 == cache->expired));
-
+
/*
* call user code
*/
- return eocTrapTable_container_load((netsnmp_container*)cache->magic);
+ /* do not load cache if new row is currently being added */
+ if (trap_adding_row)
+ {
+ snmp_log (LOG_ERR,
+ "skipping eocTrapTable_cache_load, row adding in progress\n");
+ return SNMP_ERR_NOERROR;
+ }
+ else
+ {
+
+ return eocTrapTable_container_load ((netsnmp_container *)
+ cache->magic);
+ }
} /* _cache_load */
/**
@@ -1616,8 +1814,16 @@ _cache_free(netsnmp_cache *cache, void *magic)
}
container = (netsnmp_container*)cache->magic;
-
- _container_free(container);
+ /* do not free cache if new row is currently being added */
+ if (!trap_adding_row)
+ {
+ _container_free (container);
+ }
+ else
+ {
+ snmp_log (LOG_ERR,
+ "skipping modEoCCNUWhiteListTable_cache_free, row adding in progress\n");
+ }
} /* _cache_free */
/**
@@ -1627,12 +1833,31 @@ static void
_container_item_free(eocTrapTable_rowreq_ctx *rowreq_ctx, void *context)
{
DEBUGMSGTL(("internal:eocTrapTable:_container_item_free","called\n"));
+ char key_buffer[LIBSPID_KEY_MAX_LEN];
+ int ret;
if(NULL == rowreq_ctx)
return;
- eocTrapTable_release_rowreq_ctx(rowreq_ctx);
-} /* _container_item_free */
+ /* convert IP address from bin to string to serve as key for removing */
+ ret = libspid_ip_bin_to_str (rowreq_ctx->data->eocTrapIP, key_buffer);
+
+ /* remove IP address of current item from internal storage list */
+ if (NULL != se_find_slist ("eoc_trap_list"))
+ {
+ ret = se_remove_label_from_slist ("eoc_trap_list", key_buffer);
+ if (ret == SE_DNE)
+ {
+ snmp_log (LOG_ERR, "Error! IP address not found in the table!\n");
+ }
+ }
+ else
+ {
+ snmp_log (LOG_ERR, "Trying to delete from empty IP address list!\n");
+ }
+
+ eocTrapTable_release_rowreq_ctx (rowreq_ctx);
+} /* _container_item_free */
/**
* @internal
@@ -1651,7 +1876,7 @@ _container_free(netsnmp_container *container)
* call user code
*/
eocTrapTable_container_free(container);
-
+
/*
* free all items. inefficient, but easy.
*/
diff --git a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.h b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.h
index e50b2a48e3..4f29997bee 100644
--- a/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.h
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapTable/eocTrapTable_interface.h
@@ -9,7 +9,7 @@
* \warning This code should not be modified, called directly,
* or used to interpret functionality. It is subject to
* change at any time.
- *
+ *
* @{
*/
/*
@@ -65,7 +65,7 @@ int eocTrapTable_container_size( void );
u_int eocTrapTable_dirty_get( void );
void eocTrapTable_dirty_set( u_int status );
- eocTrapTable_rowreq_ctx * eocTrapTable_allocate_rowreq_ctx(void *);
+ eocTrapTable_rowreq_ctx * eocTrapTable_allocate_rowreq_ctx(eocTrapTable_data *, void *);
void eocTrapTable_release_rowreq_ctx(eocTrapTable_rowreq_ctx *rowreq_ctx);
int eocTrapTable_index_to_oid(netsnmp_index *oid_idx,