1 /*
2 * Generated using zcbor version 0.3.99
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_1.h"
13
14 #if DEFAULT_MAX_QTY != 3
15 #error "The type file was generated with a different default_max_qty than this file"
16 #endif
17
18
decode_message_1(zcbor_state_t * state,struct message_1 * result)19 static bool decode_message_1(
20 zcbor_state_t *state, struct message_1 *result)
21 {
22 zcbor_print("%s\r\n", __func__);
23 bool int_res;
24
25 bool tmp_result = (((((zcbor_int32_decode(state, (&(*result)._message_1_METHOD))))
26 && ((zcbor_union_start_code(state) && (int_res = ((((zcbor_list_start_decode(state) && (int_res = (zcbor_multi_decode(2, 10, &(*result)._SUITES_I__suite_suite_count, (zcbor_decoder_t *)zcbor_int32_decode, state, (&(*result)._SUITES_I__suite_suite), sizeof(int32_t))), ((zcbor_list_end_decode(state)) && int_res)))) && (((*result)._message_1_SUITES_I_choice = _SUITES_I__suite) || 1))
27 || (zcbor_union_elem_code(state) && (((zcbor_int32_decode(state, (&(*result)._message_1_SUITES_I_int)))) && (((*result)._message_1_SUITES_I_choice = _message_1_SUITES_I_int) || 1)))), zcbor_union_end_code(state), int_res)))
28 && ((zcbor_bstr_decode(state, (&(*result)._message_1_G_X))))
29 && ((zcbor_union_start_code(state) && (int_res = ((((zcbor_int32_decode(state, (&(*result)._message_1_C_I_int)))) && (((*result)._message_1_C_I_choice = _message_1_C_I_int) || 1))
30 || (((zcbor_bstr_decode(state, (&(*result)._message_1_C_I_bstr)))) && (((*result)._message_1_C_I_choice = _message_1_C_I_bstr) || 1))), zcbor_union_end_code(state), int_res)))
31 && zcbor_present_decode(&((*result)._message_1_ead_1_present), (zcbor_decoder_t *)zcbor_bstr_decode, state, (&(*result)._message_1_ead_1)))));
32
33 if (!tmp_result)
34 zcbor_trace();
35
36 return tmp_result;
37 }
38
39
40
cbor_decode_message_1(const uint8_t * payload,size_t payload_len,struct message_1 * result,size_t * payload_len_out)41 bool cbor_decode_message_1(
42 const uint8_t *payload, size_t payload_len,
43 struct message_1 *result,
44 size_t *payload_len_out)
45 {
46 zcbor_state_t states[4];
47
48 zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 5);
49
50 bool ret = decode_message_1(states, result);
51
52 if (ret && (payload_len_out != NULL)) {
53 *payload_len_out = MIN(payload_len,
54 (size_t)states[0].payload - (size_t)payload);
55 }
56
57 return ret;
58 }
59