1 /*
2 * Generated using zcbor version 0.8.0
3 * https://github.com/NordicSemiconductor/zcbor
4 * Generated with a --default-max-qty of 3
5 */
6
7 #include <stdint.h>
8 #include <stdbool.h>
9 #include <stddef.h>
10 #include <string.h>
11 #include "zcbor_decode.h"
12 #include "cbor/edhoc_decode_message_2.h"
13 #include "zcbor_print.h"
14
15 #if DEFAULT_MAX_QTY != 3
16 #error "The type file was generated with a different default_max_qty than this file"
17 #endif
18
19 static bool decode_m2(zcbor_state_t *state, struct m2 *result);
20
21
decode_m2(zcbor_state_t * state,struct m2 * result)22 static bool decode_m2(
23 zcbor_state_t *state, struct m2 *result)
24 {
25 zcbor_log("%s\r\n", __func__);
26 bool int_res;
27
28 bool tmp_result = (((((zcbor_bstr_decode(state, (&(*result).m2_G_Y_CIPHERTEXT_2))))
29 && ((zcbor_union_start_code(state) && (int_res = ((((zcbor_int32_decode(state, (&(*result).m2_C_R_int)))) && (((*result).m2_C_R_choice = m2_C_R_int_c), true))
30 || (((zcbor_bstr_decode(state, (&(*result).m2_C_R_bstr)))) && (((*result).m2_C_R_choice = m2_C_R_bstr_c), true))), zcbor_union_end_code(state), int_res))))));
31
32 if (!tmp_result) {
33 zcbor_trace_file(state);
34 zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
35 } else {
36 zcbor_log("%s success\r\n", __func__);
37 }
38
39 return tmp_result;
40 }
41
42
43
cbor_decode_m2(const uint8_t * payload,size_t payload_len,struct m2 * result,size_t * payload_len_out)44 int cbor_decode_m2(
45 const uint8_t *payload, size_t payload_len,
46 struct m2 *result,
47 size_t *payload_len_out)
48 {
49 zcbor_state_t states[3];
50
51 return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
52 (zcbor_decoder_t *)decode_m2, sizeof(states) / sizeof(zcbor_state_t), 2);
53 }
54