static config_err_t _set_alert_policy_table (struct pef_config_state_data *state_data, const char *section_name, struct alert_policy_table *apt) { fiid_obj_t obj_cmd_rs = NULL; config_err_t rv = CONFIG_ERR_FATAL_ERROR; uint8_t alert_policy_entry_number; assert(state_data); assert(section_name); assert(apt); alert_policy_entry_number = atoi (section_name + strlen ("Alert_Policy_")); _FIID_OBJ_CREATE(obj_cmd_rs, tmpl_cmd_set_pef_configuration_parameters_rs); if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common.debug) pstdout_fprintf(state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_strerror(ipmi_ctx_errnum(state_data->ipmi_ctx))); /* IPMI Workaround * * Fujitsu RX 100 S5 * * All fields have to be applied simultaneously, the motherboard * does not appear to like configuration of one field of a time, * always leading to invalid input errors. */ if (ipmi_ctx_errnum (state_data->ipmi_ctx) == IPMI_ERR_BAD_COMPLETION_CODE_REQUEST_DATA_INVALID && (ipmi_check_completion_code (obj_cmd_rs, IPMI_COMP_CODE_REQUEST_INVALID_DATA_FIELD) == 1)) { struct config_section *section = NULL; struct config_keyvalue *kv; unsigned int i; for (i = 0; i < state_data->alert_policy_sections_len; i++) { if (!strcasecmp (section_name, state_data->alert_policy_sections[i]->section_name)) { section = state_data->alert_policy_sections[i]; break; } } /* shouldn't be possible */ if (!section) goto cleanup; if ((kv = config_find_keyvalue (state_data->pstate, section, "Policy_Type"))) apt->policy_type = policy_type_number (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Policy_Enabled"))) apt->policy_enabled = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (state_data->pstate, section, "Policy_Number"))) apt->policy_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Destination_Selector"))) apt->destination_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Channel_Number"))) apt->channel_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Alert_String_Set_Selector"))) apt->alert_string_set_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (state_data->pstate, section, "Event_Specific_Alert_String"))) apt->event_specific_alert_string = same (kv->value_input, "yes"); if (state_data->prog_data->args->config_args.common.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: attempting workaround\n"); if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_strerror(ipmi_ctx_errnum(state_data->ipmi_ctx))); if (!IPMI_CTX_ERRNUM_IS_FATAL_ERROR(state_data->ipmi_ctx)) rv = CONFIG_ERR_NON_FATAL_ERROR; goto cleanup; } /* success */ goto out; } else if (!IPMI_CTX_ERRNUM_IS_FATAL_ERROR(state_data->ipmi_ctx)) rv = CONFIG_ERR_NON_FATAL_ERROR; goto cleanup; } out: rv = CONFIG_ERR_SUCCESS; cleanup: _FIID_OBJ_DESTROY(obj_cmd_rs); return (rv); }
static config_err_t _set_alert_policy_table (struct ipmi_pef_config_state_data *state_data, const char *section_name, struct alert_policy_table *apt) { fiid_obj_t obj_cmd_rs = NULL; config_err_t rv = CONFIG_ERR_FATAL_ERROR; uint8_t alert_policy_entry_number; assert (state_data); assert (section_name); assert (apt); alert_policy_entry_number = atoi (section_name + strlen ("Alert_Policy_")); if (!(obj_cmd_rs = fiid_obj_create (tmpl_cmd_set_pef_configuration_parameters_rs))) { pstdout_fprintf (state_data->pstate, stderr, "fiid_obj_create: %s\n", strerror (errno)); goto cleanup; } if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { config_err_t ret; if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); /* IPMI Workaround * * Fujitsu RX 100 S5 * * Inventec 5441/Dell Xanadu II * * All fields have to be applied simultaneously, the motherboard * does not appear to like configuration of one field of a time, * always leading to invalid input errors. This isn't a * compliance issue, but makes it tough to make a portable/good * interface. */ if (ipmi_ctx_errnum (state_data->ipmi_ctx) == IPMI_ERR_BAD_COMPLETION_CODE && (ipmi_check_completion_code (obj_cmd_rs, IPMI_COMP_CODE_INVALID_DATA_FIELD_IN_REQUEST) == 1)) { struct config_section *section; struct config_keyvalue *kv; section = state_data->sections; while (section) { if (!strcasecmp (section_name, section->section_name)) break; section = section->next; } /* shouldn't be possible */ if (!section) goto cleanup; if ((kv = config_find_keyvalue (section, "Policy_Type"))) apt->policy_type = policy_type_number (kv->value_input); if ((kv = config_find_keyvalue (section, "Policy_Enabled"))) apt->policy_enabled = same (kv->value_input, "yes"); if ((kv = config_find_keyvalue (section, "Policy_Number"))) apt->policy_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Destination_Selector"))) apt->destination_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Channel_Number"))) apt->channel_number = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Alert_String_Set_Selector"))) apt->alert_string_set_selector = atoi (kv->value_input); if ((kv = config_find_keyvalue (section, "Event_Specific_Alert_String"))) apt->event_specific_alert_string = same (kv->value_input, "yes"); if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: attempting workaround\n"); if (ipmi_cmd_set_pef_configuration_parameters_alert_policy_table (state_data->ipmi_ctx, alert_policy_entry_number, apt->policy_type, apt->policy_enabled, apt->policy_number, apt->destination_selector, apt->channel_number, apt->alert_string_set_selector, apt->event_specific_alert_string, obj_cmd_rs) < 0) { if (state_data->prog_data->args->config_args.common_args.debug) pstdout_fprintf (state_data->pstate, stderr, "ipmi_cmd_set_pef_configuration_parameters_alert_policy_table: %s\n", ipmi_ctx_errormsg (state_data->ipmi_ctx)); if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } /* success */ goto out; } else if (config_is_config_param_non_fatal_error (state_data->ipmi_ctx, obj_cmd_rs, &ret)) rv = ret; goto cleanup; } out: rv = CONFIG_ERR_SUCCESS; cleanup: fiid_obj_destroy (obj_cmd_rs); return (rv); }