9
9
10
10
#include <inttypes.h>
11
11
#include "img_mgmt_config.h"
12
+ #include "image.h"
12
13
#include "mgmt/mgmt.h"
13
14
#include <zcbor_common.h>
14
15
@@ -213,15 +214,14 @@ struct img_mgmt_dfu_callbacks_t {
213
214
* proceeds. If the callback returns nonzero, the request is rejected with a
214
215
* response containing an `rc` value equal to the return code.
215
216
*
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
220
219
*
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.
223
222
*/
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 );
225
225
226
226
/**
227
227
* @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);
233
233
* response containing an `rc` value equal to the return code.
234
234
*
235
235
* @param cb The callback to execute on rx of an upload request.
236
- * @param arg Optional argument that gets passed to the callback.
237
236
*/
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 );
239
238
void img_mgmt_register_callbacks (const struct img_mgmt_dfu_callbacks_t * cb_struct );
240
239
void img_mgmt_dfu_stopped (void );
241
240
void img_mgmt_dfu_started (void );
242
241
void img_mgmt_dfu_pending (void );
243
242
void img_mgmt_dfu_confirmed (void );
244
243
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
+
245
256
#ifdef CONFIG_IMG_MGMT_VERBOSE_ERR
246
257
#define IMG_MGMT_UPLOAD_ACTION_SET_RC_RSN (action , rsn ) ((action)->rc_rsn = (rsn))
247
258
#define IMG_MGMT_UPLOAD_ACTION_RC_RSN (action ) ((action)->rc_rsn)
0 commit comments