handlers.h
1 /*
2  * Copyright (C) 2019 Koen Zandberg
3  * 2019 Kaspar Schleiser <kaspar@schleiser.de>
4  * 2019 Inria
5  * 2019 Freie Universit├Ąt Berlin
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser
8  * General Public License v2.1. See the file LICENSE in the top level
9  * directory for more details.
10  */
24 #ifndef SUIT_HANDLERS_H
25 #define SUIT_HANDLERS_H
26 
27 #include <stddef.h>
28 #include <stdint.h>
29 
30 #include "suit.h"
31 #include "uuid.h"
32 #include "nanocbor/nanocbor.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
42 #define SUIT_WRAPPER_AUTHENTICATION (2)
43 #define SUIT_WRAPPER_MANIFEST (3)
44 
50 #define SUIT_CONTAINER_VERSION (1)
51 #define SUIT_CONTAINER_SEQ_NO (2)
52 #define SUIT_CONTAINER_COMMON (3)
53 #define SUIT_CONTAINER_DEPS_RESOLUTION (7)
54 #define SUIT_CONTAINER_PAYLOAD_FETCH (8)
55 #define SUIT_CONTAINER_INSTALL (9)
56 #define SUIT_CONTAINER_VALIDATE (10)
57 #define SUIT_CONTAINER_LOAD (11)
58 #define SUIT_CONTAINER_RUN (12)
59 #define SUIT_CONTAINER_TEXT (13)
60 
66 #define SUIT_COMMON_DEPENDENCIES (1)
67 #define SUIT_COMMON_COMPONENTS (2)
68 #define SUIT_COMMON_DEP_COMPONENTS (3)
69 #define SUIT_COMMON_COMMAND_SEQUENCE (4)
70 
76 #define SUIT_COND_VENDOR_ID (1)
77 #define SUIT_COND_CLASS_ID (2)
78 #define SUIT_COND_IMAGE_MATCH (3)
79 #define SUIT_COND_USE_BEFORE (4)
80 #define SUIT_COND_COMPONENT_OFFSET (5)
81 #define SUIT_COND_DEVICE_ID (24)
82 #define SUIT_COND_IMAGE_NOT_MATCH (25)
83 #define SUIT_COND_MIN_BATTERY (26)
84 #define SUIT_COND_UPDATE_AUTHZ (27)
85 #define SUIT_COND_VERSION (28)
86 
92 #define SUIT_DIR_SET_COMPONENT_IDX (12)
93 #define SUIT_DIR_SET_DEPENDENCY_IDX (13)
94 #define SUIT_DIR_ABORT (14)
95 #define SUIT_DIR_TRY_EACH (15)
96 #define SUIT_DIR_PROCESS_DEPS (18)
97 #define SUIT_DIR_SET_PARAM (19)
98 #define SUIT_DIR_OVERRIDE_PARAM (20)
99 #define SUIT_DIR_FETCH (21)
100 #define SUIT_DIR_COPY (22)
101 #define SUIT_DIR_RUN (23)
102 #define SUIT_DIR_WAIT (29)
103 #define SUIT_DIR_RUN_SEQUENCE (30)
104 #define SUIT_DIR_RUN_WITH_ARGS (31)
105 #define SUIT_DIR_SWAP (32)
106 
118 typedef int (*suit_manifest_handler_t)(suit_manifest_t *manifest, int key,
119  nanocbor_value_t *it);
120 
124 extern const suit_manifest_handler_t suit_global_handlers[];
125 extern const size_t suit_global_handlers_len;
126 
130 extern const suit_manifest_handler_t suit_command_sequence_handlers[];
131 
135 extern const size_t suit_command_sequence_handlers_len;
136 
140 extern const suit_manifest_handler_t suit_container_handlers[];
141 
145 extern const size_t suit_container_handlers_len;
146 
150 extern const suit_manifest_handler_t suit_common_handlers[];
151 
155 extern const size_t suit_common_handlers_len;
156 
171 int suit_handle_manifest_structure(suit_manifest_t *manifest,
172  nanocbor_value_t *it,
173  const suit_manifest_handler_t *handlers,
174  size_t handlers_len);
175 
191 int suit_handle_manifest_structure_bstr(suit_manifest_t *manifest,
192  nanocbor_value_t *bseq,
193  const suit_manifest_handler_t *handlers,
194  size_t handlers_len);
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif /* SUIT_HANDLERS_H */
201 
RFC 4122 UUID functions
SUIT manifest struct.
Definition: suit.h:141