ipmi_config_err_t ipmi_config_sensors_discrete_section (ipmi_config_state_data_t *state_data, struct ipmi_config_section **section_ptr) { struct ipmi_config_section *section = NULL; char section_name[IPMI_CONFIG_MAX_SECTION_NAME_LEN + 1]; ipmi_config_err_t rv = IPMI_CONFIG_ERR_FATAL_ERROR; ipmi_config_err_t ret; assert (state_data); assert (section_ptr); memset (section_name, '\0', IPMI_CONFIG_MAX_SECTION_NAME_LEN + 1); if ((ret = ipmi_config_sensors_create_section_name (state_data, section_name, IPMI_CONFIG_MAX_SECTION_NAME_LEN)) != IPMI_CONFIG_ERR_SUCCESS) { rv = ret; if (rv == IPMI_CONFIG_ERR_FATAL_ERROR || state_data->prog_data->args->common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_config_sensors_create_section_name: %s\n", strerror (errno)); goto cleanup; } if (!(section = ipmi_config_section_create (state_data, section_name, NULL, NULL, 0, NULL, NULL))) goto cleanup; if (setup_sensor_event_enable_fields (state_data, section) < 0) goto cleanup; *section_ptr = section; return (IPMI_CONFIG_ERR_SUCCESS); cleanup: if (section) ipmi_config_section_destroy (section); return (rv); }
config_err_t ipmi_sensors_config_threshold_section (ipmi_sensors_config_state_data_t *state_data, struct config_section **section_ptr) { struct config_section *section = NULL; char section_name[CONFIG_MAX_SECTION_NAME_LEN]; uint8_t threshold_access_support = 0; uint8_t hysteresis_support = 0; config_err_t rv = CONFIG_ERR_FATAL_ERROR; config_err_t ret; uint8_t sensor_type; uint8_t sensor_units_percentage; uint8_t sensor_units_modifier; uint8_t sensor_units_rate; uint8_t sensor_base_unit_type; uint8_t sensor_modifier_unit_type; char description[CONFIG_MAX_DESCRIPTION_LEN]; char sensor_units_buf[IPMI_SENSORS_CONFIG_UNITS_BUFLEN+1]; int sensor_units_ret; const char *sensor_type_str = NULL; assert (state_data); assert (section_ptr); if ((ret = create_section_name (state_data, section_name, CONFIG_MAX_SECTION_NAME_LEN)) != CONFIG_ERR_SUCCESS) { if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "create_section_name: %s\n", strerror (errno)); rv = ret; goto cleanup; } if (!(section = config_section_create (state_data->pstate, section_name, NULL, NULL, 0, NULL, NULL))) goto cleanup; if (ipmi_sdr_parse_sensor_capabilities (state_data->sdr_ctx, NULL, 0, NULL, &threshold_access_support, &hysteresis_support, NULL, NULL) < 0) { pstdout_fprintf (state_data->pstate, stderr, "ipmi_sdr_parse_sensor_capabilities: %s\n", ipmi_sdr_ctx_errormsg (state_data->sdr_ctx)); goto cleanup; } if (ipmi_sdr_parse_sensor_type (state_data->sdr_ctx, NULL, 0, &sensor_type) < 0) { pstdout_fprintf (state_data->pstate, stderr, "ipmi_sdr_parse_sensor_type: %s\n", ipmi_sdr_ctx_errormsg (state_data->sdr_ctx)); goto cleanup; } if (ipmi_sdr_parse_sensor_units (state_data->sdr_ctx, NULL, 0, &sensor_units_percentage, &sensor_units_modifier, &sensor_units_rate, &sensor_base_unit_type, &sensor_modifier_unit_type) < 0) { pstdout_fprintf (state_data->pstate, stderr, "ipmi_sdr_parse_sensor_unit: %s\n", ipmi_sdr_ctx_errormsg (state_data->sdr_ctx)); goto cleanup; } memset (sensor_units_buf, '\0', IPMI_SENSORS_CONFIG_UNITS_BUFLEN); sensor_units_ret = ipmi_sensor_units_string (sensor_units_percentage, sensor_units_modifier, sensor_units_rate, sensor_base_unit_type, sensor_modifier_unit_type, sensor_units_buf, IPMI_SENSORS_CONFIG_UNITS_BUFLEN, 0); sensor_type_str = ipmi_get_sensor_type_string (sensor_type); memset (description, '\0', CONFIG_MAX_DESCRIPTION_LEN); if (sensor_units_ret > 0) snprintf (description, CONFIG_MAX_DESCRIPTION_LEN, "Give valid input for sensor type = %s; units = %s", sensor_type_str ? sensor_type_str : UNRECOGNIZED_SENSOR_TYPE, sensor_units_buf); else snprintf (description, CONFIG_MAX_DESCRIPTION_LEN, "Give valid input for sensor type = %s", sensor_type_str ? sensor_type_str : UNRECOGNIZED_SENSOR_TYPE); if (setup_sensor_event_enable_fields (state_data, section) < 0) goto cleanup; if (threshold_access_support == IPMI_SDR_READABLE_THRESHOLDS_SUPPORT || threshold_access_support == IPMI_SDR_READABLE_SETTABLE_THRESHOLDS_SUPPORT || state_data->prog_data->args->config_args.verbose_count) { if (_setup_threshold_fields (state_data, section, description, sensor_base_unit_type) < 0) goto cleanup; } if (hysteresis_support == IPMI_SDR_READABLE_HYSTERESIS_SUPPORT || hysteresis_support == IPMI_SDR_READABLE_SETTABLE_HYSTERESIS_SUPPORT || state_data->prog_data->args->config_args.verbose_count) { if (_setup_threshold_hysteresis_fields (state_data, section, description, sensor_base_unit_type, hysteresis_support) < 0) goto cleanup; } *section_ptr = section; return (CONFIG_ERR_SUCCESS); cleanup: if (section) config_section_destroy (section); return (rv); }