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/oscore_info.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_oscore_info(zcbor_state_t *state, const struct oscore_info *input);
20
21
encode_oscore_info(zcbor_state_t * state,const struct oscore_info * input)22 static bool encode_oscore_info(
23 zcbor_state_t *state, const struct oscore_info *input)
24 {
25 zcbor_log("%s\r\n", __func__);
26
27 bool tmp_result = (((zcbor_list_start_encode(state, 5) && ((((zcbor_bstr_encode(state, (&(*input).oscore_info_id))))
28 && ((((*input).oscore_info_id_context_choice == oscore_info_id_context_bstr_c) ? ((zcbor_bstr_encode(state, (&(*input).oscore_info_id_context_bstr))))
29 : (((*input).oscore_info_id_context_choice == oscore_info_id_context_nil_c) ? ((zcbor_nil_put(state, NULL)))
30 : false)))
31 && ((((*input).oscore_info_alg_aead_choice == oscore_info_alg_aead_int_c) ? ((zcbor_int32_encode(state, (&(*input).oscore_info_alg_aead_int))))
32 : (((*input).oscore_info_alg_aead_choice == oscore_info_alg_aead_tstr_c) ? ((zcbor_tstr_encode(state, (&(*input).oscore_info_alg_aead_tstr))))
33 : false)))
34 && ((zcbor_tstr_encode(state, (&(*input).oscore_info_type))))
35 && ((zcbor_uint32_encode(state, (&(*input).oscore_info_L))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5))));
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_oscore_info(uint8_t * payload,size_t payload_len,const struct oscore_info * input,size_t * payload_len_out)49 int cbor_encode_oscore_info(
50 uint8_t *payload, size_t payload_len,
51 const struct oscore_info *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_oscore_info, sizeof(states) / sizeof(zcbor_state_t), 1);
58 }
59