#pragma once #include #include #include #include namespace ipmi { using DbusObjectPath = std::string; using DbusService = std::string; using DbusInterface = std::string; using DbusObjectInfo = std::pair; using DbusProperty = std::string; using Value = sdbusplus::message::variant; using PropertyMap = std::map; using ObjectTree = std::map>>; using InterfaceList = std::vector; using DbusInterfaceMap = std::map; using ObjectValueTree = std::map; namespace sensor { using Offset = uint8_t; /** * @enum SkipAssertion * Matching value for skipping the update */ enum class SkipAssertion { NONE, //No skip defined ASSERT, //Skip on Assert DEASSERT, //Skip on Deassert }; struct Values { SkipAssertion skip; Value assert; Value deassert; }; /** * @enum PreReqValues * Pre-req conditions for a property. */ struct PreReqValues { Value assert; //Value in case of assert. Value deassert; //Value in case of deassert. }; using PreReqOffsetValueMap = std::map; /** * @struct SetSensorReadingReq * * IPMI Request data for Set Sensor Reading and Event Status Command */ struct SetSensorReadingReq { uint8_t number; uint8_t operation; uint8_t reading; uint8_t assertOffset0_7; uint8_t assertOffset8_14; uint8_t deassertOffset0_7; uint8_t deassertOffset8_14; uint8_t eventData1; uint8_t eventData2; uint8_t eventData3; } __attribute__((packed)); /** * @struct GetReadingResponse * * IPMI response data for Get Sensor Reading command. */ struct GetReadingResponse { uint8_t reading; //!< Sensor reading. uint8_t operation; //!< Sensor scanning status / reading state. uint8_t assertOffset0_7; //!< Discrete assertion states(0-7). uint8_t assertOffset8_14; //!< Discrete assertion states(8-14). } __attribute__((packed)); constexpr auto inventoryRoot = "/xyz/openbmc_project/inventory"; using GetSensorResponse = std::array; using OffsetValueMap = std::map; using DbusPropertyValues = std::pair; using DbusPropertyMap = std::map; using DbusInterfaceMap = std::map; using InstancePath = std::string; using Type = uint8_t; using ReadingType = uint8_t; using Multiplier = uint16_t; using OffsetB = uint16_t; using Exponent = uint8_t; using ScaledOffset = int64_t; using Scale = int16_t; using Unit = std::string; using EntityType = uint8_t; using EntityInst = uint8_t; using SensorName = std::string; enum class Mutability { Read = 1 << 0, Write = 1 << 1, }; inline Mutability operator|(Mutability lhs, Mutability rhs) { return static_cast( static_cast(lhs) | static_cast(rhs)); } inline Mutability operator&(Mutability lhs, Mutability rhs) { return static_cast( static_cast(lhs) & static_cast(rhs)); } struct Info { EntityType entityType; EntityInst instance; Type sensorType; InstancePath sensorPath; DbusInterface sensorInterface; ReadingType sensorReadingType; Multiplier coefficientM; OffsetB coefficientB; Exponent exponentB; ScaledOffset scaledOffset; bool hasScale; Scale scale; Unit unit; std::function updateFunc; std::function getFunc; Mutability mutability; std::function sensorNameFunc; DbusInterfaceMap propertyInterfaces; }; using Id = uint8_t; using IdInfoMap = std::map; using PropertyMap = ipmi::PropertyMap; using InterfaceMap = std::map; using Object = sdbusplus::message::object_path; using ObjectMap = std::map; using IpmiUpdateData = sdbusplus::message::message; struct SelData { Id sensorID; Type sensorType; ReadingType eventReadingType; Offset eventOffset; }; using InventoryPath = std::string; using InvObjectIDMap = std::map; enum class ThresholdMask { NON_CRITICAL_LOW_MASK = 0x01, CRITICAL_LOW_MASK = 0x02, NON_CRITICAL_HIGH_MASK = 0x08, CRITICAL_HIGH_MASK = 0x10, }; enum class ThresholdIndex { NON_CRITICAL_LOW_IDX = 0, CRITICAL_LOW_IDX = 1, NON_RECOVERABLE_LOW_IDX = 2, NON_CRITICAL_HIGH_IDX = 3, CRITICAL_HIGH_IDX = 4, NON_RECOVERABLE_HIGH_IDX = 5, }; struct ThresholdLevel { std::string property; ThresholdMask maskValue; ThresholdIndex idx; }; using SensorThresholds = std::vector; using Thresholds = std::map; }// namespace sensor namespace network { using ChannelEthMap = std::map; 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; 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