Move util.cpp/util.hpp to libipmid

These are functions that are used widely by ipmid providers, so it makes
sense to put them in libipmi.so (the library that all providers must
link against).

Tested-by: use nm to inspect the binaries to see that the symbols are in
           the expected library.

           arm-openbmc-linux-gnueabi-nm libipmid.so.0.0.0 \
                      | grep getDbusObject
           0001063c T _ZN4ipmi13getDbusObjectERN9sdbusplus....

Change-Id: I1221f807f2711c5301c5574623564ea1ae48a437
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/Makefile.am b/Makefile.am
index 7f24377..492f452 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,8 +12,7 @@
 ipmid_SOURCES = \
 	ipmid-new.cpp \
 	settings.cpp \
-	host-cmd-manager.cpp \
-	utils.cpp
+	host-cmd-manager.cpp
 
 libipmi20_BUILT_LIST = \
 	sensor-gen.cpp \
@@ -91,7 +90,6 @@
 	transporthandler.cpp \
 	globalhandler.cpp \
 	groupext.cpp \
-	utils.cpp \
 	selutility.cpp \
 	ipmi_fru_info_area.cpp \
 	read_fru_data.cpp \
diff --git a/app/channel.cpp b/app/channel.cpp
index 93fba24..e4532c5 100644
--- a/app/channel.cpp
+++ b/app/channel.cpp
@@ -3,12 +3,12 @@
 #include "transporthandler.hpp"
 #include "types.hpp"
 #include "user_channel/channel_layer.hpp"
-#include "utils.hpp"
 
 #include <arpa/inet.h>
 
 #include <boost/process/child.hpp>
 #include <fstream>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <set>
diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp
index 75afc1e..0cf1c74 100644
--- a/app/watchdog_service.hpp
+++ b/app/watchdog_service.hpp
@@ -1,6 +1,5 @@
 #pragma once
-#include "utils.hpp"
-
+#include <ipmid/utils.hpp>
 #include <sdbusplus/bus.hpp>
 #include <xyz/openbmc_project/State/Watchdog/server.hpp>
 
diff --git a/apphandler.cpp b/apphandler.cpp
index ac969e9..0993139 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -6,7 +6,6 @@
 #include "sys_info_param.hpp"
 #include "transporthandler.hpp"
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <arpa/inet.h>
 #include <ipmid/api.h>
@@ -19,6 +18,7 @@
 #include <array>
 #include <cstddef>
 #include <fstream>
+#include <ipmid/utils.hpp>
 #include <memory>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
diff --git a/chassishandler.cpp b/chassishandler.cpp
index c955658..2a9057d 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -5,7 +5,6 @@
 #include "ipmid.hpp"
 #include "settings.hpp"
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <arpa/inet.h>
 #include <endian.h>
@@ -19,6 +18,7 @@
 #include <cstring>
 #include <fstream>
 #include <future>
+#include <ipmid/utils.hpp>
 #include <map>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index e9cc39a..e858416 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -3,13 +3,13 @@
 #include "dcmihandler.hpp"
 
 #include "user_channel/channel_layer.hpp"
-#include "utils.hpp"
 
 #include <ipmid/api.h>
 
 #include <bitset>
 #include <cmath>
 #include <fstream>
+#include <ipmid/utils.hpp>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
diff --git a/globalhandler.cpp b/globalhandler.cpp
index 04d57af..e268fd1 100644
--- a/globalhandler.cpp
+++ b/globalhandler.cpp
@@ -1,9 +1,8 @@
 #include "globalhandler.hpp"
 
-#include "utils.hpp"
-
 #include <ipmid/api.h>
 
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <string>
diff --git a/host-cmd-manager.cpp b/host-cmd-manager.cpp
index 0a61e63..9efb787 100644
--- a/host-cmd-manager.cpp
+++ b/host-cmd-manager.cpp
@@ -5,11 +5,11 @@
 #include "systemintfcmds.hpp"
 
 #include <chrono>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
 #include <sdbusplus/timer.hpp>
-#include <utils.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/State/Host/server.hpp>
 
diff --git a/host-interface.cpp b/host-interface.cpp
index 0b5f63c..69ab376 100644
--- a/host-interface.cpp
+++ b/host-interface.cpp
@@ -3,11 +3,11 @@
 #include "host-interface.hpp"
 
 #include "systemintfcmds.hpp"
-#include "utils.hpp"
 
 #include <functional>
 #include <ipmid-host/cmd-utils.hpp>
 #include <ipmid-host/cmd.hpp>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/log.hpp>
 
 namespace phosphor
diff --git a/include/Makefile.am b/include/Makefile.am
index 55b531c..f51e7d7 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -12,6 +12,7 @@
 	ipmid/oemopenbmc.hpp \
 	ipmid/oemrouter.hpp \
 	ipmid/utility.hpp \
+	ipmid/utils.hpp \
 	ipmid-host/cmd.hpp \
 	ipmid-host/cmd-utils.hpp
 
diff --git a/utils.hpp b/include/ipmid/utils.hpp
similarity index 100%
rename from utils.hpp
rename to include/ipmid/utils.hpp
diff --git a/libipmid/Makefile.am b/libipmid/Makefile.am
index e4899e1..189693f 100644
--- a/libipmid/Makefile.am
+++ b/libipmid/Makefile.am
@@ -14,7 +14,8 @@
 libipmid_la_SOURCES = \
 	sdbus-asio.cpp \
 	signals.cpp \
-	systemintf-sdbus.cpp
+	systemintf-sdbus.cpp \
+	utils.cpp
 libipmid_la_LDFLAGS = \
 	$(SYSTEMD_LIBS) \
 	-version-info 0:0:0 -shared
diff --git a/utils.cpp b/libipmid/utils.cpp
similarity index 99%
rename from utils.cpp
rename to libipmid/utils.cpp
index 7807e76..4fd219e 100644
--- a/utils.cpp
+++ b/libipmid/utils.cpp
@@ -1,11 +1,10 @@
-#include "utils.hpp"
-
 #include <arpa/inet.h>
 #include <dirent.h>
 #include <net/if.h>
 
 #include <algorithm>
 #include <chrono>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index 94b2478..05b1b6e 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -2,11 +2,11 @@
 
 #include "fruread.hpp"
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <ipmid/api.h>
 
 #include <algorithm>
+#include <ipmid/utils.hpp>
 #include <map>
 #include <phosphor-logging/elog-errors.hpp>
 #include <sdbusplus/message/types.hpp>
diff --git a/selutility.cpp b/selutility.cpp
index b9bf7ed..b85bc40 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -3,11 +3,11 @@
 #include "selutility.hpp"
 
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <ipmid/api.h>
 
 #include <chrono>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <vector>
 #include <xyz/openbmc_project/Common/error.hpp>
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index 4f552a3..87c82b9 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -2,9 +2,9 @@
 
 #include "sensorhandler.hpp"
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <bitset>
+#include <ipmid/utils.hpp>
 #include <optional>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 9c32da9..82ed002 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -2,11 +2,11 @@
 
 #include "sensorhandler.hpp"
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <ipmid/api.h>
 
 #include <cmath>
+#include <ipmid/utils.hpp>
 #include <sdbusplus/message/types.hpp>
 
 namespace ipmi
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 051c4fd..cb73e71 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -3,7 +3,6 @@
 #include "fruread.hpp"
 #include "ipmid.hpp"
 #include "types.hpp"
-#include "utils.hpp"
 
 #include <ipmid/api.h>
 #include <mapper.h>
@@ -12,6 +11,7 @@
 #include <bitset>
 #include <cmath>
 #include <cstring>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
diff --git a/settings.cpp b/settings.cpp
index 0ddd7a6..e8b8997 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -1,7 +1,6 @@
 #include "settings.hpp"
 
-#include "utils.hpp"
-
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
diff --git a/softoff/Makefile.am b/softoff/Makefile.am
index e43cfbb..8383b68 100644
--- a/softoff/Makefile.am
+++ b/softoff/Makefile.am
@@ -7,7 +7,7 @@
 	softoff.cpp \
 	mainapp.cpp \
 	xyz/openbmc_project/Ipmi/Internal/SoftPowerOff/server.cpp \
-	../utils.cpp
+	../libipmid/utils.cpp
 
 BUILT_SOURCES = \
 	xyz/openbmc_project/Ipmi/Internal/SoftPowerOff/server.cpp \
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp
index 803efc0..e6ed0eb 100644
--- a/softoff/softoff.cpp
+++ b/softoff/softoff.cpp
@@ -18,8 +18,8 @@
 #include "softoff.hpp"
 
 #include <chrono>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/log.hpp>
-#include <utils.hpp>
 #include <xyz/openbmc_project/Control/Host/server.hpp>
 namespace phosphor
 {
diff --git a/storagehandler.cpp b/storagehandler.cpp
index cff0d84..32bb088 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -5,7 +5,6 @@
 #include "selutility.hpp"
 #include "sensorhandler.hpp"
 #include "storageaddsel.hpp"
-#include "utils.hpp"
 
 #include <arpa/inet.h>
 #include <ipmid/api.h>
@@ -16,6 +15,7 @@
 #include <chrono>
 #include <cstdio>
 #include <cstring>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 24fea47..d56a064 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -3,13 +3,13 @@
 #include "app/channel.hpp"
 #include "ipmid.hpp"
 #include "user_channel/channel_layer.hpp"
-#include "utils.hpp"
 
 #include <arpa/inet.h>
 #include <ipmid/api.h>
 
 #include <chrono>
 #include <fstream>
+#include <ipmid/utils.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/message/types.hpp>
diff --git a/whitelist-filter.cpp b/whitelist-filter.cpp
index 3b45db8..1d486ca 100644
--- a/whitelist-filter.cpp
+++ b/whitelist-filter.cpp
@@ -2,11 +2,11 @@
 #include <array>
 #include <ipmid/api.hpp>
 #include <ipmid/registration.hpp>
+#include <ipmid/utils.hpp>
 #include <ipmiwhitelist.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/log.hpp>
 #include <settings.hpp>
-#include <utils.hpp>
 #include <xyz/openbmc_project/Control/Security/RestrictionMode/server.hpp>
 
 using namespace phosphor::logging;