Merge pull request #23 from jk-ozlabs/master
dbus interface fixes
diff --git a/Makefile b/Makefile
old mode 100755
new mode 100644
diff --git a/apphandler.C b/apphandler.C
old mode 100755
new mode 100644
diff --git a/ipmid-api.h b/ipmid-api.h
old mode 100755
new mode 100644
index aa54dd7..a78846c
--- a/ipmid-api.h
+++ b/ipmid-api.h
@@ -62,16 +62,16 @@
// Note: these are also shifted left to make room for the LUN.
enum ipmi_net_fns
{
- NETFUN_CHASSIS = (0x00 << 2),
- NETFUN_BRIDGE = (0x02 << 2),
- NETFUN_SENSOR = (0x04 << 2),
- NETFUN_APP = (0x06 << 2),
- NETFUN_FIRMWARE = (0x08 << 2),
- NETFUN_STORAGE = (0x0a << 2),
- NETFUN_TRANPORT = (0x0c << 2),
- NETFUN_GRPEXT = (0x2c << 2),
- NETFUN_NONE = (0x30 << 2),
- NETFUN_OEM = (0x32 << 2)
+ NETFUN_CHASSIS = 0x00,
+ NETFUN_BRIDGE = 0x02,
+ NETFUN_SENSOR = 0x04,
+ NETFUN_APP = 0x06,
+ NETFUN_FIRMWARE = 0x08,
+ NETFUN_STORAGE = 0x0a,
+ NETFUN_TRANPORT = 0x0c,
+ NETFUN_GRPEXT = 0x2c,
+ NETFUN_NONE = 0x30,
+ NETFUN_OEM = 0x32
};
// IPMI commands for net functions. Since this is to be used both by the ipmi
diff --git a/ipmid.C b/ipmid.C
index 9b19c7e..0c7be7b 100644
--- a/ipmid.C
+++ b/ipmid.C
@@ -27,11 +27,9 @@
-// Channel that is used for OpenBMC Barreleye
-const char * DBUS_NAME = "org.openbmc.HostIpmi";
-const char * OBJ_NAME = "/org/openbmc/HostIpmi/1";
+const char * DBUS_INTF = "org.openbmc.HostIpmi";
-const char * FILTER = "type='signal',sender='org.openbmc.HostIpmi',member='ReceivedMessage'";
+const char * FILTER = "type='signal',interface='org.openbmc.HostIpmi',member='ReceivedMessage'";
typedef std::pair<ipmi_netfn_t, ipmi_cmd_t> ipmi_fn_cmd_t;
@@ -176,17 +174,17 @@
-static int send_ipmi_message(unsigned char seq, unsigned char netfn, unsigned char cmd, unsigned char *buf, unsigned char len) {
+static int send_ipmi_message(sd_bus_message *req, unsigned char seq, unsigned char netfn, unsigned char lun, unsigned char cmd, unsigned char cc, unsigned char *buf, unsigned char len) {
sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message *reply = NULL, *m=NULL;
-
-
- const char *path;
+ const char *dest, *path;
int r, pty;
+ dest = sd_bus_message_get_sender(req);
+ path = sd_bus_message_get_path(req);
- r = sd_bus_message_new_method_call(bus,&m,DBUS_NAME,OBJ_NAME,DBUS_NAME,"sendMessage");
+ r = sd_bus_message_new_method_call(bus,&m,dest,path,DBUS_INTF,"sendMessage");
if (r < 0) {
fprintf(stderr, "Failed to add the method object: %s\n", strerror(-r));
return -1;
@@ -194,11 +192,11 @@
// Responses in IPMI require a bit set. So there ya go...
- netfn |= 0x04;
+ netfn |= 0x01;
// Add the bytes needed for the methods to be called
- r = sd_bus_message_append(m, "yyy", seq, netfn, cmd);
+ r = sd_bus_message_append(m, "yyyyy", seq, netfn, lun, cmd, cc);
if (r < 0) {
fprintf(stderr, "Failed add the netfn and others : %s\n", strerror(-r));
return -1;
@@ -236,7 +234,7 @@
*ret_error) {
int r = 0;
const char *msg = NULL;
- char sequence, netfn, cmd;
+ unsigned char sequence, netfn, lun, cmd;
const void *request;
size_t sz;
size_t resplen =MAX_IPMI_BUFFER;
@@ -244,7 +242,7 @@
memset(response, 0, MAX_IPMI_BUFFER);
- r = sd_bus_message_read(m, "yyy", &sequence, &netfn, &cmd);
+ r = sd_bus_message_read(m, "yyyy", &sequence, &netfn, &lun, &cmd);
if (r < 0) {
fprintf(stderr, "Failed to parse signal message: %s\n", strerror(-r));
return -1;
@@ -275,7 +273,8 @@
hexdump(ipmiio, (void*)response, resplen);
// Send the response buffer from the ipmi command
- r = send_ipmi_message(sequence, netfn, cmd, response, resplen);
+ r = send_ipmi_message(m, sequence, netfn, lun, cmd, response[0],
+ ((unsigned char *)response) + 1, resplen - 1);
if (r < 0) {
fprintf(stderr, "Failed to send the response message\n");
return -1;
@@ -342,6 +341,9 @@
handler_fqdn += "/";
num_handlers = scandir(ipmi_lib_path, &handler_list, handler_select, alphasort);
+ if (num_handlers < 0)
+ return;
+
while(num_handlers--)
{
handler_fqdn = ipmi_lib_path;
diff --git a/ipmid.H b/ipmid.H
old mode 100755
new mode 100644