|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* DisMan Event MIB:
|
|
Packit |
fcad23 |
* Implementation of the mteTriggerExistenceTable MIB interface
|
|
Packit |
fcad23 |
* See 'mteTrigger.c' for active behaviour of this table.
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* (based on mib2c.table_data.conf output)
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
#include <net-snmp/net-snmp-config.h>
|
|
Packit |
fcad23 |
#include <net-snmp/net-snmp-features.h>
|
|
Packit |
fcad23 |
#include <net-snmp/net-snmp-includes.h>
|
|
Packit |
fcad23 |
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
Packit |
fcad23 |
#include "disman/event/mteTrigger.h"
|
|
Packit |
fcad23 |
#include "disman/event/mteTriggerExistenceTable.h"
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
netsnmp_feature_require(table_tdata)
|
|
Packit |
fcad23 |
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
|
Packit |
fcad23 |
netsnmp_feature_require(check_vb_type_and_max_size)
|
|
Packit |
fcad23 |
#endif /* NETSNMP_NO_WRITE_SUPPORT */
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
static netsnmp_table_registration_info *table_info;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/* Initializes the mteTriggerExistenceTable module */
|
|
Packit |
fcad23 |
void
|
|
Packit |
fcad23 |
init_mteTriggerExistenceTable(void)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
static oid mteTExistTable_oid[] = { 1, 3, 6, 1, 2, 1, 88, 1, 2, 4 };
|
|
Packit |
fcad23 |
size_t mteTExistTable_oid_len = OID_LENGTH(mteTExistTable_oid);
|
|
Packit |
fcad23 |
netsnmp_handler_registration *reg;
|
|
Packit |
fcad23 |
int rc;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Ensure the (combined) table container is available...
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
init_trigger_table_data();
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* ... then set up the MIB interface to the mteTriggerExistenceTable slice
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
|
Packit |
fcad23 |
reg = netsnmp_create_handler_registration("mteTriggerExistenceTable",
|
|
Packit |
fcad23 |
mteTriggerExistenceTable_handler,
|
|
Packit |
fcad23 |
mteTExistTable_oid,
|
|
Packit |
fcad23 |
mteTExistTable_oid_len,
|
|
Packit |
fcad23 |
HANDLER_CAN_RWRITE);
|
|
Packit |
fcad23 |
#else /* !NETSNMP_NO_WRITE_SUPPORT */
|
|
Packit |
fcad23 |
reg = netsnmp_create_handler_registration("mteTriggerExistenceTable",
|
|
Packit |
fcad23 |
mteTriggerExistenceTable_handler,
|
|
Packit |
fcad23 |
mteTExistTable_oid,
|
|
Packit |
fcad23 |
mteTExistTable_oid_len,
|
|
Packit |
fcad23 |
HANDLER_CAN_RONLY);
|
|
Packit |
fcad23 |
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
|
|
Packit |
fcad23 |
netsnmp_table_helper_add_indexes(table_info,
|
|
Packit |
fcad23 |
ASN_OCTET_STR, /* index: mteOwner */
|
|
Packit |
fcad23 |
/* index: mteTriggerName */
|
|
Packit |
fcad23 |
ASN_PRIV_IMPLIED_OCTET_STR,
|
|
Packit |
fcad23 |
0);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
table_info->min_column = COLUMN_MTETRIGGEREXISTENCETEST;
|
|
Packit |
fcad23 |
table_info->max_column = COLUMN_MTETRIGGEREXISTENCEEVENT;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/* Register this using the (common) trigger_table_data container */
|
|
Packit |
fcad23 |
rc = netsnmp_tdata_register(reg, trigger_table_data, table_info);
|
|
Packit |
fcad23 |
if (rc != SNMPERR_SUCCESS)
|
|
Packit |
fcad23 |
return;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
netsnmp_handler_owns_table_info(reg->handler->next);
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:init", "Trigger Exist Table\n"));
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/** handles requests for the mteTriggerExistenceTable table */
|
|
Packit |
fcad23 |
int
|
|
Packit |
fcad23 |
mteTriggerExistenceTable_handler(netsnmp_mib_handler *handler,
|
|
Packit |
fcad23 |
netsnmp_handler_registration *reginfo,
|
|
Packit |
fcad23 |
netsnmp_agent_request_info *reqinfo,
|
|
Packit |
fcad23 |
netsnmp_request_info *requests)
|
|
Packit |
fcad23 |
{
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
netsnmp_request_info *request;
|
|
Packit |
fcad23 |
netsnmp_table_request_info *tinfo;
|
|
Packit |
fcad23 |
struct mteTrigger *entry;
|
|
Packit |
fcad23 |
int ret;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
DEBUGMSGTL(("disman:event:mib", "Exist Table handler (%d)\n",
|
|
Packit |
fcad23 |
reqinfo->mode));
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
switch (reqinfo->mode) {
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Read-support (also covers GetNext requests)
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
case MODE_GET:
|
|
Packit |
fcad23 |
for (request = requests; request; request = request->next) {
|
|
Packit |
fcad23 |
if (request->processed)
|
|
Packit |
fcad23 |
continue;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
|
|
Packit |
fcad23 |
tinfo = netsnmp_extract_table_info(request);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* The mteTriggerExistenceTable should only contains entries for
|
|
Packit |
fcad23 |
* rows where the mteTriggerTest 'existence(0)' bit is set.
|
|
Packit |
fcad23 |
* So skip entries where this isn't the case.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
if (!entry || !(entry->mteTriggerTest & MTE_TRIGGER_EXISTENCE )) {
|
|
Packit |
fcad23 |
netsnmp_request_set_error(request, SNMP_NOSUCHINSTANCE);
|
|
Packit |
fcad23 |
continue;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
switch (tinfo->colnum) {
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCETEST:
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
(u_char *)&entry->mteTExTest, 1);
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCESTARTUP:
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
(u_char *)&entry->mteTExStartup, 1);
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEOBJECTSOWNER:
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
(u_char *) entry->mteTExObjOwner,
|
|
Packit |
fcad23 |
strlen(entry->mteTExObjOwner));
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEOBJECTS:
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
(u_char *) entry->mteTExObjects,
|
|
Packit |
fcad23 |
strlen(entry->mteTExObjects));
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEEVENTOWNER:
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
(u_char *) entry->mteTExEvOwner,
|
|
Packit |
fcad23 |
strlen(entry->mteTExEvOwner));
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEEVENT:
|
|
Packit |
fcad23 |
snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
|
|
Packit |
fcad23 |
(u_char *) entry->mteTExEvent,
|
|
Packit |
fcad23 |
strlen(entry->mteTExEvent));
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Write-support
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
case MODE_SET_RESERVE1:
|
|
Packit |
fcad23 |
for (request = requests; request; request = request->next) {
|
|
Packit |
fcad23 |
if (request->processed)
|
|
Packit |
fcad23 |
continue;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
|
|
Packit |
fcad23 |
tinfo = netsnmp_extract_table_info(request);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* Since the mteTriggerExistenceTable only contains entries for
|
|
Packit |
fcad23 |
* rows where the mteTriggerTest 'existence(0)' bit is set,
|
|
Packit |
fcad23 |
* strictly speaking we should reject assignments where
|
|
Packit |
fcad23 |
* this isn't the case.
|
|
Packit |
fcad23 |
* But SET requests that include an assignment of the
|
|
Packit |
fcad23 |
* 'existence(0)' bit at the same time are valid, so would
|
|
Packit |
fcad23 |
* need to be accepted. Unfortunately, this assignment
|
|
Packit |
fcad23 |
* is only applied in the COMMIT pass, so it's difficult
|
|
Packit |
fcad23 |
* to detect whether this holds or not.
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* Let's fudge things for now, by processing assignments
|
|
Packit |
fcad23 |
* even if the 'existence(0)' bit isn't set.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
switch (tinfo->colnum) {
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCETEST:
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCESTARTUP:
|
|
Packit |
fcad23 |
ret = netsnmp_check_vb_type_and_size(
|
|
Packit |
fcad23 |
request->requestvb, ASN_OCTET_STR, 1);
|
|
Packit |
fcad23 |
if (ret != SNMP_ERR_NOERROR ) {
|
|
Packit |
fcad23 |
netsnmp_set_request_error(reqinfo, request, ret );
|
|
Packit |
fcad23 |
return SNMP_ERR_NOERROR;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEOBJECTSOWNER:
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEOBJECTS:
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEEVENTOWNER:
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEEVENT:
|
|
Packit |
fcad23 |
ret = netsnmp_check_vb_type_and_max_size(
|
|
Packit |
fcad23 |
request->requestvb, ASN_OCTET_STR, MTE_STR1_LEN);
|
|
Packit |
fcad23 |
if (ret != SNMP_ERR_NOERROR ) {
|
|
Packit |
fcad23 |
netsnmp_set_request_error(reqinfo, request, ret );
|
|
Packit |
fcad23 |
return SNMP_ERR_NOERROR;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
default:
|
|
Packit |
fcad23 |
netsnmp_set_request_error(reqinfo, request,
|
|
Packit |
fcad23 |
SNMP_ERR_NOTWRITABLE);
|
|
Packit |
fcad23 |
return SNMP_ERR_NOERROR;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* The Event MIB is somewhat ambiguous as to whether the
|
|
Packit |
fcad23 |
* various trigger table entries can be modified once the
|
|
Packit |
fcad23 |
* main mteTriggerTable entry has been marked 'active'.
|
|
Packit |
fcad23 |
* But it's clear from discussion on the DisMan mailing
|
|
Packit |
fcad23 |
* list is that the intention is not.
|
|
Packit |
fcad23 |
*
|
|
Packit |
fcad23 |
* So check for whether this row is already active,
|
|
Packit |
fcad23 |
* and reject *all* SET requests if it is.
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
|
|
Packit |
fcad23 |
if (entry &&
|
|
Packit |
fcad23 |
entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) {
|
|
Packit |
fcad23 |
netsnmp_set_request_error(reqinfo, request,
|
|
Packit |
fcad23 |
SNMP_ERR_INCONSISTENTVALUE);
|
|
Packit |
fcad23 |
return SNMP_ERR_NOERROR;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
case MODE_SET_RESERVE2:
|
|
Packit |
fcad23 |
case MODE_SET_FREE:
|
|
Packit |
fcad23 |
case MODE_SET_UNDO:
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
case MODE_SET_ACTION:
|
|
Packit |
fcad23 |
for (request = requests; request; request = request->next) {
|
|
Packit |
fcad23 |
if (request->processed)
|
|
Packit |
fcad23 |
continue;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
|
|
Packit |
fcad23 |
if (!entry) {
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* New rows must be created via the RowStatus column
|
|
Packit |
fcad23 |
* (in the main mteTriggerTable)
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
netsnmp_set_request_error(reqinfo, request,
|
|
Packit |
fcad23 |
SNMP_ERR_NOCREATION);
|
|
Packit |
fcad23 |
/* or inconsistentName? */
|
|
Packit |
fcad23 |
return SNMP_ERR_NOERROR;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
case MODE_SET_COMMIT:
|
|
Packit |
fcad23 |
/*
|
|
Packit |
fcad23 |
* All these assignments are "unfailable", so it's
|
|
Packit |
fcad23 |
* (reasonably) safe to apply them in the Commit phase
|
|
Packit |
fcad23 |
*/
|
|
Packit |
fcad23 |
for (request = requests; request; request = request->next) {
|
|
Packit |
fcad23 |
if (request->processed)
|
|
Packit |
fcad23 |
continue;
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
|
|
Packit |
fcad23 |
tinfo = netsnmp_extract_table_info(request);
|
|
Packit |
fcad23 |
|
|
Packit |
fcad23 |
switch (tinfo->colnum) {
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCETEST:
|
|
Packit |
fcad23 |
entry->mteTExTest = request->requestvb->val.string[0];
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCESTARTUP:
|
|
Packit |
fcad23 |
entry->mteTExStartup = request->requestvb->val.string[0];
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEOBJECTSOWNER:
|
|
Packit |
fcad23 |
memset(entry->mteTExObjOwner, 0, sizeof(entry->mteTExObjOwner));
|
|
Packit |
fcad23 |
memcpy(entry->mteTExObjOwner, request->requestvb->val.string,
|
|
Packit |
fcad23 |
request->requestvb->val_len);
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEOBJECTS:
|
|
Packit |
fcad23 |
memset(entry->mteTExObjects, 0, sizeof(entry->mteTExObjects));
|
|
Packit |
fcad23 |
memcpy(entry->mteTExObjects, request->requestvb->val.string,
|
|
Packit |
fcad23 |
request->requestvb->val_len);
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEEVENTOWNER:
|
|
Packit |
fcad23 |
memset(entry->mteTExEvOwner, 0, sizeof(entry->mteTExEvOwner));
|
|
Packit |
fcad23 |
memcpy(entry->mteTExEvOwner, request->requestvb->val.string,
|
|
Packit |
fcad23 |
request->requestvb->val_len);
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
case COLUMN_MTETRIGGEREXISTENCEEVENT:
|
|
Packit |
fcad23 |
memset(entry->mteTExEvent, 0, sizeof(entry->mteTExEvent));
|
|
Packit |
fcad23 |
memcpy(entry->mteTExEvent, request->requestvb->val.string,
|
|
Packit |
fcad23 |
request->requestvb->val_len);
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
break;
|
|
Packit |
fcad23 |
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
|
Packit |
fcad23 |
}
|
|
Packit |
fcad23 |
return SNMP_ERR_NOERROR;
|
|
Packit |
fcad23 |
}
|