1 /*
2  * Generated using zcbor version 0.8.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 #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_message_1(zcbor_state_t *state, struct message_1 *result);
20 
21 
decode_message_1(zcbor_state_t * state,struct message_1 * result)22 static bool decode_message_1(
23 		zcbor_state_t *state, struct message_1 *result)
24 {
25 	zcbor_log("%s\r\n", __func__);
26 	bool int_res;
27 
28 	bool tmp_result = (((((zcbor_int32_decode(state, (&(*result).message_1_METHOD))))
29 	&& ((zcbor_union_start_code(state) && (int_res = ((((zcbor_list_start_decode(state) && ((zcbor_multi_decode(2, 10, &(*result).SUITES_I_suite_l_suite_count, (zcbor_decoder_t *)zcbor_int32_decode, state, (&(*result).SUITES_I_suite_l_suite), sizeof(int32_t))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state))) && (((*result).message_1_SUITES_I_choice = SUITES_I_suite_l_c), true))
30 	|| (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_c), true)))), zcbor_union_end_code(state), int_res)))
31 	&& ((zcbor_bstr_decode(state, (&(*result).message_1_G_X))))
32 	&& ((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_c), true))
33 	|| (((zcbor_bstr_decode(state, (&(*result).message_1_C_I_bstr)))) && (((*result).message_1_C_I_choice = message_1_C_I_bstr_c), true))), zcbor_union_end_code(state), int_res)))
34 	&& ((*result).message_1_ead_1_present = ((zcbor_bstr_decode(state, (&(*result).message_1_ead_1)))), 1))));
35 
36 	if (!tmp_result) {
37 		zcbor_trace_file(state);
38 		zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
39 	} else {
40 		zcbor_log("%s success\r\n", __func__);
41 	}
42 
43 	return tmp_result;
44 }
45 
46 
47 
cbor_decode_message_1(const uint8_t * payload,size_t payload_len,struct message_1 * result,size_t * payload_len_out)48 int cbor_decode_message_1(
49 		const uint8_t *payload, size_t payload_len,
50 		struct message_1 *result,
51 		size_t *payload_len_out)
52 {
53 	zcbor_state_t states[4];
54 
55 	return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states,
56 		(zcbor_decoder_t *)decode_message_1, sizeof(states) / sizeof(zcbor_state_t), 5);
57 }
58