libipmi: Decouple user commands
This makes them an optional, separate provider like the sysfs cmds.
Tested:
Ran on real hardware that included libusercmds.so in
/usr/lib/host-ipmid and on a machine that did not include it. Ran
ipmitool on the host to verify that the user commands were present
when expected.
Change-Id: I07b3af5ae603c3e5f1ea41f0afc309329f4e185d
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/Makefile.am b/Makefile.am
index 6ced8fc..63718f9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,6 @@
$(AM_V_GEN)@CHANNELGEN@ -o $(top_builddir) generate-cpp
providers_LTLIBRARIES += libipmi20.la
-libipmi20_la_LIBADD = user_channel/libuserlayer.la
libipmi20_la_SOURCES = \
net.cpp \
app/channel.cpp \
@@ -88,8 +87,6 @@
ipmi_fru_info_area.cpp \
read_fru_data.cpp \
sensordatahandler.cpp \
- user_channel/usercommands.cpp \
- user_channel/channelcommands.cpp \
$(libipmi20_BUILT_LIST)
@CODE_COVERAGE_RULES@
@@ -104,7 +101,6 @@
$(libmapper_LIBS) \
$(PHOSPHOR_LOGGING_LIBS) \
$(PHOSPHOR_DBUS_INTERFACES_LIBS) \
- $(LIBS) \
-lstdc++fs \
-version-info 0:0:0 -shared
libipmi20_la_CXXFLAGS = \
@@ -115,6 +111,19 @@
$(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \
-flto
+providers_LTLIBRARIES += libusercmds.la
+libusercmds_la_LIBADD = user_channel/libuserlayer.la
+libusercmds_la_SOURCES = \
+ user_channel/usercommands.cpp \
+ user_channel/channelcommands.cpp
+libusercmds_la_LDFLAGS = \
+ $(PHOSPHOR_LOGGING_LIBS) \
+ $(LIBS) \
+ -version-info 0:0:0 -shared
+libusercmds_la_CXXFLAGS = \
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ -flto
+
providers_LTLIBRARIES += libsysintfcmds.la
libsysintfcmds_la_SOURCES = \
systemintfcmds.cpp \
diff --git a/apphandler.cpp b/apphandler.cpp
index bed16ca..f99cbe8 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -6,8 +6,6 @@
#include "sys_info_param.hpp"
#include "transporthandler.hpp"
#include "types.hpp"
-#include "user_channel/channelcommands.hpp"
-#include "user_channel/usercommands.hpp"
#include "utils.hpp"
#include <arpa/inet.h>
@@ -1152,7 +1150,5 @@
// <Get System Info Command>
ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SYSTEM_INFO, NULL,
ipmi_app_get_system_info, PRIVILEGE_USER);
- ipmi::registerUserIpmiFunctions();
- ipmi::registerChannelFunctions();
return;
}
diff --git a/ipmid.cpp b/ipmid.cpp
index 11d6796..19b88b0 100644
--- a/ipmid.cpp
+++ b/ipmid.cpp
@@ -11,7 +11,6 @@
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
-#include <mapper.h>
#include <sys/time.h>
#include <systemd/sd-bus.h>
#include <unistd.h>
diff --git a/systemintfcmds.cpp b/systemintfcmds.cpp
index e0ff156..06a46d0 100644
--- a/systemintfcmds.cpp
+++ b/systemintfcmds.cpp
@@ -6,7 +6,6 @@
#include "host-interface.hpp"
#include <host-ipmid/ipmid-api.h>
-#include <mapper.h>
#include <cstring>
#include <host-ipmid/ipmid-host-cmd.hpp>
diff --git a/user_channel/channelcommands.cpp b/user_channel/channelcommands.cpp
index cf2c998..a0caeb6 100644
--- a/user_channel/channelcommands.cpp
+++ b/user_channel/channelcommands.cpp
@@ -390,6 +390,7 @@
return IPMI_CC_OK;
}
+void registerChannelFunctions() __attribute__((constructor));
void registerChannelFunctions()
{
ipmiChannelInit();
diff --git a/user_channel/usercommands.cpp b/user_channel/usercommands.cpp
index 3bed8c5..d901e2c 100644
--- a/user_channel/usercommands.cpp
+++ b/user_channel/usercommands.cpp
@@ -493,6 +493,7 @@
return IPMI_CC_INVALID_FIELD_REQUEST;
}
+void registerUserIpmiFunctions() __attribute__((constructor));
void registerUserIpmiFunctions()
{
ipmiUserInit();