diff options
author | Sergey Solomin <sergey.solomin@us.ibm.com> | 2016-08-23 09:07:28 -0500 |
---|---|---|
committer | Sergey Solomin <sergey.solomin@us.ibm.com> | 2016-08-25 13:37:57 -0500 |
commit | eb9b814403895d6435e04f02a9ff6c2b1b02cf54 (patch) | |
tree | 4a1713845844f874799a1b188db209adeaa3e085 /host-services.c | |
parent | bc40c178bb0b345ed1edf553b94369330003af34 (diff) | |
download | phosphor-host-ipmid-eb9b814403895d6435e04f02a9ff6c2b1b02cf54.tar.gz phosphor-host-ipmid-eb9b814403895d6435e04f02a9ff6c2b1b02cf54.zip |
Hard-coded service name replaced with call to ObjectMapper
In the openbmc code, the dbus service name is hardcoded.
The ObjectMapper provides a way to find out the service name by
issuing a GetObject method call to the ObjectMapper.
That functionality is implemented in mapper.c
The output of the call to the mapper is a service name.
Resolves openbmc/openbmc#319.
Change-Id: I724a31ede6bdf3ae4b361e730857b1f2696a8966
Signed-off-by: Sergey Solomin <sergey.solomin@us.ibm.com>
Diffstat (limited to 'host-services.c')
-rw-r--r-- | host-services.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/host-services.c b/host-services.c index cc47439..78ad4c3 100644 --- a/host-services.c +++ b/host-services.c @@ -2,13 +2,12 @@ #include <stdlib.h> #include <errno.h> #include <systemd/sd-bus.h> - +#include <mapper.h> #include "ipmid-api.h" void register_host_services() __attribute__((constructor)); // OpenBMC Host IPMI dbus framework -const char *bus_name = "org.openbmc.HostIpmi"; const char *object_name = "/org/openbmc/HostIpmi/1"; const char *intf_name = "org.openbmc.HostIpmi"; @@ -19,6 +18,7 @@ static int soft_power_off(sd_bus_message *m, void *userdata, sd_bus_error *ret_e { int64_t bt_resp = -1; int rc = 0; + char *bus_name = NULL; // Steps to be taken when we get this. // 1: Send a SMS_ATN to the Host @@ -43,7 +43,11 @@ static int soft_power_off(sd_bus_message *m, void *userdata, sd_bus_error *ret_e // Gets a hook onto either a SYSTEM or SESSION bus sd_bus *bus = ipmid_get_sd_bus_connection(); - + rc = mapper_get_service(bus, object_name, &bus_name); + if (rc < 0) { + fprintf(stderr, "Failed to get bus name, return value: %s.\n", strerror(-rc)); + goto finish; + } rc = sd_bus_call_method(bus, // In the System Bus bus_name, // Service to contact object_name, // Object path @@ -69,6 +73,7 @@ static int soft_power_off(sd_bus_message *m, void *userdata, sd_bus_error *ret_e finish: sd_bus_error_free(&bus_error); response = sd_bus_message_unref(response); + free(bus_name); if(rc < 0) { |