⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snmp_rsa_sensor.c

📁 HIP 硬件设备管理标准接口
💻 C
📖 第 1 页 / 共 2 页
字号:
        } \} while(0)/* Assuming floating point - not generic but works for BladeCenter */#define get_up_hysteresis_value(thdname, thdmatch) \do { \         working.thdname.Interpreted.Value.SensorFloat32 = working.thdmatch.Interpreted.Value.SensorFloat32 - \                                                           working.thdname.Interpreted.Value.SensorFloat32; \         if (working.thdname.Interpreted.Value.SensorFloat32 < 0) { \                dbg("Positive Hysteresis delta is less than 0"); \         	working.thdname.ValuesPresent = 0; \         } \} while(0)#define get_low_hysteresis_value(thdname, thdmatch) \do { \         working.thdname.Interpreted.Value.SensorFloat32 = working.thdname.Interpreted.Value.SensorFloat32 - \                                                           working.thdmatch.Interpreted.Value.SensorFloat32; \         if (working.thdname.Interpreted.Value.SensorFloat32 < 0) { \                dbg("Negitive Hysteresis delta is less than 0"); \         	working.thdname.ValuesPresent = 0; \         } \} while(0)SaErrorT snmp_rsa_get_sensor_thresholds(void *hnd,				        SaHpiResourceIdT id,				        SaHpiSensorNumT num,				        SaHpiSensorThresholdsT *thres){        gchar *oid = NULL;	int  found_raw, found_interpreted;	SaHpiSensorThresholdsT working;	SaHpiSensorInterpretedUnionT value;        struct snmp_value get_value;        struct oh_handler_state *handle = (struct oh_handler_state *)hnd;        struct snmp_rsa_hnd *custom_handle = (struct snmp_rsa_hnd *)handle->data;        SaHpiRdrT *rdr = oh_get_rdr_by_type(handle->rptcache, id, SAHPI_SENSOR_RDR, num);	if(rdr == NULL) {		return SA_ERR_HPI_NOT_PRESENT;	}        struct RSA_SensorInfo *s =                (struct RSA_SensorInfo *)oh_get_rdr_data(handle->rptcache, id, rdr->RecordId); 	if(s == NULL) {		return -1;	}	if (rdr->RdrTypeUnion.SensorRec.Ignore == SAHPI_TRUE) {		return SA_ERR_HPI_INVALID_CMD;	}        memset(&working, 0, sizeof(SaHpiSensorThresholdsT));	if(rdr->RdrTypeUnion.SensorRec.ThresholdDefn.IsThreshold == SAHPI_TRUE) {		found_raw = found_interpreted = 0;		if(rdr->RdrTypeUnion.SensorRec.ThresholdDefn.TholdCapabilities & SAHPI_STC_RAW) {			get_raw_thresholds(SAHPI_STM_LOW_MINOR, OidLowMinor, LowMinor);			get_raw_thresholds(SAHPI_STM_LOW_MAJOR, OidLowMajor, LowMajor);			get_raw_thresholds(SAHPI_STM_LOW_CRIT, OidLowCrit, LowCritical);			get_raw_thresholds(SAHPI_STM_UP_MINOR, OidUpMinor, UpMinor);			get_raw_thresholds(SAHPI_STM_UP_MAJOR, OidUpMajor, UpMajor);			get_raw_thresholds(SAHPI_STM_UP_CRIT, OidUpCrit, UpCritical);			/* Ignore any PosThdHysteresis and NegThdHysteresis for RAW			   (going away in 1.1) */		}		if(rdr->RdrTypeUnion.SensorRec.ThresholdDefn.TholdCapabilities & SAHPI_STC_INTERPRETED) {			get_interpreted_thresholds(SAHPI_STM_LOW_MINOR, OidLowMinor, LowMinor);			get_interpreted_thresholds(SAHPI_STM_LOW_MAJOR, OidLowMajor, LowMajor);			get_interpreted_thresholds(SAHPI_STM_LOW_CRIT, OidLowCrit, LowCritical);			get_interpreted_thresholds(SAHPI_STM_UP_MINOR, OidUpMinor, UpMinor);			get_interpreted_thresholds(SAHPI_STM_UP_MAJOR, OidUpMajor, UpMajor);			get_interpreted_thresholds(SAHPI_STM_UP_CRIT, OidUpCrit, UpCritical);			get_interpreted_thresholds(SAHPI_STM_UP_HYSTERESIS, OidUpHysteresis, PosThdHysteresis);			get_interpreted_thresholds(SAHPI_STM_LOW_HYSTERESIS, OidLowHysteresis, NegThdHysteresis);			/* Hysteresis - RSA supports a reset value for some single threshold			 * sensors. So there may be a major threshold of 78 and a reset of 76. This                         * extremely ugly code, calculates the delta to report hysteresis. 			 * If multiple thresholds are defined, the most severe one is used as the 			 * basis for the delta calculation. Also we assume all values are float32 */			if ((found_interpreted & SAHPI_STM_UP_HYSTERESIS) && 			    ((found_interpreted & SAHPI_STM_UP_CRIT) || 			    (found_interpreted & SAHPI_STM_UP_MAJOR) ||			    (found_interpreted & SAHPI_STM_UP_MINOR))) {				if (found_interpreted & SAHPI_STM_UP_CRIT) {					get_up_hysteresis_value(PosThdHysteresis, UpCritical);				}				else {					if (found_interpreted & SAHPI_STM_UP_MAJOR) {						get_up_hysteresis_value(PosThdHysteresis, UpMajor);						}					else {						if (found_interpreted & SAHPI_STM_UP_MINOR) {							get_up_hysteresis_value(PosThdHysteresis, UpMinor);						}						}					}			}			else {				dbg("Positive Hysteresis is defined but not any positive thresholds");				working.PosThdHysteresis.ValuesPresent = 0;			}    						/* Negitive hysteresis */			if ((found_interpreted & SAHPI_STM_LOW_HYSTERESIS) && 			    ((found_interpreted & SAHPI_STM_LOW_CRIT) || 			    (found_interpreted & SAHPI_STM_LOW_MAJOR) ||			    (found_interpreted & SAHPI_STM_LOW_MINOR))) {				if (found_interpreted & SAHPI_STM_LOW_CRIT) {					get_low_hysteresis_value(NegThdHysteresis, LowCritical);				}				else {					if (found_interpreted & SAHPI_STM_LOW_MAJOR) {						get_low_hysteresis_value(NegThdHysteresis, LowMajor);						}					else {						if (found_interpreted & SAHPI_STM_LOW_MINOR) {							get_low_hysteresis_value(NegThdHysteresis, LowMinor);						}						}					}			}			else {				dbg("Negitive Hysteresis is defined but not any negitive thresholds");				working.NegThdHysteresis.ValuesPresent = 0;			}    		}		if (found_raw || found_interpreted) {			memcpy(thres,&working,sizeof(SaHpiSensorThresholdsT));			return SA_OK;		} else {			dbg("No threshold values found\n");			return -1;		}        } else {                dbg("Thresholds requested, but sensor does not support them.\n");                return SA_ERR_HPI_INVALID_CMD;        }        }SaErrorT snmp_rsa_set_sensor_thresholds(void *hnd,				        SaHpiResourceIdT id,				        SaHpiSensorNumT num,				        const SaHpiSensorThresholdsT *thres){	/* Writable thresholds not supported */        return SA_ERR_HPI_INVALID_CMD;}SaErrorT snmp_rsa_get_sensor_event_enables(void *hnd,					   SaHpiResourceIdT id,					   SaHpiSensorNumT num,					   SaHpiSensorEvtEnablesT *enables){	SaHpiSensorEvtEnablesT working;	SaHpiRdrT *rdr = oh_get_rdr_by_type(((struct oh_handler_state *)hnd)->rptcache, 					    id, SAHPI_SENSOR_RDR, num);	if (rdr == NULL) {		return SA_ERR_HPI_NOT_PRESENT;	}	gpointer rsa_data = oh_get_rdr_data(		((struct oh_handler_state *)hnd)->rptcache, id, rdr->RecordId);	if (rsa_data == NULL) {		dbg("Sensor Data Pointer is NULL; RID=%x; SID=%d", id, num); 		return -1;	}	if (rdr->RdrTypeUnion.SensorRec.Ignore == SAHPI_TRUE) {		return SA_ERR_HPI_INVALID_CMD;	}	if (rdr->RdrTypeUnion.SensorRec.EventCtrl == SAHPI_SEC_NO_EVENTS) {		return SA_ERR_HPI_INVALID_CMD;	}	working = ((struct RSA_SensorInfo *)rsa_data)->sensor_evt_enablement;	memcpy(enables, &working, sizeof(SaHpiSensorEvtEnablesT));        return SA_OK;}SaErrorT snmp_rsa_set_sensor_event_enables(void *hnd,					   SaHpiResourceIdT id,					   SaHpiSensorNumT num,					   const SaHpiSensorEvtEnablesT *enables){	SaHpiRdrT *rdr = oh_get_rdr_by_type(((struct oh_handler_state *)hnd)->rptcache, 					    id, SAHPI_SENSOR_RDR, num);	if (rdr == NULL) {		return SA_ERR_HPI_NOT_PRESENT;	}		gpointer rsa_data = oh_get_rdr_data(((struct oh_handler_state *)hnd)->rptcache, id, rdr->RecordId);	if (rsa_data == NULL) {		dbg("Sensor Data Pointer is NULL; RID=%x; SID=%d", id, num); 		return -1;	}			if (rdr->RdrTypeUnion.SensorRec.Ignore == SAHPI_TRUE) {		return SA_ERR_HPI_INVALID_CMD;	}	if (rdr->RdrTypeUnion.SensorRec.EventCtrl == SAHPI_SEC_NO_EVENTS) {		return SA_ERR_HPI_INVALID_CMD;	}	if ((enables->SensorStatus & SAHPI_SENSTAT_SCAN_ENABLED) ||	    (enables->SensorStatus & SAHPI_SENSTAT_BUSY)) {		return SA_ERR_HPI_INVALID_CMD;	}	/* 	 * RSA currently does not support enabling/disabling individual events -          * just the entire sensor         */	((struct RSA_SensorInfo *)rsa_data)->sensor_evt_enablement = *enables;        return SA_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -