3 * neard - Near Field Communication manager
5 * Copyright (C) 2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #define NFC_HEADER_SIZE 1
31 enum near_tag_sub_type {
32 NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT = 0, // SAK 0x00
33 NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K, // SAK:0x08
34 NEAR_TAG_NFC_T2_MIFARE_MINI, // SAK 0x09
35 NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K, // SAK:0x18
36 NEAR_TAG_NFC_T2_MIFARE_DESFIRE, // SAK:0x20
37 NEAR_TAG_NFC_T2_JCOP30, // SAK:0x28
38 NEAR_TAG_NFC_T2_MIFARE_4K_EMUL, // SAK:0x38
39 NEAR_TAG_NFC_T2_MIFARE_1K_INFINEON, // SAK:0x88
40 NEAR_TAG_NFC_T2_MPCOS, // SAK:0x98
41 NEAR_TAG_NFC_SUBTYPE_UNKNOWN = 0xFF
44 enum near_tag_memory_layout {
45 NEAR_TAG_MEMORY_STATIC = 0,
46 NEAR_TAG_MEMORY_DYNAMIC,
47 NEAR_TAG_MEMORY_OTHER,
48 NEAR_TAG_MEMORY_UNKNOWN = 0xFF
51 typedef void (*near_tag_io_cb) (uint32_t adapter_idx, uint32_t target_idx,
54 struct near_ndef_message;
56 #define NEAR_TAG_PRIORITY_LOW -100
57 #define NEAR_TAG_PRIORITY_DEFAULT 0
58 #define NEAR_TAG_PRIORITY_HIGH 100
60 struct near_tag_driver {
64 int (*read_tag)(uint32_t adapter_idx, uint32_t target_idx,
66 int (*add_ndef)(uint32_t adapter_idx, uint32_t target_idx,
67 struct near_ndef_message *ndef,
69 int (*check_presence)(uint32_t adapter_idx, uint32_t target_idx,
75 struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx);
76 int near_tag_set_uid(struct near_tag *tag, uint8_t *uid, size_t uid_length);
77 int near_tag_set_ro(struct near_tag *tag, near_bool_t readonly);
78 near_bool_t near_tag_get_ro(struct near_tag *tag);
79 int near_tag_add_data(uint32_t adapter_idx, uint32_t target_idx,
80 uint8_t *data, size_t data_length);
81 enum near_tag_sub_type near_tag_get_subtype(uint32_t adapter_idx,
83 uint8_t *near_tag_get_nfcid(uint32_t adapter_idx, uint32_t target_idx,
85 uint8_t *near_tag_get_data(struct near_tag *tag, size_t *data_length);
86 uint32_t near_tag_get_adapter_idx(struct near_tag *tag);
87 uint32_t near_tag_get_target_idx(struct near_tag *tag);
88 int near_tag_add_ndef(struct near_tag *tag, uint8_t *ndef_data, size_t ndef_length);
89 int near_tag_driver_register(struct near_tag_driver *driver);
90 void near_tag_driver_unregister(struct near_tag_driver *driver);
91 void near_tag_set_memory_layout(struct near_tag *tag,
92 enum near_tag_memory_layout);
93 enum near_tag_memory_layout near_tag_get_memory_layout(struct near_tag *tag);
94 void near_tag_set_max_ndef_size(struct near_tag *tag, uint16_t size);
95 uint16_t near_tag_get_max_ndef_size(struct near_tag *tag);
96 void near_tag_set_c_apdu_max_size(struct near_tag *tag, uint16_t size);
97 uint16_t near_tag_get_c_apdu_max_size(struct near_tag *tag);
98 void near_tag_set_idm(struct near_tag *tag, uint8_t *idm, uint8_t len);
99 uint8_t *near_tag_get_idm(struct near_tag *tag, uint8_t *len);
100 void near_tag_set_attr_block(struct near_tag *tag, uint8_t *attr, uint8_t len);
101 uint8_t *near_tag_get_attr_block(struct near_tag *tag, uint8_t *len);