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 ~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 */ setPresent(const bool present)36 inline void setPresent(const bool present) 37 { 38 isPresent = present; 39 } 40 41 /** 42 * Retrieves the FRU's ID. 43 * 44 * @return the FRU ID. 45 */ getFruID() const46 uint8_t getFruID() const 47 { 48 return fruID; 49 } 50 51 /** 52 * Returns the length of the FRU data. 53 * 54 * @return the number of bytes. 55 */ getLength() const56 size_t getLength() const 57 { 58 return data.size(); 59 } 60 61 /** 62 * Returns the type of the current FRU area. 63 * 64 * @return the type of FRU area 65 */ getType() const66 ipmi_fru_area_type getType() const 67 { 68 return type; 69 } 70 71 /** 72 * Returns the FRU area name. 73 * 74 * @return the FRU area name 75 */ getName() const76 const char* getName() const 77 { 78 return name.c_str(); 79 } 80 81 /** 82 * Returns the data portion. 83 * 84 * @return pointer to data 85 */ getData() const86 inline const uint8_t* getData() const 87 { 88 return data.data(); 89 } 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 117