Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
tlv_internals.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2025 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <stddef.h>
20#include <stdint.h>
21#include <stdbool.h>
22
23// ─────────────────────────────────────────────────────────────────────────────
24// TLV X macros
25// Not intended for library users
26// ─────────────────────────────────────────────────────────────────────────────
27
32#define __X_DEFINE_TLV__TAG_ASSIGN(value, name, callback, unicity) name = value,
33
38#define __X_DEFINE_TLV__TAG_INDEX(value, name, callback, unicity) name##_INDEX,
39
44#define __X_DEFINE_TLV__TAG_FLAG(value, name, callback, unicity) \
45 name##_FLAG = ((TLV_flag_t) 1 << name##_INDEX),
46
51#define __X_DEFINE_TLV__TAG_TO_FLAG_CASE(value, name, callback, unicity) \
52 case name: \
53 return name##_FLAG;
54
59#define __X_DEFINE_TLV__TAG_CALLBACKS(value, name, callback, unicity) \
60 {.tag = name, \
61 .func = (tlv_handler_cb_t *) callback, \
62 .is_unique = (unicity == ENFORCE_UNIQUE_TAG)},
63
64// The generated TLV library will give the user a tag_to_flag function of the following type for
65// his TLV use case
66typedef uint32_t TLV_tag_t;
67typedef uint64_t TLV_flag_t;
69
70// This structure is returned to the TLV parser caller and can be used in conjunction with the
71// associated helper functions to get the status of received tags.
tag_to_flag_function_t * tag_to_flag_function
uint32_t TLV_tag_t
uint64_t TLV_flag_t
TLV_flag_t() tag_to_flag_function_t(TLV_tag_t tag)