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_encode.h"
12 #include "cbor/edhoc_encode_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 encode_message_1(zcbor_state_t *state, const struct message_1 *input);
20
21
encode_message_1(zcbor_state_t * state,const struct message_1 * input)22 static bool encode_message_1(
23 zcbor_state_t *state, const struct message_1 *input)
24 {
25 zcbor_log("%s\r\n", __func__);
26
27 bool tmp_result = (((((zcbor_int32_encode(state, (&(*input).message_1_METHOD))))
28 && ((((*input).message_1_SUITES_I_choice == SUITES_I_suite_l_c) ? ((zcbor_list_start_encode(state, 10) && ((zcbor_multi_encode_minmax(2, 10, &(*input).SUITES_I_suite_l_suite_count, (zcbor_encoder_t *)zcbor_int32_encode, state, (&(*input).SUITES_I_suite_l_suite), sizeof(int32_t))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 10)))
29 : (((*input).message_1_SUITES_I_choice == message_1_SUITES_I_int_c) ? ((zcbor_int32_encode(state, (&(*input).message_1_SUITES_I_int))))
30 : false)))
31 && ((zcbor_bstr_encode(state, (&(*input).message_1_G_X))))
32 && ((((*input).message_1_C_I_choice == message_1_C_I_int_c) ? ((zcbor_int32_encode(state, (&(*input).message_1_C_I_int))))
33 : (((*input).message_1_C_I_choice == message_1_C_I_bstr_c) ? ((zcbor_bstr_encode(state, (&(*input).message_1_C_I_bstr))))
34 : false)))
35 && (!(*input).message_1_ead_1_present || zcbor_bstr_encode(state, (&(*input).message_1_ead_1))))));
36
37 if (!tmp_result) {
38 zcbor_trace_file(state);
39 zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
40 } else {
41 zcbor_log("%s success\r\n", __func__);
42 }
43
44 return tmp_result;
45 }
46
47
48
cbor_encode_message_1(uint8_t * payload,size_t payload_len,const struct message_1 * input,size_t * payload_len_out)49 int cbor_encode_message_1(
50 uint8_t *payload, size_t payload_len,
51 const struct message_1 *input,
52 size_t *payload_len_out)
53 {
54 zcbor_state_t states[4];
55
56 return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
57 (zcbor_decoder_t *)encode_message_1, sizeof(states) / sizeof(zcbor_state_t), 5);
58 }
59