/* * @internal * Check the syntax for a particular column */ NETSNMP_STATIC_INLINE int _dot11ConfTotalTrapGroupTable_check_column( dot11ConfTotalTrapGroupTable_rowreq_ctx *rowreq_ctx, netsnmp_variable_list *var, int column ) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:dot11ConfTotalTrapGroupTable:_dot11ConfTotalTrapGroupTable_check_column","called\n")); netsnmp_assert(NULL != rowreq_ctx); switch(column) { /* NewTrapDescr(3)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ case COLUMN_NEWTRAPDESCR: rc = netsnmp_check_vb_type( var, ASN_OCTET_STR ); if(SNMPERR_SUCCESS == rc) { /* check that the value is in the defined range(s); inefficent * but keeps rc value knowledge in libarary where it belongs. */ if( 1 && ((rc = netsnmp_check_vb_size_range(var, 0,255)) != SNMP_ERR_NOERROR) ) { ; /* rc set in condition */ } } if(SNMPERR_SUCCESS == rc) { rc = NewTrapDescr_check_value( rowreq_ctx, (char *)var->val.string, var->val_len ); if((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from NewTrapDescr_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; /* NewTrapOnOff(4)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_NEWTRAPONOFF: rc = netsnmp_check_vb_type_and_size( var, ASN_INTEGER, sizeof( rowreq_ctx->data.NewTrapOnOff ) ); if(SNMPERR_SUCCESS == rc) { /* check that the value is one of defined enums */ if( 1 && ( *var->val.integer != NEWTRAPONOFF_ON ) && ( *var->val.integer != NEWTRAPONOFF_OFF ) ) { rc = SNMP_ERR_WRONGVALUE; } } if(SNMPERR_SUCCESS == rc) { rc = NewTrapOnOff_check_value( rowreq_ctx, *((u_long *)var->val.string) ); if((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from NewTrapOnOff_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column %d in _dot11ConfTotalTrapGroupTable_check_column\n", column); } return rc; } /* _dot11ConfTotalTrapGroupTable_check_column */
/********************************************************************** 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; }
int clSnmpsaAmfClusterStartupTimeoutHandler(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { ClSNMPRequestInfoT requestInfo; netsnmp_variable_list *reqVar = NULL; if(!requests || !reqinfo) return SNMP_ERR_GENERR; reqVar = requests->requestvb; /* We are never called for a GETNEXT if it's registered as a "instance", as it's "magically" handled for us. */ /* An instance handler also only hands us one request at a time, so we don't need to loop over a list of requests; we'll only get one. */ memset(&requestInfo, 0, sizeof(ClSNMPRequestInfoT)); /* Extract the scalar OID, convert it to string form and assign it to requestInfo.oid */ requestInfo.oidLen = OID_LENGTH(saAmfClusterStartupTimeoutOid); clSnmpOidCpy(&requestInfo, reqVar->name); requestInfo.tableType = CL_SAFAMF_SCALARS; switch(reqinfo->mode) { case MODE_GET: { ClInt32T retVal = 0, errorCode = 0; _ClSnmpGetReqInfoT reqAddInfo = {0}; void * pVal = NULL; ClCharT saAmfClusterStartupTimeoutVal[9] = {0}; requestInfo.dataLen = 8 * sizeof(ClCharT); pVal = saAmfClusterStartupTimeoutVal; requestInfo.index.scalarType = 0; requestInfo.opCode = CL_SNMP_GET; reqAddInfo.pRequest = requests; reqAddInfo.columnType = ASN_OCTET_STR; clLogDebug("SUB", "SCL", "Received GET request"); retVal = clRequestAdd(&requestInfo, pVal, NULL, &errorCode, &reqAddInfo); if(retVal != 0 || errorCode < 0) { netsnmp_request_set_error (requests, errorCode); return errorCode; } break; } /* * SET REQUEST * * multiple states in the transaction. See: * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg */ case MODE_SET_RESERVE1: { ClInt32T retVal = 0; clLogDebug("SUB", "SCL", "Received RESERVE1 request"); retVal = netsnmp_check_vb_type(reqVar, ASN_OCTET_STR); if(retVal != SNMP_ERR_NOERROR ) { netsnmp_request_set_error(requests, retVal ); return retVal; } retVal = netsnmp_check_vb_size_range(reqVar, 0, 8); if(retVal != SNMP_ERR_NOERROR) { netsnmp_request_set_error(requests, retVal ); return retVal; } break; } case MODE_SET_RESERVE2: { ClInt32T retVal = 0, errorCode = 0, noOfOp = 1; ClPtrT pVal = NULL; ClCharT Val[8] = {0}; pVal = Val; requestInfo.dataLen = 8 * sizeof(ClCharT); requestInfo.opCode = CL_SNMP_SET; requestInfo.index.scalarType = 0; memcpy(pVal, (void *)reqVar->val.integer, requestInfo.dataLen); clLogDebug("SUB", "SCL", "Calling request add"); retVal = clRequestAdd( &requestInfo, pVal, &noOfOp, &errorCode, NULL); if(CL_OK != retVal) { clLogError("SUB", "SCL", "Failed to add request to store, rc=[0x%x], errorCode=[0x%x]", retVal, errorCode); netsnmp_request_set_error(requests, errorCode); return retVal; } clLogDebug("SUB", "SCL", "Successfully added request in store"); break; } case MODE_SET_FREE: { clLogDebug("SUB", "SCL", "Received FREE request"); clSnmpUndo(); break; } case MODE_SET_ACTION: { ClInt32T retVal = 0; ClMedErrorListT medErrList; clLogDebug("SUB", "SCL", "Received ACTION request for oid[%s] ",requestInfo.oid); retVal = clSnmpCommit(&medErrList); if (retVal != 0) { clLogDebug("SUB", "SCL", "Error in commit errCount[%d]", medErrList.count); if(retVal == CL_ERR_NO_MEMORY) { retVal = CL_SNMP_ERR_NOCREATION; /* Set SNMP equivalent error from oidErrMapTable in clSnmpInit.c */ clLogError("SUB", "SCL", "ACTION phase failed, setting errorCode[0x%x] for oid[%s]", retVal, requestInfo.oid); netsnmp_request_set_error(requests, retVal); return retVal; } else { ClUint32T i; for(i = 0; i < medErrList.count; i++) { /* the oid matches the request, set error and return*/ if(!memcmp((ClUint8T*)requestInfo.oid, medErrList.pErrorList[i].oidInfo.id, medErrList.pErrorList[i].oidInfo.len)) { clLogError("SUB", "SCL", "ACTION phase failed, setting errorCode[0x%x] for oid[%s]", medErrList.pErrorList[i].errId, requestInfo.oid); netsnmp_request_set_error(requests, medErrList.pErrorList[i].errId); return retVal; } } } } break; } case MODE_SET_COMMIT: { clLogDebug("SUB", "SCL", "Received COMMIT request"); clSnmpUndo(); break; } case MODE_SET_UNDO: { clLogDebug("SUB", "SCL", "Received UNDO request"); clSnmpUndo(); break; } default: /* we should never get here, so this is a really bad error */ CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("unknown mode (%d) in clSnmpsaAmfClusterStartupTimeoutHandler\n", reqinfo->mode) ); return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; }
/* * @internal * Check the syntax for a particular column */ NETSNMP_STATIC_INLINE int _ifXTable_check_column(ifXTable_rowreq_ctx * rowreq_ctx, netsnmp_variable_list * var, int column) { int rc = SNMPERR_SUCCESS; DEBUGMSGTL(("internal:ifXTable:_ifXTable_check_column", "called\n")); netsnmp_assert(NULL != rowreq_ctx); switch (column) { /* * ifLinkUpDownTrapEnable(14)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IFLINKUPDOWNTRAPENABLE: rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(rowreq_ctx->data. ifLinkUpDownTrapEnable)); if (SNMPERR_SUCCESS == rc) { /* * check that the value is one of defined enums */ if (1 && (*var->val.integer != IFLINKUPDOWNTRAPENABLE_ENABLED) && (*var->val.integer != IFLINKUPDOWNTRAPENABLE_DISABLED) ) { rc = SNMP_ERR_WRONGVALUE; } } if (SNMPERR_SUCCESS == rc) { rc = ifLinkUpDownTrapEnable_check_value(rowreq_ctx, *((u_long *) var->val. string)); if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from ifLinkUpDownTrapEnable_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; /* * ifPromiscuousMode(16)/TruthValue/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h */ case COLUMN_IFPROMISCUOUSMODE: rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, sizeof(rowreq_ctx->data. ifPromiscuousMode)); if (SNMPERR_SUCCESS == rc) { /* * check that the value is one of defined enums */ if (1 && (*var->val.integer != TRUTHVALUE_TRUE) && (*var->val.integer != TRUTHVALUE_FALSE) ) { rc = SNMP_ERR_WRONGVALUE; } } if (SNMPERR_SUCCESS == rc) { rc = ifPromiscuousMode_check_value(rowreq_ctx, *((u_long *) var->val. string)); if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from ifPromiscuousMode_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; /* * ifAlias(18)/DisplayString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ case COLUMN_IFALIAS: rc = netsnmp_check_vb_type(var, ASN_OCTET_STR); if (SNMPERR_SUCCESS == rc) { /* * check that the value is in the defined range(s); inefficent * * but keeps rc value knowledge in libarary where it belongs. */ if (1 && ((rc = netsnmp_check_vb_size_range(var, 0, 64)) != SNMP_ERR_NOERROR) ) { ; /* rc set in condition */ } } if (SNMPERR_SUCCESS == rc) { rc = ifAlias_check_value(rowreq_ctx, (char *) var->val.string, var->val_len); if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) && (MFD_NOT_VALID_NOW != rc)) { snmp_log(LOG_ERR, "bad rc %d from ifAlias_check_value\n", rc); rc = SNMP_ERR_GENERR; } } break; default: /** We shouldn't get here */ rc = SNMP_ERR_GENERR; snmp_log(LOG_ERR, "unknown column %d in _ifXTable_check_column\n", column); } return rc; } /* _ifXTable_check_column */