summaryrefslogtreecommitdiffstats
path: root/include/ipmid
diff options
context:
space:
mode:
Diffstat (limited to 'include/ipmid')
-rw-r--r--include/ipmid/api.hpp2
-rw-r--r--include/ipmid/handler.hpp93
-rw-r--r--include/ipmid/message.hpp103
-rw-r--r--include/ipmid/message/pack.hpp37
-rw-r--r--include/ipmid/message/unpack.hpp54
-rw-r--r--include/ipmid/sessiondef.hpp52
-rw-r--r--include/ipmid/sessionhelper.hpp88
-rw-r--r--include/ipmid/types.hpp37
-rw-r--r--include/ipmid/utility.hpp7
-rw-r--r--include/ipmid/utils.hpp77
10 files changed, 360 insertions, 190 deletions
diff --git a/include/ipmid/api.hpp b/include/ipmid/api.hpp
index f4cbf13..6e33470 100644
--- a/include/ipmid/api.hpp
+++ b/include/ipmid/api.hpp
@@ -47,7 +47,7 @@ std::shared_ptr<sdbusplus::asio::connection> getSdBus();
template <typename WorkFn>
static inline void post_work(WorkFn work)
{
- getIoContext()->post(std::forward<WorkFn>(work));
+ boost::asio::post(*getIoContext(), std::forward<WorkFn>(work));
}
enum class SignalResponse : int
diff --git a/include/ipmid/handler.hpp b/include/ipmid/handler.hpp
index 1421c3d..b6c6c0f 100644
--- a/include/ipmid/handler.hpp
+++ b/include/ipmid/handler.hpp
@@ -153,6 +153,7 @@ class IpmiHandler final : public HandlerBase
using ResultType = boost::callable_traits::return_type_t<Handler>;
UnpackArgsType unpackArgs;
+ request->payload.trailingOk = false;
ipmi::Cc unpackError = request->unpack(unpackArgs);
if (unpackError != ipmi::ccSuccess)
{
@@ -178,45 +179,47 @@ class IpmiHandler final : public HandlerBase
* parameter selector. All the remaining data can be extracted using
* the Payload class and the unpack API available to the Payload class.
*/
- std::optional<InputArgsType> inputArgs;
- if constexpr (std::tuple_size<InputArgsType>::value > 0)
+ ResultType result;
+ try
{
- if constexpr (std::is_same<std::tuple_element_t<0, InputArgsType>,
- boost::asio::yield_context>::value)
- {
- inputArgs.emplace(std::tuple_cat(
- std::forward_as_tuple(*(request->ctx->yield)),
- std::move(unpackArgs)));
- }
- else if constexpr (std::is_same<
- std::tuple_element_t<0, InputArgsType>,
- ipmi::Context::ptr>::value)
- {
- inputArgs.emplace(
- std::tuple_cat(std::forward_as_tuple(request->ctx),
- std::move(unpackArgs)));
- }
- else if constexpr (std::is_same<
- std::tuple_element_t<0, InputArgsType>,
- ipmi::message::Request::ptr>::value)
+ std::optional<InputArgsType> inputArgs;
+ if constexpr (std::tuple_size<InputArgsType>::value > 0)
{
- inputArgs.emplace(std::tuple_cat(std::forward_as_tuple(request),
- std::move(unpackArgs)));
+ if constexpr (std::is_same<
+ std::tuple_element_t<0, InputArgsType>,
+ boost::asio::yield_context>::value)
+ {
+ inputArgs.emplace(std::tuple_cat(
+ std::forward_as_tuple(request->ctx->yield),
+ std::move(unpackArgs)));
+ }
+ else if constexpr (std::is_same<
+ std::tuple_element_t<0, InputArgsType>,
+ ipmi::Context::ptr>::value)
+ {
+ inputArgs.emplace(
+ std::tuple_cat(std::forward_as_tuple(request->ctx),
+ std::move(unpackArgs)));
+ }
+ else if constexpr (std::is_same<
+ std::tuple_element_t<0, InputArgsType>,
+ ipmi::message::Request::ptr>::value)
+ {
+ inputArgs.emplace(std::tuple_cat(
+ std::forward_as_tuple(request), std::move(unpackArgs)));
+ }
+ else
+ {
+ // no special parameters were requested (but others were)
+ inputArgs.emplace(std::move(unpackArgs));
+ }
}
else
{
- // no special parameters were requested (but others were)
- inputArgs.emplace(std::move(unpackArgs));
+ // no parameters were requested
+ inputArgs = std::move(unpackArgs);
}
- }
- else
- {
- // no parameters were requested
- inputArgs = std::move(unpackArgs);
- }
- ResultType result;
- try
- {
+
// execute the registered callback function and get the
// ipmi::RspType<>
result = std::apply(handler_, *inputArgs);
@@ -264,6 +267,7 @@ class IpmiHandler final : public HandlerBase
};
#ifdef ALLOW_DEPRECATED_API
+static constexpr size_t maxLegacyBufferSize = 64 * 1024;
/**
* @brief Legacy IPMI handler class
*
@@ -307,17 +311,17 @@ class IpmiHandler<ipmid_callback_t> final : public HandlerBase
executeCallback(message::Request::ptr request) override
{
message::Response::ptr response = request->makeResponse();
- size_t len = request->payload.size();
// allocate a big response buffer here
- response->payload.resize(
- getChannelMaxTransferSize(request->ctx->channel));
+ response->payload.resize(maxLegacyBufferSize);
+ size_t len = request->payload.size() - request->payload.rawIndex;
Cc ccRet{ccSuccess};
try
{
- ccRet = handler_(request->ctx->netFn, request->ctx->cmd,
- request->payload.data(), response->payload.data(),
- &len, handlerCtx);
+ ccRet =
+ handler_(request->ctx->netFn, request->ctx->cmd,
+ request->payload.data() + request->payload.rawIndex,
+ response->payload.data(), &len, handlerCtx);
}
catch (const std::exception& e)
{
@@ -396,16 +400,17 @@ class IpmiHandler<oem::Handler> final : public HandlerBase
executeCallback(message::Request::ptr request) override
{
message::Response::ptr response = request->makeResponse();
- size_t len = request->payload.size();
// allocate a big response buffer here
- response->payload.resize(
- getChannelMaxTransferSize(request->ctx->channel));
+ response->payload.resize(maxLegacyBufferSize);
+ size_t len = request->payload.size() - request->payload.rawIndex;
Cc ccRet{ccSuccess};
try
{
- ccRet = handler_(request->ctx->cmd, request->payload.data(),
- response->payload.data(), &len);
+ ccRet =
+ handler_(request->ctx->cmd,
+ request->payload.data() + request->payload.rawIndex,
+ response->payload.data(), &len);
}
catch (const std::exception& e)
{
diff --git a/include/ipmid/message.hpp b/include/ipmid/message.hpp
index 030618f..c828e3c 100644
--- a/include/ipmid/message.hpp
+++ b/include/ipmid/message.hpp
@@ -18,10 +18,12 @@
#include <algorithm>
#include <boost/asio/spawn.hpp>
#include <cstdint>
+#include <exception>
#include <ipmid/api-types.hpp>
#include <ipmid/message/types.hpp>
#include <memory>
#include <phosphor-logging/log.hpp>
+#include <sdbusplus/asio/connection.hpp>
#include <tuple>
#include <utility>
#include <vector>
@@ -33,23 +35,33 @@ struct Context
{
using ptr = std::shared_ptr<Context>;
- Context() = default;
-
- Context(NetFn netFn, Cmd cmd, int channel, int userId, Privilege priv,
- boost::asio::yield_context* yield = nullptr) :
- netFn(netFn),
- cmd(cmd), channel(channel), userId(userId), priv(priv), yield(yield)
+ Context() = delete;
+ Context(const Context&) = default;
+ Context& operator=(const Context&) = default;
+ Context(Context&&) = delete;
+ Context& operator=(Context&&) = delete;
+
+ Context(std::shared_ptr<sdbusplus::asio::connection> bus, NetFn netFn,
+ Cmd cmd, int channel, int userId, uint32_t sessionId,
+ Privilege priv, int rqSA, boost::asio::yield_context& yield) :
+ bus(bus),
+ netFn(netFn), cmd(cmd), channel(channel), userId(userId),
+ sessionId(sessionId), priv(priv), rqSA(rqSA), yield(yield)
{
}
+ std::shared_ptr<sdbusplus::asio::connection> bus;
// normal IPMI context (what call is this, from whence it came...)
- NetFn netFn = 0;
- Cmd cmd = 0;
- int channel = 0;
- int userId = 0;
- Privilege priv = Privilege::None;
- // if non-null, use this to do blocking asynchronous asio calls
- boost::asio::yield_context* yield = nullptr;
+ NetFn netFn;
+ Cmd cmd;
+ int channel;
+ int userId;
+ uint32_t sessionId;
+ Privilege priv;
+ // srcAddr is only set on IPMB requests because
+ // Platform Event Message needs it to determine the incoming format
+ int rqSA;
+ boost::asio::yield_context yield;
};
namespace message
@@ -99,15 +111,15 @@ struct Payload
Payload(Payload&&) = default;
Payload& operator=(Payload&&) = default;
- explicit Payload(std::vector<uint8_t>&& data) :
- raw(std::move(data)), unpackCheck(false)
+ explicit Payload(std::vector<uint8_t>&& data) : raw(std::move(data))
{
}
~Payload()
{
using namespace phosphor::logging;
- if (trailingOk && !unpackCheck && !fullyUnpacked())
+ if (raw.size() != 0 && std::uncaught_exceptions() == 0 && !trailingOk &&
+ !unpackCheck && !unpackError)
{
log<level::ERR>("Failed to check request for full unpack");
}
@@ -252,6 +264,27 @@ struct Payload
return packRet;
}
+ /**
+ * @brief Prepends another payload to this one
+ *
+ * Avoid using this unless absolutely required since it inserts into the
+ * front of the response payload.
+ *
+ * @param p - The payload to prepend
+ *
+ * @retunr int - non-zero on prepend errors
+ */
+ int prepend(const ipmi::message::Payload& p)
+ {
+ if (bitCount != 0 || p.bitCount != 0)
+ {
+ return 1;
+ }
+ raw.reserve(raw.size() + p.raw.size());
+ raw.insert(raw.begin(), p.raw.begin(), p.raw.end());
+ return 0;
+ }
+
/******************************************************************
* Request operations
*****************************************************************/
@@ -445,8 +478,8 @@ struct Payload
size_t bitCount = 0;
std::vector<uint8_t> raw;
size_t rawIndex = 0;
- bool trailingOk = false;
- bool unpackCheck = true;
+ bool trailingOk = true;
+ bool unpackCheck = false;
bool unpackError = false;
};
@@ -513,6 +546,21 @@ struct Response
return payload.pack(t);
}
+ /**
+ * @brief Prepends another payload to this one
+ *
+ * Avoid using this unless absolutely required since it inserts into the
+ * front of the response payload.
+ *
+ * @param p - The payload to prepend
+ *
+ * @retunr int - non-zero on prepend errors
+ */
+ int prepend(const ipmi::message::Payload& p)
+ {
+ return payload.prepend(p);
+ }
+
Payload payload;
Context::ptr ctx;
Cc cc;
@@ -560,19 +608,20 @@ struct Request
int unpack(Args&&... args)
{
int unpackRet = payload.unpack(std::forward<Args>(args)...);
- if (unpackRet == ipmi::ccSuccess)
+ if (unpackRet != ipmi::ccSuccess)
+ {
+ // not all bits were consumed by requested parameters
+ return ipmi::ccReqDataLenInvalid;
+ }
+ if (!payload.trailingOk)
{
- if (!payload.trailingOk)
+ if (!payload.fullyUnpacked())
{
- if (!payload.fullyUnpacked())
- {
- // not all bits were consumed by requested parameters
- return ipmi::ccReqDataLenInvalid;
- }
- payload.unpackCheck = false;
+ // not all bits were consumed by requested parameters
+ return ipmi::ccReqDataLenInvalid;
}
}
- return unpackRet;
+ return ipmi::ccSuccess;
}
/**
diff --git a/include/ipmid/message/pack.hpp b/include/ipmid/message/pack.hpp
index 18863c4..598e650 100644
--- a/include/ipmid/message/pack.hpp
+++ b/include/ipmid/message/pack.hpp
@@ -20,6 +20,7 @@
#include <memory>
#include <optional>
#include <phosphor-logging/log.hpp>
+#include <string_view>
#include <tuple>
#include <utility>
#include <variant>
@@ -239,6 +240,26 @@ struct PackSingle<std::vector<uint8_t>>
{
static int op(Payload& p, const std::vector<uint8_t>& t)
{
+ if (p.bitCount != 0)
+ {
+ return 1;
+ }
+ p.raw.reserve(p.raw.size() + t.size());
+ p.raw.insert(p.raw.end(), t.begin(), t.end());
+ return 0;
+ }
+};
+
+/** @brief Specialization of PackSingle for std::string_view */
+template <>
+struct PackSingle<std::string_view>
+{
+ static int op(Payload& p, const std::string_view& t)
+ {
+ if (p.bitCount != 0)
+ {
+ return 1;
+ }
p.raw.reserve(p.raw.size() + t.size());
p.raw.insert(p.raw.end(), t.begin(), t.end());
return 0;
@@ -259,6 +280,22 @@ struct PackSingle<std::variant<T...>>
}
};
+/** @brief Specialization of PackSingle for Payload */
+template <>
+struct PackSingle<Payload>
+{
+ static int op(Payload& p, const Payload& t)
+ {
+ if (p.bitCount != 0 || t.bitCount != 0)
+ {
+ return 1;
+ }
+ p.raw.reserve(p.raw.size() + t.raw.size());
+ p.raw.insert(p.raw.end(), t.raw.begin(), t.raw.end());
+ return 0;
+ }
+};
+
} // namespace details
} // namespace message
diff --git a/include/ipmid/message/unpack.hpp b/include/ipmid/message/unpack.hpp
index 94f80f1..d9ccba4 100644
--- a/include/ipmid/message/unpack.hpp
+++ b/include/ipmid/message/unpack.hpp
@@ -99,26 +99,29 @@ struct UnpackSingle
}
return 0;
}
- else
+ else if constexpr (utility::is_tuple<T>::value)
{
- if constexpr (utility::is_tuple<T>::value)
+ bool priorError = p.unpackError;
+ size_t priorIndex = p.rawIndex;
+ // more stuff to unroll if partial bytes are out
+ size_t priorBitCount = p.bitCount;
+ fixed_uint_t<details::bitStreamSize> priorBits = p.bitStream;
+ int ret = p.unpack(t);
+ if (ret != 0)
{
- bool priorError = p.unpackError;
- size_t priorIndex = p.rawIndex;
- // more stuff to unroll if partial bytes are out
- size_t priorBitCount = p.bitCount;
- fixed_uint_t<details::bitStreamSize> priorBits = p.bitStream;
- int ret = p.unpack(t);
- if (ret != 0)
- {
- t = T();
- p.rawIndex = priorIndex;
- p.bitStream = priorBits;
- p.bitCount = priorBitCount;
- p.unpackError = priorError;
- }
- return 0;
+ t = T();
+ p.rawIndex = priorIndex;
+ p.bitStream = priorBits;
+ p.bitCount = priorBitCount;
+ p.unpackError = priorError;
}
+ return ret;
+ }
+ else
+ {
+ static_assert(
+ utility::dependent_false<T>::value,
+ "Attempt to unpack a type that has no IPMI unpack operation");
}
}
};
@@ -289,18 +292,21 @@ struct UnpackSingle<std::vector<T>>
{
static int op(Payload& p, std::vector<T>& t)
{
- int ret = 0;
while (p.rawIndex < p.raw.size())
{
t.emplace_back();
- ret = UnpackSingle<T>::op(p, t.back());
- if (ret)
+ if (UnpackSingle<T>::op(p, t.back()))
{
t.pop_back();
break;
}
}
- return ret;
+ // unpacking a vector is always successful:
+ // either stuff was unpacked successfully (return 0)
+ // or stuff was not unpacked, but should still return
+ // success because an empty vector or a not-fully-unpacked
+ // payload is not a failure.
+ return 0;
}
};
@@ -324,13 +330,9 @@ struct UnpackSingle<Payload>
{
static int op(Payload& p, Payload& t)
{
+ t = p;
// mark that this payload is being included in the args
p.trailingOk = true;
- t = p;
- // reset the unpacking flags so it can be properly checked
- t.trailingOk = false;
- t.unpackCheck = true;
- t.unpackError = false;
return 0;
}
};
diff --git a/include/ipmid/sessiondef.hpp b/include/ipmid/sessiondef.hpp
new file mode 100644
index 0000000..ac63f8f
--- /dev/null
+++ b/include/ipmid/sessiondef.hpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#pragma once
+
+namespace session
+{
+
+static constexpr auto sessionManagerRootPath =
+ "/xyz/openbmc_project/ipmi/session";
+static constexpr auto sessionIntf = "xyz.openbmc_project.Ipmi.SessionInfo";
+static constexpr uint8_t ipmi20VerSession = 0x01;
+static constexpr size_t maxSessionCountPerChannel = 15;
+static constexpr size_t sessionZero = 0;
+static constexpr size_t maxSessionlessCount = 1;
+static constexpr uint8_t invalidSessionID = 0;
+static constexpr uint8_t invalidSessionHandle = 0;
+static constexpr uint8_t defaultSessionHandle = 0xFF;
+static constexpr uint8_t maxNetworkInstanceSupported = 4;
+static constexpr uint8_t ccInvalidSessionId = 0x87;
+static constexpr uint8_t ccInvalidSessionHandle = 0x88;
+static constexpr uint8_t searchCurrentSession = 0;
+static constexpr uint8_t searchSessionByHandle = 0xFE;
+static constexpr uint8_t searchSessionById = 0xFF;
+// MSB BIT 7 BIT 6 assigned for netipmid instance in session handle.
+static constexpr uint8_t multiIntfaceSessionHandleMask = 0x3F;
+
+// MSB BIT 31-BIT30 assigned for netipmid instance in session ID
+static constexpr uint32_t multiIntfaceSessionIDMask = 0x3FFFFFFF;
+
+enum class State : uint8_t
+{
+ inactive, // Session is not in use
+ setupInProgress, // Session Setup Sequence is progressing
+ active, // Session is active
+ tearDownInProgress, // When Closing Session
+};
+
+} // namespace session
diff --git a/include/ipmid/sessionhelper.hpp b/include/ipmid/sessionhelper.hpp
new file mode 100644
index 0000000..a96f037
--- /dev/null
+++ b/include/ipmid/sessionhelper.hpp
@@ -0,0 +1,88 @@
+#include <sstream>
+#include <string>
+
+/**
+ * @brief parse session input payload.
+ *
+ * This function retrives the session id and session handle from the session
+ * object path.
+ * A valid object path will be in the form
+ * "/xyz/openbmc_project/ipmi/session/channel/sessionId_sessionHandle"
+ *
+ * Ex: "/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a"
+ * SessionId : 0X12a4567d
+ * SessionHandle: 0X8a
+
+ * @param[in] objectPath - session object path
+ * @param[in] sessionId - retrived session id will be asigned.
+ * @param[in] sessionHandle - retrived session handle will be asigned.
+ *
+ * @return true if session id and session handle are retrived else returns
+ * false.
+ */
+bool parseCloseSessionInputPayload(const std::string& objectPath,
+ uint32_t& sessionId, uint8_t& sessionHandle)
+{
+ if (objectPath.empty())
+ {
+ return false;
+ }
+ // getting the position of session id and session handle string from
+ // object path.
+ std::size_t ptrPosition = objectPath.rfind("/");
+ uint16_t tempSessionHandle = 0;
+
+ if (ptrPosition != std::string::npos)
+ {
+ // get the sessionid & session handle string from the session object
+ // path Ex: sessionIdString: "12a4567d_8a"
+ std::string sessionIdString = objectPath.substr(ptrPosition + 1);
+ std::size_t pos = sessionIdString.rfind("_");
+
+ if (pos != std::string::npos)
+ {
+ // extracting the session handle
+ std::string sessionHandleString = sessionIdString.substr(pos + 1);
+ // extracting the session id
+ sessionIdString = sessionIdString.substr(0, pos);
+ // converting session id string and session handle string to
+ // hexadecimal.
+ std::stringstream handle(sessionHandleString);
+ handle >> std::hex >> tempSessionHandle;
+ sessionHandle = tempSessionHandle & 0xFF;
+ std::stringstream idString(sessionIdString);
+ idString >> std::hex >> sessionId;
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * @brief is session object matched.
+ *
+ * This function checks whether the objectPath contains reqSessionId and
+ * reqSessionHandle, e.g., "/xyz/openbmc_project/ipmi/session/eth0/12a4567d_8a"
+ * matches sessionId 0x12a4567d and sessionHandle 0x8a.
+ *
+ * @param[in] objectPath - session object path
+ * @param[in] reqSessionId - request session id
+ * @param[in] reqSessionHandle - request session handle
+ *
+ * @return true if the object is matched else return false
+ **/
+bool isSessionObjectMatched(const std::string objectPath,
+ const uint32_t reqSessionId,
+ const uint8_t reqSessionHandle)
+{
+ uint32_t sessionId = 0;
+ uint8_t sessionHandle = 0;
+
+ if (parseCloseSessionInputPayload(objectPath, sessionId, sessionHandle))
+ {
+ return (reqSessionId == sessionId) ||
+ (reqSessionHandle == sessionHandle);
+ }
+
+ return false;
+}
diff --git a/include/ipmid/types.hpp b/include/ipmid/types.hpp
index 57c5873..3e64cb4 100644
--- a/include/ipmid/types.hpp
+++ b/include/ipmid/types.hpp
@@ -5,6 +5,7 @@
#include <map>
#include <sdbusplus/server.hpp>
#include <string>
+#include <variant>
namespace ipmi
{
@@ -15,9 +16,8 @@ using DbusInterface = std::string;
using DbusObjectInfo = std::pair<DbusObjectPath, DbusService>;
using DbusProperty = std::string;
-using Value = sdbusplus::message::variant<bool, uint8_t, int16_t, uint16_t,
- int32_t, uint32_t, int64_t, uint64_t,
- double, std::string>;
+using Value = std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
+ int64_t, uint64_t, double, std::string>;
using PropertyMap = std::map<DbusProperty, Value>;
@@ -100,7 +100,15 @@ struct GetReadingResponse
constexpr auto inventoryRoot = "/xyz/openbmc_project/inventory";
-using GetSensorResponse = std::array<uint8_t, sizeof(GetReadingResponse)>;
+struct GetSensorResponse
+{
+ uint8_t reading; // sensor reading
+ bool readingOrStateUnavailable; // 1 = reading/state unavailable
+ bool scanningEnabled; // 0 = sensor scanning disabled
+ bool allEventMessagesEnabled; // 0 = All Event Messages disabled
+ uint8_t thresholdLevelsStates; // threshold/discrete sensor states
+ uint8_t discreteReadingSensorStates; // discrete-only, optional states
+};
using OffsetValueMap = std::map<Offset, Values>;
@@ -215,12 +223,7 @@ using EntityInfoMap = std::map<Id, EntityInfo>;
namespace network
{
-using ChannelEthMap = std::map<int, std::string>;
-
constexpr auto MAC_ADDRESS_FORMAT = "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx";
-constexpr auto IP_ADDRESS_FORMAT = "%u.%u.%u.%u";
-constexpr auto PREFIX_FORMAT = "%hhd";
-constexpr auto ADDR_TYPE_FORMAT = "%hhx";
constexpr auto IPV4_ADDRESS_SIZE_BYTE = 4;
constexpr auto IPV6_ADDRESS_SIZE_BYTE = 16;
@@ -228,20 +231,6 @@ constexpr auto IPV6_ADDRESS_SIZE_BYTE = 16;
constexpr auto DEFAULT_MAC_ADDRESS = "00:00:00:00:00:00";
constexpr auto DEFAULT_ADDRESS = "0.0.0.0";
-constexpr auto MAC_ADDRESS_SIZE_BYTE = 6;
-constexpr auto VLAN_SIZE_BYTE = 2;
-constexpr auto IPSRC_SIZE_BYTE = 1;
-constexpr auto BITS_32 = 32;
-constexpr auto MASK_32_BIT = 0xFFFFFFFF;
-constexpr auto VLAN_ID_MASK = 0x00000FFF;
-constexpr auto VLAN_ENABLE_MASK = 0x8000;
-
-enum class IPOrigin : uint8_t
-{
- UNSPECIFIED = 0,
- STATIC = 1,
- DHCP = 2,
-};
-
} // namespace network
+
} // namespace ipmi
diff --git a/include/ipmid/utility.hpp b/include/ipmid/utility.hpp
index 79c76f7..0c39e92 100644
--- a/include/ipmid/utility.hpp
+++ b/include/ipmid/utility.hpp
@@ -214,6 +214,13 @@ struct is_tuple<std::tuple<T...>> : std::true_type
{
};
+/** @brief used for static_assert in a constexpr-if else statement
+ */
+template <typename T>
+struct dependent_false : std::false_type
+{
+};
+
} // namespace utility
} // namespace ipmi
diff --git a/include/ipmid/utils.hpp b/include/ipmid/utils.hpp
index 9ef1488..3515eb6 100644
--- a/include/ipmid/utils.hpp
+++ b/include/ipmid/utils.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <chrono>
+#include <ipmid/api-types.hpp>
#include <ipmid/types.hpp>
#include <optional>
#include <sdbusplus/server.hpp>
@@ -112,20 +113,6 @@ DbusObjectInfo getDbusObject(sdbusplus::bus::bus& bus,
const std::string& subtreePath = ROOT,
const std::string& match = {});
-/** @brief Get the ipObject of first dbus IP object of Non-LinkLocalIPAddress
- * type from the given subtree, if not available gets IP object of
- * LinkLocalIPAddress type.
- * @param[in] bus - DBUS Bus Object.
- * @param[in] interface - Dbus interface.
- * @param[in] subtreePath - subtree from where the search should start.
- * @param[in] match - identifier for object.
- * @return On success returns the object having objectpath and servicename.
- */
-DbusObjectInfo getIPObject(sdbusplus::bus::bus& bus,
- const std::string& interface,
- const std::string& subtreePath,
- const std::string& match);
-
/** @brief Gets the value associated with the given object
* and the interface.
* @param[in] bus - DBUS Bus Object.
@@ -250,59 +237,13 @@ void callDbusMethod(sdbusplus::bus::bus& bus, const std::string& service,
} // namespace method_no_args
-namespace network
-{
-
-constexpr auto ROOT = "/xyz/openbmc_project/network";
-constexpr auto SERVICE = "xyz.openbmc_project.Network";
-constexpr auto IP_TYPE = "ipv4";
-constexpr auto IPV4_PREFIX = "169.254";
-constexpr auto IPV6_PREFIX = "fe80";
-constexpr auto IP_INTERFACE = "xyz.openbmc_project.Network.IP";
-constexpr auto MAC_INTERFACE = "xyz.openbmc_project.Network.MACAddress";
-constexpr auto SYSTEMCONFIG_INTERFACE =
- "xyz.openbmc_project.Network.SystemConfiguration";
-constexpr auto ETHERNET_INTERFACE =
- "xyz.openbmc_project.Network.EthernetInterface";
-constexpr auto IP_CREATE_INTERFACE = "xyz.openbmc_project.Network.IP.Create";
-constexpr auto VLAN_CREATE_INTERFACE =
- "xyz.openbmc_project.Network.VLAN.Create";
-constexpr auto VLAN_INTERFACE = "xyz.openbmc_project.Network.VLAN";
-
-/* @brief converts the given subnet into prefix notation.
- * @param[in] addressFamily - IP address family(AF_INET/AF_INET6).
- * @param[in] mask - Subnet Mask.
- * @returns prefix.
+/** @brief Perform the low-level i2c bus write-read.
+ * @param[in] i2cBus - i2c bus device node name, such as /dev/i2c-2.
+ * @param[in] slaveAddr - i2c device slave address.
+ * @param[in] writeData - The data written to i2c device.
+ * @param[out] readBuf - Data read from the i2c device.
*/
-uint8_t toPrefix(int addressFamily, const std::string& subnetMask);
-
-/** @brief Sets the ip on the system.
- * @param[in] bus - DBUS Bus Object.
- * @param[in] service - Dbus service name.
- * @param[in] objPath - Dbus object path.
- * @param[in] protocolType - Protocol type
- * @param[in] ipaddress - IPaddress.
- * @param[in] prefix - Prefix length.
- */
-void createIP(sdbusplus::bus::bus& bus, const std::string& service,
- const std::string& objPath, const std::string& protocolType,
- const std::string& ipaddress, uint8_t prefix);
-
-/** @brief Creates the VLAN on the given interface.
- * @param[in] bus - DBUS Bus Object.
- * @param[in] service - Dbus service name.
- * @param[in] objPath - Dbus object path.
- * @param[in] interface - EthernetInterface.
- * @param[in] vlanID - Vlan ID.
- */
-void createVLAN(sdbusplus::bus::bus& bus, const std::string& service,
- const std::string& objPath, const std::string& interface,
- uint32_t vlanID);
-
-/** @brief Gets the vlan id from the given object path.
- * @param[in] path - Dbus object path.
- */
-uint32_t getVLAN(const std::string& path);
-
-} // namespace network
+ipmi::Cc i2cWriteRead(std::string i2cBus, const uint8_t slaveAddr,
+ std::vector<uint8_t> writeData,
+ std::vector<uint8_t>& readBuf);
} // namespace ipmi
OpenPOWER on IntegriCloud