LCOV - code coverage report
Current view: top level - zephyr/mgmt/mcumgr/grp/fs_mgmt - fs_mgmt_hash_checksum.h Coverage Total Hit
Test: new.info Lines: 92.3 % 13 12
Test Date: 2025-09-05 20:47:19

            Line data    Source code
       1            0 : /*
       2              :  * Copyright (c) 2018-2022 mcumgr authors
       3              :  * Copyright (c) 2022 Laird Connectivity
       4              :  * Copyright (c) 2022 Nordic Semiconductor ASA
       5              :  *
       6              :  * SPDX-License-Identifier: Apache-2.0
       7              :  */
       8              : 
       9              : #ifndef H_MGMT_MCUMGR_GRP_FS_MGMT_CHKSUM_
      10              : #define H_MGMT_MCUMGR_GRP_FS_MGMT_CHKSUM_
      11              : 
      12              : #include <zephyr/kernel.h>
      13              : #include <zephyr/fs/fs.h>
      14              : 
      15              : #ifdef __cplusplus
      16              : extern "C" {
      17              : #endif
      18              : 
      19              : /** @typedef fs_mgmt_hash_checksum_handler_fn
      20              :  * @brief Function that gets called to generate a hash or checksum.
      21              :  *
      22              :  * @param file          Opened file context
      23              :  * @param output        Output buffer for hash/checksum
      24              :  * @param out_len       Updated with size of input data
      25              :  * @param len           Maximum length of data to perform hash/checksum on
      26              :  *
      27              :  * @return 0 on success, negative error code on failure.
      28              :  */
      29            1 : typedef int (*fs_mgmt_hash_checksum_handler_fn)(struct fs_file_t *file, uint8_t *output,
      30              :                                                 size_t *out_len, size_t len);
      31              : 
      32              : /**
      33              :  * @brief A collection of handlers for an entire hash/checksum group.
      34              :  */
      35            1 : struct fs_mgmt_hash_checksum_group {
      36              :         /** Entry list node. */
      37            1 :         sys_snode_t node;
      38              : 
      39              :         /** Array of handlers; one entry per name. */
      40            1 :         const char *group_name;
      41              : 
      42              :         /** Byte string or numerical output. */
      43            1 :         bool byte_string;
      44              : 
      45              :         /** Size (in bytes) of output. */
      46            1 :         uint8_t output_size;
      47              : 
      48              :         /** Hash/checksum function pointer. */
      49            1 :         fs_mgmt_hash_checksum_handler_fn function;
      50              : };
      51              : 
      52              : /** @typedef fs_mgmt_hash_checksum_list_cb
      53              :  * @brief Function that gets called with hash/checksum details
      54              :  *
      55              :  * @param group         Details about a supported hash/checksum
      56              :  * @param user_data     User-supplied value to calling function
      57              :  */
      58            1 : typedef void (*fs_mgmt_hash_checksum_list_cb)(const struct fs_mgmt_hash_checksum_group *group,
      59              :                                               void *user_data);
      60              : 
      61              : /**
      62              :  * @brief Registers a full hash/checksum group.
      63              :  *
      64              :  * @param group The group to register.
      65              :  */
      66            1 : void fs_mgmt_hash_checksum_register_group(struct fs_mgmt_hash_checksum_group *group);
      67              : 
      68              : /**
      69              :  * @brief Unregisters a full hash/checksum group.
      70              :  *
      71              :  * @param group The group to register.
      72              :  */
      73            1 : void fs_mgmt_hash_checksum_unregister_group(struct fs_mgmt_hash_checksum_group *group);
      74              : 
      75              : /**
      76              :  * @brief Finds a registered hash/checksum handler.
      77              :  *
      78              :  * @param name  The name of the hash/checksum group to find.
      79              :  *
      80              :  * @return      The requested hash/checksum handler on success;
      81              :  *              NULL on failure.
      82              :  */
      83            1 : const struct fs_mgmt_hash_checksum_group *fs_mgmt_hash_checksum_find_handler(const char *name);
      84              : 
      85              : /**
      86              :  * @brief Runs a callback with all supported hash/checksum types.
      87              :  *
      88              :  * @param cb            The callback function to call with each hash/checksum type.
      89              :  * @param user_data     Data to pass back with the callback function.
      90              :  */
      91            1 : void fs_mgmt_hash_checksum_find_handlers(fs_mgmt_hash_checksum_list_cb cb, void *user_data);
      92              : 
      93              : #ifdef __cplusplus
      94              : }
      95              : #endif
      96              : 
      97              : #endif /* ifndef H_MGMT_MCUMGR_GRP_FS_MGMT_CHKSUM_ */
        

Generated by: LCOV version 2.0-1