1 // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 2 #ifndef LIBPLDM_SRC_UTILS_H 3 #define LIBPLDM_SRC_UTILS_H 4 5 #include <errno.h> 6 #include <stdint.h> 7 #include <stddef.h> 8 #include <stdbool.h> 9 10 /** 11 * @brief Validate the CRC32 checksum of the given data. 12 * 13 * @param[in] expected The expected CRC32 value. 14 * @param[in] data Pointer to the data to validate. 15 * @param[in] size Size of the data in bytes. 16 * @return 0 if the checksum matches, 17 * -EUCLEAN if the checksum mismatches, 18 * -EINVAL if the arguments are invalid 19 */ 20 int pldm_edac_crc32_validate(uint32_t expected, const void *data, size_t size); 21 22 /** @brief Check whether the input time is legal 23 * 24 * @param[in] seconds. Value range 0~59 25 * @param[in] minutes. Value range 0~59 26 * @param[in] hours. Value range 0~23 27 * @param[in] day. Value range 1~31 28 * @param[in] month. Value range 1~12 29 * @param[in] year. Value range 1970~ 30 * @return true if time is legal,false if time is illegal 31 */ 32 bool is_time_legal(uint8_t seconds, uint8_t minutes, uint8_t hours, uint8_t day, 33 uint8_t month, uint16_t year); 34 35 /** @brief Check whether transfer flag is valid 36 * 37 * @param[in] transfer_flag - TransferFlag 38 * 39 * @return true if transfer flag is valid, false if not 40 */ 41 bool is_transfer_flag_valid(uint8_t transfer_flag); 42 #endif 43