diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-05-08 22:59:02 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-05-08 22:59:02 +0200 |
commit | 342ebce798fe98ede64939a49bbc3770d8214649 (patch) | |
tree | b55927f05ec0d294ababcb2b4519b7e1a628d5f8 /lib/ipmi_sel.c | |
parent | 97d6a2e491c6ed08473beb2c4bac47c5cbc1201a (diff) |
Imported Upstream version 1.8.17upstream/1.8.17
Diffstat (limited to 'lib/ipmi_sel.c')
-rw-r--r-- | lib/ipmi_sel.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c index 5df66a7..b6629a2 100644 --- a/lib/ipmi_sel.c +++ b/lib/ipmi_sel.c @@ -29,8 +29,10 @@ * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ +#define _BSD_SOURCE #include <string.h> +#include <strings.h> #include <math.h> #define __USE_XOPEN /* glibc2 needs this for strptime */ #include <time.h> @@ -43,6 +45,7 @@ #include <ipmitool/ipmi_mc.h> #include <ipmitool/ipmi_intf.h> #include <ipmitool/ipmi_sel.h> +#include <ipmitool/ipmi_sel_supermicro.h> #include <ipmitool/ipmi_sdr.h> #include <ipmitool/ipmi_fru.h> #include <ipmitool/ipmi_sensor.h> @@ -419,7 +422,12 @@ ipmi_sel_add_entries_fromfile(struct ipmi_intf * intf, const char * filename) memset(&sel_event, 0, sizeof(struct sel_event_record)); sel_event.record_id = 0x0000; sel_event.record_type = 0x02; - sel_event.sel_type.standard_type.gen_id = 0x00; + /* + * IPMI spec §32.1 generator ID + * Bit 0 = 1 "Software defined" + * Bit 1-7: SWID (IPMI spec §5.5), using 2 = "System management software" + */ + sel_event.sel_type.standard_type.gen_id = 0x41; sel_event.sel_type.standard_type.evm_rev = rqdata[0]; sel_event.sel_type.standard_type.sensor_type = rqdata[1]; sel_event.sel_type.standard_type.sensor_num = rqdata[2]; @@ -1461,11 +1469,14 @@ ipmi_sel_get_info(struct ipmi_intf * intf) if (rsp == NULL) { lprintf(LOG_ERR, "Get SEL Info command failed"); return -1; - } - if (rsp->ccode > 0) { + } else if (rsp->ccode > 0) { lprintf(LOG_ERR, "Get SEL Info command failed: %s", val2str(rsp->ccode, completion_code_vals)); return -1; + } else if (rsp->data_len != 14) { + lprintf(LOG_ERR, "Get SEL Info command failed: " + "Invalid data length %d", rsp->data_len); + return (-1); } if (verbose > 2) printbuf(rsp->data, rsp->data_len, "sel_info"); @@ -2731,24 +2742,26 @@ ipmi_sel_set_time(struct ipmi_intf * intf, const char * time_string) { //modify UTC time to local time expressed in number of seconds from 1/1/70 0:0:0 1970 GMT struct tm * tm_tmp = {0}; - int gt_year,gt_yday,gt_hour,lt_year,lt_yday,lt_hour; + int gt_year,gt_yday,gt_hour,gt_min,lt_year,lt_yday,lt_hour,lt_min; int delta_hour; tm_tmp=gmtime(&t); gt_year=tm_tmp->tm_year; gt_yday=tm_tmp->tm_yday; gt_hour=tm_tmp->tm_hour; + gt_min=tm_tmp->tm_min; memset(&*tm_tmp, 0, sizeof(struct tm)); tm_tmp=localtime(&t); lt_year=tm_tmp->tm_year; lt_yday=tm_tmp->tm_yday; lt_hour=tm_tmp->tm_hour; + lt_min=tm_tmp->tm_min; delta_hour=lt_hour - gt_hour; if ( (lt_year > gt_year) || ((lt_year == gt_year) && (lt_yday > gt_yday)) ) delta_hour += 24; if ( (lt_year < gt_year) || ((lt_year == gt_year) && (lt_yday < gt_yday)) ) delta_hour -= 24; - t += (delta_hour * 60 * 60); + t += (delta_hour * 60 * 60) + (lt_min - gt_min) * 60; } timei = (uint32_t)t; |