Beispiel #1
0
int
netsnmp_check_vb_truthvalue(const netsnmp_variable_list *var)
{
    register int rc = SNMP_ERR_NOERROR;
    
    if (NULL == var)
        return SNMP_ERR_GENERR;
    
    if ((rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(long))))
        return rc;
    
    return netsnmp_check_vb_int_range(var, 1, 2);
}
NETSNMP_INLINE int
netsnmp_check_vb_rowstatus_value(netsnmp_variable_list *var)
{
    register int rc = SNMP_ERR_NOERROR;

    if (NULL == var)
        return SNMP_ERR_GENERR;
    
    if ((rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(int))))
        return rc;
    
    return netsnmp_check_vb_int_range(var, SNMP_ROW_NONEXISTENT,
                                      SNMP_ROW_DESTROY);
}
Beispiel #3
0
int
netsnmp_check_vb_storagetype(const netsnmp_variable_list *var, int old_value)
{
    int rc = SNMP_ERR_NOERROR;

    if (NULL == var)
        return SNMP_ERR_GENERR;
    
    if ((rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(long))))
        return rc;
    
    if ((rc = netsnmp_check_vb_int_range(var, SNMP_STORAGE_NONE,
                                        SNMP_STORAGE_READONLY)))
        return rc;
        
    return check_storage_transition(old_value, *var->val.integer);
}
Beispiel #4
0
NETSNMP_INLINE int
netsnmp_check_vb_rowstatus_value(const netsnmp_variable_list *var)
{
    register int rc = SNMP_ERR_NOERROR;

    if (NULL == var)
        return SNMP_ERR_GENERR;
    
    if ((rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(long))))
        return rc;
    
    if (*var->val.integer == RS_NOTREADY)
        return SNMP_ERR_WRONGVALUE;

    return netsnmp_check_vb_int_range(var, SNMP_ROW_NONEXISTENT,
                                      SNMP_ROW_DESTROY);
}
/** handles requests for the expObjectTable table */
int
expObjectTable_handler(netsnmp_mib_handler *handler,
                       netsnmp_handler_registration *reginfo,
                       netsnmp_agent_request_info *reqinfo,
                       netsnmp_request_info *requests)
{

    netsnmp_request_info       *request;
    netsnmp_table_request_info *tinfo;
    netsnmp_tdata_row          *row;
    struct expObject           *entry;
    struct expExpression       *exp;
    char   expOwner[EXP_STR1_LEN+1];
    char   expName[ EXP_STR1_LEN+1];
    long   objIndex;
    long   ret;
    netsnmp_variable_list *vp;

    DEBUGMSGTL(("disman:expr:mib", "Expression Object Table handler (%d)\n",
                                    reqinfo->mode));
    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            entry = (struct expObject *)netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);
            if (!entry || !(entry->flags & EXP_OBJ_FLAG_VALID))
                continue;

            switch (tinfo->colnum) {
            case COLUMN_EXPOBJECTID:
                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                              (u_char *) entry->expObjectID,
                                         entry->expObjectID_len*sizeof(oid));
                break;
            case COLUMN_EXPOBJECTIDWILDCARD:
                ret = (entry->flags & EXP_OBJ_FLAG_OWILD) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_EXPOBJECTSAMPLETYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->expObjectSampleType);
                break;
            case COLUMN_EXPOBJECTDELTADISCONTINUITYID:
                /*
                 * "This object [and the next two] are instantiated only if
                 *  expObjectSampleType is 'deltaValue' or 'changedValue'"
                 */
                if ( entry->expObjectSampleType == 1 )
                    continue;
                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                              (u_char *) entry->expObjDeltaD,
                                         entry->expObjDeltaD_len*sizeof(oid));
                break;
            case COLUMN_EXPOBJECTDISCONTINUITYIDWILDCARD:
                if ( entry->expObjectSampleType == 1 )
                    continue;
                ret = (entry->flags & EXP_OBJ_FLAG_DWILD) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_EXPOBJECTDISCONTINUITYIDTYPE:
                if ( entry->expObjectSampleType == 1 )
                    continue;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->expObjDiscontinuityType);
                break;
            case COLUMN_EXPOBJECTCONDITIONAL:
                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                              (u_char *) entry->expObjCond,
                                         entry->expObjCond_len*sizeof(oid));
                break;
            case COLUMN_EXPOBJECTCONDITIONALWILDCARD:
		ret = (entry->flags & EXP_OBJ_FLAG_CWILD) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_EXPOBJECTENTRYSTATUS:
                /* What would indicate 'notReady' ? */
                ret = (entry->flags & EXP_OBJ_FLAG_ACTIVE) ?
                          RS_ACTIVE : RS_NOTINSERVICE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            entry = (struct expObject *)
                netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPOBJECTID:
            case COLUMN_EXPOBJECTDELTADISCONTINUITYID:
            case COLUMN_EXPOBJECTCONDITIONAL:
                ret = netsnmp_check_vb_oid(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_EXPOBJECTIDWILDCARD:
            case COLUMN_EXPOBJECTDISCONTINUITYIDWILDCARD:
            case COLUMN_EXPOBJECTCONDITIONALWILDCARD:
                ret = netsnmp_check_vb_truthvalue(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_EXPOBJECTSAMPLETYPE:
            case COLUMN_EXPOBJECTDISCONTINUITYIDTYPE:
                ret = netsnmp_check_vb_int_range(request->requestvb, 1, 3);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_EXPOBJECTENTRYSTATUS:
                ret = netsnmp_check_vb_rowstatus(request->requestvb,
                          (entry ? RS_ACTIVE : RS_NONEXISTENT));
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        for (request = requests; request; request = request->next) {
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPOBJECTENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Create an (empty) new row structure
                     */
                    memset(expOwner, 0, sizeof(expOwner));
                    memcpy(expOwner, tinfo->indexes->val.string,
                                     tinfo->indexes->val_len);
                    memset(expName,  0, sizeof(expName));
                    memcpy(expName,
                           tinfo->indexes->next_variable->val.string,
                           tinfo->indexes->next_variable->val_len);
                    vp = tinfo->indexes->next_variable->next_variable;
                    objIndex = *vp->val.integer;

                    row = expObject_createRow(expOwner, expName, objIndex, 0);
                    if (!row) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_RESOURCEUNAVAILABLE);
                        return SNMP_ERR_NOERROR;
                    }
                    netsnmp_insert_tdata_row( request, row );
                }
            }
        }
        break;

    case MODE_SET_FREE:
        for (request = requests; request; request = request->next) {
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPOBJECTENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Tidy up after a failed row creation request
                     */ 
                    entry = (struct expObject *)
                                netsnmp_tdata_extract_entry(request);
                    if (entry &&
                      !(entry->flags & EXP_OBJ_FLAG_VALID)) {
                        row = (netsnmp_tdata_row *)
                                netsnmp_tdata_extract_row(request);
                        expObject_removeEntry( row );
                    }
                }
            }
        }
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            tinfo = netsnmp_extract_table_info(request);
            entry = (struct expObject *)
                    netsnmp_tdata_extract_entry(request);
            if (!entry) {
                /*
                 * New rows must be created via the RowStatus column
                 */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOCREATION);
                                      /* or inconsistentName? */
                return SNMP_ERR_NOERROR;

            }
        }
        break;

    case MODE_SET_UNDO:
        break;

    case MODE_SET_COMMIT:
        /*
         * All these assignments are "unfailable", so it's
         *  (reasonably) safe to apply them in the Commit phase
         */
        ret = 0;  /* Flag to re-check expExpressionPrefix settings */
        for (request = requests; request; request = request->next) {
            entry = (struct expObject *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPOBJECTID:
                memset(entry->expObjectID, 0, sizeof(entry->expObjectID));
                memcpy(entry->expObjectID, request->requestvb->val.string,
                                           request->requestvb->val_len);
                entry->expObjectID_len = request->requestvb->val_len;
                break;
            case COLUMN_EXPOBJECTIDWILDCARD:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  EXP_OBJ_FLAG_OWILD;
                else
                    entry->flags &= ~EXP_OBJ_FLAG_OWILD;
                break;
            case COLUMN_EXPOBJECTSAMPLETYPE:
                entry->expObjectSampleType = *request->requestvb->val.integer;
                break;
            case COLUMN_EXPOBJECTDELTADISCONTINUITYID:
                memset(entry->expObjDeltaD, 0, sizeof(entry->expObjDeltaD));
                memcpy(entry->expObjDeltaD, request->requestvb->val.string,
                                            request->requestvb->val_len);
                entry->expObjDeltaD_len = request->requestvb->val_len/sizeof(oid);
               /* XXX
                if ( snmp_oid_compare( entry->expObjDeltaD,
                                       entry->expObjDeltaD_len, 
                                       sysUpTime_inst,
                                       sysUpTime_inst_len ) != 0 )
                    entry->flags |= EXP_OBJ_FLAG_DDISC;
               */

                /*
                 * If the OID used for the expExpressionPrefix object
                 *   has changed, then update the expression structure.
                 */
                if ( entry->flags & EXP_OBJ_FLAG_PREFIX ) {
                    exp = expExpression_getEntry( entry->expOwner,
                                                  entry->expName );
                    memcpy( exp->expPrefix, entry->expObjDeltaD,
                            MAX_OID_LEN*sizeof(oid));
                    exp->expPrefix_len = entry->expObjDeltaD_len;
                }
                break;
            case COLUMN_EXPOBJECTDISCONTINUITYIDWILDCARD:
                if (*request->requestvb->val.integer == TV_TRUE) {
                    /*
                     * Possible new prefix OID candidate
                     * Can't set the value here, since the OID
                     *    assignment might not have been processed yet.
                     */
                    exp = expExpression_getEntry( entry->expOwner,
                                                  entry->expName );
                    if (exp && exp->expPrefix_len == 0 )
                        ret = 1;   /* Set the prefix later  */
                    entry->flags |=  EXP_OBJ_FLAG_DWILD;
                } else {
                    if ( entry->flags | EXP_OBJ_FLAG_PREFIX ) {
                        exp = expExpression_getEntry( entry->expOwner,
                                                      entry->expName );
                        memset( exp->expPrefix, 0, MAX_OID_LEN*sizeof(oid));
                        exp->expPrefix_len = 0;
                        ret = 1;   /* Need a new prefix OID */
                    }
                    entry->flags &= ~EXP_OBJ_FLAG_DWILD;
                }
                break;
            case COLUMN_EXPOBJECTDISCONTINUITYIDTYPE:
                entry->expObjDiscontinuityType =
                           *request->requestvb->val.integer;
                break;
            case COLUMN_EXPOBJECTCONDITIONAL:
                memset(entry->expObjCond, 0, sizeof(entry->expObjCond));
                memcpy(entry->expObjCond, request->requestvb->val.string,
                                          request->requestvb->val_len);
                entry->expObjCond_len = request->requestvb->val_len/sizeof(oid);
                break;
            case COLUMN_EXPOBJECTCONDITIONALWILDCARD:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  EXP_OBJ_FLAG_CWILD;
                else
                    entry->flags &= ~EXP_OBJ_FLAG_CWILD;
                break;
            case COLUMN_EXPOBJECTENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_ACTIVE:
                    entry->flags |= EXP_OBJ_FLAG_ACTIVE;
                    break;
                case RS_NOTINSERVICE:
                    entry->flags &= ~EXP_OBJ_FLAG_ACTIVE;
                    break;
                case RS_CREATEANDGO:
                    entry->flags |= EXP_OBJ_FLAG_ACTIVE;
                    entry->flags |= EXP_OBJ_FLAG_VALID;
                    break;
                case RS_CREATEANDWAIT:
                    entry->flags |= EXP_OBJ_FLAG_VALID;
                    break;

                case RS_DESTROY:
                    row = (netsnmp_tdata_row *)
                               netsnmp_tdata_extract_row(request);
                    expObject_removeEntry(row);
                }
            }
        }

        /*
         * Need to check for changes in expExpressionPrefix handling
         */
        for (request = requests; request; request = request->next) {
            entry = (struct expObject *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPOBJECTDISCONTINUITYIDWILDCARD:
                /*
                 * If a column has just been marked as wild,
                 *   then consider using it as the prefix OID
                 */
                if (*request->requestvb->val.integer == TV_TRUE) {
                    exp = expExpression_getEntry( entry->expOwner,
                                                  entry->expName );
                    if ( exp->expPrefix_len == 0 ) {
                        memcpy( exp->expPrefix, entry->expObjDeltaD,
                                MAX_OID_LEN*sizeof(oid));
                        exp->expPrefix_len = entry->expObjDeltaD_len;
                        entry->flags |= EXP_OBJ_FLAG_PREFIX;
                    }
                }
                /*
                 * If it's just been marked as non-wildcarded
                 *   then we need to look for a new candidate.
                 */
                else {

                }
                break;
            }
        }
        break;
    }
    DEBUGMSGTL(("disman:expr:mib", "Expression Object handler - done \n"));
    return SNMP_ERR_NOERROR;
}
/** handles requests for the mteTriggerThresholdTable table */
int
mteTriggerThresholdTable_handler(netsnmp_mib_handler *handler,
                                 netsnmp_handler_registration *reginfo,
                                 netsnmp_agent_request_info *reqinfo,
                                 netsnmp_request_info *requests)
{

    netsnmp_request_info       *request;
    netsnmp_table_request_info *tinfo;
    struct mteTrigger          *entry;
    int ret;

    DEBUGMSGTL(("disman:event:mib", "Threshold Table handler (%d)\n",
                                     reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            /*
             * The mteTriggerThresholdTable should only contains entries for
             *   rows where the mteTriggerTest 'threshold(2)' bit is set.
             * So skip entries where this isn't the case.
             */
            if (!entry || !(entry->mteTriggerTest & MTE_TRIGGER_THRESHOLD ))
                continue;

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERTHRESHOLDSTARTUP:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->mteTThStartup);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISING:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->mteTThRiseValue);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDFALLING:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->mteTThFallValue);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISING:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->mteTThDRiseValue);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLING:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->mteTThDFallValue);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDOBJECTSOWNER:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThObjOwner,
                                  strlen(entry->mteTThObjOwner));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDOBJECTS:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThObjects,
                                  strlen(entry->mteTThObjects));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENTOWNER:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThRiseOwner,
                                  strlen(entry->mteTThRiseOwner));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENT:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThRiseEvent,
                                  strlen(entry->mteTThRiseEvent));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENTOWNER:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThFallOwner,
                                  strlen(entry->mteTThFallOwner));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENT:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThFallEvent,
                                  strlen(entry->mteTThFallEvent));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENTOWNER:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThDRiseOwner,
                                  strlen(entry->mteTThDRiseOwner));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENT:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThDRiseEvent,
                                  strlen(entry->mteTThDRiseEvent));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENTOWNER:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThDFallOwner,
                                  strlen(entry->mteTThDFallOwner));
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                              (u_char *) entry->mteTThDFallEvent,
                                  strlen(entry->mteTThDFallEvent));
                break;
            }
        }
        break;

#ifndef NETSNMP_NO_WRITE_SUPPORT
        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            /*
             * Since the mteTriggerThresholdTable only contains entries for
             *   rows where the mteTriggerTest 'threshold(2)' bit is set,
             *   strictly speaking we should reject assignments where
             *   this isn't the case.
             * But SET requests that include an assignment of the
             *   'threshold(2)' bit at the same time are valid, so would
             *    need to be accepted. Unfortunately, this assignment
             *   is only applied in the COMMIT pass, so it's difficult
             *   to detect whether this holds or not.
             *
             * Let's fudge things for now, by processing assignments
             *   even if the 'threshold(2)' bit isn't set.
             */
            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERTHRESHOLDSTARTUP:
                ret = netsnmp_check_vb_int_range(request->requestvb,
                                                 MTE_THRESH_START_RISE,
                                                 MTE_THRESH_START_RISEFALL );
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISING:
            case COLUMN_MTETRIGGERTHRESHOLDFALLING:
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISING:
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLING:
                ret = netsnmp_check_vb_int(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERTHRESHOLDOBJECTSOWNER:
            case COLUMN_MTETRIGGERTHRESHOLDOBJECTS:
            case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENTOWNER:
            case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENT:
            case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENTOWNER:
            case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENT:
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENTOWNER:
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENT:
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENTOWNER:
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, MTE_STR1_LEN);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }

            /*
             * The Event MIB is somewhat ambiguous as to whether the
             *  various trigger table entries can be modified once the
             *  main mteTriggerTable entry has been marked 'active'. 
             * But it's clear from discussion on the DisMan mailing
             *  list is that the intention is not.
             *
             * So check for whether this row is already active,
             *  and reject *all* SET requests if it is.
             */
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            if (entry &&
                entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_INCONSISTENTVALUE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            if (!entry) {
                /*
                 * New rows must be created via the RowStatus column
                 *   (in the main mteTriggerTable)
                 */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOCREATION);
                                      /* or inconsistentName? */
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_COMMIT:
        /*
         * All these assignments are "unfailable", so it's
         *  (reasonably) safe to apply them in the Commit phase
         */
        for (request = requests; request; request = request->next) {
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERTHRESHOLDSTARTUP:
                entry->mteTThStartup    = *request->requestvb->val.integer;
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISING:
                entry->mteTThRiseValue  = *request->requestvb->val.integer;
                break;
            case COLUMN_MTETRIGGERTHRESHOLDFALLING:
                entry->mteTThFallValue  = *request->requestvb->val.integer;
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISING:
                entry->mteTThDRiseValue = *request->requestvb->val.integer;
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLING:
                entry->mteTThDFallValue = *request->requestvb->val.integer;
                break;
            case COLUMN_MTETRIGGERTHRESHOLDOBJECTSOWNER:
                memset(entry->mteTThObjOwner, 0, sizeof(entry->mteTThObjOwner));
                memcpy(entry->mteTThObjOwner, request->requestvb->val.string,
                                              request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDOBJECTS:
                memset(entry->mteTThObjects,  0, sizeof(entry->mteTThObjects));
                memcpy(entry->mteTThObjects,  request->requestvb->val.string,
                                              request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENTOWNER:
                memset(entry->mteTThRiseOwner, 0, sizeof(entry->mteTThRiseOwner));
                memcpy(entry->mteTThRiseOwner, request->requestvb->val.string,
                                               request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDRISINGEVENT:
                memset(entry->mteTThRiseEvent, 0, sizeof(entry->mteTThRiseEvent));
                memcpy(entry->mteTThRiseEvent, request->requestvb->val.string,
                                               request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENTOWNER:
                memset(entry->mteTThFallOwner, 0, sizeof(entry->mteTThFallOwner));
                memcpy(entry->mteTThFallOwner, request->requestvb->val.string,
                                               request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDFALLINGEVENT:
                memset(entry->mteTThFallEvent, 0, sizeof(entry->mteTThFallEvent));
                memcpy(entry->mteTThFallEvent, request->requestvb->val.string,
                                               request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENTOWNER:
                memset(entry->mteTThDRiseOwner, 0, sizeof(entry->mteTThDRiseOwner));
                memcpy(entry->mteTThDRiseOwner, request->requestvb->val.string,
                                                request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTARISINGEVENT:
                memset(entry->mteTThDRiseEvent, 0, sizeof(entry->mteTThDRiseEvent));
                memcpy(entry->mteTThDRiseEvent, request->requestvb->val.string,
                                                request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENTOWNER:
                memset(entry->mteTThDFallOwner, 0, sizeof(entry->mteTThDFallOwner));
                memcpy(entry->mteTThDFallOwner, request->requestvb->val.string,
                                                request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTHRESHOLDDELTAFALLINGEVENT:
                memset(entry->mteTThDFallEvent, 0, sizeof(entry->mteTThDFallEvent));
                memcpy(entry->mteTThDFallEvent, request->requestvb->val.string,
                                                request->requestvb->val_len);
                break;
            }
        }
        break;
#endif /* !NETSNMP_NO_WRITE_SUPPORT */

    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the nsVacmAccessTable table */
int
nsVacmAccessTable_handler(netsnmp_mib_handler *handler,
                          netsnmp_handler_registration *reginfo,
                          netsnmp_agent_request_info *reqinfo,
                          netsnmp_request_info *requests)
{

    netsnmp_request_info *request;
    netsnmp_table_request_info *table_info;
    netsnmp_variable_list      *idx;
    struct vacm_accessEntry    *entry;
    char atype[20];
    int  viewIdx, ret;
    char *gName, *cPrefix;
    int  model, level;

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            /* Extract the authType token from the list of indexes */
            idx = table_info->indexes->next_variable->next_variable->next_variable->next_variable;
            memset(atype, 0, sizeof(atype));
            memcpy(atype, (char *)idx->val.string, idx->val_len);
            viewIdx = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, atype);
            DEBUGMSGTL(("nsVacm", "GET %s (%d)\n", idx->val.string, viewIdx));

            if (!entry || viewIdx < 0)
                continue;

            switch (table_info->colnum) {
            case COLUMN_NSVACMCONTEXTMATCH:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->contextMatch);
                break;
            case COLUMN_NSVACMVIEWNAME:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                               (u_char *)entry->views[ viewIdx ],
                                  strlen(entry->views[ viewIdx ]));
                break;
            case COLUMN_VACMACCESSSTORAGETYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->storageType);
                break;
            case COLUMN_NSVACMACCESSSTATUS:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->status);
                break;
            }
        }
        break;

#ifndef NETSNMP_NO_WRITE_SUPPORT
        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);
            ret = SNMP_ERR_NOERROR;

            switch (table_info->colnum) {
            case COLUMN_NSVACMCONTEXTMATCH:
                ret = netsnmp_check_vb_int_range(request->requestvb, 1, 2);
                break;
            case COLUMN_NSVACMVIEWNAME:
                ret = netsnmp_check_vb_type_and_max_size(request->requestvb,
                                                         ASN_OCTET_STR,
                                                         VACM_MAX_STRING);
                break;
            case COLUMN_VACMACCESSSTORAGETYPE:
                ret = netsnmp_check_vb_storagetype(request->requestvb,
                          (/*entry ? entry->storageType :*/ SNMP_STORAGE_NONE));
                break;
            case COLUMN_NSVACMACCESSSTATUS:
                /*
                 * The usual 'check_vb_rowstatus' call is too simplistic
                 *   to be used here.  Because we're implementing a table
                 *   within an existing table, it's quite possible for a
                 *   the vacmAccessTable entry to exist, even if this is
                 *   a "new" nsVacmAccessEntry.
                 *
                 * We can check that the value being assigned is suitable
                 *   for a RowStatus syntax object, but the transition
                 *   checks need to be done explicitly.
                 */
                ret = netsnmp_check_vb_rowstatus_value(request->requestvb);
                if ( ret != SNMP_ERR_NOERROR )
                    break;

                /*
                 * Extract the authType token from the list of indexes
                 */
                idx = table_info->indexes->next_variable->next_variable->next_variable->next_variable;
                memset(atype, 0, sizeof(atype));
                memcpy(atype, (char *)idx->val.string, idx->val_len);
                viewIdx = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, atype);
                if ( viewIdx < 0 ) {
                    ret = SNMP_ERR_NOCREATION;
                    break;
                }
                switch ( *request->requestvb->val.integer ) {
                case RS_ACTIVE:
                case RS_NOTINSERVICE:
                    /* Check that this particular view is already set */
                    if ( !entry || !entry->views[viewIdx][0] )
                        ret = SNMP_ERR_INCONSISTENTVALUE;
                    break;
                case RS_CREATEANDWAIT:
                case RS_CREATEANDGO:
                    /* Check that this particular view is not yet set */
                    if ( entry && entry->views[viewIdx][0] )
                        ret = SNMP_ERR_INCONSISTENTVALUE;
                    break;
                }
                break;
            } /* switch(colnum) */
            if ( ret != SNMP_ERR_NOERROR ) {
                netsnmp_set_request_error(reqinfo, request, ret);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);

            switch (table_info->colnum) {
            case COLUMN_NSVACMACCESSSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    if (!entry) {
                         idx = table_info->indexes; gName = (char*)idx->val.string;
                         idx = idx->next_variable;  cPrefix = (char*)idx->val.string;
                         idx = idx->next_variable;  model = *idx->val.integer;
                         idx = idx->next_variable;  level = *idx->val.integer;
                         entry = vacm_createAccessEntry( gName, cPrefix, model, level );
                         entry->storageType = ST_NONVOLATILE;
                         netsnmp_insert_iterator_context(request, (void*)entry);
                    }
                }
            }
        }
        break;

    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        /* XXX - TODO */
        break;

    case MODE_SET_ACTION:
        /* ??? Empty ??? */
        break;

    case MODE_SET_COMMIT:
        for (request = requests; request; request = request->next) {
            entry = (struct vacm_accessEntry *)
                netsnmp_extract_iterator_context(request);
            table_info = netsnmp_extract_table_info(request);
            if ( !entry )
                continue;  /* Shouldn't happen */

            /* Extract the authType token from the list of indexes */
            idx = table_info->indexes->next_variable->next_variable->next_variable->next_variable;
            memset(atype, 0, sizeof(atype));
            memcpy(atype, (char *)idx->val.string, idx->val_len);
            viewIdx = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, atype);
            if (viewIdx < 0)
                    continue;

            switch (table_info->colnum) {
            case COLUMN_NSVACMCONTEXTMATCH:
                entry->contextMatch = *request->requestvb->val.integer;
                break;
            case COLUMN_NSVACMVIEWNAME:
                memset( entry->views[viewIdx], 0, VACMSTRINGLEN );
                memcpy( entry->views[viewIdx], request->requestvb->val.string,
                                               request->requestvb->val_len);
                break;
            case COLUMN_VACMACCESSSTORAGETYPE:
                entry->storageType = *request->requestvb->val.integer;
                break;
            case COLUMN_NSVACMACCESSSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_DESTROY:
                    memset( entry->views[viewIdx], 0, VACMSTRINGLEN );
                    break;
                }
                break;
            }
        }
        break;
#endif /* !NETSNMP_NO_WRITE_SUPPORT */
    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the expExpressionTable table */
int
expExpressionTable_handler(netsnmp_mib_handler *handler,
                           netsnmp_handler_registration *reginfo,
                           netsnmp_agent_request_info *reqinfo,
                           netsnmp_request_info *requests)
{

    netsnmp_request_info       *request;
    netsnmp_table_request_info *tinfo;
    netsnmp_tdata_row          *row;
    struct expExpression       *entry;
    char   expOwner[EXP_STR1_LEN+1];
    char   expName[ EXP_STR1_LEN+1];
    long   ret;

    DEBUGMSGTL(("disman:expr:mib", "Expression Table handler (%d)\n",
                                    reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct expExpression *)
                    netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);
            if (!entry || !(entry->flags & EXP_FLAG_VALID))
                continue;

            switch (tinfo->colnum) {
            case COLUMN_EXPEXPRESSION:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                (u_char*)entry->expExpression,
                                  strlen(entry->expExpression));
                break;
            case COLUMN_EXPEXPRESSIONVALUETYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->expValueType);
                break;
            case COLUMN_EXPEXPRESSIONCOMMENT:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                (u_char*)entry->expComment,
                                  strlen(entry->expComment));
                break;
            case COLUMN_EXPEXPRESSIONDELTAINTERVAL:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->expDeltaInterval);
                break;
            case COLUMN_EXPEXPRESSIONPREFIX:
                /*
                 * XXX - Need to search expObjectTable for a suitable OID
                 */
                /*
                 * Empty OIDs (len=0) are converted into .0.0
                 *   by the SNMP library automatically :-(
                 */
                if ( entry->expPrefix_len ) {
                    snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                              (u_char *) entry->expPrefix,
                                         entry->expPrefix_len*sizeof(oid));
                } else {
                    /* XXX - possibly not needed */
                    request->requestvb->type    = ASN_OBJECT_ID;
                    request->requestvb->val_len = 0;
                }
                break;
            case COLUMN_EXPEXPRESSIONERRORS:
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           entry->expErrorCount);
                break;
            case COLUMN_EXPEXPRESSIONENTRYSTATUS:
                /* What would indicate 'notReady' ? */
                ret = (entry->flags & EXP_FLAG_ACTIVE) ?
                          RS_ACTIVE : RS_NOTINSERVICE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct expExpression *)
                netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPEXPRESSION:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, EXP_STR3_LEN);
                /* XXX - check new expression is syntactically valid */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_EXPEXPRESSIONVALUETYPE:
                ret = netsnmp_check_vb_int_range(request->requestvb, 1, 8);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_EXPEXPRESSIONCOMMENT:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, EXP_STR2_LEN);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_EXPEXPRESSIONDELTAINTERVAL:
                ret = netsnmp_check_vb_int_range(request->requestvb, 0, 86400);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_EXPEXPRESSIONENTRYSTATUS:
                ret = netsnmp_check_vb_rowstatus(request->requestvb,
                                        (entry ? RS_ACTIVE : RS_NONEXISTENT));
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPEXPRESSIONENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Create an (empty) new row structure
                     */
                    memset(expOwner, 0, sizeof(expOwner));
                    memcpy(expOwner, tinfo->indexes->val.string,
                                     tinfo->indexes->val_len);
                    memset(expName,  0, sizeof(expName));
                    memcpy(expName,
                           tinfo->indexes->next_variable->val.string,
                           tinfo->indexes->next_variable->val_len);

                    row = expExpression_createRow(expOwner, expName, 0);
                    if (!row) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_RESOURCEUNAVAILABLE);
                        return SNMP_ERR_NOERROR;
                    }
                    netsnmp_insert_tdata_row( request, row );
                }
            }
        }
        break;

    case MODE_SET_FREE:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPEXPRESSIONENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Tidy up after a failed row creation request
                     */ 
                    entry = (struct expExpression *)
                                netsnmp_tdata_extract_entry(request);
                    if (entry &&
                      !(entry->flags & EXP_FLAG_VALID)) {
                        row = (netsnmp_tdata_row *)
                                netsnmp_tdata_extract_row(request);
                        expExpression_removeEntry( row );
                    }
                }
            }
        }
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);
            entry = (struct expExpression *)
                    netsnmp_tdata_extract_entry(request);
            if (!entry) {
                /*
                 * New rows must be created via the RowStatus column
                 */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOCREATION);
                                      /* or inconsistentName? */
                return SNMP_ERR_NOERROR;

            }
        }
        break;

    case MODE_SET_UNDO:
        break;

    case MODE_SET_COMMIT:
        /*
         * All these assignments are "unfailable", so it's
         *  (reasonably) safe to apply them in the Commit phase
         */
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct expExpression *)
                netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_EXPEXPRESSION:
                memset(entry->expExpression, 0, EXP_STR3_LEN+1);
                memcpy(entry->expExpression,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_EXPEXPRESSIONVALUETYPE:
                entry->expValueType = *request->requestvb->val.integer;
                break;
            case COLUMN_EXPEXPRESSIONCOMMENT:
                memset(entry->expComment, 0, EXP_STR2_LEN+1);
                memcpy(entry->expComment,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_EXPEXPRESSIONDELTAINTERVAL:
                entry->expDeltaInterval = *request->requestvb->val.integer;
                break;
            case COLUMN_EXPEXPRESSIONENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_ACTIVE:
                    entry->flags |= EXP_FLAG_ACTIVE;
                    expExpression_enable( entry );
                    break;
                case RS_NOTINSERVICE:
                    entry->flags &= ~EXP_FLAG_ACTIVE;
                    expExpression_disable( entry );
                    break;
                case RS_CREATEANDGO:
                    entry->flags |= EXP_FLAG_ACTIVE;
                    entry->flags |= EXP_FLAG_VALID;
                    entry->session =
                        netsnmp_iquery_pdu_session(reqinfo->asp->pdu);
                    expExpression_enable( entry );
                    break;
                case RS_CREATEANDWAIT:
                    entry->flags |= EXP_FLAG_VALID;
                    entry->session =
                        netsnmp_iquery_pdu_session(reqinfo->asp->pdu);
                    break;

                case RS_DESTROY:
                    row = (netsnmp_tdata_row *)
                               netsnmp_tdata_extract_row(request);
                    expExpression_removeEntry(row);
                }
            }
        }
        break;
    }
    DEBUGMSGTL(("disman:expr:mib", "Expression Table handler - done \n"));
    return SNMP_ERR_NOERROR;
}
/**********************************************************************

		int
		CcspScalarHelperSetMibValues
			(
				ANSC_HANDLE                 hThisObject,
				netsnmp_agent_request_info  *reqinfo,
				netsnmp_request_info		*requests
			);

    description:

        This function is called to set MIB values.

    argument:   ANSC_HANDLE				hThisObject
	            The handle of the object;

				netsnmp_agent_request_info  *reqinfo,
				The request info

				netsnmp_request_info		*requests
				The requests;

	return:     The error code

**********************************************************************/
static 
int
verifyTypeAndValueInSetReserved1
	(
		netsnmp_variable_list*				pVb,
		PCCSP_MIB_MAPPING					pMapping
	)
{
	int								ret              = SNMP_ERR_NOERROR;
	ULONG							nType            = pMapping->MibInfo.uType;

	if(!pMapping->MibInfo.bWritable)
	{
		return SNMP_ERR_NOTWRITABLE;
	}

	/* check type first */
	ret = netsnmp_check_vb_type(pVb, nType);

	if( ret != SNMP_ERR_NOERROR)
	{
		return ret;
	}

	if( nType == ASN_BOOLEAN)
	{
		ret = netsnmp_check_vb_size(pVb, sizeof(BOOLEAN));
	}
	else if( nType == ASN_INTEGER || (nType >= ASN_IPADDRESS && nType <= ASN_OPAQUE))
	{
		ret = netsnmp_check_vb_size(pVb, sizeof(ULONG));
	}
	else if( nType == ASN_COUNTER64)
	{
		ret = netsnmp_check_vb_size(pVb, sizeof(U64));
	}

	if( ret != SNMP_ERR_NOERROR)
	{
		return ret;
	}

	if( pMapping->MibInfo.uMaskLimit == CCSP_MIB_LIMIT_MAX)
	{
		if( pMapping->MibInfo.uType == ASN_OCTET_STR)
		{
			ret = netsnmp_check_vb_max_size(pVb, pMapping->MibInfo.nMax);
		}			
	}
	else if( pMapping->MibInfo.uMaskLimit == CCSP_MIB_LIMIT_BOTH)
	{
		if( pMapping->MibInfo.uType == ASN_INTEGER )
		{
			ret = netsnmp_check_vb_int_range(pVb, pMapping->MibInfo.nMin, pMapping->MibInfo.nMax);
		}
		else if ( pMapping->MibInfo.uType == ASN_UNSIGNED )
		{
			ret = netsnmp_check_vb_range(pVb, pMapping->MibInfo.nMin, pMapping->MibInfo.nMax);
		}
		else if( pMapping->MibInfo.uType == ASN_OCTET_STR)
		{
			ret = netsnmp_check_vb_size_range(pVb, pMapping->MibInfo.nMin, pMapping->MibInfo.nMax);
		}
	}

	if( ret != SNMP_ERR_NOERROR)
	{
		return ret;
	}

	/* check mapping if have */
	if( nType == ASN_INTEGER || nType == ASN_UNSIGNED)
	{
		if( pMapping->MapQueue.Depth > 0)
		{
			if( CcspUtilLookforEnumMapping(&pMapping->MapQueue, (ULONG)*pVb->val.integer) == NULL)
			{
				AnscTraceError(("Invalid integer value '%ld'\n", *pVb->val.integer));

				ret = SNMP_ERR_WRONGVALUE;
			}
		}
	}
	return ret;
}
Beispiel #10
0
/** handles requests for the schedTable table */
int
schedTable_handler(netsnmp_mib_handler *handler,
                   netsnmp_handler_registration *reginfo,
                   netsnmp_agent_request_info *reqinfo,
                   netsnmp_request_info *requests)
{

    netsnmp_request_info       *request;
    netsnmp_table_request_info *tinfo;
    netsnmp_tdata_row          *row;
    struct schedTable_entry    *entry;
    int    recalculate = 0;
    size_t len;
    char  *cp;
    char   owner[SCHED_STR1_LEN+1];
    char   name[ SCHED_STR1_LEN+1];
    int    ret;

    DEBUGMSGTL(("disman:schedule:mib", "Schedule handler (%d)\n",
                                        reqinfo->mode));
    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct schedTable_entry *)
                    netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info( request);

            switch (tinfo->colnum) {
            case COLUMN_SCHEDDESCR:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->schedDescr,
                                  strlen(entry->schedDescr));
                break;
            case COLUMN_SCHEDINTERVAL:
                snmp_set_var_typed_integer(request->requestvb, ASN_UNSIGNED,
                                           entry->schedInterval);
                break;
            case COLUMN_SCHEDWEEKDAY:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                        &entry->schedWeekDay,
                                  sizeof(entry->schedWeekDay));
                break;
            case COLUMN_SCHEDMONTH:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->schedMonth,
                                  sizeof(entry->schedMonth));
                break;
            case COLUMN_SCHEDDAY:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->schedDay,
                                  sizeof(entry->schedDay));
                break;
            case COLUMN_SCHEDHOUR:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->schedHour,
                                  sizeof(entry->schedHour));
                break;
            case COLUMN_SCHEDMINUTE:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->schedMinute,
                                  sizeof(entry->schedMinute));
                break;
            case COLUMN_SCHEDCONTEXTNAME:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->schedContextName,
                                  strlen(entry->schedContextName));
                break;
            case COLUMN_SCHEDVARIABLE:
                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                               (u_char *)entry->schedVariable,
                                         entry->schedVariable_len*sizeof(oid));
                break;
            case COLUMN_SCHEDVALUE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->schedValue);
                break;
            case COLUMN_SCHEDTYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->schedType);
                break;
            case COLUMN_SCHEDADMINSTATUS:
                ret = (entry->flags & SCHEDULE_FLAG_ENABLED ) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_SCHEDOPERSTATUS:
                ret = (entry->flags & SCHEDULE_FLAG_ENABLED ) ?
                           TV_TRUE : TV_FALSE;
                /*
                 * Check for one-shot entries that have already fired
                 */
                if ((entry->schedType == SCHED_TYPE_ONESHOT) &&
                    (entry->schedLastRun != 0 ))
                    ret = 3;  /* finished(3) */
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_SCHEDFAILURES:
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           entry->schedFailures);
                break;
            case COLUMN_SCHEDLASTFAILURE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->schedLastFailure);
                break;
            case COLUMN_SCHEDLASTFAILED:
                /*
                 * Convert 'schedLastFailed' timestamp
                 *   into DateAndTime string
                 */
                cp = (char *) date_n_time( &entry->schedLastFailed, &len );
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         cp, len);
                break;
            case COLUMN_SCHEDSTORAGETYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->schedStorageType);
                break;
            case COLUMN_SCHEDROWSTATUS:
                ret = (entry->flags & SCHEDULE_FLAG_ACTIVE ) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_SCHEDTRIGGERS:
                snmp_set_var_typed_integer(request->requestvb, ASN_COUNTER,
                                           entry->schedTriggers);
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct schedTable_entry *)
                    netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info( request);

            switch (tinfo->colnum) {
            case COLUMN_SCHEDDESCR:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, SCHED_STR2_LEN);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDINTERVAL:
                ret = netsnmp_check_vb_uint( request->requestvb );
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDWEEKDAY:
                ret = netsnmp_check_vb_type_and_size(
                          request->requestvb, ASN_OCTET_STR, 1);
                /* XXX - check for bit(7) set */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDMONTH:
                ret = netsnmp_check_vb_type_and_size(  /* max_size ?? */
                          request->requestvb, ASN_OCTET_STR, 2);
                /* XXX - check for bit(12)-bit(15) set */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDDAY:
                ret = netsnmp_check_vb_type_and_size(  /* max_size ?? */
                          request->requestvb, ASN_OCTET_STR, 4+4);
                /* XXX - check for bit(62) or bit(63) set */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDHOUR:
                ret = netsnmp_check_vb_type_and_size(  /* max_size ?? */
                          request->requestvb, ASN_OCTET_STR, 3);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDMINUTE:
                ret = netsnmp_check_vb_type_and_size(  /* max_size ?? */
                          request->requestvb, ASN_OCTET_STR, 8);
                /* XXX - check for bit(60)-bit(63) set */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDCONTEXTNAME:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, SCHED_STR1_LEN);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDVARIABLE:
                ret = netsnmp_check_vb_oid( request->requestvb );
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDVALUE:
                ret = netsnmp_check_vb_int( request->requestvb );
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDTYPE:
                ret = netsnmp_check_vb_int_range( request->requestvb,
                             SCHED_TYPE_PERIODIC, SCHED_TYPE_ONESHOT );
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDADMINSTATUS:
                ret = netsnmp_check_vb_truthvalue( request->requestvb );
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request,
                                              SNMP_ERR_WRONGTYPE);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDSTORAGETYPE:
                ret = netsnmp_check_vb_int_range( request->requestvb,
                                                  ST_NONE, ST_READONLY );
                /* XXX - check valid/consistent assignments */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_SCHEDROWSTATUS:
                ret = netsnmp_check_vb_rowstatus( request->requestvb,
                          (entry ? RS_ACTIVE: RS_NONEXISTENT));
                /* XXX - check consistency assignments */
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_SCHEDROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Create an (empty) new row structure
                     */
                    memset(owner, 0, SCHED_STR1_LEN+1);
                    memset(name,  0, SCHED_STR1_LEN+1);
                    memcpy(owner, tinfo->indexes->val.string,
                                  tinfo->indexes->val_len);
                    memcpy(name,  tinfo->indexes->next_variable->val.string,
                                  tinfo->indexes->next_variable->val_len);
                    row = schedTable_createEntry(owner, name);
                    if (!row) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_RESOURCEUNAVAILABLE);
                        return SNMP_ERR_NOERROR;
                    }
                    netsnmp_insert_tdata_row(request, row);
                }
            }
        }
        break;

    case MODE_SET_FREE:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_SCHEDROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Tidy up after a failed row creation request
                     */ 
                    entry = (struct schedTable_entry *)
                                netsnmp_tdata_extract_entry(request);
                    if (entry &&
                      !(entry->flags & SCHEDULE_FLAG_VALID)) {
                        row = (netsnmp_tdata_row *)
                                netsnmp_tdata_extract_row(request);
                        schedTable_removeEntry(row);
                    }
                }
            }
        }
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            entry = (struct schedTable_entry *)
                    netsnmp_tdata_extract_entry(request);
            if (!entry) {
                /*
                 * New rows must be created via the RowStatus column
                 */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOCREATION);
                                      /* or inconsistentName? */
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_UNDO:
        break;

    case MODE_SET_COMMIT:
        /*
         * All these assignments are "unfailable", so it's
         *  (reasonably) safe to apply them in the Commit phase
         */
        entry = NULL;
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct schedTable_entry *)
                    netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info( request);

            switch (tinfo->colnum) {
            case COLUMN_SCHEDDESCR:
                memset(entry->schedDescr, 0, sizeof(entry->schedDescr));
                memcpy(entry->schedDescr, request->requestvb->val.string,
                                          request->requestvb->val_len);
                break;
            case COLUMN_SCHEDINTERVAL:
                entry->schedInterval = *request->requestvb->val.integer;
                recalculate = 1;
                break;
            case COLUMN_SCHEDWEEKDAY:
                entry->schedWeekDay  = request->requestvb->val.string[0];
                recalculate = 1;
                break;
            case COLUMN_SCHEDMONTH:
                entry->schedMonth[0] = request->requestvb->val.string[0];
                entry->schedMonth[1] = request->requestvb->val.string[1];
                recalculate = 1;
                break;
            case COLUMN_SCHEDDAY:
                memset(entry->schedDay, 0, sizeof(entry->schedDay));
                memcpy(entry->schedDay, request->requestvb->val.string,
                                        request->requestvb->val_len);
                recalculate = 1;
                break;
            case COLUMN_SCHEDHOUR:
                entry->schedHour[0]  = request->requestvb->val.string[0];
                entry->schedHour[1]  = request->requestvb->val.string[1];
                entry->schedHour[2]  = request->requestvb->val.string[2];
                recalculate = 1;
                break;
            case COLUMN_SCHEDMINUTE:
                memset(entry->schedMinute, 0, sizeof(entry->schedMinute));
                memcpy(entry->schedMinute, request->requestvb->val.string,
                                           request->requestvb->val_len);
                recalculate = 1;
                break;
            case COLUMN_SCHEDCONTEXTNAME:
                memset(entry->schedContextName, 0, sizeof(entry->schedContextName));
                memcpy(entry->schedContextName,
                                           request->requestvb->val.string,
                                           request->requestvb->val_len);
                break;
            case COLUMN_SCHEDVARIABLE:
                memset(entry->schedVariable, 0, sizeof(entry->schedVariable));
                memcpy(entry->schedVariable,
                                           request->requestvb->val.string,
                                           request->requestvb->val_len);
                entry->schedVariable_len =
                                  request->requestvb->val_len/sizeof(oid);
                break;
            case COLUMN_SCHEDVALUE:
                entry->schedValue = *request->requestvb->val.integer;
                break;
            case COLUMN_SCHEDTYPE:
                entry->schedType  = *request->requestvb->val.integer;
                break;
            case COLUMN_SCHEDADMINSTATUS:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  SCHEDULE_FLAG_ENABLED;
                else
                    entry->flags &= ~SCHEDULE_FLAG_ENABLED;
                break;
            case COLUMN_SCHEDSTORAGETYPE:
                entry->schedStorageType = *request->requestvb->val.integer;
                break;
            case COLUMN_SCHEDROWSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_ACTIVE:
                    entry->flags |= SCHEDULE_FLAG_ACTIVE;
                    break;
                case RS_CREATEANDGO:
                    entry->flags |= SCHEDULE_FLAG_ACTIVE;
                    entry->flags |= SCHEDULE_FLAG_VALID;
                    entry->session =
                        netsnmp_iquery_pdu_session(reqinfo->asp->pdu);
                    break;
                case RS_CREATEANDWAIT:
                    entry->flags |= SCHEDULE_FLAG_VALID;
                    entry->session =
                        netsnmp_iquery_pdu_session(reqinfo->asp->pdu);
                    break;

                case RS_DESTROY:
                    row = (netsnmp_tdata_row *)
                               netsnmp_tdata_extract_row(request);
                    schedTable_removeEntry(row);
                }
                recalculate = 1;
                break;
            }
        }
        if (recalculate) {
            netsnmp_assert(entry);
            sched_nextTime(entry);
        }
        break;
    }
    return SNMP_ERR_NOERROR;
}
/** handles requests for the mteTriggerDeltaTable table */
int
mteTriggerDeltaTable_handler(netsnmp_mib_handler *handler,
                             netsnmp_handler_registration *reginfo,
                             netsnmp_agent_request_info *reqinfo,
                             netsnmp_request_info *requests)
{

    netsnmp_request_info       *request;
    netsnmp_table_request_info *tinfo;
    struct mteTrigger          *entry;
    int ret;

    DEBUGMSGTL(("disman:event:mib", "Delta Table handler (%d)\n",
                                     reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            /*
             * The mteTriggerBooleanTable should only contains entries for
             *   rows where the mteTriggerSampleType is 'deltaValue(2)'
             * So skip entries where this isn't the case.
             */
            if (!entry || !(entry->flags & MTE_TRIGGER_FLAG_DELTA )) {
                netsnmp_request_set_error(request, SNMP_NOSUCHINSTANCE);
                continue;
            }

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERDELTADISCONTINUITYID:
                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                              (u_char *) entry->mteDeltaDiscontID,
                                         entry->mteDeltaDiscontID_len*sizeof(oid));
                break;
            case COLUMN_MTETRIGGERDELTADISCONTINUITYIDWILDCARD:
                ret = (entry->flags & MTE_TRIGGER_FLAG_DWILD ) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE:
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER,
                                           entry->mteDeltaDiscontIDType);
                break;
            }
        }
        break;

        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            /*
             * Since the mteTriggerDeltaTable only contains entries for
             *   rows where mteTriggerSampleType is 'deltaValue(2)',
             *   strictly speaking we should reject assignments where
             *   this isn't the case.
             * But SET requests that include an assignment of
             *   'deltaValue(2)' at the same time are valid, so would
             *    need to be accepted. Unfortunately, this assignment
             *   is only applied in the COMMIT pass, so it's difficult
             *   to detect whether this holds or not.
             *
             * Let's fudge things for now, by processing
             *   assignments even if this value isn't set.
             */
            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERDELTADISCONTINUITYID:
                ret = netsnmp_check_vb_oid(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERDELTADISCONTINUITYIDWILDCARD:
                ret = netsnmp_check_vb_truthvalue(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE:
                ret = netsnmp_check_vb_int_range(request->requestvb,
                                                 MTE_DELTAD_TTICKS,
                                                 MTE_DELTAD_DATETIME);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }

            /*
             * The Event MIB is somewhat ambiguous as to whether the
             *  various trigger table entries can be modified once the
             *  main mteTriggerTable entry has been marked 'active'. 
             * But it's clear from discussion on the DisMan mailing
             *  list is that the intention is not.
             *
             * So check for whether this row is already active,
             *  and reject *all* SET requests if it is.
             */
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            if (entry &&
                entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) {
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_INCONSISTENTVALUE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            if (!entry) {
                /*
                 * New rows must be created via the RowStatus column
                 *   (in the main mteTriggerTable)
                 */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOCREATION);
                                      /* or inconsistentName? */
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_COMMIT:
        /*
         * All these assignments are "unfailable", so it's
         *  (reasonably) safe to apply them in the Commit phase
         */
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERDELTADISCONTINUITYID:
                if ( snmp_oid_compare(
                       request->requestvb->val.objid,
                       request->requestvb->val_len/sizeof(oid),
                       _sysUpTime_instance, _sysUpTime_inst_len) != 0 ) {
                    memset(entry->mteDeltaDiscontID, 0,
                           sizeof(entry->mteDeltaDiscontID));
                    memcpy(entry->mteDeltaDiscontID,
                           request->requestvb->val.string,
                           request->requestvb->val_len);
                    entry->mteDeltaDiscontID_len =
                        request->requestvb->val_len/sizeof(oid);
                    entry->flags &= ~MTE_TRIGGER_FLAG_SYSUPT;
                }
                break;
            case COLUMN_MTETRIGGERDELTADISCONTINUITYIDWILDCARD:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  MTE_TRIGGER_FLAG_DWILD;
                else
                    entry->flags &= ~MTE_TRIGGER_FLAG_DWILD;
                break;
            case COLUMN_MTETRIGGERDELTADISCONTINUITYIDTYPE:
                entry->mteDeltaDiscontIDType = *request->requestvb->val.integer;
                break;
            }
        }
        break;
    }
    return SNMP_ERR_NOERROR;
}
Beispiel #12
0
/** handles requests for the mteTriggerTable table */
int
mteTriggerTable_handler(netsnmp_mib_handler *handler,
                        netsnmp_handler_registration *reginfo,
                        netsnmp_agent_request_info *reqinfo,
                        netsnmp_request_info *requests)
{

    netsnmp_request_info       *request;
    netsnmp_table_request_info *tinfo;
    netsnmp_tdata_row          *row;
    struct mteTrigger          *entry;
    char mteOwner[MTE_STR1_LEN+1];
    char mteTName[MTE_STR1_LEN+1];
    long ret;

    DEBUGMSGTL(("disman:event:mib", "Trigger Table handler (%d)\n",
                                     reqinfo->mode));

    switch (reqinfo->mode) {
        /*
         * Read-support (also covers GetNext requests)
         */
    case MODE_GET:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERCOMMENT:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->mteTriggerComment,
                                  strlen(entry->mteTriggerComment));
                break;
            case COLUMN_MTETRIGGERTEST:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                        &entry->mteTriggerTest, 1);
                break;
            case COLUMN_MTETRIGGERSAMPLETYPE:
                ret = (entry->flags & MTE_TRIGGER_FLAG_DELTA ) ?
                           MTE_SAMPLE_DELTA : MTE_SAMPLE_ABSOLUTE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_MTETRIGGERVALUEID:
                snmp_set_var_typed_value(request->requestvb, ASN_OBJECT_ID,
                              (u_char *) entry->mteTriggerValueID,
                                         entry->mteTriggerValueID_len*sizeof(oid));
                break;
            case COLUMN_MTETRIGGERVALUEIDWILDCARD:
                ret = (entry->flags & MTE_TRIGGER_FLAG_VWILD ) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_MTETRIGGERTARGETTAG:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->mteTriggerTarget,
                                  strlen(entry->mteTriggerTarget));
                break;
            case COLUMN_MTETRIGGERCONTEXTNAME:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->mteTriggerContext,
                                  strlen(entry->mteTriggerContext));
                break;
            case COLUMN_MTETRIGGERCONTEXTNAMEWILDCARD:
                ret = (entry->flags & MTE_TRIGGER_FLAG_CWILD ) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_MTETRIGGERFREQUENCY:
                snmp_set_var_typed_integer(request->requestvb, ASN_UNSIGNED,
                                           entry->mteTriggerFrequency);
                break;
            case COLUMN_MTETRIGGEROBJECTSOWNER:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->mteTriggerOOwner,
                                  strlen(entry->mteTriggerOOwner));
                break;
            case COLUMN_MTETRIGGEROBJECTS:
                snmp_set_var_typed_value(request->requestvb, ASN_OCTET_STR,
                                         entry->mteTriggerObjects,
                                  strlen(entry->mteTriggerObjects));
                break;
            case COLUMN_MTETRIGGERENABLED:
                ret = (entry->flags & MTE_TRIGGER_FLAG_ENABLED ) ?
                           TV_TRUE : TV_FALSE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            case COLUMN_MTETRIGGERENTRYSTATUS:
                ret = (entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) ?
                           RS_ACTIVE : RS_NOTINSERVICE;
                snmp_set_var_typed_integer(request->requestvb, ASN_INTEGER, ret);
                break;
            }
        }
        break;

#ifndef NETSNMP_NO_WRITE_SUPPORT
        /*
         * Write-support
         */
    case MODE_SET_RESERVE1:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERCOMMENT:
            case COLUMN_MTETRIGGERTARGETTAG:
            case COLUMN_MTETRIGGERCONTEXTNAME:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, MTE_STR2_LEN);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERTEST:
                ret = netsnmp_check_vb_type_and_size(
                          request->requestvb, ASN_OCTET_STR, 1);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERSAMPLETYPE:
                ret = netsnmp_check_vb_int_range(request->requestvb,
                                    MTE_SAMPLE_ABSOLUTE, MTE_SAMPLE_DELTA);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERVALUEID:
                ret = netsnmp_check_vb_oid(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERVALUEIDWILDCARD:
            case COLUMN_MTETRIGGERCONTEXTNAMEWILDCARD:
            case COLUMN_MTETRIGGERENABLED:
                ret = netsnmp_check_vb_truthvalue(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;

            case COLUMN_MTETRIGGERFREQUENCY:
                ret = netsnmp_check_vb_uint(request->requestvb);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGEROBJECTSOWNER:
            case COLUMN_MTETRIGGEROBJECTS:
                ret = netsnmp_check_vb_type_and_max_size(
                          request->requestvb, ASN_OCTET_STR, MTE_STR1_LEN);
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            case COLUMN_MTETRIGGERENTRYSTATUS:
                ret = netsnmp_check_vb_rowstatus(request->requestvb,
                          (entry ? RS_ACTIVE : RS_NONEXISTENT));
                if (ret != SNMP_ERR_NOERROR) {
                    netsnmp_set_request_error(reqinfo, request, ret);
                    return SNMP_ERR_NOERROR;
                }
                break;
            default:
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOTWRITABLE);
                return SNMP_ERR_NOERROR;
            }


            /*
             * Once a row has been made active, it cannot be
             *   modified except to delete it.  There's no good
             *   reason for this, but that's what the MIB says.
             *
             * The published version of the Event MIB even forbids
             *   enabling (or disabling) an active row, which
             *   would make this object completely pointless!
             * Fortunately this ludicrous decision has since been corrected.
             */
            if (entry &&
                entry->flags & MTE_TRIGGER_FLAG_ACTIVE ) {
                /* check for the acceptable assignments */
                if ((tinfo->colnum == COLUMN_MTETRIGGERENABLED) ||
                    (tinfo->colnum == COLUMN_MTETRIGGERENTRYSTATUS &&
                         *request->requestvb->val.integer != RS_NOTINSERVICE))
                    continue;

                /* Otherwise, reject this request */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_INCONSISTENTVALUE);
                return SNMP_ERR_NOERROR;
            }
        }
        break;

    case MODE_SET_RESERVE2:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Create an (empty) new row structure
                     */
                    memset(mteOwner, 0, sizeof(mteOwner));
                    memcpy(mteOwner, tinfo->indexes->val.string,
                                     tinfo->indexes->val_len);
                    memset(mteTName, 0, sizeof(mteTName));
                    memcpy(mteTName,
                           tinfo->indexes->next_variable->val.string,
                           tinfo->indexes->next_variable->val_len);

                    row = mteTrigger_createEntry(mteOwner, mteTName, 0);
                    if (!row) {
                        netsnmp_set_request_error(reqinfo, request,
                                                  SNMP_ERR_RESOURCEUNAVAILABLE);
                        return SNMP_ERR_NOERROR;
                    }
                    netsnmp_insert_tdata_row( request, row );
                }
            }
        }
        break;

    case MODE_SET_FREE:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_CREATEANDGO:
                case RS_CREATEANDWAIT:
                    /*
                     * Tidy up after a failed row creation request
                     */ 
                    entry = (struct mteTrigger *)
                                netsnmp_tdata_extract_entry(request);
                    if (entry &&
                      !(entry->flags & MTE_TRIGGER_FLAG_VALID)) {
                        row = (netsnmp_tdata_row *)
                                netsnmp_tdata_extract_row(request);
                        mteTrigger_removeEntry( row );
                    }
                }
            }
        }
        break;

    case MODE_SET_ACTION:
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            tinfo = netsnmp_extract_table_info(request);
            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            if (!entry) {
                /*
                 * New rows must be created via the RowStatus column
                 */
                netsnmp_set_request_error(reqinfo, request,
                                          SNMP_ERR_NOCREATION);
                                      /* or inconsistentName? */
                return SNMP_ERR_NOERROR;

            }
        }
        break;

    case MODE_SET_UNDO:
        break;

    case MODE_SET_COMMIT:
        /*
         * All these assignments are "unfailable", so it's
         *  (reasonably) safe to apply them in the Commit phase
         */
        for (request = requests; request; request = request->next) {
            if (request->processed)
                continue;

            entry = (struct mteTrigger *) netsnmp_tdata_extract_entry(request);
            tinfo = netsnmp_extract_table_info(request);

            switch (tinfo->colnum) {
            case COLUMN_MTETRIGGERCOMMENT:
                memset(entry->mteTriggerComment, 0,
                       sizeof(entry->mteTriggerComment));
                memcpy(entry->mteTriggerComment,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERTEST:
                entry->mteTriggerTest = request->requestvb->val.string[0];
                break;
            case COLUMN_MTETRIGGERSAMPLETYPE:
                if (*request->requestvb->val.integer == MTE_SAMPLE_DELTA)
                    entry->flags |=  MTE_TRIGGER_FLAG_DELTA;
                else
                    entry->flags &= ~MTE_TRIGGER_FLAG_DELTA;
                break;
            case COLUMN_MTETRIGGERVALUEID:
                memset(entry->mteTriggerValueID, 0,
                       sizeof(entry->mteTriggerValueID));
                memcpy(entry->mteTriggerValueID,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                entry->mteTriggerValueID_len = request->requestvb->val_len/sizeof(oid);
                break;
            case COLUMN_MTETRIGGERVALUEIDWILDCARD:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  MTE_TRIGGER_FLAG_VWILD;
                else
                    entry->flags &= ~MTE_TRIGGER_FLAG_VWILD;
                break;
            case COLUMN_MTETRIGGERTARGETTAG:
                memset(entry->mteTriggerTarget, 0,
                       sizeof(entry->mteTriggerTarget));
                memcpy(entry->mteTriggerTarget,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERCONTEXTNAME:
                memset(entry->mteTriggerContext, 0,
                       sizeof(entry->mteTriggerContext));
                memcpy(entry->mteTriggerContext,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERCONTEXTNAMEWILDCARD:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  MTE_TRIGGER_FLAG_CWILD;
                else
                    entry->flags &= ~MTE_TRIGGER_FLAG_CWILD;
                break;
            case COLUMN_MTETRIGGERFREQUENCY:
                entry->mteTriggerFrequency = *request->requestvb->val.integer;
                break;
            case COLUMN_MTETRIGGEROBJECTSOWNER:
                memset(entry->mteTriggerOOwner, 0,
                       sizeof(entry->mteTriggerOOwner));
                memcpy(entry->mteTriggerOOwner,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGEROBJECTS:
                memset(entry->mteTriggerObjects, 0,
                       sizeof(entry->mteTriggerObjects));
                memcpy(entry->mteTriggerObjects,
                       request->requestvb->val.string,
                       request->requestvb->val_len);
                break;
            case COLUMN_MTETRIGGERENABLED:
                if (*request->requestvb->val.integer == TV_TRUE)
                    entry->flags |=  MTE_TRIGGER_FLAG_ENABLED;
                else
                    entry->flags &= ~MTE_TRIGGER_FLAG_ENABLED;
                break;
            case COLUMN_MTETRIGGERENTRYSTATUS:
                switch (*request->requestvb->val.integer) {
                case RS_ACTIVE:
                    entry->flags |= MTE_TRIGGER_FLAG_ACTIVE;
                    mteTrigger_enable( entry );
                    break;
                case RS_CREATEANDGO:
                    entry->flags |= MTE_TRIGGER_FLAG_ACTIVE;
                    entry->flags |= MTE_TRIGGER_FLAG_VALID;
                    entry->session =
                        netsnmp_iquery_pdu_session(reqinfo->asp->pdu);
                    mteTrigger_enable( entry );
                    break;
                case RS_CREATEANDWAIT:
                    entry->flags |= MTE_TRIGGER_FLAG_VALID;
                    entry->session =
                        netsnmp_iquery_pdu_session(reqinfo->asp->pdu);
                    break;

                case RS_DESTROY:
                    row = (netsnmp_tdata_row *)
                               netsnmp_tdata_extract_row(request);
                    mteTrigger_removeEntry(row);
                }
                break;
            }
        }

        /** set up to save persistent store */
        snmp_store_needed(NULL);

        break;

#endif /* !NETSNMP_NO_WRITE_SUPPORT */

    }
    return SNMP_ERR_NOERROR;
}