ipmi_sensor.h
来自「支持IPMI协议的开源API包。可以开发服务器硬件状态监控程序。」· C头文件 代码 · 共 506 行 · 第 1/2 页
H
506 行
void ipmi_sensor_threshold_set_readable(ipmi_sensor_t *sensor, enum ipmi_thresh_e thresh, int val);void ipmi_sensor_threshold_set_settable(ipmi_sensor_t *sensor, enum ipmi_thresh_e thresh, int val);/* Returns true if the sensor reports when an operator want to remove the hot-swappable entity from the system. If this returns true, the offset will be set to the offset in the sensor of the hot-swap request value. val_when_requesting will be set to the value (1 or 0) that the offset will be set to when the sensor is requesting a hot-swap. This should generally be a slot sensor (sensor type 21h). */int ipmi_sensor_is_hot_swap_requester(ipmi_sensor_t *sensor, unsigned int *offset, unsigned int *val_when_requesting);void ipmi_sensor_set_hot_swap_requester(ipmi_sensor_t *sensor, unsigned int offset, unsigned int val_when_requesting);/* Allow OEM code to call the event handlers. Note that if the event is handled by the handlers, then "*event" will be set to NULL and *handled will be set to true. If the event is not handled, then *handled will be set to false and the event value will be unchanged. This is to help the OEM handlers only deliver the event once to the user. */voidipmi_sensor_call_threshold_event_handlers(ipmi_sensor_t *sensor, enum ipmi_event_dir_e dir, enum ipmi_thresh_e threshold, enum ipmi_event_value_dir_e high_low, enum ipmi_value_present_e value_present, unsigned int raw_value, double value, ipmi_event_t **event, int *handled);void ipmi_sensor_call_discrete_event_handlers(ipmi_sensor_t *sensor, enum ipmi_event_dir_e dir, int offset, int severity, int prev_severity, ipmi_event_t **event, int *handled);/* Typedefs for the sensor polymorphic functions. */typedef int (*ipmi_sensor_convert_from_raw_cb)( ipmi_sensor_t *sensor, int val, double *result);typedef int (*ipmi_sensor_convert_to_raw_cb)( ipmi_sensor_t *sensor, enum ipmi_round_e rounding, double val, int *result);typedef int (*ipmi_sensor_get_tolerance_cb)(ipmi_sensor_t *sensor, int val, double *tolerance);typedef int (*ipmi_sensor_get_accuracy_cb)(ipmi_sensor_t *sensor, int val, double *accuracy);typedef int (*ipmi_sensor_events_enable_set_cb)( ipmi_sensor_t *sensor, ipmi_event_state_t *states, ipmi_sensor_done_cb done, void *cb_data);typedef int (*ipmi_sensor_events_enable_get_cb)( ipmi_sensor_t *sensor, ipmi_event_enables_get_cb done, void *cb_data);typedef int (*ipmi_sensor_rearm_cb)( ipmi_sensor_t *sensor, int global_enable, ipmi_event_state_t *state, ipmi_sensor_done_cb done, void *cb_data);typedef int (*ipmi_sensor_get_hysteresis_cb)( ipmi_sensor_t *sensor, ipmi_hysteresis_get_cb done, void *cb_data);typedef int (*ipmi_sensor_set_hysteresis_cb)( ipmi_sensor_t *sensor, unsigned int positive_hysteresis, unsigned int negative_hysteresis, ipmi_sensor_done_cb done, void *cb_data);typedef int (*ipmi_thresholds_set_cb)( ipmi_sensor_t *sensor, ipmi_thresholds_t *thresholds, ipmi_sensor_done_cb done, void *cb_data);typedef int (*ipmi_thresholds_get_cb)( ipmi_sensor_t *sensor, ipmi_thresh_get_cb done, void *cb_data);typedef int (*ipmi_reading_get_cb)( ipmi_sensor_t *sensor, ipmi_reading_done_cb done, void *cb_data);typedef int (*ipmi_states_get_cb)(ipmi_sensor_t *sensor, ipmi_states_read_cb done, void *cb_data);typedef char *(*ipmi_sensor_reading_name_string_cb)( ipmi_sensor_t *sensor, int val);typedef struct ipmi_sensor_cbs_s{ ipmi_sensor_events_enable_set_cb ipmi_sensor_events_enable_set; ipmi_sensor_events_enable_get_cb ipmi_sensor_events_enable_get; ipmi_sensor_events_enable_set_cb ipmi_sensor_events_enable; ipmi_sensor_events_enable_set_cb ipmi_sensor_events_disable; ipmi_sensor_rearm_cb ipmi_sensor_rearm; /* These are for threshold sensors only. */ ipmi_sensor_convert_from_raw_cb ipmi_sensor_convert_from_raw; ipmi_sensor_convert_to_raw_cb ipmi_sensor_convert_to_raw; ipmi_sensor_get_accuracy_cb ipmi_sensor_get_accuracy; ipmi_sensor_get_tolerance_cb ipmi_sensor_get_tolerance; ipmi_sensor_get_hysteresis_cb ipmi_sensor_get_hysteresis; ipmi_sensor_set_hysteresis_cb ipmi_sensor_set_hysteresis; ipmi_thresholds_set_cb ipmi_thresholds_set; ipmi_thresholds_get_cb ipmi_thresholds_get; ipmi_reading_get_cb ipmi_reading_get; /* This is for a discrete sensor. */ ipmi_states_get_cb ipmi_states_get; ipmi_sensor_reading_name_string_cb ipmi_sensor_reading_name_string;} ipmi_sensor_cbs_t;/* Can be used by OEM code to replace some or all of the callbacks for a sensor. */void ipmi_sensor_get_callbacks(ipmi_sensor_t *sensor, ipmi_sensor_cbs_t *cbs);void ipmi_sensor_set_callbacks(ipmi_sensor_t *sensor, ipmi_sensor_cbs_t *cbs);/* The standard callbacks. This is read-only, don't change them. */extern const ipmi_sensor_cbs_t ipmi_standard_sensor_cb;typedef void (*ipmi_sensor_cleanup_oem_info_cb)(ipmi_sensor_t *sensor, void *oem_info);void ipmi_sensor_set_oem_info(ipmi_sensor_t *sensor, void *oem_info, ipmi_sensor_cleanup_oem_info_cb cleanup_handler);void *ipmi_sensor_get_oem_info(ipmi_sensor_t *sensor);/* Operations and callbacks for sensor operations. Operations on a sensor that can be delayed should be serialized (to avoid user confusion and for handling multi-part operations properly), thus each sensor has an operation queue, only one operation at a time may be running. If you want to do an operation that requires sending a message and getting a response, you must put that operation into the opq. When the handler you registered in the opq is called, you can actually perform the operation. When your operation completes (no matter what, you must call it, even if the operation fails), you must call ipmi_sensor_opq_done. The sensor will be locked properly for your callback. To handle the sensor locking for you for command responses, you can send the message with ipmi_sensor_send_command, it will return the response when it comes in to your handler with the sensor locked. */typedef void (*ipmi_sensor_op_cb)(ipmi_sensor_t *sensor, int err, void *cb_data);typedef void (*ipmi_sensor_rsp_cb)(ipmi_sensor_t *sensor, int err, ipmi_msg_t *rsp, void *cb_data);typedef struct ipmi_sensor_op_info_s{ ipmi_sensor_id_t __sensor_id; ipmi_sensor_t *__sensor; void *__cb_data; ipmi_sensor_op_cb __handler; ipmi_sensor_rsp_cb __rsp_handler; ipmi_msg_t *__rsp; int __err;} ipmi_sensor_op_info_t;/* Add an operation to the sensor operation queue. If nothing is in the operation queue, the handler will be performed immediately. If something else is currently being operated on, the operation will be queued until other operations before it have been completed. Then the handler will be called. */int ipmi_sensor_add_opq(ipmi_sensor_t *sensor, ipmi_sensor_op_cb handler, ipmi_sensor_op_info_t *info, void *cb_data);int ipmi_sensor_id_add_opq(ipmi_sensor_id_t sensor_id, ipmi_sensor_op_cb handler, ipmi_sensor_op_info_t *info, void *cb_data);/* When an operation is completed (even if it fails), this *MUST* be called to cause the next operation to run. */void ipmi_sensor_opq_done(ipmi_sensor_t *sensor);/* Send an IPMI command to a specific MC. The response handler will be called with the sensor locked. */int ipmi_sensor_send_command(ipmi_sensor_t *sensor, ipmi_mc_t *mc, unsigned int lun, ipmi_msg_t *msg, ipmi_sensor_rsp_cb handler, ipmi_sensor_op_info_t *info, void *cb_data);/* Send an IPMI command to a specific address in the domain. This way, if you don't have an MC to represent the address, you can still send the command. The response handler will be called with the sensor locked. */int ipmi_sensor_send_command_addr(ipmi_domain_t *domain, ipmi_sensor_t *sensor, ipmi_addr_t *addr, unsigned int addr_len, ipmi_msg_t *msg, ipmi_sensor_rsp_cb handler, ipmi_sensor_op_info_t *info, void *cb_data);/* Custom sensor strings. These pointers are kept in the data structure. You should use a static string here, which should always be doable, I think. If not, a management interface needs to be added for these. */void ipmi_sensor_set_sensor_type_string(ipmi_sensor_t *sensor, char *str);void ipmi_sensor_set_event_reading_type_string(ipmi_sensor_t *sensor, char *str);void ipmi_sensor_set_rate_unit_string(ipmi_sensor_t *sensor, char *str);void ipmi_sensor_set_base_unit_string(ipmi_sensor_t *sensor, char *str);void ipmi_sensor_set_modifier_unit_string(ipmi_sensor_t *sensor, char *str);/* Get the MC that the message is sent to for reading and controlling the sensor. */ipmi_mc_t *ipmi_sensor_get_mc(ipmi_sensor_t *sensor);/* Return the MC that held the sensor's SDR (or NULL if the sensor came from the main SDR repository or was synthesized. */ipmi_mc_t *ipmi_sensor_get_source_mc(ipmi_sensor_t *sensor);/* Do a pointer callback but ignore the sequence number in the MC. This is primarily for handling incoming events, where the sequence number doesn't matter. */int ipmi_sensor_pointer_noseq_cb(ipmi_sensor_id_t id, ipmi_sensor_ptr_cb handler, void *cb_data);#endif /* _IPMI_SENSOR_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?