1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_HDI_NFC_V1_1_NFCTYPES_H
17#define OHOS_HDI_NFC_V1_1_NFCTYPES_H
18
19#include <cstdbool>
20#include <cstdint>
21#include <vector>
22
23#ifndef HDI_BUFF_MAX_SIZE
24#define HDI_BUFF_MAX_SIZE (1024 * 200)
25#endif
26
27#ifndef HDI_CHECK_VALUE_RETURN
28#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
29    if ((lv) compare (rv)) { \
30        return ret; \
31    } \
32} while (false)
33#endif
34
35#ifndef HDI_CHECK_VALUE_RET_GOTO
36#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
37    if ((lv) compare (rv)) { \
38        ret = value; \
39        goto table; \
40    } \
41} while (false)
42#endif
43
44namespace OHOS {
45class MessageParcel;
46}
47
48namespace OHOS {
49namespace HDI {
50namespace Nfc {
51namespace V1_1 {
52
53using namespace OHOS;
54
55enum VendorProtocalDiscoveryCfg : int32_t {
56    NCI_PROTOCOL_18092_ACTIVE = 0,
57    NCI_PROTOCOL_B_PRIME = 1,
58    NCI_PROTOCOL_DUAL = 2,
59    NCI_PROTOCOL_15693 = 3,
60    NCI_PROTOCOL_KOVIO = 4,
61    NCI_PROTOCOL_MIFARE = 5,
62    NCI_DISCOVERY_TYPE_POLL_KOVIO = 6,
63    NCI_DISCOVERY_TYPE_POLL_B_PRIME = 7,
64    NCI_DISCOVERY_TYPE_LISTEN_B_PRIME = 8,
65    VENDOR_PROPEIETARY_CFG_MAX = 9,
66};
67
68struct NfcVendorConfig {
69    uint32_t isoDepExtApduLength;
70    uint8_t defaultOffHostRoute;
71    uint8_t defaultOffHostRouteFelica;
72    uint8_t defaultSysCodeRoute;
73    uint8_t defaultSysCodePwrState;
74    uint8_t defaultUnconfiguredRoute;
75    uint8_t esePipeId;
76    uint8_t simPipeId;
77    bool pollBailOutMode;
78    uint8_t checkAlgorithm;
79    std::vector<uint8_t> vendorProtocalDiscoveryCfg;
80    uint8_t vendorProtocalDiscoveryCfgSize;
81    std::vector<uint8_t> hostWhitelist;
82    std::vector<uint8_t> offHostRouteUicc;
83    std::vector<uint8_t> offHostRouteEse;
84    uint8_t defaultIsoDepRoute;
85};
86
87bool NfcVendorConfigBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Nfc::V1_1::NfcVendorConfig& dataBlock);
88
89bool NfcVendorConfigBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Nfc::V1_1::NfcVendorConfig& dataBlock);
90
91} // V1_1
92} // Nfc
93} // HDI
94} // OHOS
95
96#endif // OHOS_HDI_NFC_V1_1_NFCTYPES_H
97
98