#include #include #include #include #include "bmc-conf-commit.h" #define COMMENT_CHAR '#' u_int16_t get_sms_io_base () { return IPMI_KCS_SMS_IO_BASE_SR870BN4; } #ifndef whitespace #define whitespace(c) (((c) == ' ') || ((c) == '\t')) #endif char * stripwhite (char *string) { register char *s, *t; for (s = string; whitespace (*s); s++) ; if (*s == 0) return s; t = s + strlen (s) - 1; while (t > s && whitespace (*t)) t--; *++t = '\0'; return s; } char * fi_getline (FILE *fp) { char *line_string = NULL; char *line_start_ptr = NULL; size_t n = 0; int retval = 0; char *line = NULL; if (fp == NULL) return NULL; while (1) { if (line_string) { free (line_string); line_string = NULL; line_start_ptr = NULL; } retval = getline (&line_string, &n, fp); if (retval == -1) break; line_start_ptr = stripwhite (line_string); if (strcmp (line_start_ptr, "\n") == 0 || strcmp (line_start_ptr, "\r\n") == 0) continue; if (line_start_ptr[0] != COMMENT_CHAR) break; } if (line_start_ptr) line = strdup (line_start_ptr); if (line_string) free (line_string); if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = 0; if (line[strlen(line) - 1] == '\r') line[strlen(line) - 1] = 0; return line; } char * get_token (char *line) { char *token_start_ptr = NULL; token_start_ptr = strchr (line, ' '); if (token_start_ptr == NULL) return NULL; return strdup (stripwhite (token_start_ptr)); } int kcs_bmc_lan_set_arp_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t bmc_generated_gratuitous_arps_flag; u_int8_t bmc_generated_arp_responses_flag; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } bmc_generated_gratuitous_arps_flag = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } bmc_generated_arp_responses_flag = atoi (value_string); free (line); free (value_string); status = ipmi_lan_set_arp (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, bmc_generated_gratuitous_arps_flag, bmc_generated_arp_responses_flag, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_arp: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_arp"); return (-1); } return (0); } int kcs_lan_set_gratuitous_arp_interval_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t gratuitous_arp_interval; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } gratuitous_arp_interval = atoi (value_string); free (line); free (value_string); status = ipmi_lan_set_gratuitous_arp_interval (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, gratuitous_arp_interval, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_gratuitous_arp_interval: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_gratuitous_arp_interval"); return (-1); } return (0); } int kcs_lan_set_auth_type_enables_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; int n; int i; u_int8_t max_privilege_auth_type_callback_level = 0; u_int8_t max_privilege_auth_type_user_level = 0; u_int8_t max_privilege_auth_type_operator_level = 0; u_int8_t max_privilege_auth_type_admin_level = 0; u_int8_t max_privilege_auth_type_oem_level = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); for (i = 0; i < 6; i++) { if (i == 3) continue; line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } n = atoi (value_string); free (line); free (value_string); if (n == 1) max_privilege_auth_type_callback_level = BIT_SET (max_privilege_auth_type_callback_level, i); } for (i = 0; i < 6; i++) { if (i == 3) continue; line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } n = atoi (value_string); free (line); free (value_string); if (n == 1) max_privilege_auth_type_user_level = BIT_SET (max_privilege_auth_type_user_level, i); } for (i = 0; i < 6; i++) { if (i == 3) continue; line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } n = atoi (value_string); free (line); free (value_string); if (n == 1) max_privilege_auth_type_operator_level = BIT_SET (max_privilege_auth_type_operator_level, i); } for (i = 0; i < 6; i++) { if (i == 3) continue; line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } n = atoi (value_string); free (line); free (value_string); if (n == 1) max_privilege_auth_type_admin_level = BIT_SET (max_privilege_auth_type_admin_level, i); } for (i = 0; i < 6; i++) { if (i == 3) continue; line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } n = atoi (value_string); free (line); free (value_string); if (n == 1) max_privilege_auth_type_oem_level = BIT_SET (max_privilege_auth_type_oem_level, i); } status = ipmi_lan_set_auth_type_enables (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, max_privilege_auth_type_callback_level, max_privilege_auth_type_user_level, max_privilege_auth_type_operator_level, max_privilege_auth_type_admin_level, max_privilege_auth_type_oem_level, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_auth_type_enables: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_auth_type_enables"); return (-1); } return (0); } int kcs_lan_set_ip_addr_source_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t ip_addr_source; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } ip_addr_source = atoi (value_string); free (line); free (value_string); status = ipmi_lan_set_ip_addr_source (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, ip_addr_source, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_ip_addr_source: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_ip_addr_source"); return (-1); } return (0); } int kcs_lan_set_ip_addr_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4; u_int64_t ip_address = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%u.%u.%u.%u", &b1, &b2, &b3, &b4); free (value_string); ip_address = bits_merge (ip_address, 0, 8, b1); ip_address = bits_merge (ip_address, 8, 16, b2); ip_address = bits_merge (ip_address, 16, 24, b3); ip_address = bits_merge (ip_address, 24, 32, b4); status = ipmi_lan_set_ip_addr (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, ip_address, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_ip_addr: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_ip_addr"); return (-1); } return (0); } int kcs_lan_set_gw1_ip_addr_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4; u_int64_t ip_address = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%u.%u.%u.%u", &b1, &b2, &b3, &b4); free (value_string); ip_address = bits_merge (ip_address, 0, 8, b1); ip_address = bits_merge (ip_address, 8, 16, b2); ip_address = bits_merge (ip_address, 16, 24, b3); ip_address = bits_merge (ip_address, 24, 32, b4); status = ipmi_lan_set_gw1_ip_addr (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, ip_address, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_gw1_ip_addr: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_gw1_ip_addr"); return (-1); } return (0); } int kcs_lan_set_gw2_ip_addr_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4; u_int64_t ip_address = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%u.%u.%u.%u", &b1, &b2, &b3, &b4); free (value_string); ip_address = bits_merge (ip_address, 0, 8, b1); ip_address = bits_merge (ip_address, 8, 16, b2); ip_address = bits_merge (ip_address, 16, 24, b3); ip_address = bits_merge (ip_address, 24, 32, b4); status = ipmi_lan_set_gw2_ip_addr (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, ip_address, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_gw2_ip_addr: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_gw2_ip_addr"); return (-1); } return (0); } int kcs_lan_set_subnet_mask_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4; u_int64_t subnet_mask = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%u.%u.%u.%u", &b1, &b2, &b3, &b4); free (value_string); subnet_mask = bits_merge (subnet_mask, 0, 8, b1); subnet_mask = bits_merge (subnet_mask, 8, 16, b2); subnet_mask = bits_merge (subnet_mask, 16, 24, b3); subnet_mask = bits_merge (subnet_mask, 24, 32, b4); status = ipmi_lan_set_subnet_mask (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, subnet_mask, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_subnet_mask: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_subnet_mask"); return (-1); } return (0); } int kcs_lan_set_mac_addr_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4, b5, b6; u_int64_t mac_address = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%02X:%02X:%02X:%02X:%02X:%02X", &b1, &b2, &b3, &b4, &b5, &b6); free (value_string); mac_address = bits_merge (mac_address, 0, 8, b1); mac_address = bits_merge (mac_address, 8, 16, b2); mac_address = bits_merge (mac_address, 16, 24, b3); mac_address = bits_merge (mac_address, 24, 32, b4); mac_address = bits_merge (mac_address, 32, 40, b5); mac_address = bits_merge (mac_address, 40, 48, b6); status = ipmi_lan_set_mac_addr (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, mac_address, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_mac_addr: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_mac_addr"); return (-1); } return (0); } int kcs_lan_set_gw1_mac_addr_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4, b5, b6; u_int64_t mac_address = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%02X:%02X:%02X:%02X:%02X:%02X", &b1, &b2, &b3, &b4, &b5, &b6); free (value_string); mac_address = bits_merge (mac_address, 0, 8, b1); mac_address = bits_merge (mac_address, 8, 16, b2); mac_address = bits_merge (mac_address, 16, 24, b3); mac_address = bits_merge (mac_address, 24, 32, b4); mac_address = bits_merge (mac_address, 32, 40, b5); mac_address = bits_merge (mac_address, 40, 48, b6); status = ipmi_lan_set_gw1_mac_addr (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, mac_address, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_gw1_mac_addr: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_gw1_mac_addr"); return (-1); } return (0); } int kcs_lan_set_gw2_mac_addr_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; unsigned int b1, b2, b3, b4, b5, b6; u_int64_t mac_address = 0; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_lan_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } free (line); sscanf (value_string, "%02X:%02X:%02X:%02X:%02X:%02X", &b1, &b2, &b3, &b4, &b5, &b6); free (value_string); mac_address = bits_merge (mac_address, 0, 8, b1); mac_address = bits_merge (mac_address, 8, 16, b2); mac_address = bits_merge (mac_address, 16, 24, b3); mac_address = bits_merge (mac_address, 24, 32, b4); mac_address = bits_merge (mac_address, 32, 40, b5); mac_address = bits_merge (mac_address, 40, 48, b6); status = ipmi_lan_set_gw2_mac_addr (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, mac_address, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_lan_set_gw2_mac_addr: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_lan_set_gw2_mac_addr"); return (-1); } return (0); } int set_user_name_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; int user_id; char *line; char *value_string; char *user_name; for (user_id = 2; user_id <= 4; user_id++) { obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_user_name_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } user_name = value_string; free (line); status = ipmi_kcs_set_user_name (get_sms_io_base (), user_id, user_name, obj_hdr_rs, obj_data_rs); free (value_string); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_kcs_set_user_name: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); } if (status != 0) perror ("ipmi_kcs_set_user_name"); } return (0); } int set_user_password_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; int user_id; char *line; char *value_string; char *password; for (user_id = 1; user_id <= 4; user_id++) { obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_user_password_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } password = value_string; free (line); status = ipmi_kcs_set_user_password (get_sms_io_base (), user_id, IPMI_PASSWORD_OPERATION_SET_PASSWORD, password, obj_hdr_rs, obj_data_rs); free (value_string); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_kcs_set_user_password: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); } if (status != 0) perror ("ipmi_kcs_set_user_password"); } return (0); } int set_user_access_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; int user_id; char *line; char *value_string; u_int8_t restrict_to_callback; u_int8_t enable_link_auth; u_int8_t enable_ipmi_msgs; u_int8_t user_privilege_level_limit; u_int8_t user_session_number_limit = 0; for (user_id = 1; user_id <= 4; user_id++) { obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_user_access_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } user_privilege_level_limit = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } enable_ipmi_msgs = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } enable_link_auth = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } restrict_to_callback = atoi (value_string); free (line); free (value_string); status = ipmi_kcs_set_user_access (get_sms_io_base (), BMC_LAN_CHANNEL_NUMBER, user_id, restrict_to_callback, enable_link_auth, enable_ipmi_msgs, user_privilege_level_limit, user_session_number_limit, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_kcs_set_user_access: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); status = -1; } } return (0); } int set_channel_access_commit (FILE *fp) { char *line; int i; for (i = 0; i < 10; i++) { line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); free (line); } return (0); } int set_serial_connmode_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t basic_mode_enable; u_int8_t ppp_mode_enable; u_int8_t terminal_mode_enable; u_int8_t direct; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_serial_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } basic_mode_enable = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } ppp_mode_enable = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } terminal_mode_enable = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } direct = atoi (value_string); free (line); free (value_string); status = ipmi_set_serial_connmode (get_sms_io_base (), BMC_SERIAL_CHANNEL_NUMBER, basic_mode_enable, ppp_mode_enable, terminal_mode_enable, direct, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_set_serial_connmode: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_set_serial_connmode"); return (-1); } return (0); } int set_serial_page_blackout_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t page_blackout_interval; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_serial_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } page_blackout_interval = atoi (value_string); free (line); free (value_string); status = ipmi_set_serial_page_blackout_interval (get_sms_io_base (), BMC_SERIAL_CHANNEL_NUMBER, page_blackout_interval, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_set_serial_page_blackout: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_set_serial_page_blackout"); return (-1); } return (0); } int set_serial_retry_time_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t retry_time; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_serial_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } retry_time = atoi (value_string); free (line); free (value_string); status = ipmi_set_serial_retry_time (get_sms_io_base (), BMC_SERIAL_CHANNEL_NUMBER, retry_time, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_set_serial_retry_time: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_set_serial_retry_time"); return (-1); } return (0); } int set_serial_comm_bits_commit (FILE *fp) { u_int8_t status; fiid_obj_t obj_hdr_rs; fiid_obj_t obj_data_rs; char *line; char *value_string; u_int8_t dtr_hangup; u_int8_t flow_control; u_int8_t bit_rate; obj_hdr_rs = alloca (fiid_obj_len_bytes (tmpl_hdr_kcs)); obj_data_rs = alloca (fiid_obj_len_bytes (tmpl_set_serial_conf_param_rs)); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } dtr_hangup = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } flow_control = atoi (value_string); free (line); free (value_string); line = fi_getline (fp); if (line == NULL || *line == '\0') return (-1); if ((value_string = get_token (line)) == NULL) { free (line); return (-1); } bit_rate = atoi (value_string); free (line); free (value_string); status = ipmi_set_serial_comm_bits (get_sms_io_base (), BMC_SERIAL_CHANNEL_NUMBER, dtr_hangup, flow_control, bit_rate, obj_hdr_rs, obj_data_rs); if (IPMI_COMP_CODE (obj_data_rs) != IPMI_COMMAND_SUCCESS) { char err_msg[IPMI_ERR_STR_MAX_LEN]; ipmi_strerror_r (obj_data_rs, err_msg, IPMI_ERR_STR_MAX_LEN); fprintf (stderr, "error: ipmi_set_serial_comm_bits: %d: %s\n", IPMI_COMP_CODE(obj_data_rs), err_msg); return (-1); } if (status != 0) { perror ("ipmi_set_serial_comm_bits"); return (-1); } return (0); } int main () { ipmi_kcs_io_init (get_sms_io_base(), 2000); kcs_bmc_lan_set_arp_commit (stdin); printf ("completed kcs_bmc_lan_set_arp_commit\n"); /* sleep (5); */ kcs_lan_set_gratuitous_arp_interval_commit (stdin); printf ("completed kcs_lan_set_gratuitous_arp_interval_commit\n"); /* sleep (5); */ kcs_lan_set_auth_type_enables_commit (stdin); printf ("completed kcs_lan_set_auth_type_enables_commit\n"); /* sleep (5); */ kcs_lan_set_ip_addr_source_commit (stdin); printf ("completed kcs_lan_set_ip_addr_source_commit\n"); /* sleep (5); */ kcs_lan_set_ip_addr_commit (stdin); printf ("completed kcs_lan_set_ip_addr_commit\n"); /* sleep (5); */ kcs_lan_set_gw1_ip_addr_commit (stdin); printf ("completed kcs_lan_set_gw1_ip_addr_commit\n"); /* sleep (5); */ kcs_lan_set_gw2_ip_addr_commit (stdin); printf ("completed kcs_lan_set_gw2_ip_addr_commit\n"); /* sleep (5); */ kcs_lan_set_subnet_mask_commit (stdin); printf ("completed kcs_lan_set_subnet_mask_commit\n"); /* sleep (5); */ kcs_lan_set_mac_addr_commit (stdin); printf ("completed kcs_lan_set_mac_addr_commit\n"); /* sleep (5); */ kcs_lan_set_gw1_mac_addr_commit (stdin); printf ("completed kcs_lan_set_gw1_mac_addr_commit\n"); /* sleep (5); */ kcs_lan_set_gw2_mac_addr_commit (stdin); printf ("completed kcs_lan_set_gw2_mac_addr_commit\n"); /* sleep (5); */ set_user_name_commit (stdin); printf ("completed set_user_name_commit\n"); /* sleep (5); */ set_user_password_commit (stdin); printf ("completed set_user_password_commit\n"); /* sleep (5); */ set_user_access_commit (stdin); printf ("completed set_user_access_commit\n"); /* sleep (5); */ set_channel_access_commit (stdin); printf ("completed set_channel_access_commit\n"); /* sleep (5); */ set_serial_connmode_commit (stdin); printf ("completed set_serial_connmode_commit\n"); /* sleep (5); */ set_serial_page_blackout_commit (stdin); printf ("completed set_serial_page_blackout_commit\n"); /* sleep (5); */ set_serial_retry_time_commit (stdin); printf ("completed set_serial_retry_time_commit\n"); /* sleep (5); */ set_serial_comm_bits_commit (stdin); printf ("completed set_serial_comm_bits_commit\n"); return 0; }