diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-09-10 15:44:41 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-09-10 15:44:41 +0200 |
commit | a9ee361f27e0439530387765924574e5358c8a5c (patch) | |
tree | 3104aecc4d574f7d7bbb269223814586277b1797 /lib/ipmi_delloem.c | |
parent | 82ac6c87ce0b0af2fb8de25d70442fec406bb742 (diff) |
New upstream version 1.8.19upstream/1.8.19upstream
Diffstat (limited to 'lib/ipmi_delloem.c')
-rw-r--r-- | lib/ipmi_delloem.c | 727 |
1 files changed, 330 insertions, 397 deletions
diff --git a/lib/ipmi_delloem.c b/lib/ipmi_delloem.c index bc78c1d..e868913 100644 --- a/lib/ipmi_delloem.c +++ b/lib/ipmi_delloem.c @@ -62,6 +62,7 @@ #include <ipmitool/ipmi_entity.h> #include <ipmitool/ipmi_fru.h> #include <ipmitool/ipmi_sensor.h> +#include <ipmitool/ipmi_time.h> #define DELL_OEM_NETFN (uint8_t)(0x30) #define GET_IDRAC_VIRTUAL_MAC (uint8_t)(0xC9) @@ -170,12 +171,10 @@ static int ipmi_lcd_get_status(struct ipmi_intf *intf); static int ipmi_lcd_set_kvm(struct ipmi_intf *intf, char status); static int ipmi_lcd_set_lock(struct ipmi_intf *intf, char lock); static int ipmi_lcd_set_single_line_text(struct ipmi_intf *intf, char *text); -static int ipmi_lcd_set_text(struct ipmi_intf *intf, char *text, - int line_number); +static int ipmi_lcd_set_text(struct ipmi_intf *intf, char *text); static int ipmi_lcd_configure_wh(struct ipmi_intf *intf, uint32_t mode, - uint16_t lcdquallifier, uint8_t errordisp, int8_t line_number, char *text); -static int ipmi_lcd_configure(struct ipmi_intf *intf, int command, - int8_t line_number, char *text); + uint16_t lcdquallifier, uint8_t errordisp, char *text); +static int ipmi_lcd_configure(struct ipmi_intf *intf, int command, char *text); static void ipmi_lcd_usage(void); /* MAC Function prototypes */ static int ipmi_delloem_mac_main(struct ipmi_intf *intf, int argc, char **argv); @@ -201,7 +200,6 @@ static int ipmi_lan_set_nic_selection_12g(struct ipmi_intf *intf, /* Power monitor Function prototypes */ static int ipmi_delloem_powermonitor_main(struct ipmi_intf *intf, int argc, char **argv); -static void ipmi_time_to_str(time_t rawTime, char *strTime); static int ipmi_get_sensor_reading(struct ipmi_intf *intf, unsigned char sensorNumber, SensorReadingType *pSensorReadingData); static int ipmi_get_power_capstatus_command(struct ipmi_intf *intf); @@ -271,25 +269,25 @@ ipmi_delloem_main(struct ipmi_intf * intf, int argc, char ** argv) { int rc = 0; current_arg = 0; - if (argc == 0 || strncmp(argv[0], "help\0", 5) == 0) { + if (!argc || !strcmp(argv[0], "help")) { usage(); return 0; } - if (0 ==strncmp(argv[current_arg], "lcd\0", 4)) { + if (0 ==strcmp(argv[current_arg], "lcd")) { rc = ipmi_delloem_lcd_main(intf,argc,argv); - } else if (strncmp(argv[current_arg], "mac\0", 4) == 0) { + } else if (!strcmp(argv[current_arg], "mac")) { /* mac address*/ rc = ipmi_delloem_mac_main(intf,argc,argv); - } else if (strncmp(argv[current_arg], "lan\0", 4) == 0) { + } else if (!strcmp(argv[current_arg], "lan")) { /* lan address*/ rc = ipmi_delloem_lan_main(intf,argc,argv); - } else if (strncmp(argv[current_arg], "setled\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "setled")) { /* SetLED support */ rc = ipmi_delloem_setled_main(intf,argc,argv); - } else if (strncmp(argv[current_arg], "powermonitor\0", 13) == 0) { + } else if (!strcmp(argv[current_arg], "powermonitor")) { /*Powermanagement report processing*/ rc = ipmi_delloem_powermonitor_main(intf,argc,argv); - } else if (strncmp(argv[current_arg], "vFlash\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "vFlash")) { /* vFlash Support */ rc = ipmi_delloem_vFlash_main(intf,argc,argv); } else { @@ -361,7 +359,7 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) return -1; } /* ipmitool delloem lcd info*/ - if (argc == 1 || strcmp(argv[current_arg], "help") == 0) { + if (argc == 1 || !strcmp(argv[current_arg], "help")) { ipmi_lcd_usage(); return 0; } @@ -370,15 +368,15 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) if (!IsLCDSupported()) { lprintf(LOG_ERR, "lcd is not supported on this system."); return -1; - } else if (strncmp(argv[current_arg], "info\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "info")) { if (iDRAC_FLAG_ALL) { rc = ipmi_lcd_get_info_wh(intf); } else { rc = ipmi_lcd_get_info(intf); } - } else if (strncmp(argv[current_arg], "status\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "status")) { rc = ipmi_lcd_get_status(intf); - } else if (strncmp(argv[current_arg], "set\0", 4) == 0) { + } else if (!strcmp(argv[current_arg], "set")) { /* ipmitool delloem lcd set*/ uint8_t line_number = 0; current_arg++; @@ -386,7 +384,7 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) ipmi_lcd_usage(); return -1; } - if (strncmp(argv[current_arg], "line\0", 5) == 0) { + if (!strcmp(argv[current_arg], "line")) { current_arg++; if (argc <= current_arg) { usage(); @@ -404,164 +402,170 @@ ipmi_delloem_lcd_main(struct ipmi_intf * intf, int argc, char ** argv) return -1; } } - if ((strncmp(argv[current_arg], "mode\0", 5) == 0) - && (iDRAC_FLAG_ALL)) { + if (!strcmp(argv[current_arg], "mode") + && iDRAC_FLAG_ALL) + { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_lcd_usage(); return -1; } - if (strncmp(argv[current_arg], "none\0", 5) == 0) { + if (!strcmp(argv[current_arg], "none")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_CONFIG_NONE, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "modelname\0", 10) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "modelname")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_CONFIG_DEFAULT, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "userdefined\0", 12) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "userdefined")) { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_CONFIG_USER_DEFINED, - 0xFF, 0XFF, line_number, argv[current_arg]); - } else if (strncmp(argv[current_arg], "ipv4address\0", 12) == 0) { + 0xFF, 0XFF, argv[current_arg]); + } else if (!strcmp(argv[current_arg], "ipv4address")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_iDRAC_IPV4ADRESS, - 0xFF, 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "macaddress\0", 11) == 0) { + 0xFF, 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "macaddress")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_IDRAC_MAC_ADDRESS, - 0xFF, 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "systemname\0", 11) == 0) { + 0xFF, 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "systemname")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_OS_SYSTEM_NAME, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "servicetag\0", 11) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "servicetag")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_SERVICE_TAG, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "ipv6address\0", 12) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "ipv6address")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_iDRAC_IPV6ADRESS, - 0xFF, 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "ambienttemp\0", 12) == 0) { + 0xFF, 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "ambienttemp")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_AMBEINT_TEMP, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "systemwatt\0", 11) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "systemwatt")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_SYSTEM_WATTS, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "assettag\0", 9) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "assettag")) { rc = ipmi_lcd_configure_wh(intf, IPMI_DELL_LCD_ASSET_TAG, 0xFF, - 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "help\0", 5) == 0) { + 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "help")) { ipmi_lcd_usage(); } else { lprintf(LOG_ERR, "Invalid DellOEM command: %s", argv[current_arg]); ipmi_lcd_usage(); } - } else if ((strncmp(argv[current_arg], "lcdqualifier\0", 13) == 0) - && (iDRAC_FLAG_ALL)) { + } else if (!strcmp(argv[current_arg], "lcdqualifier") + && iDRAC_FLAG_ALL) + { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_lcd_usage(); return -1; } - if (strncmp(argv[current_arg], "watt\0", 5) == 0) { - rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x00, 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "btuphr\0",7) == 0) { - rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x01, 0XFF, 0, NULL); - } else if (strncmp(argv[current_arg], "celsius\0", 8) == 0) { - rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x02, 0xFF, 0, NULL); - } else if (strncmp(argv[current_arg], "fahrenheit", 11) == 0) { - rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x03, 0xFF, 0, NULL); - } else if (strncmp(argv[current_arg], "help\0", 5) == 0) { + if (!strcmp(argv[current_arg], "watt")) { + rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x00, 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "btuphr")) { + rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x01, 0XFF, NULL); + } else if (!strcmp(argv[current_arg], "celsius")) { + rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x02, 0xFF, NULL); + } else if (!strcmp(argv[current_arg], "fahrenheit")) { + rc = ipmi_lcd_configure_wh(intf, 0xFF, 0x03, 0xFF, NULL); + } else if (!strcmp(argv[current_arg], "help")) { ipmi_lcd_usage(); } else { lprintf(LOG_ERR, "Invalid DellOEM command: %s", argv[current_arg]); ipmi_lcd_usage(); } - } else if ((strncmp(argv[current_arg], "errordisplay\0", 13) == 0) - && (iDRAC_FLAG_ALL)) { + } else if (!strcmp(argv[current_arg], "errordisplay") + && iDRAC_FLAG_ALL) + { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_lcd_usage(); return -1; } - if (strncmp(argv[current_arg], "sel\0", 4) == 0) { + if (!strcmp(argv[current_arg], "sel")) { rc = ipmi_lcd_configure_wh(intf, 0xFF, 0xFF, - IPMI_DELL_LCD_ERROR_DISP_SEL, 0, NULL); - } else if (strncmp(argv[current_arg], "simple\0", 7) == 0) { + IPMI_DELL_LCD_ERROR_DISP_SEL, NULL); + } else if (!strcmp(argv[current_arg], "simple")) { rc = ipmi_lcd_configure_wh(intf, 0xFF, 0xFF, - IPMI_DELL_LCD_ERROR_DISP_VERBOSE, 0, NULL); - } else if (strncmp(argv[current_arg], "help\0", 5) == 0) { + IPMI_DELL_LCD_ERROR_DISP_VERBOSE, NULL); + } else if (!strcmp(argv[current_arg], "help")) { ipmi_lcd_usage(); } else { lprintf(LOG_ERR, "Invalid DellOEM command: %s", argv[current_arg]); ipmi_lcd_usage(); } - } else if ((strncmp(argv[current_arg], "none\0", 5) == 0) - && (iDRAC_FLAG==0)) { - rc = ipmi_lcd_configure(intf, IPMI_DELL_LCD_CONFIG_NONE, 0, NULL); - } else if ((strncmp(argv[current_arg], "default\0", 8) == 0) - && (iDRAC_FLAG==0)) { - rc = ipmi_lcd_configure(intf, IPMI_DELL_LCD_CONFIG_DEFAULT, 0, NULL); - } else if ((strncmp(argv[current_arg], "custom\0", 7) == 0) - && (iDRAC_FLAG==0)) { + } else if (!strcmp(argv[current_arg], "none") + && iDRAC_FLAG==0) + { + rc = ipmi_lcd_configure(intf, IPMI_DELL_LCD_CONFIG_NONE, NULL); + } else if (!strcmp(argv[current_arg], "default") + && iDRAC_FLAG==0) + { + rc = ipmi_lcd_configure(intf, IPMI_DELL_LCD_CONFIG_DEFAULT, NULL); + } else if (!strcmp(argv[current_arg], "custom") + && iDRAC_FLAG==0) + { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } rc = ipmi_lcd_configure(intf, IPMI_DELL_LCD_CONFIG_USER_DEFINED, - line_number, argv[current_arg]); - } else if (strncmp(argv[current_arg], "vkvm\0", 5) == 0) { + argv[current_arg]); + } else if (!strcmp(argv[current_arg], "vkvm")) { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } - if (strncmp(argv[current_arg], "active\0", 7) == 0) { + if (!strcmp(argv[current_arg], "active")) { rc = ipmi_lcd_set_kvm(intf, 1); - } else if (strncmp(argv[current_arg], "inactive\0", 9) == 0) { + } else if (!strcmp(argv[current_arg], "inactive")) { rc = ipmi_lcd_set_kvm(intf, 0); - } else if (strncmp(argv[current_arg], "help\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "help")) { ipmi_lcd_usage(); } else { lprintf(LOG_ERR, "Invalid DellOEM command: %s", argv[current_arg]); ipmi_lcd_usage(); } - } else if (strncmp(argv[current_arg], "frontpanelaccess\0", 17) == 0) { + } else if (!strcmp(argv[current_arg], "frontpanelaccess")) { current_arg++; if (argc <= current_arg) { ipmi_lcd_usage(); return -1; } - if (strncmp(argv[current_arg], "viewandmodify\0", 14) == 0) { + if (!strcmp(argv[current_arg], "viewandmodify")) { rc = ipmi_lcd_set_lock(intf, 0); - } else if (strncmp(argv[current_arg], "viewonly\0", 9)==0) { + } else if (strcmp(argv[current_arg], "viewonly")==0) { rc = ipmi_lcd_set_lock(intf, 1); - } else if (strncmp(argv[current_arg], "disabled\0", 9)==0) { + } else if (strcmp(argv[current_arg], "disabled")==0) { rc = ipmi_lcd_set_lock(intf, 2); - } else if (strncmp(argv[current_arg], "help\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "help")) { ipmi_lcd_usage(); } else { lprintf(LOG_ERR, "Invalid DellOEM command: %s", argv[current_arg]); ipmi_lcd_usage(); } - } else if( (strncmp(argv[current_arg], "help\0", 5) == 0) + } else if( (!strcmp(argv[current_arg], "help")) && (iDRAC_FLAG==0)) { ipmi_lcd_usage(); } else { @@ -1201,17 +1205,17 @@ ipmi_lcd_set_kvm(struct ipmi_intf * intf, char status) req.msg.data_len = 5; req.msg.data = data; data[0] = IPMI_DELL_LCD_STATUS_SELECTOR; - data[1] = status; /* active- incative*/ + data[1] = status; /* active- inactive */ data[2] = lcdstatus.lock_status; /* full-veiw-locked */ rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error setting LCD status"); rc= -1; } else if ((rsp->ccode == 0xc1) || (rsp->ccode == 0xcb)) { lprintf(LOG_ERR, "Error getting LCD status: " "Command not supported on this system."); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error setting LCD status: %s", val2str(rsp->ccode, completion_code_vals)); rc= -1; @@ -1223,7 +1227,7 @@ ipmi_lcd_set_kvm(struct ipmi_intf * intf, char status) * * Description: This function sets lcd access mode * Input: intf - ipmi interface - * lock - View and modify / View only / Diabled + * lock - View and modify / View only / Disabled * Output: * Return: -1 on error * 0 if successful @@ -1247,17 +1251,17 @@ ipmi_lcd_set_lock(struct ipmi_intf * intf, char lock) req.msg.data_len = 5; req.msg.data = data; data[0] = IPMI_DELL_LCD_STATUS_SELECTOR; - data[1] = lcdstatus.vKVM_status; /* active- incative */ + data[1] = lcdstatus.vKVM_status; /* active- inactive */ data[2] = lock; /* full- veiw-locked */ rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error setting LCD status"); rc = -1; } else if ((rsp->ccode == 0xc1) || (rsp->ccode == 0xcb)) { lprintf(LOG_ERR, "Error getting LCD status: " "Command not supported on this system."); rc = -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error setting LCD status: %s", val2str(rsp->ccode, completion_code_vals)); rc= -1; @@ -1332,13 +1336,12 @@ ipmi_lcd_set_single_line_text(struct ipmi_intf * intf, char * text) * Description: This function sets lcd line text * Input: intf - ipmi interface * text - lcd string - * line_number- line number * Output: * Return: -1 on error * 0 if successful */ static int -ipmi_lcd_set_text(struct ipmi_intf * intf, char * text, int line_number) +ipmi_lcd_set_text(struct ipmi_intf * intf, char * text) { int rc = 0; IPMI_DELL_LCD_CAPS lcd_caps; @@ -1367,7 +1370,6 @@ ipmi_lcd_set_text(struct ipmi_intf * intf, char * text, int line_number) * Input: intf - ipmi interface * lcdquallifier- lcd quallifier * errordisp - error number - * line_number-line number * text - lcd string * Output: * Return: -1 on error @@ -1375,12 +1377,12 @@ ipmi_lcd_set_text(struct ipmi_intf * intf, char * text, int line_number) */ static int ipmi_lcd_configure_wh(struct ipmi_intf * intf, uint32_t mode, - uint16_t lcdquallifier, uint8_t errordisp, int8_t line_number, char * text) + uint16_t lcdquallifier, uint8_t errordisp, char * text) { int rc = 0; if (IPMI_DELL_LCD_CONFIG_USER_DEFINED == mode) { /* Any error was reported earlier. */ - rc = ipmi_lcd_set_text(intf, text, line_number); + rc = ipmi_lcd_set_text(intf, text); } if (rc == 0) { rc = ipmi_lcd_set_configure_command_wh(intf, mode ,lcdquallifier,errordisp); @@ -1393,19 +1395,17 @@ ipmi_lcd_configure_wh(struct ipmi_intf * intf, uint32_t mode, * Description: This function updates the current lcd configuration * Input: intf - ipmi interface * command- lcd command - * line_number-line number * text - lcd string * Output: * Return: -1 on error * 0 if successful */ static int -ipmi_lcd_configure(struct ipmi_intf * intf, int command, - int8_t line_number, char * text) +ipmi_lcd_configure(struct ipmi_intf * intf, int command, char * text) { int rc = 0; if (IPMI_DELL_LCD_CONFIG_USER_DEFINED == command) { - rc = ipmi_lcd_set_text(intf, text, line_number); + rc = ipmi_lcd_set_text(intf, text); } if (rc == 0) { rc = ipmi_lcd_set_configure_command(intf, command); @@ -1515,18 +1515,18 @@ ipmi_delloem_mac_main(struct ipmi_intf * intf, int argc, char ** argv) int rc = 0; int currIdInt = -1; current_arg++; - if (argc > 1 && strcmp(argv[current_arg], "help") == 0) { + if (argc > 1 && !strcmp(argv[current_arg], "help")) { ipmi_mac_usage(); return 0; } ipmi_idracvalidator_command(intf); if (argc == 1) { rc = ipmi_macinfo(intf, 0xff); - } else if (strncmp(argv[current_arg], "list\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "list")) { rc = ipmi_macinfo(intf, 0xff); - } else if (strncmp(argv[current_arg], "get\0", 4) == 0) { + } else if (!strcmp(argv[current_arg], "get")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_mac_usage(); return -1; } @@ -1595,24 +1595,22 @@ ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum) req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { - return -1; - } - if (rsp->ccode > 0) { + if (!rsp || rsp->ccode) { return -1; } + if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MONOLITHIC== IMC_Type)) { - /* Get the Chasiss Assigned MAC Addresss for 12g Only */ + /* Get the Chasiss Assigned MAC Address for 12g Only */ memcpy(VirtualMacAddress, ((rsp->data) + 1), MACADDRESSLENGH); for (i = 0; i < MACADDRESSLENGH; i++) { if (VirtualMacAddress[i] != 0) { UseVirtualMacAddress = 1; } } - /* Get the Server Assigned MAC Addresss for 12g Only */ + /* Get the Server Assigned MAC Address for 12g Only */ if (!UseVirtualMacAddress) { memcpy(VirtualMacAddress, ((rsp->data) + 1 + MACADDRESSLENGH), MACADDRESSLENGH); @@ -1690,11 +1688,11 @@ ipmi_macinfo_drac_idrac_mac(struct ipmi_intf* intf,uint8_t NicNum) req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting MAC Address"); return -1; } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting MAC Address (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -1756,11 +1754,11 @@ ipmi_macinfo_10g(struct ipmi_intf* intf, uint8_t NicNum) req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting MAC Address"); return -1; } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting MAC Address (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -1830,11 +1828,11 @@ ipmi_macinfo_11g(struct ipmi_intf* intf, uint8_t NicNum) req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting MAC Address"); return -1; } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting MAC Address (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -1861,11 +1859,11 @@ ipmi_macinfo_11g(struct ipmi_intf* intf, uint8_t NicNum) req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting MAC Address"); return -1; } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting MAC Address (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -1950,7 +1948,7 @@ ipmi_mac_usage(void) * * Description: This function processes the delloem lan command * Input: intf - ipmi interface - * argc - no of arguments + * argc - no of arguments (unused, left in for calling consistency) * argv - argument string array * Output: * @@ -1958,13 +1956,13 @@ ipmi_mac_usage(void) * -1 - failure */ static int -ipmi_delloem_lan_main(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_delloem_lan_main(struct ipmi_intf * intf, int __UNUSED__(argc), char ** argv) { int rc = 0; int nic_selection = 0; char nic_set[2] = {0}; current_arg++; - if (argv[current_arg] == NULL || strcmp(argv[current_arg], "help") == 0) { + if (!argv[current_arg] || !strcmp(argv[current_arg], "help")) { ipmi_lan_usage(); return 0; } @@ -1972,9 +1970,9 @@ ipmi_delloem_lan_main(struct ipmi_intf * intf, int argc, char ** argv) if (!IsLANSupported()) { lprintf(LOG_ERR, "lan is not supported on this system."); return -1; - } else if (strncmp(argv[current_arg], "set\0", 4) == 0) { + } else if (!strcmp(argv[current_arg], "set")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_lan_usage(); return -1; } @@ -2008,12 +2006,12 @@ ipmi_delloem_lan_main(struct ipmi_intf * intf, int argc, char ** argv) rc = ipmi_lan_set_nic_selection(intf,nic_selection); } return 0; - } else if (strncmp(argv[current_arg], "get\0", 4) == 0) { + } else if (!strcmp(argv[current_arg], "get")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { rc = ipmi_lan_get_nic_selection(intf); return rc; - } else if (strncmp(argv[current_arg], "active\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "active")) { rc = ipmi_lan_get_active_nic(intf); return rc; } else { @@ -2053,47 +2051,47 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting nic selection"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting nic selection (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; } nic_set[0] = rsp->data[0]; nic_set[1] = rsp->data[1]; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "dedicated\0", 10) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "dedicated")) { nic_set[0] = 1; nic_set[1] = 0; return 0; } - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "shared\0", 7) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "shared")) { /* placeholder */ } else { return INVALID; } current_arg++; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "with\0", 5) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "with")) { /* placeholder */ } else { return INVALID; } current_arg++; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "failover\0", 9) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "failover")) { failover = 1; } if (failover) { current_arg++; } - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "lom1\0", 5) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "lom1")) { if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } @@ -2111,8 +2109,8 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, } } return 0; - } else if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "lom2\0", 5) == 0) { + } else if (argv[current_arg] + && !strcmp(argv[current_arg], "lom2")) { if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } @@ -2130,8 +2128,8 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, } } return 0; - } else if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "lom3\0", 5) == 0) { + } else if (argv[current_arg] + && !strcmp(argv[current_arg], "lom3")) { if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } @@ -2149,8 +2147,8 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, } } return 0; - } else if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "lom4\0", 5) == 0) { + } else if (argv[current_arg] + && !strcmp(argv[current_arg], "lom4")) { if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } @@ -2168,8 +2166,8 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, } } return 0; - } else if (failover && argv[current_arg] != NULL - && strncmp(argv[current_arg], "none\0", 5) == 0) { + } else if (failover && argv[current_arg] + && !strcmp(argv[current_arg], "none")) { if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type) ) { return INVAILD_SHARED_MODE; } @@ -2180,16 +2178,16 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, nic_set[1] = 0; } return 0; - } else if (failover && argv[current_arg] != NULL - && strncmp(argv[current_arg], "all\0", 4) == 0) { + } else if (failover && argv[current_arg] + && !strcmp(argv[current_arg], "all")) { /* placeholder */ } else { return INVALID; } current_arg++; - if (failover && argv[current_arg] != NULL - && strncmp(argv[current_arg], "loms\0", 5) == 0) { + if (failover && argv[current_arg] + && !strcmp(argv[current_arg], "loms")) { if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_13G_MODULAR == IMC_Type)) { return INVAILD_SHARED_MODE; } @@ -2205,47 +2203,47 @@ get_nic_selection_mode_12g(struct ipmi_intf* intf,int current_arg, static int get_nic_selection_mode(int current_arg, char ** argv) { - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "dedicated\0", 10) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "dedicated")) { return DEDICATED; } - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "shared\0", 7) == 0) { - if (argv[current_arg+1] == NULL) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "shared")) { + if (!argv[current_arg+1]) { return SHARED; } } current_arg++; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "with\0", 5) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "with")) { /* place holder */ } else { return INVALID; } current_arg++; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "failover\0", 9) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "failover")) { /* place holder */ } else { return INVALID; } current_arg++; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "lom2\0", 5) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "lom2")) { return SHARED_WITH_FAILOVER_LOM2; - } else if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "all\0", 4) == 0) { + } else if (argv[current_arg] + && !strcmp(argv[current_arg], "all")) { /* place holder */ } else { return INVALID; } current_arg++; - if (argv[current_arg] != NULL - && strncmp(argv[current_arg], "loms\0", 5) == 0) { + if (argv[current_arg] + && !strcmp(argv[current_arg], "loms")) { return SHARED_WITH_FAILOVER_ALL_LOMS; } return INVALID; @@ -2268,7 +2266,7 @@ ipmi_lan_set_nic_selection_12g(struct ipmi_intf * intf, uint8_t * nic_selection) req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in setting nic selection"); return -1; } else if( (nic_selection[0] == 1) @@ -2278,7 +2276,7 @@ ipmi_lan_set_nic_selection_12g(struct ipmi_intf * intf, uint8_t * nic_selection) lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in setting nic selection (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2303,10 +2301,10 @@ ipmi_lan_set_nic_selection(struct ipmi_intf * intf, uint8_t nic_selection) req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in setting nic selection"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in setting nic selection (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2336,10 +2334,10 @@ ipmi_lan_get_nic_selection(struct ipmi_intf * intf) req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting nic selection"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting nic selection (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2392,10 +2390,10 @@ ipmi_lan_get_active_nic(struct ipmi_intf * intf) req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting Active LOM Status"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting Active LOM Status (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2411,10 +2409,10 @@ ipmi_lan_get_active_nic(struct ipmi_intf * intf) req.msg.data = msg_data; req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting Active LOM Status"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting Active LOM Status (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2505,68 +2503,68 @@ ipmi_delloem_powermonitor_main(struct ipmi_intf * intf, int argc, char ** argv) { int rc = 0; current_arg++; - if (argc > 1 && strcmp(argv[current_arg], "help") == 0) { + if (argc > 1 && !strcmp(argv[current_arg], "help")) { ipmi_powermonitor_usage(); return 0; } ipmi_idracvalidator_command(intf); if (argc == 1) { rc = ipmi_powermgmt(intf); - } else if (strncmp(argv[current_arg], "status\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "status")) { rc = ipmi_powermgmt(intf); - } else if (strncmp(argv[current_arg], "clear\0", 6) == 0) { + } else if (!strcmp(argv[current_arg], "clear")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_powermonitor_usage(); return -1; - } else if (strncmp(argv[current_arg], "peakpower\0", 10) == 0) { + } else if (!strcmp(argv[current_arg], "peakpower")) { rc = ipmi_powermgmt_clear(intf, 1); - } else if (strncmp(argv[current_arg], "cumulativepower\0", 16) == 0) { + } else if (!strcmp(argv[current_arg], "cumulativepower")) { rc = ipmi_powermgmt_clear(intf, 0); } else { ipmi_powermonitor_usage(); return -1; } - } else if (strncmp(argv[current_arg], "powerconsumption\0", 17) == 0) { + } else if (!strcmp(argv[current_arg], "powerconsumption")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { rc = ipmi_print_get_power_consmpt_data(intf,watt); - } else if (strncmp(argv[current_arg], "watt\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "watt")) { rc = ipmi_print_get_power_consmpt_data(intf, watt); - } else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "btuphr")) { rc = ipmi_print_get_power_consmpt_data(intf, btuphr); } else { ipmi_powermonitor_usage(); return -1; } - } else if (strncmp(argv[current_arg], "powerconsumptionhistory\0", 23) == 0) { + } else if (!strcmp(argv[current_arg], "powerconsumptionhistory")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { rc = ipmi_print_power_consmpt_history(intf,watt); - } else if (strncmp(argv[current_arg], "watt\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "watt")) { rc = ipmi_print_power_consmpt_history(intf, watt); - } else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "btuphr")) { rc = ipmi_print_power_consmpt_history(intf, btuphr); } else { ipmi_powermonitor_usage(); return -1; } - } else if (strncmp(argv[current_arg], "getpowerbudget\0", 15) == 0) { + } else if (!strcmp(argv[current_arg], "getpowerbudget")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { rc=ipmi_print_power_cap(intf,watt); - } else if (strncmp(argv[current_arg], "watt\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "watt")) { rc = ipmi_print_power_cap(intf, watt); - } else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "btuphr")) { rc = ipmi_print_power_cap(intf, btuphr); } else { ipmi_powermonitor_usage(); return -1; } - } else if (strncmp(argv[current_arg], "setpowerbudget\0", 15) == 0) { + } else if (!strcmp(argv[current_arg], "setpowerbudget")) { int val; current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_powermonitor_usage(); return -1; } @@ -2581,21 +2579,21 @@ ipmi_delloem_powermonitor_main(struct ipmi_intf * intf, int argc, char ** argv) return (-1); } current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_powermonitor_usage(); - } else if (strncmp(argv[current_arg], "watt\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "watt")) { rc = ipmi_set_power_cap(intf,watt,val); - } else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0) { + } else if (!strcmp(argv[current_arg], "btuphr")) { rc = ipmi_set_power_cap(intf, btuphr,val); - } else if (strncmp(argv[current_arg], "percent\0", 8) == 0) { + } else if (!strcmp(argv[current_arg], "percent")) { rc = ipmi_set_power_cap(intf,percent,val); } else { ipmi_powermonitor_usage(); return -1; } - } else if (strncmp(argv[current_arg], "enablepowercap\0", 15) == 0) { + } else if (!strcmp(argv[current_arg], "enablepowercap")) { ipmi_set_power_capstatus_command(intf,1); - } else if (strncmp(argv[current_arg], "disablepowercap\0", 16) == 0) { + } else if (!strcmp(argv[current_arg], "disablepowercap")) { ipmi_set_power_capstatus_command(intf,0); } else { ipmi_powermonitor_usage(); @@ -2603,24 +2601,7 @@ ipmi_delloem_powermonitor_main(struct ipmi_intf * intf, int argc, char ** argv) } return rc; } -/* - * Function Name: ipmi_time_to_str - * - * Description: This function converts ipmi time format into gmtime format - * Input: rawTime - ipmi time format - * Output: strTime - gmtime format - * - * Return: - */ -static void -ipmi_time_to_str(time_t rawTime, char * strTime) -{ - struct tm *tm; - char *temp; - tm = gmtime(&rawTime); - temp = asctime(tm); - strcpy(strTime,temp); -} + /* * Function Name: ipmi_get_sensor_reading * @@ -2645,19 +2626,19 @@ ipmi_get_sensor_reading(struct ipmi_intf *intf, unsigned char sensorNumber, req.msg.cmd = GET_SENSOR_READING; req.msg.data = &sensorNumber; req.msg.data_len = 1; - if (pSensorReadingData == NULL) { + if (!pSensorReadingData) { return -1; } memset(pSensorReadingData, 0, sizeof(SensorReadingType)); rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { return 1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { return 1; } memcpy(pSensorReadingData, rsp->data, sizeof(SensorReadingType)); /* if there is an error transmitting ipmi command, return error */ - if (rsp->ccode != 0) { + if (rsp->ccode) { rc = 1; } /* if sensor messages are disabled, return error*/ @@ -2690,14 +2671,14 @@ ipmi_get_power_capstatus_command(struct ipmi_intf * intf) data[0] = 01; data[1] = 0xFF; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error getting powercap status"); return -1; } else if (( iDRAC_FLAG_12_13 ) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; /* Return Error as unlicensed */ - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error getting powercap statusr: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2741,14 +2722,14 @@ ipmi_set_power_capstatus_command(struct ipmi_intf * intf, uint8_t val) data[0] = 00; data[1] = val; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error setting powercap status"); return -1; } else if ((iDRAC_FLAG_12_13) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) { lprintf(LOG_ERR, "FM001 : A required license is missing or expired"); return -1; /* return unlicensed Error code */ - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error setting powercap statusr: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -2770,24 +2751,15 @@ ipmi_powermgmt(struct ipmi_intf * intf) struct ipmi_rs * rsp; struct ipmi_rq req; uint8_t msg_data[2]; - uint32_t cumStartTimeConv; - uint32_t cumReadingConv; - uint32_t maxPeakStartTimeConv; - uint32_t ampPeakTimeConv; - uint16_t ampReadingConv; - uint32_t wattPeakTimeConv; - uint32_t wattReadingConv; - uint32_t bmctimeconv; - uint32_t * bmctimeconvval; + uint32_t cumStartTime; + uint32_t cumReading; + uint32_t maxPeakStartTime; + uint32_t ampPeakTime; + uint32_t wattPeakTime; + uint32_t bmctime; IPMI_POWER_MONITOR * pwrMonitorInfo; - char cumStartTime[26]; - char maxPeakStartTime[26]; - char ampPeakTime[26]; - char wattPeakTime[26]; - char bmctime[26]; - int ampReading; int ampReadingRemainder; int remainder; @@ -2799,22 +2771,17 @@ ipmi_powermgmt(struct ipmi_intf * intf) req.msg.cmd = IPMI_CMD_GET_SEL_TIME; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error getting BMC time info."); return -1; } - if (rsp->ccode != 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Error getting power management information, return code %x", rsp->ccode); return -1; } - bmctimeconvval=(uint32_t*)rsp->data; -# if WORDS_BIGENDIAN - bmctimeconv=BSWAP_32(*bmctimeconvval); -# else - bmctimeconv=*bmctimeconvval; -# endif + bmctime = ipmi32toh(rsp->data); /* get powermanagement info*/ req.msg.netfn = DELL_OEM_NETFN; @@ -2828,7 +2795,7 @@ ipmi_powermgmt(struct ipmi_intf * intf) msg_data[1] = 0x01; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error getting power management information."); return -1; } @@ -2841,7 +2808,7 @@ ipmi_powermgmt(struct ipmi_intf * intf) lprintf(LOG_ERR, "Error getting power management information: " "Command not supported on this system."); return -1; - }else if (rsp->ccode != 0) { + }else if (rsp->ccode) { lprintf(LOG_ERR, "Error getting power management information, return code %x", rsp->ccode); @@ -2849,54 +2816,35 @@ ipmi_powermgmt(struct ipmi_intf * intf) } pwrMonitorInfo = (IPMI_POWER_MONITOR*)rsp->data; -# if WORDS_BIGENDIAN - cumStartTimeConv = BSWAP_32(pwrMonitorInfo->cumStartTime); - cumReadingConv = BSWAP_32(pwrMonitorInfo->cumReading); - maxPeakStartTimeConv = BSWAP_32(pwrMonitorInfo->maxPeakStartTime); - ampPeakTimeConv = BSWAP_32(pwrMonitorInfo->ampPeakTime); - ampReadingConv = BSWAP_16(pwrMonitorInfo->ampReading); - wattPeakTimeConv = BSWAP_32(pwrMonitorInfo->wattPeakTime); - wattReadingConv = BSWAP_16(pwrMonitorInfo->wattReading); -# else - cumStartTimeConv = pwrMonitorInfo->cumStartTime; - cumReadingConv = pwrMonitorInfo->cumReading; - maxPeakStartTimeConv = pwrMonitorInfo->maxPeakStartTime; - ampPeakTimeConv = pwrMonitorInfo->ampPeakTime; - ampReadingConv = pwrMonitorInfo->ampReading; - wattPeakTimeConv = pwrMonitorInfo->wattPeakTime; - wattReadingConv = pwrMonitorInfo->wattReading; -# endif - - ipmi_time_to_str(cumStartTimeConv, cumStartTime); - ipmi_time_to_str(maxPeakStartTimeConv, maxPeakStartTime); - ipmi_time_to_str(ampPeakTimeConv, ampPeakTime); - ipmi_time_to_str(wattPeakTimeConv, wattPeakTime); - ipmi_time_to_str(bmctimeconv, bmctime); + cumStartTime = ipmi32toh(&pwrMonitorInfo->cumStartTime); + cumReading = ipmi32toh(&pwrMonitorInfo->cumReading); + maxPeakStartTime = ipmi32toh(&pwrMonitorInfo->maxPeakStartTime); + ampPeakTime = ipmi32toh(&pwrMonitorInfo->ampPeakTime); + ampReading = ipmi16toh(&pwrMonitorInfo->ampReading); + wattPeakTime = ipmi32toh(&pwrMonitorInfo->wattPeakTime); + wattReading = ipmi16toh(&pwrMonitorInfo->wattReading); - remainder = (cumReadingConv % 1000); - cumReadingConv = cumReadingConv / 1000; + remainder = (cumReading % 1000); + cumReading = cumReading / 1000; remainder = (remainder + 50) / 100; - ampReading = ampReadingConv; - ampReadingRemainder = ampReading%10; - ampReading = ampReading/10; - - wattReading = wattReadingConv; + ampReadingRemainder = ampReading % 10; + ampReading = ampReading / 10; printf("Power Tracking Statistics\n"); printf("Statistic : Cumulative Energy Consumption\n"); - printf("Start Time : %s", cumStartTime); - printf("Finish Time : %s", bmctime); - printf("Reading : %d.%d kWh\n\n", cumReadingConv, remainder); + printf("Start Time : %s", ipmi_timestamp_numeric(cumStartTime)); + printf("Finish Time : %s", ipmi_timestamp_numeric(bmctime)); + printf("Reading : %d.%d kWh\n\n", cumReading, remainder); printf("Statistic : System Peak Power\n"); - printf("Start Time : %s", maxPeakStartTime); - printf("Peak Time : %s", wattPeakTime); + printf("Start Time : %s", ipmi_timestamp_numeric(maxPeakStartTime)); + printf("Peak Time : %s", ipmi_timestamp_numeric(wattPeakTime)); printf("Peak Reading : %d W\n\n", wattReading); printf("Statistic : System Peak Amperage\n"); - printf("Start Time : %s", maxPeakStartTime); - printf("Peak Time : %s", ampPeakTime); + printf("Start Time : %s", ipmi_timestamp_numeric(maxPeakStartTime)); + printf("Peak Time : %s", ipmi_timestamp_numeric(ampPeakTime)); printf("Peak Reading : %d.%d A\n", ampReading, ampReadingRemainder); return 0; } @@ -2932,7 +2880,7 @@ ipmi_powermgmt_clear(struct ipmi_intf * intf, uint8_t clearValue) msg_data[2] = clearType; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error clearing power values."); return -1; } else if ((iDRAC_FLAG_12_13) @@ -2944,7 +2892,7 @@ ipmi_powermgmt_clear(struct ipmi_intf * intf, uint8_t clearValue) lprintf(LOG_ERR, "Error clearing power values, command not supported on this system."); return -1; - } else if (rsp->ccode != 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error clearing power values: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -3010,7 +2958,7 @@ ipmi_get_power_headroom_command(struct ipmi_intf * intf,uint8_t unit) req.msg.data_len = 0; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error getting power headroom status"); return -1; } else if ((iDRAC_FLAG_12_13) @@ -3022,7 +2970,7 @@ ipmi_get_power_headroom_command(struct ipmi_intf * intf,uint8_t unit) lprintf(LOG_ERR, "Error getting power headroom status: " "Command not supported on this system "); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error getting power headroom status: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -3077,7 +3025,7 @@ ipmi_get_power_consumption_data(struct ipmi_intf * intf,uint8_t unit) int status = 0; int sensor_number = 0; sdr = ipmi_sdr_find_sdr_byid(intf, "System Level"); - if (sdr == NULL) { + if (!sdr) { lprintf(LOG_ERR, "Error : Can not access the System Level sensor data"); return -1; @@ -3089,7 +3037,7 @@ ipmi_get_power_consumption_data(struct ipmi_intf * intf,uint8_t unit) sdr->record.common->keys.owner_id, sdr->record.common->keys.lun, sdr->record.common->keys.channel); - if (rsp == NULL || rsp->ccode != 0) { + if (!rsp || rsp->ccode) { lprintf(LOG_ERR, "Error : Can not access the System Level sensor data"); return -1; @@ -3144,7 +3092,7 @@ ipmi_get_instan_power_consmpt_data(struct ipmi_intf * intf, msg_data[1] = 0x00; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error getting instantaneous power consumption data ."); return -1; } else if ((iDRAC_FLAG_12_13) @@ -3156,7 +3104,7 @@ ipmi_get_instan_power_consmpt_data(struct ipmi_intf * intf, lprintf(LOG_ERR, "Error getting instantaneous power consumption data: " "Command not supported on this system."); return -1; - } else if (rsp->ccode != 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error getting instantaneous power consumption data: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -3396,12 +3344,7 @@ ipmi_get_minpower_consmpt_history(struct ipmi_intf * intf, static int ipmi_print_power_consmpt_history(struct ipmi_intf * intf, int unit) { - char timestr[30]; - uint32_t lastminutepeakpower; - uint32_t lasthourpeakpower; - uint32_t lastdaypeakpower; - uint32_t lastweekpeakpower; - uint64_t tempbtuphrconv; + uint64_t tmp; int rc = 0; IPMI_AVGPOWER_CONSUMP_HISTORY avgpower; @@ -3426,101 +3369,91 @@ ipmi_print_power_consmpt_history(struct ipmi_intf * intf, int unit) return rc; } printf("Power Consumption History\n\n"); - /* The fields are alligned manually changing the spaces will alter + /* The fields are aligned manually changing the spaces will alter * the alignment*/ printf("Statistic Last Minute Last Hour " "Last Day Last Week\n\n"); if (unit == btuphr) { printf("Average Power Consumption "); - tempbtuphrconv = watt_to_btuphr_conversion(avgpower.lastminutepower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(avgpower.lasthourpower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(avgpower.lastdaypower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(avgpower.lastweakpower); - printf("%4" PRId64 " BTU/hr\n", tempbtuphrconv); + tmp = watt_to_btuphr_conversion(avgpower.lastminutepower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(avgpower.lasthourpower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(avgpower.lastdaypower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(avgpower.lastweakpower); + printf("%4" PRId64 " BTU/hr\n", tmp); printf("Max Power Consumption "); - tempbtuphrconv = watt_to_btuphr_conversion(stPeakpower.lastminutepower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(stPeakpower.lasthourpower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(stPeakpower.lastdaypower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(stPeakpower.lastweakpower); - printf("%4" PRId64 " BTU/hr\n", tempbtuphrconv); + tmp = watt_to_btuphr_conversion(stPeakpower.lastminutepower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(stPeakpower.lasthourpower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(stPeakpower.lastdaypower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(stPeakpower.lastweakpower); + printf("%4" PRId64 " BTU/hr\n", tmp); printf("Min Power Consumption "); - tempbtuphrconv = watt_to_btuphr_conversion(stMinpower.lastminutepower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(stMinpower.lasthourpower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(stMinpower.lastdaypower); - printf("%4" PRId64 " BTU/hr ", tempbtuphrconv); - tempbtuphrconv = watt_to_btuphr_conversion(stMinpower.lastweakpower); - printf("%4" PRId64 " BTU/hr\n\n", tempbtuphrconv); + tmp = watt_to_btuphr_conversion(stMinpower.lastminutepower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(stMinpower.lasthourpower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(stMinpower.lastdaypower); + printf("%4" PRId64 " BTU/hr ", tmp); + tmp = watt_to_btuphr_conversion(stMinpower.lastweakpower); + printf("%4" PRId64 " BTU/hr\n\n", tmp); } else { printf("Average Power Consumption "); - tempbtuphrconv = (avgpower.lastminutepower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (avgpower.lasthourpower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (avgpower.lastdaypower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv=(avgpower.lastweakpower); - printf("%4" PRId64 " W \n", tempbtuphrconv); + tmp = avgpower.lastminutepower; + printf("%4" PRId64 " W ", tmp); + tmp = avgpower.lasthourpower; + printf("%4" PRId64 " W ", tmp); + tmp = avgpower.lastdaypower; + printf("%4" PRId64 " W ", tmp); + tmp = avgpower.lastweakpower; + printf("%4" PRId64 " W \n", tmp); printf("Max Power Consumption "); - tempbtuphrconv = (stPeakpower.lastminutepower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (stPeakpower.lasthourpower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (stPeakpower.lastdaypower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (stPeakpower.lastweakpower); - printf("%4" PRId64 " W \n", tempbtuphrconv); + tmp = stPeakpower.lastminutepower; + printf("%4" PRId64 " W ", tmp); + tmp = stPeakpower.lasthourpower; + printf("%4" PRId64 " W ", tmp); + tmp = stPeakpower.lastdaypower; + printf("%4" PRId64 " W ", tmp); + tmp = stPeakpower.lastweakpower; + printf("%4" PRId64 " W \n", tmp); printf("Min Power Consumption "); - tempbtuphrconv = (stMinpower.lastminutepower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (stMinpower.lasthourpower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (stMinpower.lastdaypower); - printf("%4" PRId64 " W ", tempbtuphrconv); - tempbtuphrconv = (stMinpower.lastweakpower); - printf("%4" PRId64 " W \n\n", tempbtuphrconv); + tmp = stMinpower.lastminutepower; + printf("%4" PRId64 " W ", tmp); + tmp = stMinpower.lasthourpower; + printf("%4" PRId64 " W ", tmp); + tmp = stMinpower.lastdaypower; + printf("%4" PRId64 " W ", tmp); + tmp = stMinpower.lastweakpower; + printf("%4" PRId64 " W \n\n", tmp); } - lastminutepeakpower = stPeakpower.lastminutepowertime; - lasthourpeakpower = stPeakpower.lasthourpowertime; - lastdaypeakpower = stPeakpower.lastdaypowertime; - lastweekpeakpower = stPeakpower.lastweekpowertime; - printf("Max Power Time\n"); - ipmi_time_to_str(lastminutepeakpower, timestr); - printf("Last Minute : %s",timestr); - ipmi_time_to_str(lasthourpeakpower, timestr); - printf("Last Hour : %s",timestr); - ipmi_time_to_str(lastdaypeakpower, timestr); - printf("Last Day : %s",timestr); - ipmi_time_to_str(lastweekpeakpower, timestr); - printf("Last Week : %s",timestr); - - lastminutepeakpower=stMinpower.lastminutepowertime; - lasthourpeakpower=stMinpower.lasthourpowertime; - lastdaypeakpower=stMinpower.lastdaypowertime; - lastweekpeakpower=stMinpower.lastweekpowertime; + printf("Last Minute : %s", + ipmi_timestamp_numeric(stPeakpower.lastminutepowertime)); + printf("Last Hour : %s", + ipmi_timestamp_numeric(stPeakpower.lasthourpowertime)); + printf("Last Day : %s", + ipmi_timestamp_numeric(stPeakpower.lastdaypowertime)); + printf("Last Week : %s", + ipmi_timestamp_numeric(stPeakpower.lastweekpowertime)); printf("Min Power Time\n"); - ipmi_time_to_str(lastminutepeakpower, timestr); - printf("Last Minute : %s", timestr); - ipmi_time_to_str(lasthourpeakpower, timestr); - printf("Last Hour : %s", timestr); - ipmi_time_to_str(lastdaypeakpower, timestr); - printf("Last Day : %s", timestr); - ipmi_time_to_str(lastweekpeakpower, timestr); - printf("Last Week : %s", timestr); + printf("Last Minute : %s", + ipmi_timestamp_numeric(stMinpower.lastminutepowertime)); + printf("Last Hour : %s", + ipmi_timestamp_numeric(stMinpower.lasthourpowertime)); + printf("Last Day : %s", + ipmi_timestamp_numeric(stMinpower.lastdaypowertime)); + printf("Last Week : %s", + ipmi_timestamp_numeric(stMinpower.lastweekpowertime)); return rc; } /* @@ -3688,7 +3621,7 @@ ipmi_set_power_cap(struct ipmi_intf * intf, int unit, int val) val = btuphr_to_watt_conversion(val); } else if (unit == percent) { if ((val < 0) || (val > 100)) { - lprintf(LOG_ERR, "Cap value is out of boundary conditon it " + lprintf(LOG_ERR, "Cap value is out of boundary condition it " "should be between 0 - 100"); return -1; } @@ -3703,7 +3636,7 @@ ipmi_set_power_cap(struct ipmi_intf * intf, int unit, int val) if (((val < ipmipowercap.MinimumPowerConsmp) || (val > ipmipowercap.MaximumPowerConsmp)) && (unit == watt)) { lprintf(LOG_ERR, - "Cap value is out of boundary conditon it should be between %d - %d", + "Cap value is out of boundary condition it should be between %d - %d", ipmipowercap.MinimumPowerConsmp, ipmipowercap.MaximumPowerConsmp); return -1; } else if (((val < ipmipowercap.MinimumPowerConsmp) @@ -3711,7 +3644,7 @@ ipmi_set_power_cap(struct ipmi_intf * intf, int unit, int val) minpowerbtuphr = watt_to_btuphr_conversion(ipmipowercap.MinimumPowerConsmp); maxpowerbtuphr = watt_to_btuphr_conversion(ipmipowercap.MaximumPowerConsmp); lprintf(LOG_ERR, - "Cap value is out of boundary conditon it should be between %d", + "Cap value is out of boundary condition it should be between %d", minpowerbtuphr); lprintf(LOG_ERR, " -%d", maxpowerbtuphr); return -1; @@ -3808,7 +3741,7 @@ ipmi_powermonitor_usage(void) * * Description: This function processes the delloem vFlash command * Input: intf - ipmi interface - * argc - no of arguments + * argc - no of arguments (unused) * argv - argument string array * Output: * @@ -3816,7 +3749,7 @@ ipmi_powermonitor_usage(void) * -1 - failure */ static int -ipmi_delloem_vFlash_main(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_delloem_vFlash_main(struct ipmi_intf * intf, int __UNUSED__(argc), char ** argv) { int rc = 0; current_arg++; @@ -3837,7 +3770,7 @@ get_vFlash_compcode_str(uint8_t vflashcompcode, const struct vFlashstr *vs) { static char un_str[32]; int i; - for (i = 0; vs[i].str != NULL; i++) { + for (i = 0; vs[i].str; i++) { if (vs[i].val == vflashcompcode) return vs[i].str; } @@ -3871,10 +3804,10 @@ ipmi_get_sd_card_info(struct ipmi_intf * intf) { req.msg.data_len = input_length; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error in getting SD Card Extended Information"); return -1; - } else if (rsp->ccode > 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error in getting SD Card Extended Information (%s)", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -3935,26 +3868,26 @@ static int ipmi_delloem_vFlash_process(struct ipmi_intf * intf, int current_arg, char ** argv) { int rc; - if (strncmp(intf->name,"wmi\0",4) && strncmp(intf->name, "open\0",5)) { + if (strcmp(intf->name,"wmi") && strcmp(intf->name, "open")) { lprintf(LOG_ERR, "vFlash support is enabled only for wmi and open interface."); lprintf(LOG_ERR, "Its not enabled for lan and lanplus interface."); return -1; } - if (argv[current_arg] == NULL || strcmp(argv[current_arg], "help") == 0) { + if (!argv[current_arg] || !strcmp(argv[current_arg], "help")) { ipmi_vFlash_usage(); return 0; } ipmi_idracvalidator_command(intf); - if (!strncmp(argv[current_arg], "info\0", 5)) { + if (!strcmp(argv[current_arg], "info")) { current_arg++; - if (argv[current_arg] == NULL) { + if (!argv[current_arg]) { ipmi_vFlash_usage(); return -1; - } else if (strncmp(argv[current_arg], "Card\0", 5) == 0) { + } else if (!strcmp(argv[current_arg], "Card")) { current_arg++; - if (argv[current_arg] != NULL) { + if (argv[current_arg]) { ipmi_vFlash_usage(); return -1; } @@ -4052,7 +3985,7 @@ CheckSetLEDSupport(struct ipmi_intf * intf) data[9] = 0x00; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL || rsp->ccode != 0) { + if (!rsp || rsp->ccode) { return; } SetLEDSupported = 1; @@ -4094,10 +4027,10 @@ ipmi_getdrivemap(struct ipmi_intf * intf, int b, int d, int f, int *bay, data[7] = (d << 3) + f; /* devfn */ rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error issuing getdrivemap command."); return -1; - } else if (rsp->ccode != 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error issuing getdrivemap command: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -4149,10 +4082,10 @@ ipmi_setled_state(struct ipmi_intf * intf, int bayId, int slotId, int state) data[11] = state >> 8; /* state MSB; */ rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Error issuing setled command."); return -1; - } else if (rsp->ccode != 0) { + } else if (rsp->ccode) { lprintf(LOG_ERR, "Error issuing setled command: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -4217,7 +4150,7 @@ ipmi_delloem_setled_main(struct ipmi_intf * intf, int argc, char ** argv) return -1; } /* ipmitool delloem setled info*/ - if (argc == 1 || strcmp(argv[current_arg], "help") == 0) { + if (argc == 1 || !strcmp(argv[current_arg], "help")) { ipmi_setled_usage(); return 0; } |