summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipmid.cpp197
-rw-r--r--ipmid.hpp2
-rw-r--r--ipmisensor.cpp3
-rw-r--r--sensorhandler.cpp204
-rw-r--r--sensorhandler.h4
-rw-r--r--storageaddsel.cpp8
6 files changed, 209 insertions, 209 deletions
diff --git a/ipmid.cpp b/ipmid.cpp
index 2689117..9e267bc 100644
--- a/ipmid.cpp
+++ b/ipmid.cpp
@@ -559,200 +559,3 @@ finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
-
-// Use a lookup table to find the interface name of a specific sensor
-// This will be used until an alternative is found. this is the first
-// step for mapping IPMI
-int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) {
-
- char *str1;
- sd_bus_error error = SD_BUS_ERROR_NULL;
- sd_bus_message *reply = NULL, *m=NULL;
-
-
- int r;
-
- r = sd_bus_message_new_method_call(bus,&m,interface->bus,interface->path,"org.freedesktop.DBus.Properties","Get");
- if (r < 0) {
- fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
- fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
- interface->bus, interface->path, interface->interface);
- goto final;
- }
-
- r = sd_bus_message_append(m, "ss", "org.openbmc.InventoryItem", property_name);
- if (r < 0) {
- fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
- fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
- interface->bus, interface->path, interface->interface);
- goto final;
- }
-
- r = sd_bus_call(bus, m, 0, &error, &reply);
- if (r < 0) {
- fprintf(stderr, "Failed to call the method: %s", strerror(-r));
- goto final;
- }
-
- r = sd_bus_message_read(reply, "v", "s", &str1) ;
- if (r < 0) {
- fprintf(stderr, "Failed to get a response: %s", strerror(-r));
- goto final;
- }
-
- strcpy(property_value, str1);
-
-final:
-
- sd_bus_error_free(&error);
- m = sd_bus_message_unref(m);
- reply = sd_bus_message_unref(reply);
-
- return r;
-}
-
-
-// Use a lookup table to find the interface name of a specific sensor
-// This will be used until an alternative is found. this is the first
-// step for mapping IPMI
-int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {
- char *busname = NULL;
- const char *iface = "org.openbmc.managers.System";
- const char *objname = "/org/openbmc/managers/System";
- char *str1 = NULL, *str2, *str3;
- sd_bus_error error = SD_BUS_ERROR_NULL;
- sd_bus_message *reply = NULL;
-
-
- int r;
- r = mapper_get_service(bus, objname, &busname);
- if (r < 0) {
- fprintf(stderr, "Failed to get system manager busname: %s\n", strerror(-r));
- goto final;
- }
-
- r = sd_bus_call_method(bus,busname,objname,iface, "getObjectFromByteId",
- &error, &reply, "sy", type, num);
- if (r < 0) {
- fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
- goto final;
- }
-
- r = sd_bus_message_read(reply, "(ss)", &str2, &str3);
- if (r < 0) {
- fprintf(stderr, "Failed to get a response: %s", strerror(-r));
- goto final;
- }
-
- r = mapper_get_service(bus, str2, &str1);
- if (r < 0) {
- fprintf(stderr, "Failed to get item busname: %s\n", strerror(-r));
- goto final;
- }
-
- strncpy(interface->bus, str1, MAX_DBUS_PATH);
- strncpy(interface->path, str2, MAX_DBUS_PATH);
- strncpy(interface->interface, str3, MAX_DBUS_PATH);
-
- interface->sensornumber = num;
-
-final:
-
- sd_bus_error_free(&error);
- reply = sd_bus_message_unref(reply);
- free(busname);
- free(str1);
-
- return r;
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// Routines used by ipmi commands wanting to interact on the dbus
-//
-/////////////////////////////////////////////////////////////////////
-int set_sensor_dbus_state_s(uint8_t number, const char *method, const char *value) {
-
-
- dbus_interface_t a;
- int r;
- sd_bus_error error = SD_BUS_ERROR_NULL;
- sd_bus_message *m=NULL;
-
- fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n",
- number, method, value);
-
- r = find_openbmc_path("SENSOR", number, &a);
-
- if (r < 0) {
- fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
- return 0;
- }
-
- r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
- if (r < 0) {
- fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
- goto final;
- }
-
- r = sd_bus_message_append(m, "v", "s", value);
- if (r < 0) {
- fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
- goto final;
- }
-
-
- r = sd_bus_call(bus, m, 0, &error, NULL);
- if (r < 0) {
- fprintf(stderr, "Failed to call the method: %s", strerror(-r));
- }
-
-final:
- sd_bus_error_free(&error);
- m = sd_bus_message_unref(m);
-
- return 0;
-}
-int set_sensor_dbus_state_y(uint8_t number, const char *method, const uint8_t value) {
-
-
- dbus_interface_t a;
- int r;
- sd_bus_error error = SD_BUS_ERROR_NULL;
- sd_bus_message *m=NULL;
-
- fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of 0x%02x\n",
- number, method, value);
-
- r = find_openbmc_path("SENSOR", number, &a);
-
- if (r < 0) {
- fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
- return 0;
- }
-
- r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
- if (r < 0) {
- fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
- goto final;
- }
-
- r = sd_bus_message_append(m, "v", "i", value);
- if (r < 0) {
- fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
- goto final;
- }
-
-
- r = sd_bus_call(bus, m, 0, &error, NULL);
- if (r < 0) {
- fprintf(stderr, "12 Failed to call the method: %s", strerror(-r));
- }
-
-final:
- sd_bus_error_free(&error);
- m = sd_bus_message_unref(m);
-
- return 0;
-}
diff --git a/ipmid.hpp b/ipmid.hpp
index bcf15b5..9f1ee95 100644
--- a/ipmid.hpp
+++ b/ipmid.hpp
@@ -22,6 +22,4 @@ ipmi_ret_t ipmi_netfn_router(const ipmi_netfn_t, const ipmi_cmd_t, ipmi_request_
extern FILE *ipmiio, *ipmidbus, *ipmicmddetails;
-int set_sensor_dbus_state_s(uint8_t , const char *, const char *);
-int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t);
#endif
diff --git a/ipmisensor.cpp b/ipmisensor.cpp
index 3e67b41..aaa6cb6 100644
--- a/ipmisensor.cpp
+++ b/ipmisensor.cpp
@@ -2,7 +2,6 @@
#include <string.h>
#include <stdint.h>
#include <malloc.h>
-#include <ipmid.hpp>
#include "sensorhandler.h"
extern uint8_t find_sensor(uint8_t);
@@ -36,8 +35,6 @@ struct lookup_t {
};
extern int updateDbusInterface(uint8_t , const char *, const char *);
-extern int find_openbmc_path(const char *, const uint8_t , dbus_interface_t *) ;
-
int set_sensor_dbus_state_simple(const sensorRES_t *pRec, const lookup_t *pTable, const char *value) {
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index f906921..6503db8 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -1,13 +1,14 @@
#include "sensorhandler.h"
#include "host-ipmid/ipmid-api.h"
+#include <mapper.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <systemd/sd-bus.h>
+#include "ipmid.hpp"
extern int updateSensorRecordFromSSRAESC(const void *);
-extern int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) ;
-extern int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) ;
+extern sd_bus *bus;
void register_netfn_sen_functions() __attribute__((constructor));
@@ -48,6 +49,205 @@ struct sensorreadingresp_t {
uint8_t indication[2];
} __attribute__ ((packed)) ;
+
+// Use a lookup table to find the interface name of a specific sensor
+// This will be used until an alternative is found. this is the first
+// step for mapping IPMI
+int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) {
+
+ char *str1;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *reply = NULL, *m=NULL;
+
+
+ int r;
+
+ r = sd_bus_message_new_method_call(bus,&m,interface->bus,interface->path,"org.freedesktop.DBus.Properties","Get");
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+ fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
+ interface->bus, interface->path, interface->interface);
+ goto final;
+ }
+
+ r = sd_bus_message_append(m, "ss", "org.openbmc.InventoryItem", property_name);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+ fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
+ interface->bus, interface->path, interface->interface);
+ goto final;
+ }
+
+ r = sd_bus_call(bus, m, 0, &error, &reply);
+ if (r < 0) {
+ fprintf(stderr, "Failed to call the method: %s", strerror(-r));
+ goto final;
+ }
+
+ r = sd_bus_message_read(reply, "v", "s", &str1) ;
+ if (r < 0) {
+ fprintf(stderr, "Failed to get a response: %s", strerror(-r));
+ goto final;
+ }
+
+ strcpy(property_value, str1);
+
+final:
+
+ sd_bus_error_free(&error);
+ m = sd_bus_message_unref(m);
+ reply = sd_bus_message_unref(reply);
+
+ return r;
+}
+
+
+// Use a lookup table to find the interface name of a specific sensor
+// This will be used until an alternative is found. this is the first
+// step for mapping IPMI
+int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {
+ char *busname = NULL;
+ const char *iface = "org.openbmc.managers.System";
+ const char *objname = "/org/openbmc/managers/System";
+ char *str1 = NULL, *str2, *str3;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *reply = NULL;
+
+
+ int r;
+ r = mapper_get_service(bus, objname, &busname);
+ if (r < 0) {
+ fprintf(stderr, "Failed to get system manager busname: %s\n", strerror(-r));
+ goto final;
+ }
+
+ r = sd_bus_call_method(bus,busname,objname,iface, "getObjectFromByteId",
+ &error, &reply, "sy", type, num);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+ goto final;
+ }
+
+ r = sd_bus_message_read(reply, "(ss)", &str2, &str3);
+ if (r < 0) {
+ fprintf(stderr, "Failed to get a response: %s", strerror(-r));
+ goto final;
+ }
+
+ r = mapper_get_service(bus, str2, &str1);
+ if (r < 0) {
+ fprintf(stderr, "Failed to get item busname: %s\n", strerror(-r));
+ goto final;
+ }
+
+ strncpy(interface->bus, str1, MAX_DBUS_PATH);
+ strncpy(interface->path, str2, MAX_DBUS_PATH);
+ strncpy(interface->interface, str3, MAX_DBUS_PATH);
+
+ interface->sensornumber = num;
+
+final:
+
+ sd_bus_error_free(&error);
+ reply = sd_bus_message_unref(reply);
+ free(busname);
+ free(str1);
+
+ return r;
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// Routines used by ipmi commands wanting to interact on the dbus
+//
+/////////////////////////////////////////////////////////////////////
+int set_sensor_dbus_state_s(uint8_t number, const char *method, const char *value) {
+
+
+ dbus_interface_t a;
+ int r;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *m=NULL;
+
+ fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n",
+ number, method, value);
+
+ r = find_openbmc_path("SENSOR", number, &a);
+
+ if (r < 0) {
+ fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
+ return 0;
+ }
+
+ r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+ goto final;
+ }
+
+ r = sd_bus_message_append(m, "v", "s", value);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+ goto final;
+ }
+
+
+ r = sd_bus_call(bus, m, 0, &error, NULL);
+ if (r < 0) {
+ fprintf(stderr, "Failed to call the method: %s", strerror(-r));
+ }
+
+final:
+ sd_bus_error_free(&error);
+ m = sd_bus_message_unref(m);
+
+ return 0;
+}
+int set_sensor_dbus_state_y(uint8_t number, const char *method, const uint8_t value) {
+
+
+ dbus_interface_t a;
+ int r;
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *m=NULL;
+
+ fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of 0x%02x\n",
+ number, method, value);
+
+ r = find_openbmc_path("SENSOR", number, &a);
+
+ if (r < 0) {
+ fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
+ return 0;
+ }
+
+ r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
+ goto final;
+ }
+
+ r = sd_bus_message_append(m, "v", "i", value);
+ if (r < 0) {
+ fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
+ goto final;
+ }
+
+
+ r = sd_bus_call(bus, m, 0, &error, NULL);
+ if (r < 0) {
+ fprintf(stderr, "12 Failed to call the method: %s", strerror(-r));
+ }
+
+final:
+ sd_bus_error_free(&error);
+ m = sd_bus_message_unref(m);
+
+ return 0;
+}
+
+
uint8_t dbus_to_sensor_type(char *p) {
sensorTypemap_t *s = g_SensorTypeMap;
diff --git a/sensorhandler.h b/sensorhandler.h
index dd940dc..e8e46a5 100644
--- a/sensorhandler.h
+++ b/sensorhandler.h
@@ -20,4 +20,8 @@ struct dbus_interface_t {
char path[MAX_DBUS_PATH];
char interface[MAX_DBUS_PATH];
};
+
+int set_sensor_dbus_state_s(uint8_t , const char *, const char *);
+int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t);
+int find_openbmc_path(const char *, const uint8_t , dbus_interface_t *);
#endif
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 2deb3cb..47328b0 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -8,14 +8,12 @@
#include <memory>
#include <systemd/sd-bus.h>
#include <mapper.h>
-#include "ipmid.hpp"
-#include "storagehandler.h"
+#include "host-ipmid/ipmid-api.h"
#include "sensorhandler.h"
+#include "storagehandler.h"
-using namespace std;
-
-extern int find_openbmc_path(const char *, const uint8_t , dbus_interface_t *);
+using namespace std;
//////////////////////////
struct esel_section_headers_t {
OpenPOWER on IntegriCloud