blob: ae88faa1e5662e3e470adaa93ecfd96e48bda808 [file] [log] [blame]
Ratan Gupta00659052017-02-23 17:29:08 +05301#pragma once
2
3#include <stdint.h>
4
5#include <map>
6#include <string>
7
8#include <sdbusplus/server.hpp>
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -05009#include "sensorhandler.h"
Ratan Gupta00659052017-02-23 17:29:08 +053010
11namespace ipmi
12{
Ratan Guptadcb10672017-07-10 10:33:50 +053013
14using DbusObjectPath = std::string;
15using DbusService = std::string;
16using DbusInterface = std::string;
17using DbusObjectInfo = std::pair<DbusObjectPath, DbusService>;
18using DbusProperty = std::string;
Ratan Guptacc8feb42017-07-25 21:52:10 +053019
20using Value = sdbusplus::message::variant<bool, uint8_t, int16_t,
21 uint16_t, int32_t, uint32_t,
22 int64_t, uint64_t, std::string>;
23
Ratan Guptadcb10672017-07-10 10:33:50 +053024using PropertyMap = std::map<DbusProperty, Value>;
Ratan Guptab8e99552017-07-27 07:07:48 +053025
Ratan Guptadcb10672017-07-10 10:33:50 +053026using ObjectTree = std::map<DbusObjectPath,
27 std::map<DbusService, std::vector<DbusInterface>>>;
Ratan Gupta8c31d232017-08-13 05:49:43 +053028
Ratan Guptacc6cdbf2017-09-01 23:06:25 +053029using InterfaceList = std::vector<std::string>;
30
Ratan Gupta00659052017-02-23 17:29:08 +053031namespace sensor
32{
33
34using Offset = uint8_t;
Ratan Gupta00659052017-02-23 17:29:08 +053035
36struct Values
37{
38 Value assert;
39 Value deassert;
40};
41
42using OffsetValueMap = std::map<Offset,Values>;
43
Ratan Gupta00659052017-02-23 17:29:08 +053044using DbusPropertyMap = std::map<DbusProperty,OffsetValueMap>;
45
Ratan Gupta00659052017-02-23 17:29:08 +053046using DbusInterfaceMap = std::map<DbusInterface,DbusPropertyMap>;
47
48using InstancePath = std::string;
49using Type = uint8_t;
50using ReadingType = uint8_t;
Emily Shaffer10f49592017-05-10 12:01:10 -070051using Multiplier = uint16_t;
52using OffsetB = uint16_t;
53using Exponent = uint8_t;
54using ScaledOffset = int64_t;
Ratan Gupta00659052017-02-23 17:29:08 +053055
Emily Shaffercc941e12017-06-14 13:06:26 -070056enum class Mutability
57{
58 Read = 1 << 0,
59 Write = 1 << 1,
60};
61
62inline Mutability operator|(Mutability lhs, Mutability rhs)
63{
64 return static_cast<Mutability>(
65 static_cast<uint8_t>(lhs) | static_cast<uint8_t>(rhs));
66}
67
68inline Mutability operator&(Mutability lhs, Mutability rhs)
69{
70 return static_cast<Mutability>(
71 static_cast<uint8_t>(lhs) & static_cast<uint8_t>(rhs));
72}
73
Ratan Gupta00659052017-02-23 17:29:08 +053074struct Info
75{
76 Type sensorType;
77 InstancePath sensorPath;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050078 DbusInterface sensorInterface;
Ratan Gupta00659052017-02-23 17:29:08 +053079 ReadingType sensorReadingType;
Emily Shaffer10f49592017-05-10 12:01:10 -070080 Multiplier coefficientM;
81 OffsetB coefficientB;
82 Exponent exponentB;
83 ScaledOffset scaledOffset;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050084 std::function<uint8_t(SetSensorReadingReq&, const Info&)> updateFunc;
Emily Shaffercc941e12017-06-14 13:06:26 -070085 Mutability mutability;
Deepak Kodihalli1bb0d382017-08-12 02:01:27 -050086 DbusInterfaceMap propertyInterfaces;
Ratan Gupta00659052017-02-23 17:29:08 +053087};
88
89using Id = uint8_t;
90using IdInfoMap = std::map<Id,Info>;
91
Ratan Guptadcb10672017-07-10 10:33:50 +053092using PropertyMap = ipmi::PropertyMap;
Tom Josephbe703f72017-03-09 12:34:35 +053093
94using InterfaceMap = std::map<DbusInterface, PropertyMap>;
95
96using Object = sdbusplus::message::object_path;
97using ObjectMap = std::map<Object, InterfaceMap>;
98
Dhruvaraj Subhashchandrane0af7202017-07-12 06:35:20 -050099using IpmiUpdateData = sdbusplus::message::message;
100
Tom Josephdd78a1d2017-05-05 11:04:29 +0530101struct SelData
102{
103 Id sensorID;
104 Type sensorType;
105 ReadingType eventReadingType;
106 Offset eventOffset;
107};
108
109using InventoryPath = std::string;
110
111using InvObjectIDMap = std::map<InventoryPath, SelData>;
112
Ratan Gupta8c31d232017-08-13 05:49:43 +0530113}// namespace sensor
114
115namespace network
116{
117
118constexpr auto MAC_ADDRESS_FORMAT = "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx";
119constexpr auto IP_ADDRESS_FORMAT = "%u.%u.%u.%u";
120constexpr auto PREFIX_FORMAT = "%hhd";
121constexpr auto ADDR_TYPE_FORMAT = "%hhx";
122
123constexpr auto IPV4_ADDRESS_SIZE_BYTE = 4;
124constexpr auto IPV6_ADDRESS_SIZE_BYTE = 16;
125
126constexpr auto DEFAULT_MAC_ADDRESS = "00:00:00:00:00:00";
127constexpr auto DEFAULT_ADDRESS = "0.0.0.0";
128
Ratan Guptab8e99552017-07-27 07:07:48 +0530129constexpr auto MAC_ADDRESS_SIZE_BYTE = 6;
Ratan Gupta533d03b2017-07-30 10:39:22 +0530130constexpr auto VLAN_SIZE_BYTE = 2;
Ratan Guptacc6cdbf2017-09-01 23:06:25 +0530131constexpr auto IPSRC_SIZE_BYTE = 1;
Ratan Guptab8e99552017-07-27 07:07:48 +0530132constexpr auto BITS_32 = 32;
133constexpr auto MASK_32_BIT = 0xFFFFFFFF;
Ratan Gupta533d03b2017-07-30 10:39:22 +0530134constexpr auto VLAN_ID_MASK = 0x00000FFF;
135constexpr auto VLAN_ENABLE_MASK = 0x8000;
Ratan Guptab8e99552017-07-27 07:07:48 +0530136
Ratan Guptacc6cdbf2017-09-01 23:06:25 +0530137enum class IPOrigin: uint8_t
138{
139 UNSPECIFIED = 0,
140 STATIC = 1,
141 DHCP = 2,
142};
143
144
Ratan Gupta8c31d232017-08-13 05:49:43 +0530145}//namespace network
Ratan Gupta00659052017-02-23 17:29:08 +0530146}//namespace ipmi