Exemplo n.º 1
0
NETSNMP_INLINE int
netsnmp_check_vb_type_and_size(const netsnmp_variable_list *var,
                               int type, size_t size)
{
    register int rc = SNMP_ERR_NOERROR;

    if (NULL == var)
        return SNMP_ERR_GENERR;
    
    if ((rc = netsnmp_check_vb_type(var,type)))
        ;
    else
        rc = netsnmp_check_vb_size(var, size);

    return rc;
}
/**********************************************************************

		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;
}