libnfc  1.8.0
nfc-types.h
Go to the documentation of this file.
1 /*-
2  * Free/Libre Near Field Communication (NFC) library
3  *
4  * Libnfc historical contributors:
5  * Copyright (C) 2009 Roel Verdult
6  * Copyright (C) 2009-2013 Romuald Conty
7  * Copyright (C) 2010-2012 Romain Tartière
8  * Copyright (C) 2010-2013 Philippe Teuwen
9  * Copyright (C) 2012-2013 Ludovic Rousseau
10  * See AUTHORS file for a more comprehensive list of contributors.
11  * Additional contributors of this file:
12  * Copyright (C) 2020 Adam Laurie
13  *
14  * This program is free software: you can redistribute it and/or modify it
15  * under the terms of the GNU Lesser General Public License as published by the
16  * Free Software Foundation, either version 3 of the License, or (at your
17  * option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but WITHOUT
20  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
22  * more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>
26  */
27 
33 #ifndef __NFC_TYPES_H__
34 #define __NFC_TYPES_H__
35 
36 #include <stddef.h>
37 #include <stdint.h>
38 #include <stdbool.h>
39 #include <stdio.h>
40 
41 #ifndef NFC_BUFSIZE_CONNSTRING
42 #define NFC_BUFSIZE_CONNSTRING 1024
43 #endif
44 
48 typedef struct nfc_context nfc_context;
49 
53 typedef struct nfc_device nfc_device;
54 
58 typedef struct nfc_driver nfc_driver;
59 
63 typedef char nfc_connstring[NFC_BUFSIZE_CONNSTRING];
64 
68 typedef enum {
143 } nfc_property;
144 
145 // Compiler directive, set struct alignment to 1 uint8_t for compatibility
146 # pragma pack(1)
147 
152 typedef enum {
153  NDM_UNDEFINED = 0,
154  NDM_PASSIVE,
155  NDM_ACTIVE,
156 } nfc_dep_mode;
157 
162 typedef struct {
164  uint8_t abtNFCID3[10];
166  uint8_t btDID;
168  uint8_t btBS;
170  uint8_t btBR;
172  uint8_t btTO;
174  uint8_t btPP;
176  uint8_t abtGB[48];
177  size_t szGB;
180 } nfc_dep_info;
181 
186 typedef struct {
187  uint8_t abtAtqa[2];
188  uint8_t btSak;
189  size_t szUidLen;
190  uint8_t abtUid[10];
191  size_t szAtsLen;
192  uint8_t abtAts[254]; // Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS
194 
199 typedef struct {
200  size_t szLen;
201  uint8_t btResCode;
202  uint8_t abtId[8];
203  uint8_t abtPad[8];
204  uint8_t abtSysCode[2];
206 
211 typedef struct {
213  uint8_t abtPupi[4];
215  uint8_t abtApplicationData[4];
217  uint8_t abtProtocolInfo[3];
221 
226 typedef struct {
228  uint8_t abtDIV[4];
230  uint8_t btVerLog;
232  uint8_t btConfig;
234  size_t szAtrLen;
235  uint8_t abtAtr[33];
237 
242 typedef struct {
243  uint8_t abtUID[8];
245 
250 typedef struct {
251  uint8_t abtUID[8];
253 
258 typedef struct {
259  uint8_t abtUID[4];
260  uint8_t btProdCode;
261  uint8_t btFabCode;
263 
268 typedef struct {
269  uint8_t btSensRes[2];
270  uint8_t btId[4];
272 
277 typedef struct {
278  size_t szDataLen;
279  uint8_t abtData[32];
281 
286 typedef union {
287  nfc_iso14443a_info nai;
288  nfc_felica_info nfi;
289  nfc_iso14443b_info nbi;
293  nfc_jewel_info nji;
294  nfc_dep_info ndi;
295  nfc_barcode_info nti; // "t" for Thinfilm, "b" already used
296  nfc_iso14443biclass_info nhi; // hid iclass / picopass - nii already used
298 
303 typedef enum {
304  NBR_UNDEFINED = 0,
305  NBR_106,
306  NBR_212,
307  NBR_424,
308  NBR_847,
309 } nfc_baud_rate;
310 
315 typedef enum {
316  NMT_ISO14443A = 1,
317  NMT_JEWEL,
318  NMT_ISO14443B,
319  NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
320  NMT_ISO14443B2SR, // ISO14443-2B ST SRx
321  NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
322  NMT_FELICA,
323  NMT_DEP,
324  NMT_BARCODE, // Thinfilm NFC Barcode
325  NMT_ISO14443BICLASS, // HID iClass 14443B mode
326  NMT_END_ENUM = NMT_ISO14443BICLASS, // dummy for sizing - always should alias last
328 
333 typedef enum {
334  N_TARGET,
335  N_INITIATOR,
336 } nfc_mode;
337 
342 typedef struct {
344  nfc_baud_rate nbr;
346 
351 typedef struct {
352  nfc_target_info nti;
353  nfc_modulation nm;
354 } nfc_target;
355 
356 // Reset struct alignment to default
357 # pragma pack()
358 
359 #endif // _LIBNFC_TYPES_H_
nfc_mode
NFC mode type enumeration.
Definition: nfc-types.h:333
struct nfc_driver nfc_driver
Definition: nfc-types.h:58
nfc_property
Definition: nfc-types.h:68
@ NP_TIMEOUT_ATR
Definition: nfc-types.h:81
@ NP_TIMEOUT_COMMAND
Definition: nfc-types.h:74
@ NP_INFINITE_SELECT
Definition: nfc-types.h:115
@ NP_HANDLE_CRC
Definition: nfc-types.h:94
@ NP_FORCE_ISO14443_A
Definition: nfc-types.h:138
@ NP_ACCEPT_INVALID_FRAMES
Definition: nfc-types.h:119
@ NP_ACTIVATE_FIELD
Definition: nfc-types.h:105
@ NP_TIMEOUT_COM
Definition: nfc-types.h:86
@ NP_AUTO_ISO14443_4
Definition: nfc-types.h:134
@ NP_EASY_FRAMING
Definition: nfc-types.h:136
@ NP_ACTIVATE_CRYPTO1
Definition: nfc-types.h:109
@ NP_FORCE_ISO14443_B
Definition: nfc-types.h:140
@ NP_ACCEPT_MULTIPLE_FRAMES
Definition: nfc-types.h:126
@ NP_HANDLE_PARITY
Definition: nfc-types.h:102
@ NP_FORCE_SPEED_106
Definition: nfc-types.h:142
char nfc_connstring[NFC_BUFSIZE_CONNSTRING]
Definition: nfc-types.h:63
nfc_dep_mode
NFC D.E.P. (Data Exchange Protocol) active/passive mode.
Definition: nfc-types.h:152
nfc_modulation_type
NFC modulation type enumeration.
Definition: nfc-types.h:315
nfc_baud_rate
NFC baud rate enumeration.
Definition: nfc-types.h:303
Thinfilm NFC Barcode information.
Definition: nfc-types.h:277
NFC library context Struct which contains internal options, references, pointers, etc....
Definition: nfc-internal.h:175
NFC target information in D.E.P. (Data Exchange Protocol) see ISO/IEC 18092 (NFCIP-1)
Definition: nfc-types.h:162
uint8_t btPP
Definition: nfc-types.h:174
uint8_t btDID
Definition: nfc-types.h:166
nfc_dep_mode ndm
Definition: nfc-types.h:179
uint8_t btTO
Definition: nfc-types.h:172
uint8_t btBS
Definition: nfc-types.h:168
uint8_t btBR
Definition: nfc-types.h:170
NFC device information.
Definition: nfc-internal.h:190
NFC FeLiCa tag information.
Definition: nfc-types.h:199
NFC ISO14443A tag (MIFARE) information.
Definition: nfc-types.h:186
NFC ISO14443-2B ASK CTx tag information.
Definition: nfc-types.h:258
NFC ISO14443-2B ST SRx tag information.
Definition: nfc-types.h:250
NFC ISO14443B tag information.
Definition: nfc-types.h:211
uint8_t ui8CardIdentifier
Definition: nfc-types.h:219
NFC ISO14443B' tag information.
Definition: nfc-types.h:226
NFC ISO14443BiClass tag information.
Definition: nfc-types.h:242
NFC Jewel tag information.
Definition: nfc-types.h:268
NFC modulation structure.
Definition: nfc-types.h:342
NFC target structure.
Definition: nfc-types.h:351
Union between all kind of tags information structures.
Definition: nfc-types.h:286