summaryrefslogtreecommitdiff
path: root/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c')
-rw-r--r--cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c615
1 files changed, 615 insertions, 0 deletions
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
new file mode 100644
index 0000000000..0b4441a71f
--- /dev/null
+++ b/cleopatre/application/spidnetsnmp/agent/mibgroup/mstar-eoc-mib/eocTrapGroup/eocTrapGroup.c
@@ -0,0 +1,615 @@
+/*
+ * Note: this file originally auto-generated by mib2c using
+ * : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
+ */
+
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include "eocTrapGroup.h"
+
+/** Initializes the eocTrapGroup module */
+void
+init_eocTrapGroup(void)
+{
+ static oid eocTrapMaxTimes_oid[] = { 1,3,6,1,4,1,17409,2,4,8,1 };
+ static oid eocTrapMinInterval_oid[] = { 1,3,6,1,4,1,17409,2,4,8,2 };
+ static oid eocTrapMaxInterval_oid[] = { 1,3,6,1,4,1,17409,2,4,8,3 };
+ static oid eocTrapVersion_oid[] = { 1,3,6,1,4,1,17409,2,4,8,4 };
+
+ DEBUGMSGTL(("eocTrapGroup", "Initializing\n"));
+
+ netsnmp_register_scalar(
+ netsnmp_create_handler_registration("eocTrapMaxTimes", handle_eocTrapMaxTimes,
+ eocTrapMaxTimes_oid, OID_LENGTH(eocTrapMaxTimes_oid),
+ HANDLER_CAN_RWRITE
+ ));
+ netsnmp_register_scalar(
+ netsnmp_create_handler_registration("eocTrapMinInterval", handle_eocTrapMinInterval,
+ eocTrapMinInterval_oid, OID_LENGTH(eocTrapMinInterval_oid),
+ HANDLER_CAN_RWRITE
+ ));
+ netsnmp_register_scalar(
+ netsnmp_create_handler_registration("eocTrapMaxInterval", handle_eocTrapMaxInterval,
+ eocTrapMaxInterval_oid, OID_LENGTH(eocTrapMaxInterval_oid),
+ HANDLER_CAN_RWRITE
+ ));
+ netsnmp_register_scalar(
+ netsnmp_create_handler_registration("eocTrapVersion", handle_eocTrapVersion,
+ eocTrapVersion_oid, OID_LENGTH(eocTrapVersion_oid),
+ HANDLER_CAN_RONLY
+ ));
+}
+
+int
+handle_eocTrapMaxTimes(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *reqinfo,
+ 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:
+ 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, "%d", &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, "%d", &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:
+ /*
+ * free resources allocated in RESERVE1 and/or
+ * RESERVE2. Something failed somewhere, and the states
+ * below won't be called.
+ */
+ 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
+ */
+ break;
+
+ 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);
+ }
+ 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;
+}
+int
+handle_eocTrapMinInterval(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *reqinfo,
+ 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:
+ /* 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, "%d", &value))
+ {
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
+ }
+ else if (value >= 0)
+ {
+ min_interval = value;
+ }
+ else
+ {
+ snmp_log (LOG_ERR,
+ "eoCTrapGroup: MinInterval: \
+ config file value negative: %d\n", value);
+ min_interval = TRAP_MIN_INTERVAL_DEFAULT_VALUE;
+ }
+ }
+ 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, "%d", &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.
+ */
+ 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
+ */
+ break;
+
+ 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);
+ }
+ 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;
+}
+int
+handle_eocTrapMaxInterval(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *reqinfo,
+ netsnmp_request_info *requests)
+{
+ int ret;
+ 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:
+ /* 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, "%d", &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:
+ /*
+ * malloc "undo" storage buffer
+ */
+ /* 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, "%d", &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.
+ */
+ 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
+ */
+ break;
+
+ 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);
+ }
+
+ 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;
+}
+int
+handle_eocTrapVersion(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ 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 *) 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;
+}