99
1010#include <inttypes.h>
1111#include "img_mgmt_config.h"
12+ #include "image.h"
1213#include "mgmt/mgmt.h"
1314#include <zcbor_common.h>
1415
@@ -213,15 +214,14 @@ struct img_mgmt_dfu_callbacks_t {
213214 * proceeds. If the callback returns nonzero, the request is rejected with a
214215 * response containing an `rc` value equal to the return code.
215216 *
216- * @param offset The offset specified by the incoming request.
217- * @param size The total size of the image being uploaded.
218- * @param arg Optional argument specified when the callback
219- * was configured.
217+ * @param req Image upload request structure
218+ * @param action Image upload action structure
220219 *
221- * @return 0 if the upload request should be accepted; nonzero to reject the request with the
222- * specified status.
220+ * @return 0 if the upload request should be accepted; nonzero to reject
221+ * the request with the specified status.
223222 */
224- typedef int (* img_mgmt_upload_fn )(uint32_t offset , uint32_t size , void * arg );
223+ typedef int (* img_mgmt_upload_fn )(const struct img_mgmt_upload_req req ,
224+ const struct img_mgmt_upload_action action );
225225
226226/**
227227 * @brief Configures a callback that gets called whenever a valid image upload
@@ -233,15 +233,26 @@ typedef int (*img_mgmt_upload_fn)(uint32_t offset, uint32_t size, void *arg);
233233 * response containing an `rc` value equal to the return code.
234234 *
235235 * @param cb The callback to execute on rx of an upload request.
236- * @param arg Optional argument that gets passed to the callback.
237236 */
238- void img_mgmt_set_upload_cb (img_mgmt_upload_fn cb , void * arg );
237+ void img_mgmt_set_upload_cb (img_mgmt_upload_fn cb );
239238void img_mgmt_register_callbacks (const struct img_mgmt_dfu_callbacks_t * cb_struct );
240239void img_mgmt_dfu_stopped (void );
241240void img_mgmt_dfu_started (void );
242241void img_mgmt_dfu_pending (void );
243242void img_mgmt_dfu_confirmed (void );
244243
244+ /**
245+ * Compares two image version numbers in a semver-compatible way.
246+ *
247+ * @param a The first version to compare.
248+ * @param b The second version to compare.
249+ *
250+ * @return -1 if a < b
251+ * @return 0 if a = b
252+ * @return 1 if a > b
253+ */
254+ int img_mgmt_vercmp (const struct image_version * a , const struct image_version * b );
255+
245256#ifdef CONFIG_IMG_MGMT_VERBOSE_ERR
246257#define IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN (action , rsn ) ((action)->rc_rsn = (rsn))
247258#define IMG_MGMT_UPLOAD_ACTION_RC_RSN (action ) ((action)->rc_rsn)
0 commit comments