summaryrefslogtreecommitdiffstats
path: root/chassishandler.C
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@us.ibm.com>2016-07-22 08:35:41 -0400
committerBrad Bishop <bradleyb@us.ibm.com>2016-07-27 15:19:24 -0400
commit3551868f8b46bec8711887c72b26f4c628d1600f (patch)
tree2979a7e7443de66941fa1f0c546c7cbb50d0dacf /chassishandler.C
parent87e080b537aff3fd22ec56ef72660937bed38422 (diff)
downloadphosphor-host-ipmid-3551868f8b46bec8711887c72b26f4c628d1600f.tar.gz
phosphor-host-ipmid-3551868f8b46bec8711887c72b26f4c628d1600f.zip
Use mapper calls to lookup objects
This is a reaction to a managers.System API update. The update removes the bus name field from the 'GetObject' method responses. Change-Id: I51fb1d1bad20317a429e5b06712475929b6fb4fb Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'chassishandler.C')
-rw-r--r--chassishandler.C93
1 files changed, 7 insertions, 86 deletions
diff --git a/chassishandler.C b/chassishandler.C
index 6a9a28f..ded9157 100644
--- a/chassishandler.C
+++ b/chassishandler.C
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
+#include <mapper.h>
//Defines
@@ -27,80 +28,6 @@ const char *settings_object_name = "/org/openbmc/settings/host0";
const char *settings_intf_name = "org.freedesktop.DBus.Properties";
const char *host_intf_name = "org.openbmc.settings.Host";
-const char *objmapper_service_name = "org.openbmc.ObjectMapper";
-const char *objmapper_object_name = "/org/openbmc/ObjectMapper";
-const char *objmapper_intf_name = "org.openbmc.ObjectMapper";
-
-int object_mapper_get_connection(char **buf, const char *obj_path)
-{
- sd_bus_error error = SD_BUS_ERROR_NULL;
- sd_bus_message *m = NULL;
- sd_bus *bus = NULL;
- char *temp_buf = NULL, *intf = NULL;
- size_t buf_size = 0;
- int r;
-
- // Get the system bus where most system services are provided.
- bus = ipmid_get_sd_bus_connection();
-
- /*
- * Bus, service, object path, interface and method are provided to call
- * the method.
- * Signatures and input arguments are provided by the arguments at the
- * end.
- */
- r = sd_bus_call_method(bus,
- objmapper_service_name, /* service to contact */
- objmapper_object_name, /* object path */
- objmapper_intf_name, /* interface name */
- "GetObject", /* method name */
- &error, /* object to return error in */
- &m, /* return message on success */
- "s", /* input signature */
- obj_path /* first argument */
- );
-
- if (r < 0) {
- fprintf(stderr, "Failed to issue method call: %s\n", error.message);
- goto finish;
- }
-
- // Get the key, aka, the connection name
- sd_bus_message_read(m, "a{sas}", 1, &temp_buf, 1, &intf);
-
- /*
- * TODO: check the return code. Currently for no reason the message
- * parsing of object mapper is always complaining about
- * "Device or resource busy", but the result seems OK for now. Need
- * further checks.
- * TODO: The following code is preserved in the comments so that it can be
- * resumed after the problem aforementioned is resolved.
- *r = sd_bus_message_read(m, "a{sas}", 1, &temp_buf, 1, &intf);
- *if (r < 0) {
- * fprintf(stderr, "Failed to parse response message: %s\n", strerror(-r));
- * goto finish;
- *}
- */
-
- buf_size = strlen(temp_buf) + 1;
- printf("IPMID connection name: %s\n", temp_buf);
- *buf = (char *)malloc(buf_size);
-
- if (*buf == NULL) {
- fprintf(stderr, "Malloc failed for get_sys_boot_options");
- r = -1;
- goto finish;
- }
-
- memcpy(*buf, temp_buf, buf_size);
-
-finish:
- sd_bus_error_free(&error);
- sd_bus_message_unref(m);
-
- return r;
-}
-
int dbus_get_property(const char *name, char **buf)
{
sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -110,18 +37,15 @@ int dbus_get_property(const char *name, char **buf)
char *connection = NULL;
int r;
- r = object_mapper_get_connection(&connection, settings_object_name);
+ // Get the system bus where most system services are provided.
+ bus = ipmid_get_sd_bus_connection();
+ r = mapper_get_service(bus, settings_object_name, &connection);
if (r < 0) {
fprintf(stderr, "Failed to get connection, return value: %d.\n", r);
goto finish;
}
- printf("connection: %s\n", connection);
-
- // Get the system bus where most system services are provided.
- bus = ipmid_get_sd_bus_connection();
-
/*
* Bus, service, object path, interface and method are provided to call
* the method.
@@ -178,18 +102,15 @@ int dbus_set_property(const char * name, const char *value)
char *connection = NULL;
int r;
- r = object_mapper_get_connection(&connection, settings_object_name);
+ // Get the system bus where most system services are provided.
+ bus = ipmid_get_sd_bus_connection();
+ r = mapper_get_service(bus, settings_object_name, &connection);
if (r < 0) {
fprintf(stderr, "Failed to get connection, return value: %d.\n", r);
goto finish;
}
- printf("connection: %s\n", connection);
-
- // Get the system bus where most system services are provided.
- bus = ipmid_get_sd_bus_connection();
-
/*
* Bus, service, object path, interface and method are provided to call
* the method.
OpenPOWER on IntegriCloud