Branch data Line data Source code
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_encode.h"
12 : : #include "cbor/edhoc_encode_enc_structure.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_edhoc_enc_structure(zcbor_state_t *state, const struct edhoc_enc_structure *input);
20 : :
21 : :
22 : 9 : static bool encode_edhoc_enc_structure(
23 : : zcbor_state_t *state, const struct edhoc_enc_structure *input)
24 : : {
25 : : zcbor_log("%s\r\n", __func__);
26 : :
27 [ + - ]: 18 : bool tmp_result = (((zcbor_list_start_encode(state, 3) && ((((zcbor_tstr_encode(state, (&(*input).edhoc_enc_structure_context))))
28 [ + - ]: 9 : && ((zcbor_bstr_encode(state, (&(*input).edhoc_enc_structure_protected))))
29 [ + - - + : 18 : && ((zcbor_bstr_encode(state, (&(*input).edhoc_enc_structure_external_aad))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 3))));
+ - ]
30 : :
31 : 9 : if (!tmp_result) {
32 : : zcbor_trace_file(state);
33 : : zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
34 : : } else {
35 : : zcbor_log("%s success\r\n", __func__);
36 : : }
37 : :
38 : 9 : return tmp_result;
39 : : }
40 : :
41 : :
42 : :
43 : 9 : int cbor_encode_edhoc_enc_structure(
44 : : uint8_t *payload, size_t payload_len,
45 : : struct edhoc_enc_structure *input,
46 : : size_t *payload_len_out)
47 : : {
48 : : zcbor_state_t states[3];
49 : :
50 : 9 : return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states,
51 : : (zcbor_decoder_t *)encode_edhoc_enc_structure, sizeof(states) / sizeof(zcbor_state_t), 1);
52 : : }
|