mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
add ipmi_event file for event generation
This commit is contained in:
parent
3b58655b89
commit
2ab696dc17
@ -39,5 +39,5 @@ ipmitooldir = $(includedir)/ipmitool
|
|||||||
noinst_HEADERS = bswap.h helper.h ipmi.h ipmi_intf.h \
|
noinst_HEADERS = bswap.h helper.h ipmi.h ipmi_intf.h \
|
||||||
ipmi_chassis.h ipmi_entity.h ipmi_fru.h ipmi_lanp.h \
|
ipmi_chassis.h ipmi_entity.h ipmi_fru.h ipmi_lanp.h \
|
||||||
ipmi_sdr.h ipmi_sel.h ipmi_sol.h ipmi_bmc.h \
|
ipmi_sdr.h ipmi_sel.h ipmi_sol.h ipmi_bmc.h \
|
||||||
ipmi_channel.h ipmi_sensor.h
|
ipmi_channel.h ipmi_sensor.h ipmi_event.h
|
||||||
|
|
||||||
|
47
ipmitool/include/ipmitool/ipmi_event.h
Normal file
47
ipmitool/include/ipmitool/ipmi_event.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IPMI_EVENT_H
|
||||||
|
#define IPMI_EVENT_H
|
||||||
|
|
||||||
|
#if HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
#include <ipmitool/ipmi.h>
|
||||||
|
|
||||||
|
int ipmi_event_main(struct ipmi_intf *, int, char **);
|
||||||
|
|
||||||
|
#endif /*IPMI_EVENT_H*/
|
@ -38,7 +38,7 @@ MAINTAINERCLEANFILES = Makefile.in
|
|||||||
noinst_LTLIBRARIES = libipmitool.la
|
noinst_LTLIBRARIES = libipmitool.la
|
||||||
libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_lanp.c \
|
libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_lanp.c \
|
||||||
ipmi_fru.c ipmi_chassis.c ipmi_bmc.c dimm_spd.c ipmi_sensor.c \
|
ipmi_fru.c ipmi_chassis.c ipmi_bmc.c dimm_spd.c ipmi_sensor.c \
|
||||||
ipmi_channel.c
|
ipmi_channel.c ipmi_event.c
|
||||||
libipmitool_la_LDFLAGS = -export-dynamic
|
libipmitool_la_LDFLAGS = -export-dynamic
|
||||||
libipmitool_la_LIBADD = -lm
|
libipmitool_la_LIBADD = -lm
|
||||||
libipmitool_la_DEPENDENCIES =
|
libipmitool_la_DEPENDENCIES =
|
||||||
|
140
ipmitool/lib/ipmi_event.c
Normal file
140
ipmitool/lib/ipmi_event.c
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* Redistribution of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* Redistribution in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of Sun Microsystems, Inc. or the names of
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* This software is provided "AS IS," without a warranty of any kind.
|
||||||
|
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
||||||
|
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
||||||
|
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
||||||
|
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||||
|
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
||||||
|
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
||||||
|
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
||||||
|
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* You acknowledge that this software is not designed or intended for use
|
||||||
|
* in the design, construction, operation or maintenance of any nuclear
|
||||||
|
* facility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include <ipmitool/ipmi.h>
|
||||||
|
#include <ipmitool/ipmi_intf.h>
|
||||||
|
#include <ipmitool/helper.h>
|
||||||
|
#include <ipmitool/ipmi_sel.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
ipmi_send_platform_event(struct ipmi_intf * intf, int num)
|
||||||
|
{
|
||||||
|
struct ipmi_rs * rsp;
|
||||||
|
struct ipmi_rq req;
|
||||||
|
unsigned char rqdata[8];
|
||||||
|
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
memset(rqdata, 0, 8);
|
||||||
|
|
||||||
|
printf("Sending ");
|
||||||
|
|
||||||
|
/* IPMB/LAN/etc */
|
||||||
|
switch (num) {
|
||||||
|
case 0: /* temperature */
|
||||||
|
printf("Temperature");
|
||||||
|
rqdata[0] = 0x04; /* EvMRev */
|
||||||
|
rqdata[1] = 0x01; /* Sensor Type */
|
||||||
|
rqdata[2] = 0x30; /* Sensor # */
|
||||||
|
rqdata[3] = 0x04; /* Event Dir / Event Type */
|
||||||
|
rqdata[4] = 0x00; /* Event Data 1 */
|
||||||
|
rqdata[5] = 0x00; /* Event Data 2 */
|
||||||
|
rqdata[6] = 0x00; /* Event Data 3 */
|
||||||
|
break;
|
||||||
|
case 1: /* correctable ECC */
|
||||||
|
printf("Memory Correctable ECC");
|
||||||
|
rqdata[0] = 0x04; /* EvMRev */
|
||||||
|
rqdata[1] = 0x0c; /* Sensor Type */
|
||||||
|
rqdata[2] = 0x01; /* Sensor # */
|
||||||
|
rqdata[3] = 0x6f; /* Event Dir / Event Type */
|
||||||
|
rqdata[4] = 0x00; /* Event Data 1 */
|
||||||
|
rqdata[5] = 0x00; /* Event Data 2 */
|
||||||
|
rqdata[6] = 0x00; /* Event Data 3 */
|
||||||
|
break;
|
||||||
|
case 2: /* uncorrectable ECC */
|
||||||
|
printf("Memory Uncorrectable ECC");
|
||||||
|
rqdata[0] = 0x04; /* EvMRev */
|
||||||
|
rqdata[1] = 0x0c; /* Sensor Type */
|
||||||
|
rqdata[2] = 0x01; /* Sensor # */
|
||||||
|
rqdata[3] = 0x6f; /* Event Dir / Event Type */
|
||||||
|
rqdata[4] = 0x01; /* Event Data 1 */
|
||||||
|
rqdata[5] = 0x00; /* Event Data 2 */
|
||||||
|
rqdata[6] = 0x00; /* Event Data 3 */
|
||||||
|
break;
|
||||||
|
case 3: /* parity error */
|
||||||
|
printf("Memory Parity Error");
|
||||||
|
rqdata[0] = 0x04; /* EvMRev */
|
||||||
|
rqdata[1] = 0x0c; /* Sensor Type */
|
||||||
|
rqdata[2] = 0x01; /* Sensor # */
|
||||||
|
rqdata[3] = 0x6f; /* Event Dir / Event Type */
|
||||||
|
rqdata[4] = 0x02; /* Event Data 1 */
|
||||||
|
rqdata[5] = 0x00; /* Event Data 2 */
|
||||||
|
rqdata[6] = 0x00; /* Event Data 3 */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Invalid event number: %d\n", num);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" event to BMC\n");
|
||||||
|
|
||||||
|
req.msg.netfn = IPMI_NETFN_SE;
|
||||||
|
req.msg.cmd = 0x02;
|
||||||
|
req.msg.data = rqdata;
|
||||||
|
req.msg.data_len = 7;
|
||||||
|
|
||||||
|
rsp = intf->sendrecv(intf, &req);
|
||||||
|
if (!rsp || rsp->ccode) {
|
||||||
|
printf("Error:%x Platform Event Message Command\n", rsp?rsp->ccode:0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ipmi_event_main(struct ipmi_intf * intf, int argc, char ** argv)
|
||||||
|
{
|
||||||
|
unsigned char c;
|
||||||
|
|
||||||
|
if (!argc || !strncmp(argv[0], "help", 4))
|
||||||
|
printf("usage: event <num>\n");
|
||||||
|
else {
|
||||||
|
c = (unsigned char)strtol(argv[optind+1], NULL, 0);
|
||||||
|
ipmi_send_platform_event(intf, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user