Ejemplo n.º 1
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);
}
/** Decides if an incoming value for the netSnmpHostStorage mib node is legal.
 *  @param type    The incoming data type.
 *  @param val     The value to be checked.
 *  @param val_len The length of data stored in val (in bytes).
 *  @param old_val
 *  @param old_val_len
 *  @return 0 if the incoming value is legal, an SNMP error code otherwise.
 */
int
check_netSnmpHostStorage(int type, long *val, size_t val_len,
                         long *old_val, size_t old_val_len)
{

    int             ret;

    /** Check to see that we were called legally */
    if (!val)
        return SNMP_ERR_GENERR;

    /** Check the incoming type for correctness */
    if (type != ASN_INTEGER)
        return SNMP_ERR_WRONGTYPE;

    /** Check the enums.  Legal values will continue, others return error. */
    switch (*val) {
    case NETSNMPHOSTSTORAGE_OTHER:
    case NETSNMPHOSTSTORAGE_VOLATILE:
    case NETSNMPHOSTSTORAGE_NONVOLATILE:
    case NETSNMPHOSTSTORAGE_PERMANENT:
    case NETSNMPHOSTSTORAGE_READONLY:
        break;

    /** not a legal enum value.  return an error */
    default:
        return SNMP_ERR_INCONSISTENTVALUE;
    }
    ret = SNMP_ERR_NOERROR;

    if (ret =
        check_storage_transition((old_val) ? *old_val : SNMP_STORAGE_NONE,
                                 *val))
        return ret;

    /** looks ok, call the local version of the same function. */
    return check_netSnmpHostStorage_local(type, val, val_len, old_val,
                                          old_val_len);
}