/src/ipmi-fru-parser/fru_area.hpp
Line | Count | Source |
1 | | #ifndef __IPMI_FRU_AREA_H__ |
2 | | #define __IPMI_FRU_AREA_H__ |
3 | | |
4 | | #include "frup.hpp" |
5 | | #include "writefrudata.hpp" |
6 | | |
7 | | #include <cstdint> |
8 | | #include <memory> |
9 | | #include <string> |
10 | | #include <vector> |
11 | | |
12 | | using std::uint8_t; |
13 | | |
14 | | /** |
15 | | * IPMIFruArea represents a piece of a FRU that is accessible over IPMI. |
16 | | */ |
17 | | class IPMIFruArea |
18 | | { |
19 | | public: |
20 | | IPMIFruArea() = delete; |
21 | 1.25k | ~IPMIFruArea() = default; |
22 | | |
23 | | /** |
24 | | * Construct an IPMIFruArea. |
25 | | * |
26 | | * @param[in] fruID - FRU identifier value |
27 | | * @param[in] type - the type of FRU area. |
28 | | */ |
29 | | IPMIFruArea(const uint8_t fruID, const ipmi_fru_area_type type); |
30 | | |
31 | | /** |
32 | | * Set whether the FRU is present. |
33 | | * |
34 | | * @param[in] present - True if present. |
35 | | */ |
36 | | inline void setPresent(const bool present) |
37 | 0 | { |
38 | 0 | isPresent = present; |
39 | 0 | } |
40 | | |
41 | | /** |
42 | | * Retrieves the FRU's ID. |
43 | | * |
44 | | * @return the FRU ID. |
45 | | */ |
46 | | uint8_t getFruID() const |
47 | 0 | { |
48 | 0 | return fruID; |
49 | 0 | } |
50 | | |
51 | | /** |
52 | | * Returns the length of the FRU data. |
53 | | * |
54 | | * @return the number of bytes. |
55 | | */ |
56 | | size_t getLength() const |
57 | 1.83k | { |
58 | 1.83k | return data.size(); |
59 | 1.83k | } |
60 | | |
61 | | /** |
62 | | * Returns the type of the current FRU area. |
63 | | * |
64 | | * @return the type of FRU area |
65 | | */ |
66 | | ipmi_fru_area_type getType() const |
67 | 2.72k | { |
68 | 2.72k | return type; |
69 | 2.72k | } |
70 | | |
71 | | /** |
72 | | * Returns the FRU area name. |
73 | | * |
74 | | * @return the FRU area name |
75 | | */ |
76 | | const char* getName() const |
77 | 0 | { |
78 | 0 | return name.c_str(); |
79 | 0 | } |
80 | | |
81 | | /** |
82 | | * Returns the data portion. |
83 | | * |
84 | | * @return pointer to data |
85 | | */ |
86 | | inline const uint8_t* getData() const |
87 | 888 | { |
88 | 888 | return data.data(); |
89 | 888 | } |
90 | | |
91 | | /** |
92 | | * Accepts a pointer to data and sets it in the object. |
93 | | * |
94 | | * @param[in] value - The data to copy into the FRU area |
95 | | * @param[in] length - the number of bytes value points to |
96 | | */ |
97 | | void setData(const uint8_t* value, const size_t length); |
98 | | |
99 | | private: |
100 | | // Unique way of identifying a FRU |
101 | | uint8_t fruID = 0; |
102 | | |
103 | | // Type of the FRU matching offsets in common header |
104 | | ipmi_fru_area_type type = IPMI_FRU_AREA_INTERNAL_USE; |
105 | | |
106 | | // Name of the FRU area. ( BOARD/CHASSIS/PRODUCT ) |
107 | | std::string name; |
108 | | |
109 | | // If a FRU is physically present. |
110 | | bool isPresent = false; |
111 | | |
112 | | // Actual area data. |
113 | | std::vector<uint8_t> data; |
114 | | }; |
115 | | |
116 | | #endif |